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
, u32 min
, u32 max
),
21 TP_ARGS(crtc
, min
, max
),
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
);
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
, u32 min
, u32 max
, u32 frame
),
47 TP_ARGS(crtc
, min
, max
, frame
),
50 __field(enum pipe
, pipe
)
52 __field(u32
, scanline
)
58 __entry
->pipe
= crtc
->pipe
;
59 __entry
->frame
= frame
;
60 __entry
->scanline
= intel_get_crtc_scanline(crtc
);
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
),
75 __field(enum pipe
, pipe
)
77 __field(u32
, scanline
)
81 __entry
->pipe
= crtc
->pipe
;
82 __entry
->frame
= frame
;
83 __entry
->scanline
= intel_get_crtc_scanline(crtc
);
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_vma_bind
,
111 TP_PROTO(struct i915_vma
*vma
, unsigned flags
),
115 __field(struct drm_i915_gem_object
*, obj
)
116 __field(struct i915_address_space
*, vm
)
119 __field(unsigned, flags
)
123 __entry
->obj
= vma
->obj
;
124 __entry
->vm
= vma
->vm
;
125 __entry
->offset
= vma
->node
.start
;
126 __entry
->size
= vma
->node
.size
;
127 __entry
->flags
= flags
;
130 TP_printk("obj=%p, offset=%016llx size=%x%s vm=%p",
131 __entry
->obj
, __entry
->offset
, __entry
->size
,
132 __entry
->flags
& PIN_MAPPABLE
? ", mappable" : "",
136 TRACE_EVENT(i915_vma_unbind
,
137 TP_PROTO(struct i915_vma
*vma
),
141 __field(struct drm_i915_gem_object
*, obj
)
142 __field(struct i915_address_space
*, vm
)
148 __entry
->obj
= vma
->obj
;
149 __entry
->vm
= vma
->vm
;
150 __entry
->offset
= vma
->node
.start
;
151 __entry
->size
= vma
->node
.size
;
154 TP_printk("obj=%p, offset=%016llx size=%x vm=%p",
155 __entry
->obj
, __entry
->offset
, __entry
->size
, __entry
->vm
)
158 #define VM_TO_TRACE_NAME(vm) \
159 (i915_is_ggtt(vm) ? "G" : \
162 DECLARE_EVENT_CLASS(i915_va
,
163 TP_PROTO(struct i915_address_space
*vm
, u64 start
, u64 length
, const char *name
),
164 TP_ARGS(vm
, start
, length
, name
),
167 __field(struct i915_address_space
*, vm
)
175 __entry
->start
= start
;
176 __entry
->end
= start
+ length
- 1;
177 __assign_str(name
, name
);
180 TP_printk("vm=%p (%s), 0x%llx-0x%llx",
181 __entry
->vm
, __get_str(name
), __entry
->start
, __entry
->end
)
184 DEFINE_EVENT(i915_va
, i915_va_alloc
,
185 TP_PROTO(struct i915_address_space
*vm
, u64 start
, u64 length
, const char *name
),
186 TP_ARGS(vm
, start
, length
, name
)
189 DECLARE_EVENT_CLASS(i915_page_table_entry
,
190 TP_PROTO(struct i915_address_space
*vm
, u32 pde
, u64 start
, u64 pde_shift
),
191 TP_ARGS(vm
, pde
, start
, pde_shift
),
194 __field(struct i915_address_space
*, vm
)
203 __entry
->start
= start
;
204 __entry
->end
= ((start
+ (1ULL << pde_shift
)) & ~((1ULL << pde_shift
)-1)) - 1;
207 TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
208 __entry
->vm
, __entry
->pde
, __entry
->start
, __entry
->end
)
211 DEFINE_EVENT(i915_page_table_entry
, i915_page_table_entry_alloc
,
212 TP_PROTO(struct i915_address_space
*vm
, u32 pde
, u64 start
, u64 pde_shift
),
213 TP_ARGS(vm
, pde
, start
, pde_shift
)
216 /* Avoid extra math because we only support two sizes. The format is defined by
217 * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
218 #define TRACE_PT_SIZE(bits) \
219 ((((bits) == 1024) ? 288 : 144) + 1)
221 DECLARE_EVENT_CLASS(i915_page_table_entry_update
,
222 TP_PROTO(struct i915_address_space
*vm
, u32 pde
,
223 struct i915_page_table
*pt
, u32 first
, u32 count
, u32 bits
),
224 TP_ARGS(vm
, pde
, pt
, first
, count
, bits
),
227 __field(struct i915_address_space
*, vm
)
231 __dynamic_array(char, cur_ptes
, TRACE_PT_SIZE(bits
))
237 __entry
->first
= first
;
238 __entry
->last
= first
+ count
- 1;
239 scnprintf(__get_str(cur_ptes
),
246 TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
247 __entry
->vm
, __entry
->pde
, __entry
->last
, __entry
->first
,
251 DEFINE_EVENT(i915_page_table_entry_update
, i915_page_table_entry_map
,
252 TP_PROTO(struct i915_address_space
*vm
, u32 pde
,
253 struct i915_page_table
*pt
, u32 first
, u32 count
, u32 bits
),
254 TP_ARGS(vm
, pde
, pt
, first
, count
, bits
)
257 TRACE_EVENT(i915_gem_object_change_domain
,
258 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 old_read
, u32 old_write
),
259 TP_ARGS(obj
, old_read
, old_write
),
262 __field(struct drm_i915_gem_object
*, obj
)
263 __field(u32
, read_domains
)
264 __field(u32
, write_domain
)
269 __entry
->read_domains
= obj
->base
.read_domains
| (old_read
<< 16);
270 __entry
->write_domain
= obj
->base
.write_domain
| (old_write
<< 16);
273 TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
275 __entry
->read_domains
>> 16,
276 __entry
->read_domains
& 0xffff,
277 __entry
->write_domain
>> 16,
278 __entry
->write_domain
& 0xffff)
281 TRACE_EVENT(i915_gem_object_pwrite
,
282 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 offset
, u32 len
),
283 TP_ARGS(obj
, offset
, len
),
286 __field(struct drm_i915_gem_object
*, obj
)
293 __entry
->offset
= offset
;
297 TP_printk("obj=%p, offset=%u, len=%u",
298 __entry
->obj
, __entry
->offset
, __entry
->len
)
301 TRACE_EVENT(i915_gem_object_pread
,
302 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 offset
, u32 len
),
303 TP_ARGS(obj
, offset
, len
),
306 __field(struct drm_i915_gem_object
*, obj
)
313 __entry
->offset
= offset
;
317 TP_printk("obj=%p, offset=%u, len=%u",
318 __entry
->obj
, __entry
->offset
, __entry
->len
)
321 TRACE_EVENT(i915_gem_object_fault
,
322 TP_PROTO(struct drm_i915_gem_object
*obj
, u32 index
, bool gtt
, bool write
),
323 TP_ARGS(obj
, index
, gtt
, write
),
326 __field(struct drm_i915_gem_object
*, obj
)
334 __entry
->index
= index
;
336 __entry
->write
= write
;
339 TP_printk("obj=%p, %s index=%u %s",
341 __entry
->gtt
? "GTT" : "CPU",
343 __entry
->write
? ", writable" : "")
346 DECLARE_EVENT_CLASS(i915_gem_object
,
347 TP_PROTO(struct drm_i915_gem_object
*obj
),
351 __field(struct drm_i915_gem_object
*, obj
)
358 TP_printk("obj=%p", __entry
->obj
)
361 DEFINE_EVENT(i915_gem_object
, i915_gem_object_clflush
,
362 TP_PROTO(struct drm_i915_gem_object
*obj
),
366 DEFINE_EVENT(i915_gem_object
, i915_gem_object_destroy
,
367 TP_PROTO(struct drm_i915_gem_object
*obj
),
371 TRACE_EVENT(i915_gem_evict
,
372 TP_PROTO(struct drm_device
*dev
, u32 size
, u32 align
, unsigned flags
),
373 TP_ARGS(dev
, size
, align
, flags
),
379 __field(unsigned, flags
)
383 __entry
->dev
= dev
->primary
->index
;
384 __entry
->size
= size
;
385 __entry
->align
= align
;
386 __entry
->flags
= flags
;
389 TP_printk("dev=%d, size=%d, align=%d %s",
390 __entry
->dev
, __entry
->size
, __entry
->align
,
391 __entry
->flags
& PIN_MAPPABLE
? ", mappable" : "")
394 TRACE_EVENT(i915_gem_evict_everything
,
395 TP_PROTO(struct drm_device
*dev
),
403 __entry
->dev
= dev
->primary
->index
;
406 TP_printk("dev=%d", __entry
->dev
)
409 TRACE_EVENT(i915_gem_evict_vm
,
410 TP_PROTO(struct i915_address_space
*vm
),
415 __field(struct i915_address_space
*, vm
)
419 __entry
->dev
= vm
->dev
->primary
->index
;
423 TP_printk("dev=%d, vm=%p", __entry
->dev
, __entry
->vm
)
426 TRACE_EVENT(i915_gem_ring_sync_to
,
427 TP_PROTO(struct intel_engine_cs
*from
,
428 struct intel_engine_cs
*to
,
429 struct drm_i915_gem_request
*req
),
430 TP_ARGS(from
, to
, req
),
434 __field(u32
, sync_from
)
435 __field(u32
, sync_to
)
440 __entry
->dev
= from
->dev
->primary
->index
;
441 __entry
->sync_from
= from
->id
;
442 __entry
->sync_to
= to
->id
;
443 __entry
->seqno
= i915_gem_request_get_seqno(req
);
446 TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
448 __entry
->sync_from
, __entry
->sync_to
,
452 TRACE_EVENT(i915_gem_ring_dispatch
,
453 TP_PROTO(struct drm_i915_gem_request
*req
, u32 flags
),
464 struct intel_engine_cs
*ring
=
465 i915_gem_request_get_ring(req
);
466 __entry
->dev
= ring
->dev
->primary
->index
;
467 __entry
->ring
= ring
->id
;
468 __entry
->seqno
= i915_gem_request_get_seqno(req
);
469 __entry
->flags
= flags
;
470 i915_trace_irq_get(ring
, req
);
473 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
474 __entry
->dev
, __entry
->ring
, __entry
->seqno
, __entry
->flags
)
477 TRACE_EVENT(i915_gem_ring_flush
,
478 TP_PROTO(struct intel_engine_cs
*ring
, u32 invalidate
, u32 flush
),
479 TP_ARGS(ring
, invalidate
, flush
),
484 __field(u32
, invalidate
)
489 __entry
->dev
= ring
->dev
->primary
->index
;
490 __entry
->ring
= ring
->id
;
491 __entry
->invalidate
= invalidate
;
492 __entry
->flush
= flush
;
495 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
496 __entry
->dev
, __entry
->ring
,
497 __entry
->invalidate
, __entry
->flush
)
500 DECLARE_EVENT_CLASS(i915_gem_request
,
501 TP_PROTO(struct drm_i915_gem_request
*req
),
511 struct intel_engine_cs
*ring
=
512 i915_gem_request_get_ring(req
);
513 __entry
->dev
= ring
->dev
->primary
->index
;
514 __entry
->ring
= ring
->id
;
515 __entry
->seqno
= i915_gem_request_get_seqno(req
);
518 TP_printk("dev=%u, ring=%u, seqno=%u",
519 __entry
->dev
, __entry
->ring
, __entry
->seqno
)
522 DEFINE_EVENT(i915_gem_request
, i915_gem_request_add
,
523 TP_PROTO(struct drm_i915_gem_request
*req
),
527 TRACE_EVENT(i915_gem_request_notify
,
528 TP_PROTO(struct intel_engine_cs
*ring
),
538 __entry
->dev
= ring
->dev
->primary
->index
;
539 __entry
->ring
= ring
->id
;
540 __entry
->seqno
= ring
->get_seqno(ring
, false);
543 TP_printk("dev=%u, ring=%u, seqno=%u",
544 __entry
->dev
, __entry
->ring
, __entry
->seqno
)
547 DEFINE_EVENT(i915_gem_request
, i915_gem_request_retire
,
548 TP_PROTO(struct drm_i915_gem_request
*req
),
552 DEFINE_EVENT(i915_gem_request
, i915_gem_request_complete
,
553 TP_PROTO(struct drm_i915_gem_request
*req
),
557 TRACE_EVENT(i915_gem_request_wait_begin
,
558 TP_PROTO(struct drm_i915_gem_request
*req
),
565 __field(bool, blocking
)
568 /* NB: the blocking information is racy since mutex_is_locked
569 * doesn't check that the current thread holds the lock. The only
570 * other option would be to pass the boolean information of whether
571 * or not the class was blocking down through the stack which is
575 struct intel_engine_cs
*ring
=
576 i915_gem_request_get_ring(req
);
577 __entry
->dev
= ring
->dev
->primary
->index
;
578 __entry
->ring
= ring
->id
;
579 __entry
->seqno
= i915_gem_request_get_seqno(req
);
581 mutex_is_locked(&ring
->dev
->struct_mutex
);
584 TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
585 __entry
->dev
, __entry
->ring
,
586 __entry
->seqno
, __entry
->blocking
? "yes (NB)" : "no")
589 DEFINE_EVENT(i915_gem_request
, i915_gem_request_wait_end
,
590 TP_PROTO(struct drm_i915_gem_request
*req
),
594 TRACE_EVENT(i915_flip_request
,
595 TP_PROTO(int plane
, struct drm_i915_gem_object
*obj
),
601 __field(struct drm_i915_gem_object
*, obj
)
605 __entry
->plane
= plane
;
609 TP_printk("plane=%d, obj=%p", __entry
->plane
, __entry
->obj
)
612 TRACE_EVENT(i915_flip_complete
,
613 TP_PROTO(int plane
, struct drm_i915_gem_object
*obj
),
619 __field(struct drm_i915_gem_object
*, obj
)
623 __entry
->plane
= plane
;
627 TP_printk("plane=%d, obj=%p", __entry
->plane
, __entry
->obj
)
630 TRACE_EVENT_CONDITION(i915_reg_rw
,
631 TP_PROTO(bool write
, u32 reg
, u64 val
, int len
, bool trace
),
633 TP_ARGS(write
, reg
, val
, len
, trace
),
645 __entry
->val
= (u64
)val
;
647 __entry
->write
= write
;
651 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
652 __entry
->write
? "write" : "read",
653 __entry
->reg
, __entry
->len
,
654 (u32
)(__entry
->val
& 0xffffffff),
655 (u32
)(__entry
->val
>> 32))
658 TRACE_EVENT(intel_gpu_freq_change
,
667 __entry
->freq
= freq
;
670 TP_printk("new_freq=%u", __entry
->freq
)
674 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
676 * With full ppgtt enabled each process using drm will allocate at least one
677 * translation table. With these traces it is possible to keep track of the
678 * allocation and of the lifetime of the tables; this can be used during
679 * testing/debug to verify that we are not leaking ppgtts.
680 * These traces identify the ppgtt through the vm pointer, which is also printed
681 * by the i915_vma_bind and i915_vma_unbind tracepoints.
683 DECLARE_EVENT_CLASS(i915_ppgtt
,
684 TP_PROTO(struct i915_address_space
*vm
),
688 __field(struct i915_address_space
*, vm
)
694 __entry
->dev
= vm
->dev
->primary
->index
;
697 TP_printk("dev=%u, vm=%p", __entry
->dev
, __entry
->vm
)
700 DEFINE_EVENT(i915_ppgtt
, i915_ppgtt_create
,
701 TP_PROTO(struct i915_address_space
*vm
),
705 DEFINE_EVENT(i915_ppgtt
, i915_ppgtt_release
,
706 TP_PROTO(struct i915_address_space
*vm
),
711 * DOC: i915_context_create and i915_context_free tracepoints
713 * These tracepoints are used to track creation and deletion of contexts.
714 * If full ppgtt is enabled, they also print the address of the vm assigned to
717 DECLARE_EVENT_CLASS(i915_context
,
718 TP_PROTO(struct intel_context
*ctx
),
723 __field(struct intel_context
*, ctx
)
724 __field(struct i915_address_space
*, vm
)
729 __entry
->vm
= ctx
->ppgtt
? &ctx
->ppgtt
->base
: NULL
;
730 __entry
->dev
= ctx
->i915
->dev
->primary
->index
;
733 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
734 __entry
->dev
, __entry
->ctx
, __entry
->vm
)
737 DEFINE_EVENT(i915_context
, i915_context_create
,
738 TP_PROTO(struct intel_context
*ctx
),
742 DEFINE_EVENT(i915_context
, i915_context_free
,
743 TP_PROTO(struct intel_context
*ctx
),
748 * DOC: switch_mm tracepoint
750 * This tracepoint allows tracking of the mm switch, which is an important point
751 * in the lifetime of the vm in the legacy submission path. This tracepoint is
752 * called only if full ppgtt is enabled.
754 TRACE_EVENT(switch_mm
,
755 TP_PROTO(struct intel_engine_cs
*ring
, struct intel_context
*to
),
761 __field(struct intel_context
*, to
)
762 __field(struct i915_address_space
*, vm
)
767 __entry
->ring
= ring
->id
;
769 __entry
->vm
= to
->ppgtt
? &to
->ppgtt
->base
: NULL
;
770 __entry
->dev
= ring
->dev
->primary
->index
;
773 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
774 __entry
->dev
, __entry
->ring
, __entry
->to
, __entry
->vm
)
777 #endif /* _I915_TRACE_H_ */
779 /* This part must be outside protection */
780 #undef TRACE_INCLUDE_PATH
781 #define TRACE_INCLUDE_PATH .
782 #include <trace/define_trace.h>