xref: /openbmc/linux/drivers/gpu/drm/i915/i915_trace.h (revision f7018c21)
1 #if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
2 #define _I915_TRACE_H_
3 
4 #include <linux/stringify.h>
5 #include <linux/types.h>
6 #include <linux/tracepoint.h>
7 
8 #include <drm/drmP.h>
9 #include "i915_drv.h"
10 #include "intel_ringbuffer.h"
11 
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM i915
14 #define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)
15 #define TRACE_INCLUDE_FILE i915_trace
16 
17 /* object tracking */
18 
19 TRACE_EVENT(i915_gem_object_create,
20 	    TP_PROTO(struct drm_i915_gem_object *obj),
21 	    TP_ARGS(obj),
22 
23 	    TP_STRUCT__entry(
24 			     __field(struct drm_i915_gem_object *, obj)
25 			     __field(u32, size)
26 			     ),
27 
28 	    TP_fast_assign(
29 			   __entry->obj = obj;
30 			   __entry->size = obj->base.size;
31 			   ),
32 
33 	    TP_printk("obj=%p, size=%u", __entry->obj, __entry->size)
34 );
35 
36 TRACE_EVENT(i915_vma_bind,
37 	    TP_PROTO(struct i915_vma *vma, unsigned flags),
38 	    TP_ARGS(vma, flags),
39 
40 	    TP_STRUCT__entry(
41 			     __field(struct drm_i915_gem_object *, obj)
42 			     __field(struct i915_address_space *, vm)
43 			     __field(u32, offset)
44 			     __field(u32, size)
45 			     __field(unsigned, flags)
46 			     ),
47 
48 	    TP_fast_assign(
49 			   __entry->obj = vma->obj;
50 			   __entry->vm = vma->vm;
51 			   __entry->offset = vma->node.start;
52 			   __entry->size = vma->node.size;
53 			   __entry->flags = flags;
54 			   ),
55 
56 	    TP_printk("obj=%p, offset=%08x size=%x%s vm=%p",
57 		      __entry->obj, __entry->offset, __entry->size,
58 		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
59 		      __entry->vm)
60 );
61 
62 TRACE_EVENT(i915_vma_unbind,
63 	    TP_PROTO(struct i915_vma *vma),
64 	    TP_ARGS(vma),
65 
66 	    TP_STRUCT__entry(
67 			     __field(struct drm_i915_gem_object *, obj)
68 			     __field(struct i915_address_space *, vm)
69 			     __field(u32, offset)
70 			     __field(u32, size)
71 			     ),
72 
73 	    TP_fast_assign(
74 			   __entry->obj = vma->obj;
75 			   __entry->vm = vma->vm;
76 			   __entry->offset = vma->node.start;
77 			   __entry->size = vma->node.size;
78 			   ),
79 
80 	    TP_printk("obj=%p, offset=%08x size=%x vm=%p",
81 		      __entry->obj, __entry->offset, __entry->size, __entry->vm)
82 );
83 
84 TRACE_EVENT(i915_gem_object_change_domain,
85 	    TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
86 	    TP_ARGS(obj, old_read, old_write),
87 
88 	    TP_STRUCT__entry(
89 			     __field(struct drm_i915_gem_object *, obj)
90 			     __field(u32, read_domains)
91 			     __field(u32, write_domain)
92 			     ),
93 
94 	    TP_fast_assign(
95 			   __entry->obj = obj;
96 			   __entry->read_domains = obj->base.read_domains | (old_read << 16);
97 			   __entry->write_domain = obj->base.write_domain | (old_write << 16);
98 			   ),
99 
100 	    TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
101 		      __entry->obj,
102 		      __entry->read_domains >> 16,
103 		      __entry->read_domains & 0xffff,
104 		      __entry->write_domain >> 16,
105 		      __entry->write_domain & 0xffff)
106 );
107 
108 TRACE_EVENT(i915_gem_object_pwrite,
109 	    TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
110 	    TP_ARGS(obj, offset, len),
111 
112 	    TP_STRUCT__entry(
113 			     __field(struct drm_i915_gem_object *, obj)
114 			     __field(u32, offset)
115 			     __field(u32, len)
116 			     ),
117 
118 	    TP_fast_assign(
119 			   __entry->obj = obj;
120 			   __entry->offset = offset;
121 			   __entry->len = len;
122 			   ),
123 
124 	    TP_printk("obj=%p, offset=%u, len=%u",
125 		      __entry->obj, __entry->offset, __entry->len)
126 );
127 
128 TRACE_EVENT(i915_gem_object_pread,
129 	    TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
130 	    TP_ARGS(obj, offset, len),
131 
132 	    TP_STRUCT__entry(
133 			     __field(struct drm_i915_gem_object *, obj)
134 			     __field(u32, offset)
135 			     __field(u32, len)
136 			     ),
137 
138 	    TP_fast_assign(
139 			   __entry->obj = obj;
140 			   __entry->offset = offset;
141 			   __entry->len = len;
142 			   ),
143 
144 	    TP_printk("obj=%p, offset=%u, len=%u",
145 		      __entry->obj, __entry->offset, __entry->len)
146 );
147 
148 TRACE_EVENT(i915_gem_object_fault,
149 	    TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
150 	    TP_ARGS(obj, index, gtt, write),
151 
152 	    TP_STRUCT__entry(
153 			     __field(struct drm_i915_gem_object *, obj)
154 			     __field(u32, index)
155 			     __field(bool, gtt)
156 			     __field(bool, write)
157 			     ),
158 
159 	    TP_fast_assign(
160 			   __entry->obj = obj;
161 			   __entry->index = index;
162 			   __entry->gtt = gtt;
163 			   __entry->write = write;
164 			   ),
165 
166 	    TP_printk("obj=%p, %s index=%u %s",
167 		      __entry->obj,
168 		      __entry->gtt ? "GTT" : "CPU",
169 		      __entry->index,
170 		      __entry->write ? ", writable" : "")
171 );
172 
173 DECLARE_EVENT_CLASS(i915_gem_object,
174 	    TP_PROTO(struct drm_i915_gem_object *obj),
175 	    TP_ARGS(obj),
176 
177 	    TP_STRUCT__entry(
178 			     __field(struct drm_i915_gem_object *, obj)
179 			     ),
180 
181 	    TP_fast_assign(
182 			   __entry->obj = obj;
183 			   ),
184 
185 	    TP_printk("obj=%p", __entry->obj)
186 );
187 
188 DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
189 	     TP_PROTO(struct drm_i915_gem_object *obj),
190 	     TP_ARGS(obj)
191 );
192 
193 DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
194 	    TP_PROTO(struct drm_i915_gem_object *obj),
195 	    TP_ARGS(obj)
196 );
197 
198 TRACE_EVENT(i915_gem_evict,
199 	    TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
200 	    TP_ARGS(dev, size, align, flags),
201 
202 	    TP_STRUCT__entry(
203 			     __field(u32, dev)
204 			     __field(u32, size)
205 			     __field(u32, align)
206 			     __field(unsigned, flags)
207 			    ),
208 
209 	    TP_fast_assign(
210 			   __entry->dev = dev->primary->index;
211 			   __entry->size = size;
212 			   __entry->align = align;
213 			   __entry->flags = flags;
214 			  ),
215 
216 	    TP_printk("dev=%d, size=%d, align=%d %s",
217 		      __entry->dev, __entry->size, __entry->align,
218 		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
219 );
220 
221 TRACE_EVENT(i915_gem_evict_everything,
222 	    TP_PROTO(struct drm_device *dev),
223 	    TP_ARGS(dev),
224 
225 	    TP_STRUCT__entry(
226 			     __field(u32, dev)
227 			    ),
228 
229 	    TP_fast_assign(
230 			   __entry->dev = dev->primary->index;
231 			  ),
232 
233 	    TP_printk("dev=%d", __entry->dev)
234 );
235 
236 TRACE_EVENT(i915_gem_evict_vm,
237 	    TP_PROTO(struct i915_address_space *vm),
238 	    TP_ARGS(vm),
239 
240 	    TP_STRUCT__entry(
241 			     __field(u32, dev)
242 			     __field(struct i915_address_space *, vm)
243 			    ),
244 
245 	    TP_fast_assign(
246 			   __entry->dev = vm->dev->primary->index;
247 			   __entry->vm = vm;
248 			  ),
249 
250 	    TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
251 );
252 
253 TRACE_EVENT(i915_gem_ring_sync_to,
254 	    TP_PROTO(struct intel_ring_buffer *from,
255 		     struct intel_ring_buffer *to,
256 		     u32 seqno),
257 	    TP_ARGS(from, to, seqno),
258 
259 	    TP_STRUCT__entry(
260 			     __field(u32, dev)
261 			     __field(u32, sync_from)
262 			     __field(u32, sync_to)
263 			     __field(u32, seqno)
264 			     ),
265 
266 	    TP_fast_assign(
267 			   __entry->dev = from->dev->primary->index;
268 			   __entry->sync_from = from->id;
269 			   __entry->sync_to = to->id;
270 			   __entry->seqno = seqno;
271 			   ),
272 
273 	    TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
274 		      __entry->dev,
275 		      __entry->sync_from, __entry->sync_to,
276 		      __entry->seqno)
277 );
278 
279 TRACE_EVENT(i915_gem_ring_dispatch,
280 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno, u32 flags),
281 	    TP_ARGS(ring, seqno, flags),
282 
283 	    TP_STRUCT__entry(
284 			     __field(u32, dev)
285 			     __field(u32, ring)
286 			     __field(u32, seqno)
287 			     __field(u32, flags)
288 			     ),
289 
290 	    TP_fast_assign(
291 			   __entry->dev = ring->dev->primary->index;
292 			   __entry->ring = ring->id;
293 			   __entry->seqno = seqno;
294 			   __entry->flags = flags;
295 			   i915_trace_irq_get(ring, seqno);
296 			   ),
297 
298 	    TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
299 		      __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
300 );
301 
302 TRACE_EVENT(i915_gem_ring_flush,
303 	    TP_PROTO(struct intel_ring_buffer *ring, u32 invalidate, u32 flush),
304 	    TP_ARGS(ring, invalidate, flush),
305 
306 	    TP_STRUCT__entry(
307 			     __field(u32, dev)
308 			     __field(u32, ring)
309 			     __field(u32, invalidate)
310 			     __field(u32, flush)
311 			     ),
312 
313 	    TP_fast_assign(
314 			   __entry->dev = ring->dev->primary->index;
315 			   __entry->ring = ring->id;
316 			   __entry->invalidate = invalidate;
317 			   __entry->flush = flush;
318 			   ),
319 
320 	    TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
321 		      __entry->dev, __entry->ring,
322 		      __entry->invalidate, __entry->flush)
323 );
324 
325 DECLARE_EVENT_CLASS(i915_gem_request,
326 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
327 	    TP_ARGS(ring, seqno),
328 
329 	    TP_STRUCT__entry(
330 			     __field(u32, dev)
331 			     __field(u32, ring)
332 			     __field(u32, seqno)
333 			     ),
334 
335 	    TP_fast_assign(
336 			   __entry->dev = ring->dev->primary->index;
337 			   __entry->ring = ring->id;
338 			   __entry->seqno = seqno;
339 			   ),
340 
341 	    TP_printk("dev=%u, ring=%u, seqno=%u",
342 		      __entry->dev, __entry->ring, __entry->seqno)
343 );
344 
345 DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
346 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
347 	    TP_ARGS(ring, seqno)
348 );
349 
350 TRACE_EVENT(i915_gem_request_complete,
351 	    TP_PROTO(struct intel_ring_buffer *ring),
352 	    TP_ARGS(ring),
353 
354 	    TP_STRUCT__entry(
355 			     __field(u32, dev)
356 			     __field(u32, ring)
357 			     __field(u32, seqno)
358 			     ),
359 
360 	    TP_fast_assign(
361 			   __entry->dev = ring->dev->primary->index;
362 			   __entry->ring = ring->id;
363 			   __entry->seqno = ring->get_seqno(ring, false);
364 			   ),
365 
366 	    TP_printk("dev=%u, ring=%u, seqno=%u",
367 		      __entry->dev, __entry->ring, __entry->seqno)
368 );
369 
370 DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
371 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
372 	    TP_ARGS(ring, seqno)
373 );
374 
375 TRACE_EVENT(i915_gem_request_wait_begin,
376 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
377 	    TP_ARGS(ring, seqno),
378 
379 	    TP_STRUCT__entry(
380 			     __field(u32, dev)
381 			     __field(u32, ring)
382 			     __field(u32, seqno)
383 			     __field(bool, blocking)
384 			     ),
385 
386 	    /* NB: the blocking information is racy since mutex_is_locked
387 	     * doesn't check that the current thread holds the lock. The only
388 	     * other option would be to pass the boolean information of whether
389 	     * or not the class was blocking down through the stack which is
390 	     * less desirable.
391 	     */
392 	    TP_fast_assign(
393 			   __entry->dev = ring->dev->primary->index;
394 			   __entry->ring = ring->id;
395 			   __entry->seqno = seqno;
396 			   __entry->blocking = mutex_is_locked(&ring->dev->struct_mutex);
397 			   ),
398 
399 	    TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
400 		      __entry->dev, __entry->ring, __entry->seqno,
401 		      __entry->blocking ?  "yes (NB)" : "no")
402 );
403 
404 DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
405 	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
406 	    TP_ARGS(ring, seqno)
407 );
408 
409 DECLARE_EVENT_CLASS(i915_ring,
410 	    TP_PROTO(struct intel_ring_buffer *ring),
411 	    TP_ARGS(ring),
412 
413 	    TP_STRUCT__entry(
414 			     __field(u32, dev)
415 			     __field(u32, ring)
416 			     ),
417 
418 	    TP_fast_assign(
419 			   __entry->dev = ring->dev->primary->index;
420 			   __entry->ring = ring->id;
421 			   ),
422 
423 	    TP_printk("dev=%u, ring=%u", __entry->dev, __entry->ring)
424 );
425 
426 DEFINE_EVENT(i915_ring, i915_ring_wait_begin,
427 	    TP_PROTO(struct intel_ring_buffer *ring),
428 	    TP_ARGS(ring)
429 );
430 
431 DEFINE_EVENT(i915_ring, i915_ring_wait_end,
432 	    TP_PROTO(struct intel_ring_buffer *ring),
433 	    TP_ARGS(ring)
434 );
435 
436 TRACE_EVENT(i915_flip_request,
437 	    TP_PROTO(int plane, struct drm_i915_gem_object *obj),
438 
439 	    TP_ARGS(plane, obj),
440 
441 	    TP_STRUCT__entry(
442 		    __field(int, plane)
443 		    __field(struct drm_i915_gem_object *, obj)
444 		    ),
445 
446 	    TP_fast_assign(
447 		    __entry->plane = plane;
448 		    __entry->obj = obj;
449 		    ),
450 
451 	    TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
452 );
453 
454 TRACE_EVENT(i915_flip_complete,
455 	    TP_PROTO(int plane, struct drm_i915_gem_object *obj),
456 
457 	    TP_ARGS(plane, obj),
458 
459 	    TP_STRUCT__entry(
460 		    __field(int, plane)
461 		    __field(struct drm_i915_gem_object *, obj)
462 		    ),
463 
464 	    TP_fast_assign(
465 		    __entry->plane = plane;
466 		    __entry->obj = obj;
467 		    ),
468 
469 	    TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
470 );
471 
472 TRACE_EVENT_CONDITION(i915_reg_rw,
473 	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
474 
475 	TP_ARGS(write, reg, val, len, trace),
476 
477 	TP_CONDITION(trace),
478 
479 	TP_STRUCT__entry(
480 		__field(u64, val)
481 		__field(u32, reg)
482 		__field(u16, write)
483 		__field(u16, len)
484 		),
485 
486 	TP_fast_assign(
487 		__entry->val = (u64)val;
488 		__entry->reg = reg;
489 		__entry->write = write;
490 		__entry->len = len;
491 		),
492 
493 	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
494 		__entry->write ? "write" : "read",
495 		__entry->reg, __entry->len,
496 		(u32)(__entry->val & 0xffffffff),
497 		(u32)(__entry->val >> 32))
498 );
499 
500 TRACE_EVENT(intel_gpu_freq_change,
501 	    TP_PROTO(u32 freq),
502 	    TP_ARGS(freq),
503 
504 	    TP_STRUCT__entry(
505 			     __field(u32, freq)
506 			     ),
507 
508 	    TP_fast_assign(
509 			   __entry->freq = freq;
510 			   ),
511 
512 	    TP_printk("new_freq=%u", __entry->freq)
513 );
514 
515 #endif /* _I915_TRACE_H_ */
516 
517 /* This part must be outside protection */
518 #undef TRACE_INCLUDE_PATH
519 #define TRACE_INCLUDE_PATH .
520 #include <trace/define_trace.h>
521