amdgpu_trace.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #if !defined(_AMDGPU_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  3. #define _AMDGPU_TRACE_H_
  4. #include <linux/stringify.h>
  5. #include <linux/types.h>
  6. #include <linux/tracepoint.h>
  7. #include <drm/drmP.h>
  8. #undef TRACE_SYSTEM
  9. #define TRACE_SYSTEM amdgpu
  10. #define TRACE_INCLUDE_FILE amdgpu_trace
  11. #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
  12. job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
  13. TRACE_EVENT(amdgpu_ttm_tt_populate,
  14. TP_PROTO(struct amdgpu_device *adev, uint64_t dma_address, uint64_t phys_address),
  15. TP_ARGS(adev, dma_address, phys_address),
  16. TP_STRUCT__entry(
  17. __field(uint16_t, domain)
  18. __field(uint8_t, bus)
  19. __field(uint8_t, slot)
  20. __field(uint8_t, func)
  21. __field(uint64_t, dma)
  22. __field(uint64_t, phys)
  23. ),
  24. TP_fast_assign(
  25. __entry->domain = pci_domain_nr(adev->pdev->bus);
  26. __entry->bus = adev->pdev->bus->number;
  27. __entry->slot = PCI_SLOT(adev->pdev->devfn);
  28. __entry->func = PCI_FUNC(adev->pdev->devfn);
  29. __entry->dma = dma_address;
  30. __entry->phys = phys_address;
  31. ),
  32. TP_printk("%04x:%02x:%02x.%x: 0x%llx => 0x%llx",
  33. (unsigned)__entry->domain,
  34. (unsigned)__entry->bus,
  35. (unsigned)__entry->slot,
  36. (unsigned)__entry->func,
  37. (unsigned long long)__entry->dma,
  38. (unsigned long long)__entry->phys)
  39. );
  40. TRACE_EVENT(amdgpu_ttm_tt_unpopulate,
  41. TP_PROTO(struct amdgpu_device *adev, uint64_t dma_address, uint64_t phys_address),
  42. TP_ARGS(adev, dma_address, phys_address),
  43. TP_STRUCT__entry(
  44. __field(uint16_t, domain)
  45. __field(uint8_t, bus)
  46. __field(uint8_t, slot)
  47. __field(uint8_t, func)
  48. __field(uint64_t, dma)
  49. __field(uint64_t, phys)
  50. ),
  51. TP_fast_assign(
  52. __entry->domain = pci_domain_nr(adev->pdev->bus);
  53. __entry->bus = adev->pdev->bus->number;
  54. __entry->slot = PCI_SLOT(adev->pdev->devfn);
  55. __entry->func = PCI_FUNC(adev->pdev->devfn);
  56. __entry->dma = dma_address;
  57. __entry->phys = phys_address;
  58. ),
  59. TP_printk("%04x:%02x:%02x.%x: 0x%llx => 0x%llx",
  60. (unsigned)__entry->domain,
  61. (unsigned)__entry->bus,
  62. (unsigned)__entry->slot,
  63. (unsigned)__entry->func,
  64. (unsigned long long)__entry->dma,
  65. (unsigned long long)__entry->phys)
  66. );
  67. TRACE_EVENT(amdgpu_mm_rreg,
  68. TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
  69. TP_ARGS(did, reg, value),
  70. TP_STRUCT__entry(
  71. __field(unsigned, did)
  72. __field(uint32_t, reg)
  73. __field(uint32_t, value)
  74. ),
  75. TP_fast_assign(
  76. __entry->did = did;
  77. __entry->reg = reg;
  78. __entry->value = value;
  79. ),
  80. TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
  81. (unsigned long)__entry->did,
  82. (unsigned long)__entry->reg,
  83. (unsigned long)__entry->value)
  84. );
  85. TRACE_EVENT(amdgpu_mm_wreg,
  86. TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
  87. TP_ARGS(did, reg, value),
  88. TP_STRUCT__entry(
  89. __field(unsigned, did)
  90. __field(uint32_t, reg)
  91. __field(uint32_t, value)
  92. ),
  93. TP_fast_assign(
  94. __entry->did = did;
  95. __entry->reg = reg;
  96. __entry->value = value;
  97. ),
  98. TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
  99. (unsigned long)__entry->did,
  100. (unsigned long)__entry->reg,
  101. (unsigned long)__entry->value)
  102. );
  103. TRACE_EVENT(amdgpu_iv,
  104. TP_PROTO(struct amdgpu_iv_entry *iv),
  105. TP_ARGS(iv),
  106. TP_STRUCT__entry(
  107. __field(unsigned, client_id)
  108. __field(unsigned, src_id)
  109. __field(unsigned, ring_id)
  110. __field(unsigned, vm_id)
  111. __field(unsigned, vm_id_src)
  112. __field(uint64_t, timestamp)
  113. __field(unsigned, timestamp_src)
  114. __field(unsigned, pas_id)
  115. __array(unsigned, src_data, 4)
  116. ),
  117. TP_fast_assign(
  118. __entry->client_id = iv->client_id;
  119. __entry->src_id = iv->src_id;
  120. __entry->ring_id = iv->ring_id;
  121. __entry->vm_id = iv->vm_id;
  122. __entry->vm_id_src = iv->vm_id_src;
  123. __entry->timestamp = iv->timestamp;
  124. __entry->timestamp_src = iv->timestamp_src;
  125. __entry->pas_id = iv->pas_id;
  126. __entry->src_data[0] = iv->src_data[0];
  127. __entry->src_data[1] = iv->src_data[1];
  128. __entry->src_data[2] = iv->src_data[2];
  129. __entry->src_data[3] = iv->src_data[3];
  130. ),
  131. TP_printk("client_id:%u src_id:%u ring:%u vm_id:%u timestamp: %llu pas_id:%u src_data: %08x %08x %08x %08x\n",
  132. __entry->client_id, __entry->src_id,
  133. __entry->ring_id, __entry->vm_id,
  134. __entry->timestamp, __entry->pas_id,
  135. __entry->src_data[0], __entry->src_data[1],
  136. __entry->src_data[2], __entry->src_data[3])
  137. );
  138. TRACE_EVENT(amdgpu_bo_create,
  139. TP_PROTO(struct amdgpu_bo *bo),
  140. TP_ARGS(bo),
  141. TP_STRUCT__entry(
  142. __field(struct amdgpu_bo *, bo)
  143. __field(u32, pages)
  144. __field(u32, type)
  145. __field(u32, prefer)
  146. __field(u32, allow)
  147. __field(u32, visible)
  148. ),
  149. TP_fast_assign(
  150. __entry->bo = bo;
  151. __entry->pages = bo->tbo.num_pages;
  152. __entry->type = bo->tbo.mem.mem_type;
  153. __entry->prefer = bo->preferred_domains;
  154. __entry->allow = bo->allowed_domains;
  155. __entry->visible = bo->flags;
  156. ),
  157. TP_printk("bo=%p, pages=%u, type=%d, preferred=%d, allowed=%d, visible=%d",
  158. __entry->bo, __entry->pages, __entry->type,
  159. __entry->prefer, __entry->allow, __entry->visible)
  160. );
  161. TRACE_EVENT(amdgpu_cs,
  162. TP_PROTO(struct amdgpu_cs_parser *p, int i),
  163. TP_ARGS(p, i),
  164. TP_STRUCT__entry(
  165. __field(struct amdgpu_bo_list *, bo_list)
  166. __field(u32, ring)
  167. __field(u32, dw)
  168. __field(u32, fences)
  169. ),
  170. TP_fast_assign(
  171. __entry->bo_list = p->bo_list;
  172. __entry->ring = p->job->ring->idx;
  173. __entry->dw = p->job->ibs[i].length_dw;
  174. __entry->fences = amdgpu_fence_count_emitted(
  175. p->job->ring);
  176. ),
  177. TP_printk("bo_list=%p, ring=%u, dw=%u, fences=%u",
  178. __entry->bo_list, __entry->ring, __entry->dw,
  179. __entry->fences)
  180. );
  181. TRACE_EVENT(amdgpu_cs_ioctl,
  182. TP_PROTO(struct amdgpu_job *job),
  183. TP_ARGS(job),
  184. TP_STRUCT__entry(
  185. __field(uint64_t, sched_job_id)
  186. __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  187. __field(unsigned int, context)
  188. __field(unsigned int, seqno)
  189. __field(struct dma_fence *, fence)
  190. __field(char *, ring_name)
  191. __field(u32, num_ibs)
  192. ),
  193. TP_fast_assign(
  194. __entry->sched_job_id = job->base.id;
  195. __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  196. __entry->context = job->base.s_fence->finished.context;
  197. __entry->seqno = job->base.s_fence->finished.seqno;
  198. __entry->ring_name = job->ring->name;
  199. __entry->num_ibs = job->num_ibs;
  200. ),
  201. TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
  202. __entry->sched_job_id, __get_str(timeline), __entry->context,
  203. __entry->seqno, __entry->ring_name, __entry->num_ibs)
  204. );
  205. TRACE_EVENT(amdgpu_sched_run_job,
  206. TP_PROTO(struct amdgpu_job *job),
  207. TP_ARGS(job),
  208. TP_STRUCT__entry(
  209. __field(uint64_t, sched_job_id)
  210. __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  211. __field(unsigned int, context)
  212. __field(unsigned int, seqno)
  213. __field(char *, ring_name)
  214. __field(u32, num_ibs)
  215. ),
  216. TP_fast_assign(
  217. __entry->sched_job_id = job->base.id;
  218. __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
  219. __entry->context = job->base.s_fence->finished.context;
  220. __entry->seqno = job->base.s_fence->finished.seqno;
  221. __entry->ring_name = job->ring->name;
  222. __entry->num_ibs = job->num_ibs;
  223. ),
  224. TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
  225. __entry->sched_job_id, __get_str(timeline), __entry->context,
  226. __entry->seqno, __entry->ring_name, __entry->num_ibs)
  227. );
  228. TRACE_EVENT(amdgpu_vm_grab_id,
  229. TP_PROTO(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
  230. struct amdgpu_job *job),
  231. TP_ARGS(vm, ring, job),
  232. TP_STRUCT__entry(
  233. __field(struct amdgpu_vm *, vm)
  234. __field(u32, ring)
  235. __field(u32, vm_id)
  236. __field(u32, vm_hub)
  237. __field(u64, pd_addr)
  238. __field(u32, needs_flush)
  239. ),
  240. TP_fast_assign(
  241. __entry->vm = vm;
  242. __entry->ring = ring->idx;
  243. __entry->vm_id = job->vm_id;
  244. __entry->vm_hub = ring->funcs->vmhub,
  245. __entry->pd_addr = job->vm_pd_addr;
  246. __entry->needs_flush = job->vm_needs_flush;
  247. ),
  248. TP_printk("vm=%p, ring=%u, id=%u, hub=%u, pd_addr=%010Lx needs_flush=%u",
  249. __entry->vm, __entry->ring, __entry->vm_id,
  250. __entry->vm_hub, __entry->pd_addr, __entry->needs_flush)
  251. );
  252. TRACE_EVENT(amdgpu_vm_bo_map,
  253. TP_PROTO(struct amdgpu_bo_va *bo_va,
  254. struct amdgpu_bo_va_mapping *mapping),
  255. TP_ARGS(bo_va, mapping),
  256. TP_STRUCT__entry(
  257. __field(struct amdgpu_bo *, bo)
  258. __field(long, start)
  259. __field(long, last)
  260. __field(u64, offset)
  261. __field(u64, flags)
  262. ),
  263. TP_fast_assign(
  264. __entry->bo = bo_va ? bo_va->base.bo : NULL;
  265. __entry->start = mapping->start;
  266. __entry->last = mapping->last;
  267. __entry->offset = mapping->offset;
  268. __entry->flags = mapping->flags;
  269. ),
  270. TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
  271. __entry->bo, __entry->start, __entry->last,
  272. __entry->offset, __entry->flags)
  273. );
  274. TRACE_EVENT(amdgpu_vm_bo_unmap,
  275. TP_PROTO(struct amdgpu_bo_va *bo_va,
  276. struct amdgpu_bo_va_mapping *mapping),
  277. TP_ARGS(bo_va, mapping),
  278. TP_STRUCT__entry(
  279. __field(struct amdgpu_bo *, bo)
  280. __field(long, start)
  281. __field(long, last)
  282. __field(u64, offset)
  283. __field(u64, flags)
  284. ),
  285. TP_fast_assign(
  286. __entry->bo = bo_va->base.bo;
  287. __entry->start = mapping->start;
  288. __entry->last = mapping->last;
  289. __entry->offset = mapping->offset;
  290. __entry->flags = mapping->flags;
  291. ),
  292. TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
  293. __entry->bo, __entry->start, __entry->last,
  294. __entry->offset, __entry->flags)
  295. );
  296. DECLARE_EVENT_CLASS(amdgpu_vm_mapping,
  297. TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
  298. TP_ARGS(mapping),
  299. TP_STRUCT__entry(
  300. __field(u64, soffset)
  301. __field(u64, eoffset)
  302. __field(u64, flags)
  303. ),
  304. TP_fast_assign(
  305. __entry->soffset = mapping->start;
  306. __entry->eoffset = mapping->last + 1;
  307. __entry->flags = mapping->flags;
  308. ),
  309. TP_printk("soffs=%010llx, eoffs=%010llx, flags=%llx",
  310. __entry->soffset, __entry->eoffset, __entry->flags)
  311. );
  312. DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_update,
  313. TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
  314. TP_ARGS(mapping)
  315. );
  316. DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_mapping,
  317. TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
  318. TP_ARGS(mapping)
  319. );
  320. TRACE_EVENT(amdgpu_vm_set_ptes,
  321. TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
  322. uint32_t incr, uint64_t flags),
  323. TP_ARGS(pe, addr, count, incr, flags),
  324. TP_STRUCT__entry(
  325. __field(u64, pe)
  326. __field(u64, addr)
  327. __field(u32, count)
  328. __field(u32, incr)
  329. __field(u64, flags)
  330. ),
  331. TP_fast_assign(
  332. __entry->pe = pe;
  333. __entry->addr = addr;
  334. __entry->count = count;
  335. __entry->incr = incr;
  336. __entry->flags = flags;
  337. ),
  338. TP_printk("pe=%010Lx, addr=%010Lx, incr=%u, flags=%llx, count=%u",
  339. __entry->pe, __entry->addr, __entry->incr,
  340. __entry->flags, __entry->count)
  341. );
  342. TRACE_EVENT(amdgpu_vm_copy_ptes,
  343. TP_PROTO(uint64_t pe, uint64_t src, unsigned count),
  344. TP_ARGS(pe, src, count),
  345. TP_STRUCT__entry(
  346. __field(u64, pe)
  347. __field(u64, src)
  348. __field(u32, count)
  349. ),
  350. TP_fast_assign(
  351. __entry->pe = pe;
  352. __entry->src = src;
  353. __entry->count = count;
  354. ),
  355. TP_printk("pe=%010Lx, src=%010Lx, count=%u",
  356. __entry->pe, __entry->src, __entry->count)
  357. );
  358. TRACE_EVENT(amdgpu_vm_flush,
  359. TP_PROTO(struct amdgpu_ring *ring, unsigned vm_id,
  360. uint64_t pd_addr),
  361. TP_ARGS(ring, vm_id, pd_addr),
  362. TP_STRUCT__entry(
  363. __field(u32, ring)
  364. __field(u32, vm_id)
  365. __field(u32, vm_hub)
  366. __field(u64, pd_addr)
  367. ),
  368. TP_fast_assign(
  369. __entry->ring = ring->idx;
  370. __entry->vm_id = vm_id;
  371. __entry->vm_hub = ring->funcs->vmhub;
  372. __entry->pd_addr = pd_addr;
  373. ),
  374. TP_printk("ring=%u, id=%u, hub=%u, pd_addr=%010Lx",
  375. __entry->ring, __entry->vm_id,
  376. __entry->vm_hub,__entry->pd_addr)
  377. );
  378. TRACE_EVENT(amdgpu_bo_list_set,
  379. TP_PROTO(struct amdgpu_bo_list *list, struct amdgpu_bo *bo),
  380. TP_ARGS(list, bo),
  381. TP_STRUCT__entry(
  382. __field(struct amdgpu_bo_list *, list)
  383. __field(struct amdgpu_bo *, bo)
  384. __field(u64, bo_size)
  385. ),
  386. TP_fast_assign(
  387. __entry->list = list;
  388. __entry->bo = bo;
  389. __entry->bo_size = amdgpu_bo_size(bo);
  390. ),
  391. TP_printk("list=%p, bo=%p, bo_size=%Ld",
  392. __entry->list,
  393. __entry->bo,
  394. __entry->bo_size)
  395. );
  396. TRACE_EVENT(amdgpu_cs_bo_status,
  397. TP_PROTO(uint64_t total_bo, uint64_t total_size),
  398. TP_ARGS(total_bo, total_size),
  399. TP_STRUCT__entry(
  400. __field(u64, total_bo)
  401. __field(u64, total_size)
  402. ),
  403. TP_fast_assign(
  404. __entry->total_bo = total_bo;
  405. __entry->total_size = total_size;
  406. ),
  407. TP_printk("total_bo_size=%Ld, total_bo_count=%Ld",
  408. __entry->total_bo, __entry->total_size)
  409. );
  410. TRACE_EVENT(amdgpu_ttm_bo_move,
  411. TP_PROTO(struct amdgpu_bo* bo, uint32_t new_placement, uint32_t old_placement),
  412. TP_ARGS(bo, new_placement, old_placement),
  413. TP_STRUCT__entry(
  414. __field(struct amdgpu_bo *, bo)
  415. __field(u64, bo_size)
  416. __field(u32, new_placement)
  417. __field(u32, old_placement)
  418. ),
  419. TP_fast_assign(
  420. __entry->bo = bo;
  421. __entry->bo_size = amdgpu_bo_size(bo);
  422. __entry->new_placement = new_placement;
  423. __entry->old_placement = old_placement;
  424. ),
  425. TP_printk("bo=%p, from=%d, to=%d, size=%Ld",
  426. __entry->bo, __entry->old_placement,
  427. __entry->new_placement, __entry->bo_size)
  428. );
  429. #undef AMDGPU_JOB_GET_TIMELINE_NAME
  430. #endif
  431. /* This part must be outside protection */
  432. #undef TRACE_INCLUDE_PATH
  433. #define TRACE_INCLUDE_PATH .
  434. #include <trace/define_trace.h>