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 TRACE_EVENT(i915_va_alloc,
179 TP_PROTO(struct i915_vma *vma),
183 __field(struct i915_address_space *, vm)
189 __entry->vm = vma->vm;
190 __entry->start = vma->node.start;
191 __entry->end = vma->node.start + vma->node.size - 1;
194 TP_printk("vm=%p (%c), 0x%llx-0x%llx",
195 __entry->vm, i915_is_ggtt(__entry->vm) ? 'G' : 'P', __entry->start, __entry->end)
198 DECLARE_EVENT_CLASS(i915_px_entry,
199 TP_PROTO(struct i915_address_space *vm, u32 px, u64 start, u64 px_shift),
200 TP_ARGS(vm, px, start, px_shift),
203 __field(struct i915_address_space *, vm)
212 __entry->start = start;
213 __entry->end = ((start + (1ULL << px_shift)) & ~((1ULL << px_shift)-1)) - 1;
216 TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
217 __entry->vm, __entry->px, __entry->start, __entry->end)
220 DEFINE_EVENT(i915_px_entry, i915_page_table_entry_alloc,
221 TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
222 TP_ARGS(vm, pde, start, pde_shift)
225 DEFINE_EVENT_PRINT(i915_px_entry, i915_page_directory_entry_alloc,
226 TP_PROTO(struct i915_address_space *vm, u32 pdpe, u64 start, u64 pdpe_shift),
227 TP_ARGS(vm, pdpe, start, pdpe_shift),
229 TP_printk("vm=%p, pdpe=%d (0x%llx-0x%llx)",
230 __entry->vm, __entry->px, __entry->start, __entry->end)
233 DEFINE_EVENT_PRINT(i915_px_entry, i915_page_directory_pointer_entry_alloc,
234 TP_PROTO(struct i915_address_space *vm, u32 pml4e, u64 start, u64 pml4e_shift),
235 TP_ARGS(vm, pml4e, start, pml4e_shift),
237 TP_printk("vm=%p, pml4e=%d (0x%llx-0x%llx)",
238 __entry->vm, __entry->px, __entry->start, __entry->end)
241 /* Avoid extra math because we only support two sizes. The format is defined by
242 * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
243 #define TRACE_PT_SIZE(bits) \
244 ((((bits) == 1024) ? 288 : 144) + 1)
246 DECLARE_EVENT_CLASS(i915_page_table_entry_update,
247 TP_PROTO(struct i915_address_space *vm, u32 pde,
248 struct i915_page_table *pt, u32 first, u32 count, u32 bits),
249 TP_ARGS(vm, pde, pt, first, count, bits),
252 __field(struct i915_address_space *, vm)
256 __dynamic_array(char, cur_ptes, TRACE_PT_SIZE(bits))
262 __entry->first = first;
263 __entry->last = first + count - 1;
264 scnprintf(__get_str(cur_ptes),
271 TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
272 __entry->vm, __entry->pde, __entry->last, __entry->first,
276 DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_map,
277 TP_PROTO(struct i915_address_space *vm, u32 pde,
278 struct i915_page_table *pt, u32 first, u32 count, u32 bits),
279 TP_ARGS(vm, pde, pt, first, count, bits)
282 TRACE_EVENT(i915_gem_object_change_domain,
283 TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
284 TP_ARGS(obj, old_read, old_write),
287 __field(struct drm_i915_gem_object *, obj)
288 __field(u32, read_domains)
289 __field(u32, write_domain)
294 __entry->read_domains = obj->base.read_domains | (old_read << 16);
295 __entry->write_domain = obj->base.write_domain | (old_write << 16);
298 TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
300 __entry->read_domains >> 16,
301 __entry->read_domains & 0xffff,
302 __entry->write_domain >> 16,
303 __entry->write_domain & 0xffff)
306 TRACE_EVENT(i915_gem_object_pwrite,
307 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
308 TP_ARGS(obj, offset, len),
311 __field(struct drm_i915_gem_object *, obj)
318 __entry->offset = offset;
322 TP_printk("obj=%p, offset=%u, len=%u",
323 __entry->obj, __entry->offset, __entry->len)
326 TRACE_EVENT(i915_gem_object_pread,
327 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
328 TP_ARGS(obj, offset, len),
331 __field(struct drm_i915_gem_object *, obj)
338 __entry->offset = offset;
342 TP_printk("obj=%p, offset=%u, len=%u",
343 __entry->obj, __entry->offset, __entry->len)
346 TRACE_EVENT(i915_gem_object_fault,
347 TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
348 TP_ARGS(obj, index, gtt, write),
351 __field(struct drm_i915_gem_object *, obj)
359 __entry->index = index;
361 __entry->write = write;
364 TP_printk("obj=%p, %s index=%u %s",
366 __entry->gtt ? "GTT" : "CPU",
368 __entry->write ? ", writable" : "")
371 DECLARE_EVENT_CLASS(i915_gem_object,
372 TP_PROTO(struct drm_i915_gem_object *obj),
376 __field(struct drm_i915_gem_object *, obj)
383 TP_printk("obj=%p", __entry->obj)
386 DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
387 TP_PROTO(struct drm_i915_gem_object *obj),
391 DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
392 TP_PROTO(struct drm_i915_gem_object *obj),
396 TRACE_EVENT(i915_gem_evict,
397 TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
398 TP_ARGS(dev, size, align, flags),
404 __field(unsigned, flags)
408 __entry->dev = dev->primary->index;
409 __entry->size = size;
410 __entry->align = align;
411 __entry->flags = flags;
414 TP_printk("dev=%d, size=%d, align=%d %s",
415 __entry->dev, __entry->size, __entry->align,
416 __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
419 TRACE_EVENT(i915_gem_evict_everything,
420 TP_PROTO(struct drm_device *dev),
428 __entry->dev = dev->primary->index;
431 TP_printk("dev=%d", __entry->dev)
434 TRACE_EVENT(i915_gem_evict_vm,
435 TP_PROTO(struct i915_address_space *vm),
440 __field(struct i915_address_space *, vm)
444 __entry->dev = vm->dev->primary->index;
448 TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
451 TRACE_EVENT(i915_gem_ring_sync_to,
452 TP_PROTO(struct drm_i915_gem_request *to_req,
453 struct intel_engine_cs *from,
454 struct drm_i915_gem_request *req),
455 TP_ARGS(to_req, from, req),
459 __field(u32, sync_from)
460 __field(u32, sync_to)
465 __entry->dev = from->dev->primary->index;
466 __entry->sync_from = from->id;
467 __entry->sync_to = to_req->engine->id;
468 __entry->seqno = i915_gem_request_get_seqno(req);
471 TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
473 __entry->sync_from, __entry->sync_to,
477 TRACE_EVENT(i915_gem_ring_dispatch,
478 TP_PROTO(struct drm_i915_gem_request *req, u32 flags),
489 struct intel_engine_cs *engine =
490 i915_gem_request_get_ring(req);
491 __entry->dev = engine->dev->primary->index;
492 __entry->ring = engine->id;
493 __entry->seqno = i915_gem_request_get_seqno(req);
494 __entry->flags = flags;
495 i915_trace_irq_get(engine, req);
498 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
499 __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
502 TRACE_EVENT(i915_gem_ring_flush,
503 TP_PROTO(struct drm_i915_gem_request *req, u32 invalidate, u32 flush),
504 TP_ARGS(req, invalidate, flush),
509 __field(u32, invalidate)
514 __entry->dev = req->engine->dev->primary->index;
515 __entry->ring = req->engine->id;
516 __entry->invalidate = invalidate;
517 __entry->flush = flush;
520 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
521 __entry->dev, __entry->ring,
522 __entry->invalidate, __entry->flush)
525 DECLARE_EVENT_CLASS(i915_gem_request,
526 TP_PROTO(struct drm_i915_gem_request *req),
536 struct intel_engine_cs *engine =
537 i915_gem_request_get_ring(req);
538 __entry->dev = engine->dev->primary->index;
539 __entry->ring = engine->id;
540 __entry->seqno = i915_gem_request_get_seqno(req);
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_add,
548 TP_PROTO(struct drm_i915_gem_request *req),
552 TRACE_EVENT(i915_gem_request_notify,
553 TP_PROTO(struct intel_engine_cs *engine),
563 __entry->dev = engine->dev->primary->index;
564 __entry->ring = engine->id;
565 __entry->seqno = engine->get_seqno(engine, false);
568 TP_printk("dev=%u, ring=%u, seqno=%u",
569 __entry->dev, __entry->ring, __entry->seqno)
572 DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
573 TP_PROTO(struct drm_i915_gem_request *req),
577 DEFINE_EVENT(i915_gem_request, i915_gem_request_complete,
578 TP_PROTO(struct drm_i915_gem_request *req),
582 TRACE_EVENT(i915_gem_request_wait_begin,
583 TP_PROTO(struct drm_i915_gem_request *req),
590 __field(bool, blocking)
593 /* NB: the blocking information is racy since mutex_is_locked
594 * doesn't check that the current thread holds the lock. The only
595 * other option would be to pass the boolean information of whether
596 * or not the class was blocking down through the stack which is
600 struct intel_engine_cs *engine =
601 i915_gem_request_get_ring(req);
602 __entry->dev = engine->dev->primary->index;
603 __entry->ring = engine->id;
604 __entry->seqno = i915_gem_request_get_seqno(req);
606 mutex_is_locked(&engine->dev->struct_mutex);
609 TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
610 __entry->dev, __entry->ring,
611 __entry->seqno, __entry->blocking ? "yes (NB)" : "no")
614 DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
615 TP_PROTO(struct drm_i915_gem_request *req),
619 TRACE_EVENT(i915_flip_request,
620 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
626 __field(struct drm_i915_gem_object *, obj)
630 __entry->plane = plane;
634 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
637 TRACE_EVENT(i915_flip_complete,
638 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
644 __field(struct drm_i915_gem_object *, obj)
648 __entry->plane = plane;
652 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
655 TRACE_EVENT_CONDITION(i915_reg_rw,
656 TP_PROTO(bool write, i915_reg_t reg, u64 val, int len, bool trace),
658 TP_ARGS(write, reg, val, len, trace),
670 __entry->val = (u64)val;
671 __entry->reg = i915_mmio_reg_offset(reg);
672 __entry->write = write;
676 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
677 __entry->write ? "write" : "read",
678 __entry->reg, __entry->len,
679 (u32)(__entry->val & 0xffffffff),
680 (u32)(__entry->val >> 32))
683 TRACE_EVENT(intel_gpu_freq_change,
692 __entry->freq = freq;
695 TP_printk("new_freq=%u", __entry->freq)
699 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
701 * With full ppgtt enabled each process using drm will allocate at least one
702 * translation table. With these traces it is possible to keep track of the
703 * allocation and of the lifetime of the tables; this can be used during
704 * testing/debug to verify that we are not leaking ppgtts.
705 * These traces identify the ppgtt through the vm pointer, which is also printed
706 * by the i915_vma_bind and i915_vma_unbind tracepoints.
708 DECLARE_EVENT_CLASS(i915_ppgtt,
709 TP_PROTO(struct i915_address_space *vm),
713 __field(struct i915_address_space *, vm)
719 __entry->dev = vm->dev->primary->index;
722 TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
725 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
726 TP_PROTO(struct i915_address_space *vm),
730 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
731 TP_PROTO(struct i915_address_space *vm),
736 * DOC: i915_context_create and i915_context_free tracepoints
738 * These tracepoints are used to track creation and deletion of contexts.
739 * If full ppgtt is enabled, they also print the address of the vm assigned to
742 DECLARE_EVENT_CLASS(i915_context,
743 TP_PROTO(struct intel_context *ctx),
748 __field(struct intel_context *, ctx)
749 __field(struct i915_address_space *, vm)
754 __entry->vm = ctx->ppgtt ? &ctx->ppgtt->base : NULL;
755 __entry->dev = ctx->i915->dev->primary->index;
758 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
759 __entry->dev, __entry->ctx, __entry->vm)
762 DEFINE_EVENT(i915_context, i915_context_create,
763 TP_PROTO(struct intel_context *ctx),
767 DEFINE_EVENT(i915_context, i915_context_free,
768 TP_PROTO(struct intel_context *ctx),
773 * DOC: switch_mm tracepoint
775 * This tracepoint allows tracking of the mm switch, which is an important point
776 * in the lifetime of the vm in the legacy submission path. This tracepoint is
777 * called only if full ppgtt is enabled.
779 TRACE_EVENT(switch_mm,
780 TP_PROTO(struct intel_engine_cs *engine, struct intel_context *to),
786 __field(struct intel_context *, to)
787 __field(struct i915_address_space *, vm)
792 __entry->ring = engine->id;
794 __entry->vm = to->ppgtt? &to->ppgtt->base : NULL;
795 __entry->dev = engine->dev->primary->index;
798 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
799 __entry->dev, __entry->ring, __entry->to, __entry->vm)
802 #endif /* _I915_TRACE_H_ */
804 /* This part must be outside protection */
805 #undef TRACE_INCLUDE_PATH
806 #define TRACE_INCLUDE_PATH .
807 #include <trace/define_trace.h>