1 #if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
4 #include <linux/stringify.h>
5 #include <linux/types.h>
6 #include <linux/tracepoint.h>
10 #include "intel_drv.h"
11 #include "intel_ringbuffer.h"
14 #define TRACE_SYSTEM i915
15 #define TRACE_INCLUDE_FILE i915_trace
19 TRACE_EVENT(i915_pipe_update_start
,
20 TP_PROTO(struct intel_crtc
*crtc
),
24 __field(enum pipe
, pipe
)
26 __field(u32
, scanline
)
32 __entry
->pipe
= crtc
->pipe
;
33 __entry
->frame
= crtc
->base
.dev
->driver
->get_vblank_counter(crtc
->base
.dev
,
35 __entry
->scanline
= intel_get_crtc_scanline(crtc
);
36 __entry
->min
= crtc
->debug
.min_vbl
;
37 __entry
->max
= crtc
->debug
.max_vbl
;
40 TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
41 pipe_name(__entry
->pipe
), __entry
->frame
,
42 __entry
->scanline
, __entry
->min
, __entry
->max
)
45 TRACE_EVENT(i915_pipe_update_vblank_evaded
,
46 TP_PROTO(struct intel_crtc
*crtc
),
50 __field(enum pipe
, pipe
)
52 __field(u32
, scanline
)
58 __entry
->pipe
= crtc
->pipe
;
59 __entry
->frame
= crtc
->debug
.start_vbl_count
;
60 __entry
->scanline
= crtc
->debug
.scanline_start
;
61 __entry
->min
= crtc
->debug
.min_vbl
;
62 __entry
->max
= crtc
->debug
.max_vbl
;
65 TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
66 pipe_name(__entry
->pipe
), __entry
->frame
,
67 __entry
->scanline
, __entry
->min
, __entry
->max
)
70 TRACE_EVENT(i915_pipe_update_end
,
71 TP_PROTO(struct intel_crtc
*crtc
, u32 frame
, int scanline_end
),
72 TP_ARGS(crtc
, frame
, scanline_end
),
75 __field(enum pipe
, pipe
)
77 __field(u32
, scanline
)
81 __entry
->pipe
= crtc
->pipe
;
82 __entry
->frame
= frame
;
83 __entry
->scanline
= scanline_end
;
86 TP_printk("pipe %c, frame=%u, scanline=%u",
87 pipe_name(__entry
->pipe
), __entry
->frame
,
93 TRACE_EVENT(i915_gem_object_create
,
94 TP_PROTO(struct drm_i915_gem_object
*obj
),
98 __field(struct drm_i915_gem_object
*, obj
)
104 __entry
->size
= obj
->base
.size
;
107 TP_printk("obj=%p, size=%u", __entry
->obj
, __entry
->size
)
110 TRACE_EVENT(i915_gem_shrink
,
111 TP_PROTO(struct drm_i915_private
*i915
, unsigned long target
, unsigned flags
),
112 TP_ARGS(i915
, target
, flags
),
116 __field(unsigned long, target
)
117 __field(unsigned, flags
)
121 __entry
->dev
= i915
->dev
->primary
->index
;
122 __entry
->target
= target
;
123 __entry
->flags
= flags
;
126 TP_printk("dev=%d, target=%lu, flags=%x",
127 __entry
->dev
, __entry
->target
, __entry
->flags
)
130 TRACE_EVENT(i915_vma_bind
,
131 TP_PROTO(struct i915_vma
*vma
, unsigned flags
),
135 __field(struct drm_i915_gem_object
*, obj
)
136 __field(struct i915_address_space
*, vm
)
139 __field(unsigned, flags
)
143 __entry
->obj
= vma
->obj
;
144 __entry
->vm
= vma
->vm
;
145 __entry
->offset
= vma
->node
.start
;
146 __entry
->size
= vma
->node
.size
;
147 __entry
->flags
= flags
;
150 TP_printk("obj=%p, offset=%016llx size=%x%s vm=%p",
151 __entry
->obj
, __entry
->offset
, __entry
->size
,
152 __entry
->flags
& PIN_MAPPABLE
? ", mappable" : "",
156 TRACE_EVENT(i915_vma_unbind
,
157 TP_PROTO(struct i915_vma
*vma
),
161 __field(struct drm_i915_gem_object
*, obj
)
162 __field(struct i915_address_space
*, vm
)
168 __entry
->obj
= vma
->obj
;
169 __entry
->vm
= vma
->vm
;
170 __entry
->offset
= vma
->node
.start
;
171 __entry
->size
= vma
->node
.size
;
174 TP_printk("obj=%p, offset=%016llx size=%x vm=%p",
175 __entry
->obj
, __entry
->offset
, __entry
->size
, __entry
->vm
)
178 #define VM_TO_TRACE_NAME(vm) \
179 (i915_is_ggtt(vm) ? "G" : \
182 DECLARE_EVENT_CLASS(i915_va
,
183 TP_PROTO(struct i915_address_space
*vm
, u64 start
, u64 length
, const char *name
),
184 TP_ARGS(vm
, start
, length
, name
),
187 __field(struct i915_address_space
*, vm
)
195 __entry
->start
= start
;
196 __entry
->end
= start
+ length
- 1;
197 __assign_str(name
, name
);
200 TP_printk("vm=%p (%s), 0x%llx-0x%llx",
201 __entry
->vm
, __get_str(name
), __entry
->start
, __entry
->end
)
204 DEFINE_EVENT(i915_va
, i915_va_alloc
,
205 TP_PROTO(struct i915_address_space
*vm
, u64 start
, u64 length
, const char *name
),
206 TP_ARGS(vm
, start
, length
, name
)
209 DECLARE_EVENT_CLASS(i915_px_entry
,
210 TP_PROTO(struct i915_address_space
*vm
, u32 px
, u64 start
, u64 px_shift
),
211 TP_ARGS(vm
, px
, start
, px_shift
),
214 __field(struct i915_address_space
*, vm
)
223 __entry
->start
= start
;
224 __entry
->end
= ((start
+ (1ULL << px_shift
)) & ~((1ULL << px_shift
)-1)) - 1;
227 TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
228 __entry
->vm
, __entry
->px
, __entry
->start
, __entry
->end
)
231 DEFINE_EVENT(i915_px_entry
, i915_page_table_entry_alloc
,
232 TP_PROTO(struct i915_address_space
*vm
, u32 pde
, u64 start
, u64 pde_shift
),
233 TP_ARGS(vm
, pde
, start
, pde_shift
)
236 DEFINE_EVENT_PRINT(i915_px_entry
, i915_page_directory_entry_alloc
,
237 TP_PROTO(struct i915_address_space
*vm
, u32 pdpe
, u64 start
, u64 pdpe_shift
),
238 TP_ARGS(vm
, pdpe
, start
, pdpe_shift
),
240 TP_printk("vm=%p, pdpe=%d (0x%llx-0x%llx)",
241 __entry
->vm
, __entry
->px
, __entry
->start
, __entry
->end
)
244 DEFINE_EVENT_PRINT(i915_px_entry
, i915_page_directory_pointer_entry_alloc
,
245 TP_PROTO(struct i915_address_space
*vm
, u32 pml4e
, u64 start
, u64 pml4e_shift
),
246 TP_ARGS(vm
, pml4e
, start
, pml4e_shift
),
248 TP_printk("vm=%p, pml4e=%d (0x%llx-0x%llx)",
249 __entry
->vm
, __entry
->px
, __entry
->start
, __entry
->end
)
252 /* Avoid extra math because we only support two sizes. The format is defined by
253 * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
254 #define TRACE_PT_SIZE(bits) \
255 ((((bits) == 1024) ? 288 : 144) + 1)
257 DECLARE_EVENT_CLASS(i915_page_table_entry_update
,
258 TP_PROTO(struct i915_address_space
*vm
, u32 pde
,
259 struct i915_page_table
*pt
, u32 first
, u32 count
, u32 bits
),
260 TP_ARGS(vm
, pde
, pt
, first
, count
, bits
),
263 __field(struct i915_address_space
*, vm
)
267 __dynamic_array(char, cur_ptes
, TRACE_PT_SIZE(bits
))
273 __entry
->first
= first
;
274 __entry
->last
= first
+ count
- 1;
275 scnprintf(__get_str(cur_ptes
),
282 TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
283 __entry
->vm
, __entry
->pde
, __entry
->last
, __entry
->first
,
287 DEFINE_EVENT(i915_page_table_entry_update
, i915_page_table_entry_map
,
288 TP_PROTO(struct i915_address_space
*vm
, u32 pde
,
289 struct i915_page_table
*pt
, u32 first
, u32 count
, u32 bits
),
290 TP_ARGS(vm
, pde
, pt
, first
, count
, bits
)
293 TRACE_EVENT(i915_gem_object_change_domain
,
294 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 old_read
, u32 old_write
),
295 TP_ARGS(obj
, old_read
, old_write
),
298 __field(struct drm_i915_gem_object
*, obj
)
299 __field(u32
, read_domains
)
300 __field(u32
, write_domain
)
305 __entry
->read_domains
= obj
->base
.read_domains
| (old_read
<< 16);
306 __entry
->write_domain
= obj
->base
.write_domain
| (old_write
<< 16);
309 TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
311 __entry
->read_domains
>> 16,
312 __entry
->read_domains
& 0xffff,
313 __entry
->write_domain
>> 16,
314 __entry
->write_domain
& 0xffff)
317 TRACE_EVENT(i915_gem_object_pwrite
,
318 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 offset
, u32 len
),
319 TP_ARGS(obj
, offset
, len
),
322 __field(struct drm_i915_gem_object
*, obj
)
329 __entry
->offset
= offset
;
333 TP_printk("obj=%p, offset=%u, len=%u",
334 __entry
->obj
, __entry
->offset
, __entry
->len
)
337 TRACE_EVENT(i915_gem_object_pread
,
338 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 offset
, u32 len
),
339 TP_ARGS(obj
, offset
, len
),
342 __field(struct drm_i915_gem_object
*, obj
)
349 __entry
->offset
= offset
;
353 TP_printk("obj=%p, offset=%u, len=%u",
354 __entry
->obj
, __entry
->offset
, __entry
->len
)
357 TRACE_EVENT(i915_gem_object_fault
,
358 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 index
, bool gtt
, bool write
),
359 TP_ARGS(obj
, index
, gtt
, write
),
362 __field(struct drm_i915_gem_object
*, obj
)
370 __entry
->index
= index
;
372 __entry
->write
= write
;
375 TP_printk("obj=%p, %s index=%u %s",
377 __entry
->gtt
? "GTT" : "CPU",
379 __entry
->write
? ", writable" : "")
382 DECLARE_EVENT_CLASS(i915_gem_object
,
383 TP_PROTO(struct drm_i915_gem_object
*obj
),
387 __field(struct drm_i915_gem_object
*, obj
)
394 TP_printk("obj=%p", __entry
->obj
)
397 DEFINE_EVENT(i915_gem_object
, i915_gem_object_clflush
,
398 TP_PROTO(struct drm_i915_gem_object
*obj
),
402 DEFINE_EVENT(i915_gem_object
, i915_gem_object_destroy
,
403 TP_PROTO(struct drm_i915_gem_object
*obj
),
407 TRACE_EVENT(i915_gem_evict
,
408 TP_PROTO(struct drm_device
*dev
, u32 size
, u32 align
, unsigned flags
),
409 TP_ARGS(dev
, size
, align
, flags
),
415 __field(unsigned, flags
)
419 __entry
->dev
= dev
->primary
->index
;
420 __entry
->size
= size
;
421 __entry
->align
= align
;
422 __entry
->flags
= flags
;
425 TP_printk("dev=%d, size=%d, align=%d %s",
426 __entry
->dev
, __entry
->size
, __entry
->align
,
427 __entry
->flags
& PIN_MAPPABLE
? ", mappable" : "")
430 TRACE_EVENT(i915_gem_evict_everything
,
431 TP_PROTO(struct drm_device
*dev
),
439 __entry
->dev
= dev
->primary
->index
;
442 TP_printk("dev=%d", __entry
->dev
)
445 TRACE_EVENT(i915_gem_evict_vm
,
446 TP_PROTO(struct i915_address_space
*vm
),
451 __field(struct i915_address_space
*, vm
)
455 __entry
->dev
= vm
->dev
->primary
->index
;
459 TP_printk("dev=%d, vm=%p", __entry
->dev
, __entry
->vm
)
462 TRACE_EVENT(i915_gem_ring_sync_to
,
463 TP_PROTO(struct drm_i915_gem_request
*to_req
,
464 struct intel_engine_cs
*from
,
465 struct drm_i915_gem_request
*req
),
466 TP_ARGS(to_req
, from
, req
),
470 __field(u32
, sync_from
)
471 __field(u32
, sync_to
)
476 __entry
->dev
= from
->dev
->primary
->index
;
477 __entry
->sync_from
= from
->id
;
478 __entry
->sync_to
= to_req
->ring
->id
;
479 __entry
->seqno
= i915_gem_request_get_seqno(req
);
482 TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
484 __entry
->sync_from
, __entry
->sync_to
,
488 TRACE_EVENT(i915_gem_ring_dispatch
,
489 TP_PROTO(struct drm_i915_gem_request
*req
, u32 flags
),
500 struct intel_engine_cs
*ring
=
501 i915_gem_request_get_ring(req
);
502 __entry
->dev
= ring
->dev
->primary
->index
;
503 __entry
->ring
= ring
->id
;
504 __entry
->seqno
= i915_gem_request_get_seqno(req
);
505 __entry
->flags
= flags
;
506 i915_trace_irq_get(ring
, req
);
509 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
510 __entry
->dev
, __entry
->ring
, __entry
->seqno
, __entry
->flags
)
513 TRACE_EVENT(i915_gem_ring_flush
,
514 TP_PROTO(struct drm_i915_gem_request
*req
, u32 invalidate
, u32 flush
),
515 TP_ARGS(req
, invalidate
, flush
),
520 __field(u32
, invalidate
)
525 __entry
->dev
= req
->ring
->dev
->primary
->index
;
526 __entry
->ring
= req
->ring
->id
;
527 __entry
->invalidate
= invalidate
;
528 __entry
->flush
= flush
;
531 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
532 __entry
->dev
, __entry
->ring
,
533 __entry
->invalidate
, __entry
->flush
)
536 DECLARE_EVENT_CLASS(i915_gem_request
,
537 TP_PROTO(struct drm_i915_gem_request
*req
),
547 struct intel_engine_cs
*ring
=
548 i915_gem_request_get_ring(req
);
549 __entry
->dev
= ring
->dev
->primary
->index
;
550 __entry
->ring
= ring
->id
;
551 __entry
->seqno
= i915_gem_request_get_seqno(req
);
554 TP_printk("dev=%u, ring=%u, seqno=%u",
555 __entry
->dev
, __entry
->ring
, __entry
->seqno
)
558 DEFINE_EVENT(i915_gem_request
, i915_gem_request_add
,
559 TP_PROTO(struct drm_i915_gem_request
*req
),
563 TRACE_EVENT(i915_gem_request_notify
,
564 TP_PROTO(struct intel_engine_cs
*ring
),
574 __entry
->dev
= ring
->dev
->primary
->index
;
575 __entry
->ring
= ring
->id
;
576 __entry
->seqno
= ring
->get_seqno(ring
, false);
579 TP_printk("dev=%u, ring=%u, seqno=%u",
580 __entry
->dev
, __entry
->ring
, __entry
->seqno
)
583 DEFINE_EVENT(i915_gem_request
, i915_gem_request_retire
,
584 TP_PROTO(struct drm_i915_gem_request
*req
),
588 DEFINE_EVENT(i915_gem_request
, i915_gem_request_complete
,
589 TP_PROTO(struct drm_i915_gem_request
*req
),
593 TRACE_EVENT(i915_gem_request_wait_begin
,
594 TP_PROTO(struct drm_i915_gem_request
*req
),
601 __field(bool, blocking
)
604 /* NB: the blocking information is racy since mutex_is_locked
605 * doesn't check that the current thread holds the lock. The only
606 * other option would be to pass the boolean information of whether
607 * or not the class was blocking down through the stack which is
611 struct intel_engine_cs
*ring
=
612 i915_gem_request_get_ring(req
);
613 __entry
->dev
= ring
->dev
->primary
->index
;
614 __entry
->ring
= ring
->id
;
615 __entry
->seqno
= i915_gem_request_get_seqno(req
);
617 mutex_is_locked(&ring
->dev
->struct_mutex
);
620 TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
621 __entry
->dev
, __entry
->ring
,
622 __entry
->seqno
, __entry
->blocking
? "yes (NB)" : "no")
625 DEFINE_EVENT(i915_gem_request
, i915_gem_request_wait_end
,
626 TP_PROTO(struct drm_i915_gem_request
*req
),
630 TRACE_EVENT(i915_flip_request
,
631 TP_PROTO(int plane
, struct drm_i915_gem_object
*obj
),
637 __field(struct drm_i915_gem_object
*, obj
)
641 __entry
->plane
= plane
;
645 TP_printk("plane=%d, obj=%p", __entry
->plane
, __entry
->obj
)
648 TRACE_EVENT(i915_flip_complete
,
649 TP_PROTO(int plane
, struct drm_i915_gem_object
*obj
),
655 __field(struct drm_i915_gem_object
*, obj
)
659 __entry
->plane
= plane
;
663 TP_printk("plane=%d, obj=%p", __entry
->plane
, __entry
->obj
)
666 TRACE_EVENT_CONDITION(i915_reg_rw
,
667 TP_PROTO(bool write
, u32 reg
, u64 val
, int len
, bool trace
),
669 TP_ARGS(write
, reg
, val
, len
, trace
),
681 __entry
->val
= (u64
)val
;
683 __entry
->write
= write
;
687 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
688 __entry
->write
? "write" : "read",
689 __entry
->reg
, __entry
->len
,
690 (u32
)(__entry
->val
& 0xffffffff),
691 (u32
)(__entry
->val
>> 32))
694 TRACE_EVENT(intel_gpu_freq_change
,
703 __entry
->freq
= freq
;
706 TP_printk("new_freq=%u", __entry
->freq
)
710 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
712 * With full ppgtt enabled each process using drm will allocate at least one
713 * translation table. With these traces it is possible to keep track of the
714 * allocation and of the lifetime of the tables; this can be used during
715 * testing/debug to verify that we are not leaking ppgtts.
716 * These traces identify the ppgtt through the vm pointer, which is also printed
717 * by the i915_vma_bind and i915_vma_unbind tracepoints.
719 DECLARE_EVENT_CLASS(i915_ppgtt
,
720 TP_PROTO(struct i915_address_space
*vm
),
724 __field(struct i915_address_space
*, vm
)
730 __entry
->dev
= vm
->dev
->primary
->index
;
733 TP_printk("dev=%u, vm=%p", __entry
->dev
, __entry
->vm
)
736 DEFINE_EVENT(i915_ppgtt
, i915_ppgtt_create
,
737 TP_PROTO(struct i915_address_space
*vm
),
741 DEFINE_EVENT(i915_ppgtt
, i915_ppgtt_release
,
742 TP_PROTO(struct i915_address_space
*vm
),
747 * DOC: i915_context_create and i915_context_free tracepoints
749 * These tracepoints are used to track creation and deletion of contexts.
750 * If full ppgtt is enabled, they also print the address of the vm assigned to
753 DECLARE_EVENT_CLASS(i915_context
,
754 TP_PROTO(struct intel_context
*ctx
),
759 __field(struct intel_context
*, ctx
)
760 __field(struct i915_address_space
*, vm
)
765 __entry
->vm
= ctx
->ppgtt
? &ctx
->ppgtt
->base
: NULL
;
766 __entry
->dev
= ctx
->i915
->dev
->primary
->index
;
769 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
770 __entry
->dev
, __entry
->ctx
, __entry
->vm
)
773 DEFINE_EVENT(i915_context
, i915_context_create
,
774 TP_PROTO(struct intel_context
*ctx
),
778 DEFINE_EVENT(i915_context
, i915_context_free
,
779 TP_PROTO(struct intel_context
*ctx
),
784 * DOC: switch_mm tracepoint
786 * This tracepoint allows tracking of the mm switch, which is an important point
787 * in the lifetime of the vm in the legacy submission path. This tracepoint is
788 * called only if full ppgtt is enabled.
790 TRACE_EVENT(switch_mm
,
791 TP_PROTO(struct intel_engine_cs
*ring
, struct intel_context
*to
),
797 __field(struct intel_context
*, to
)
798 __field(struct i915_address_space
*, vm
)
803 __entry
->ring
= ring
->id
;
805 __entry
->vm
= to
->ppgtt
? &to
->ppgtt
->base
: NULL
;
806 __entry
->dev
= ring
->dev
->primary
->index
;
809 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
810 __entry
->dev
, __entry
->ring
, __entry
->to
, __entry
->vm
)
813 #endif /* _I915_TRACE_H_ */
815 /* This part must be outside protection */
816 #undef TRACE_INCLUDE_PATH
817 #define TRACE_INCLUDE_PATH .
818 #include <trace/define_trace.h>