2 * Copyright 2017 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
24 #if !defined(_AMDGPU_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
25 #define _AMDGPU_TRACE_H_
27 #include <linux/stringify.h>
28 #include <linux/types.h>
29 #include <linux/tracepoint.h>
34 #define TRACE_SYSTEM amdgpu
35 #define TRACE_INCLUDE_FILE amdgpu_trace
37 #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
38 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
40 TRACE_EVENT(amdgpu_mm_rreg
,
41 TP_PROTO(unsigned did
, uint32_t reg
, uint32_t value
),
42 TP_ARGS(did
, reg
, value
),
44 __field(unsigned, did
)
45 __field(uint32_t, reg
)
46 __field(uint32_t, value
)
51 __entry
->value
= value
;
53 TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
54 (unsigned long)__entry
->did
,
55 (unsigned long)__entry
->reg
,
56 (unsigned long)__entry
->value
)
59 TRACE_EVENT(amdgpu_mm_wreg
,
60 TP_PROTO(unsigned did
, uint32_t reg
, uint32_t value
),
61 TP_ARGS(did
, reg
, value
),
63 __field(unsigned, did
)
64 __field(uint32_t, reg
)
65 __field(uint32_t, value
)
70 __entry
->value
= value
;
72 TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
73 (unsigned long)__entry
->did
,
74 (unsigned long)__entry
->reg
,
75 (unsigned long)__entry
->value
)
78 TRACE_EVENT(amdgpu_iv
,
79 TP_PROTO(struct amdgpu_iv_entry
*iv
),
82 __field(unsigned, client_id
)
83 __field(unsigned, src_id
)
84 __field(unsigned, ring_id
)
85 __field(unsigned, vmid
)
86 __field(unsigned, vmid_src
)
87 __field(uint64_t, timestamp
)
88 __field(unsigned, timestamp_src
)
89 __field(unsigned, pasid
)
90 __array(unsigned, src_data
, 4)
93 __entry
->client_id
= iv
->client_id
;
94 __entry
->src_id
= iv
->src_id
;
95 __entry
->ring_id
= iv
->ring_id
;
96 __entry
->vmid
= iv
->vmid
;
97 __entry
->vmid_src
= iv
->vmid_src
;
98 __entry
->timestamp
= iv
->timestamp
;
99 __entry
->timestamp_src
= iv
->timestamp_src
;
100 __entry
->pasid
= iv
->pasid
;
101 __entry
->src_data
[0] = iv
->src_data
[0];
102 __entry
->src_data
[1] = iv
->src_data
[1];
103 __entry
->src_data
[2] = iv
->src_data
[2];
104 __entry
->src_data
[3] = iv
->src_data
[3];
106 TP_printk("client_id:%u src_id:%u ring:%u vmid:%u timestamp: %llu pasid:%u src_data: %08x %08x %08x %08x\n",
107 __entry
->client_id
, __entry
->src_id
,
108 __entry
->ring_id
, __entry
->vmid
,
109 __entry
->timestamp
, __entry
->pasid
,
110 __entry
->src_data
[0], __entry
->src_data
[1],
111 __entry
->src_data
[2], __entry
->src_data
[3])
115 TRACE_EVENT(amdgpu_bo_create
,
116 TP_PROTO(struct amdgpu_bo
*bo
),
119 __field(struct amdgpu_bo
*, bo
)
124 __field(u32
, visible
)
129 __entry
->pages
= bo
->tbo
.num_pages
;
130 __entry
->type
= bo
->tbo
.mem
.mem_type
;
131 __entry
->prefer
= bo
->preferred_domains
;
132 __entry
->allow
= bo
->allowed_domains
;
133 __entry
->visible
= bo
->flags
;
136 TP_printk("bo=%p, pages=%u, type=%d, preferred=%d, allowed=%d, visible=%d",
137 __entry
->bo
, __entry
->pages
, __entry
->type
,
138 __entry
->prefer
, __entry
->allow
, __entry
->visible
)
141 TRACE_EVENT(amdgpu_cs
,
142 TP_PROTO(struct amdgpu_cs_parser
*p
, int i
),
145 __field(struct amdgpu_bo_list
*, bo_list
)
152 __entry
->bo_list
= p
->bo_list
;
153 __entry
->ring
= p
->ring
->idx
;
154 __entry
->dw
= p
->job
->ibs
[i
].length_dw
;
155 __entry
->fences
= amdgpu_fence_count_emitted(
158 TP_printk("bo_list=%p, ring=%u, dw=%u, fences=%u",
159 __entry
->bo_list
, __entry
->ring
, __entry
->dw
,
163 TRACE_EVENT(amdgpu_cs_ioctl
,
164 TP_PROTO(struct amdgpu_job
*job
),
167 __field(uint64_t, sched_job_id
)
168 __string(timeline
, AMDGPU_JOB_GET_TIMELINE_NAME(job
))
169 __field(unsigned int, context
)
170 __field(unsigned int, seqno
)
171 __field(struct dma_fence
*, fence
)
172 __field(char *, ring_name
)
173 __field(u32
, num_ibs
)
177 __entry
->sched_job_id
= job
->base
.id
;
178 __assign_str(timeline
, AMDGPU_JOB_GET_TIMELINE_NAME(job
))
179 __entry
->context
= job
->base
.s_fence
->finished
.context
;
180 __entry
->seqno
= job
->base
.s_fence
->finished
.seqno
;
181 __entry
->ring_name
= to_amdgpu_ring(job
->base
.sched
)->name
;
182 __entry
->num_ibs
= job
->num_ibs
;
184 TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
185 __entry
->sched_job_id
, __get_str(timeline
), __entry
->context
,
186 __entry
->seqno
, __entry
->ring_name
, __entry
->num_ibs
)
189 TRACE_EVENT(amdgpu_sched_run_job
,
190 TP_PROTO(struct amdgpu_job
*job
),
193 __field(uint64_t, sched_job_id
)
194 __string(timeline
, AMDGPU_JOB_GET_TIMELINE_NAME(job
))
195 __field(unsigned int, context
)
196 __field(unsigned int, seqno
)
197 __field(char *, ring_name
)
198 __field(u32
, num_ibs
)
202 __entry
->sched_job_id
= job
->base
.id
;
203 __assign_str(timeline
, AMDGPU_JOB_GET_TIMELINE_NAME(job
))
204 __entry
->context
= job
->base
.s_fence
->finished
.context
;
205 __entry
->seqno
= job
->base
.s_fence
->finished
.seqno
;
206 __entry
->ring_name
= to_amdgpu_ring(job
->base
.sched
)->name
;
207 __entry
->num_ibs
= job
->num_ibs
;
209 TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
210 __entry
->sched_job_id
, __get_str(timeline
), __entry
->context
,
211 __entry
->seqno
, __entry
->ring_name
, __entry
->num_ibs
)
215 TRACE_EVENT(amdgpu_vm_grab_id
,
216 TP_PROTO(struct amdgpu_vm
*vm
, struct amdgpu_ring
*ring
,
217 struct amdgpu_job
*job
),
218 TP_ARGS(vm
, ring
, job
),
224 __field(u64
, pd_addr
)
225 __field(u32
, needs_flush
)
229 __entry
->pasid
= vm
->pasid
;
230 __entry
->ring
= ring
->idx
;
231 __entry
->vmid
= job
->vmid
;
232 __entry
->vm_hub
= ring
->funcs
->vmhub
,
233 __entry
->pd_addr
= job
->vm_pd_addr
;
234 __entry
->needs_flush
= job
->vm_needs_flush
;
236 TP_printk("pasid=%d, ring=%u, id=%u, hub=%u, pd_addr=%010Lx needs_flush=%u",
237 __entry
->pasid
, __entry
->ring
, __entry
->vmid
,
238 __entry
->vm_hub
, __entry
->pd_addr
, __entry
->needs_flush
)
241 TRACE_EVENT(amdgpu_vm_bo_map
,
242 TP_PROTO(struct amdgpu_bo_va
*bo_va
,
243 struct amdgpu_bo_va_mapping
*mapping
),
244 TP_ARGS(bo_va
, mapping
),
246 __field(struct amdgpu_bo
*, bo
)
254 __entry
->bo
= bo_va
? bo_va
->base
.bo
: NULL
;
255 __entry
->start
= mapping
->start
;
256 __entry
->last
= mapping
->last
;
257 __entry
->offset
= mapping
->offset
;
258 __entry
->flags
= mapping
->flags
;
260 TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
261 __entry
->bo
, __entry
->start
, __entry
->last
,
262 __entry
->offset
, __entry
->flags
)
265 TRACE_EVENT(amdgpu_vm_bo_unmap
,
266 TP_PROTO(struct amdgpu_bo_va
*bo_va
,
267 struct amdgpu_bo_va_mapping
*mapping
),
268 TP_ARGS(bo_va
, mapping
),
270 __field(struct amdgpu_bo
*, bo
)
278 __entry
->bo
= bo_va
? bo_va
->base
.bo
: NULL
;
279 __entry
->start
= mapping
->start
;
280 __entry
->last
= mapping
->last
;
281 __entry
->offset
= mapping
->offset
;
282 __entry
->flags
= mapping
->flags
;
284 TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
285 __entry
->bo
, __entry
->start
, __entry
->last
,
286 __entry
->offset
, __entry
->flags
)
289 DECLARE_EVENT_CLASS(amdgpu_vm_mapping
,
290 TP_PROTO(struct amdgpu_bo_va_mapping
*mapping
),
293 __field(u64
, soffset
)
294 __field(u64
, eoffset
)
299 __entry
->soffset
= mapping
->start
;
300 __entry
->eoffset
= mapping
->last
+ 1;
301 __entry
->flags
= mapping
->flags
;
303 TP_printk("soffs=%010llx, eoffs=%010llx, flags=%llx",
304 __entry
->soffset
, __entry
->eoffset
, __entry
->flags
)
307 DEFINE_EVENT(amdgpu_vm_mapping
, amdgpu_vm_bo_update
,
308 TP_PROTO(struct amdgpu_bo_va_mapping
*mapping
),
312 DEFINE_EVENT(amdgpu_vm_mapping
, amdgpu_vm_bo_mapping
,
313 TP_PROTO(struct amdgpu_bo_va_mapping
*mapping
),
317 DEFINE_EVENT(amdgpu_vm_mapping
, amdgpu_vm_bo_cs
,
318 TP_PROTO(struct amdgpu_bo_va_mapping
*mapping
),
322 TRACE_EVENT(amdgpu_vm_set_ptes
,
323 TP_PROTO(uint64_t pe
, uint64_t addr
, unsigned count
,
324 uint32_t incr
, uint64_t flags
),
325 TP_ARGS(pe
, addr
, count
, incr
, flags
),
336 __entry
->addr
= addr
;
337 __entry
->count
= count
;
338 __entry
->incr
= incr
;
339 __entry
->flags
= flags
;
341 TP_printk("pe=%010Lx, addr=%010Lx, incr=%u, flags=%llx, count=%u",
342 __entry
->pe
, __entry
->addr
, __entry
->incr
,
343 __entry
->flags
, __entry
->count
)
346 TRACE_EVENT(amdgpu_vm_copy_ptes
,
347 TP_PROTO(uint64_t pe
, uint64_t src
, unsigned count
),
348 TP_ARGS(pe
, src
, count
),
358 __entry
->count
= count
;
360 TP_printk("pe=%010Lx, src=%010Lx, count=%u",
361 __entry
->pe
, __entry
->src
, __entry
->count
)
364 TRACE_EVENT(amdgpu_vm_flush
,
365 TP_PROTO(struct amdgpu_ring
*ring
, unsigned vmid
,
367 TP_ARGS(ring
, vmid
, pd_addr
),
372 __field(u64
, pd_addr
)
376 __entry
->ring
= ring
->idx
;
377 __entry
->vmid
= vmid
;
378 __entry
->vm_hub
= ring
->funcs
->vmhub
;
379 __entry
->pd_addr
= pd_addr
;
381 TP_printk("ring=%u, id=%u, hub=%u, pd_addr=%010Lx",
382 __entry
->ring
, __entry
->vmid
,
383 __entry
->vm_hub
,__entry
->pd_addr
)
386 DECLARE_EVENT_CLASS(amdgpu_pasid
,
387 TP_PROTO(unsigned pasid
),
390 __field(unsigned, pasid
)
393 __entry
->pasid
= pasid
;
395 TP_printk("pasid=%u", __entry
->pasid
)
398 DEFINE_EVENT(amdgpu_pasid
, amdgpu_pasid_allocated
,
399 TP_PROTO(unsigned pasid
),
403 DEFINE_EVENT(amdgpu_pasid
, amdgpu_pasid_freed
,
404 TP_PROTO(unsigned pasid
),
408 TRACE_EVENT(amdgpu_bo_list_set
,
409 TP_PROTO(struct amdgpu_bo_list
*list
, struct amdgpu_bo
*bo
),
412 __field(struct amdgpu_bo_list
*, list
)
413 __field(struct amdgpu_bo
*, bo
)
414 __field(u64
, bo_size
)
418 __entry
->list
= list
;
420 __entry
->bo_size
= amdgpu_bo_size(bo
);
422 TP_printk("list=%p, bo=%p, bo_size=%Ld",
428 TRACE_EVENT(amdgpu_cs_bo_status
,
429 TP_PROTO(uint64_t total_bo
, uint64_t total_size
),
430 TP_ARGS(total_bo
, total_size
),
432 __field(u64
, total_bo
)
433 __field(u64
, total_size
)
437 __entry
->total_bo
= total_bo
;
438 __entry
->total_size
= total_size
;
440 TP_printk("total_bo_size=%Ld, total_bo_count=%Ld",
441 __entry
->total_bo
, __entry
->total_size
)
444 TRACE_EVENT(amdgpu_bo_move
,
445 TP_PROTO(struct amdgpu_bo
* bo
, uint32_t new_placement
, uint32_t old_placement
),
446 TP_ARGS(bo
, new_placement
, old_placement
),
448 __field(struct amdgpu_bo
*, bo
)
449 __field(u64
, bo_size
)
450 __field(u32
, new_placement
)
451 __field(u32
, old_placement
)
456 __entry
->bo_size
= amdgpu_bo_size(bo
);
457 __entry
->new_placement
= new_placement
;
458 __entry
->old_placement
= old_placement
;
460 TP_printk("bo=%p, from=%d, to=%d, size=%Ld",
461 __entry
->bo
, __entry
->old_placement
,
462 __entry
->new_placement
, __entry
->bo_size
)
465 #undef AMDGPU_JOB_GET_TIMELINE_NAME
468 /* This part must be outside protection */
469 #undef TRACE_INCLUDE_PATH
470 #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/amd/amdgpu
471 #include <trace/define_trace.h>