xref: /openbmc/linux/drivers/gpu/drm/i915/i915_trace.h (revision 3df0bd19)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
3 #define _I915_TRACE_H_
4 
5 #include <linux/stringify.h>
6 #include <linux/types.h>
7 #include <linux/tracepoint.h>
8 
9 #include "i915_drv.h"
10 #include "intel_drv.h"
11 #include "intel_ringbuffer.h"
12 
13 #undef TRACE_SYSTEM
14 #define TRACE_SYSTEM i915
15 #define TRACE_INCLUDE_FILE i915_trace
16 
17 /* watermark/fifo updates */
18 
19 TRACE_EVENT(intel_cpu_fifo_underrun,
20 	    TP_PROTO(struct drm_i915_private *dev_priv, enum pipe pipe),
21 	    TP_ARGS(dev_priv, pipe),
22 
23 	    TP_STRUCT__entry(
24 			     __field(enum pipe, pipe)
25 			     __field(u32, frame)
26 			     __field(u32, scanline)
27 			     ),
28 
29 	    TP_fast_assign(
30 			   __entry->pipe = pipe;
31 			   __entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm, pipe);
32 			   __entry->scanline = intel_get_crtc_scanline(intel_get_crtc_for_pipe(dev_priv, pipe));
33 			   ),
34 
35 	    TP_printk("pipe %c, frame=%u, scanline=%u",
36 		      pipe_name(__entry->pipe),
37 		      __entry->frame, __entry->scanline)
38 );
39 
40 TRACE_EVENT(intel_pch_fifo_underrun,
41 	    TP_PROTO(struct drm_i915_private *dev_priv, enum pipe pch_transcoder),
42 	    TP_ARGS(dev_priv, pch_transcoder),
43 
44 	    TP_STRUCT__entry(
45 			     __field(enum pipe, pipe)
46 			     __field(u32, frame)
47 			     __field(u32, scanline)
48 			     ),
49 
50 	    TP_fast_assign(
51 			   enum pipe pipe = pch_transcoder;
52 			   __entry->pipe = pipe;
53 			   __entry->frame = dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm, pipe);
54 			   __entry->scanline = intel_get_crtc_scanline(intel_get_crtc_for_pipe(dev_priv, pipe));
55 			   ),
56 
57 	    TP_printk("pch transcoder %c, frame=%u, scanline=%u",
58 		      pipe_name(__entry->pipe),
59 		      __entry->frame, __entry->scanline)
60 );
61 
62 TRACE_EVENT(intel_memory_cxsr,
63 	    TP_PROTO(struct drm_i915_private *dev_priv, bool old, bool new),
64 	    TP_ARGS(dev_priv, old, new),
65 
66 	    TP_STRUCT__entry(
67 			     __array(u32, frame, 3)
68 			     __array(u32, scanline, 3)
69 			     __field(bool, old)
70 			     __field(bool, new)
71 			     ),
72 
73 	    TP_fast_assign(
74 			   enum pipe pipe;
75 			   for_each_pipe(dev_priv, pipe) {
76 				   __entry->frame[pipe] =
77 					   dev_priv->drm.driver->get_vblank_counter(&dev_priv->drm, pipe);
78 				   __entry->scanline[pipe] =
79 					   intel_get_crtc_scanline(intel_get_crtc_for_pipe(dev_priv, pipe));
80 			   }
81 			   __entry->old = old;
82 			   __entry->new = new;
83 			   ),
84 
85 	    TP_printk("%s->%s, pipe A: frame=%u, scanline=%u, pipe B: frame=%u, scanline=%u, pipe C: frame=%u, scanline=%u",
86 		      onoff(__entry->old), onoff(__entry->new),
87 		      __entry->frame[PIPE_A], __entry->scanline[PIPE_A],
88 		      __entry->frame[PIPE_B], __entry->scanline[PIPE_B],
89 		      __entry->frame[PIPE_C], __entry->scanline[PIPE_C])
90 );
91 
92 TRACE_EVENT(g4x_wm,
93 	    TP_PROTO(struct intel_crtc *crtc, const struct g4x_wm_values *wm),
94 	    TP_ARGS(crtc, wm),
95 
96 	    TP_STRUCT__entry(
97 			     __field(enum pipe, pipe)
98 			     __field(u32, frame)
99 			     __field(u32, scanline)
100 			     __field(u16, primary)
101 			     __field(u16, sprite)
102 			     __field(u16, cursor)
103 			     __field(u16, sr_plane)
104 			     __field(u16, sr_cursor)
105 			     __field(u16, sr_fbc)
106 			     __field(u16, hpll_plane)
107 			     __field(u16, hpll_cursor)
108 			     __field(u16, hpll_fbc)
109 			     __field(bool, cxsr)
110 			     __field(bool, hpll)
111 			     __field(bool, fbc)
112 			     ),
113 
114 	    TP_fast_assign(
115 			   __entry->pipe = crtc->pipe;
116 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
117 										       crtc->pipe);
118 			   __entry->scanline = intel_get_crtc_scanline(crtc);
119 			   __entry->primary = wm->pipe[crtc->pipe].plane[PLANE_PRIMARY];
120 			   __entry->sprite = wm->pipe[crtc->pipe].plane[PLANE_SPRITE0];
121 			   __entry->cursor = wm->pipe[crtc->pipe].plane[PLANE_CURSOR];
122 			   __entry->sr_plane = wm->sr.plane;
123 			   __entry->sr_cursor = wm->sr.cursor;
124 			   __entry->sr_fbc = wm->sr.fbc;
125 			   __entry->hpll_plane = wm->hpll.plane;
126 			   __entry->hpll_cursor = wm->hpll.cursor;
127 			   __entry->hpll_fbc = wm->hpll.fbc;
128 			   __entry->cxsr = wm->cxsr;
129 			   __entry->hpll = wm->hpll_en;
130 			   __entry->fbc = wm->fbc_en;
131 			   ),
132 
133 	    TP_printk("pipe %c, frame=%u, scanline=%u, wm %d/%d/%d, sr %s/%d/%d/%d, hpll %s/%d/%d/%d, fbc %s",
134 		      pipe_name(__entry->pipe), __entry->frame, __entry->scanline,
135 		      __entry->primary, __entry->sprite, __entry->cursor,
136 		      yesno(__entry->cxsr), __entry->sr_plane, __entry->sr_cursor, __entry->sr_fbc,
137 		      yesno(__entry->hpll), __entry->hpll_plane, __entry->hpll_cursor, __entry->hpll_fbc,
138 		      yesno(__entry->fbc))
139 );
140 
141 TRACE_EVENT(vlv_wm,
142 	    TP_PROTO(struct intel_crtc *crtc, const struct vlv_wm_values *wm),
143 	    TP_ARGS(crtc, wm),
144 
145 	    TP_STRUCT__entry(
146 			     __field(enum pipe, pipe)
147 			     __field(u32, frame)
148 			     __field(u32, scanline)
149 			     __field(u32, level)
150 			     __field(u32, cxsr)
151 			     __field(u32, primary)
152 			     __field(u32, sprite0)
153 			     __field(u32, sprite1)
154 			     __field(u32, cursor)
155 			     __field(u32, sr_plane)
156 			     __field(u32, sr_cursor)
157 			     ),
158 
159 	    TP_fast_assign(
160 			   __entry->pipe = crtc->pipe;
161 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
162 										       crtc->pipe);
163 			   __entry->scanline = intel_get_crtc_scanline(crtc);
164 			   __entry->level = wm->level;
165 			   __entry->cxsr = wm->cxsr;
166 			   __entry->primary = wm->pipe[crtc->pipe].plane[PLANE_PRIMARY];
167 			   __entry->sprite0 = wm->pipe[crtc->pipe].plane[PLANE_SPRITE0];
168 			   __entry->sprite1 = wm->pipe[crtc->pipe].plane[PLANE_SPRITE1];
169 			   __entry->cursor = wm->pipe[crtc->pipe].plane[PLANE_CURSOR];
170 			   __entry->sr_plane = wm->sr.plane;
171 			   __entry->sr_cursor = wm->sr.cursor;
172 			   ),
173 
174 	    TP_printk("pipe %c, frame=%u, scanline=%u, level=%d, cxsr=%d, wm %d/%d/%d/%d, sr %d/%d",
175 		      pipe_name(__entry->pipe), __entry->frame,
176 		      __entry->scanline, __entry->level, __entry->cxsr,
177 		      __entry->primary, __entry->sprite0, __entry->sprite1, __entry->cursor,
178 		      __entry->sr_plane, __entry->sr_cursor)
179 );
180 
181 TRACE_EVENT(vlv_fifo_size,
182 	    TP_PROTO(struct intel_crtc *crtc, u32 sprite0_start, u32 sprite1_start, u32 fifo_size),
183 	    TP_ARGS(crtc, sprite0_start, sprite1_start, fifo_size),
184 
185 	    TP_STRUCT__entry(
186 			     __field(enum pipe, pipe)
187 			     __field(u32, frame)
188 			     __field(u32, scanline)
189 			     __field(u32, sprite0_start)
190 			     __field(u32, sprite1_start)
191 			     __field(u32, fifo_size)
192 			     ),
193 
194 	    TP_fast_assign(
195 			   __entry->pipe = crtc->pipe;
196 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
197 										       crtc->pipe);
198 			   __entry->scanline = intel_get_crtc_scanline(crtc);
199 			   __entry->sprite0_start = sprite0_start;
200 			   __entry->sprite1_start = sprite1_start;
201 			   __entry->fifo_size = fifo_size;
202 			   ),
203 
204 	    TP_printk("pipe %c, frame=%u, scanline=%u, %d/%d/%d",
205 		      pipe_name(__entry->pipe), __entry->frame,
206 		      __entry->scanline, __entry->sprite0_start,
207 		      __entry->sprite1_start, __entry->fifo_size)
208 );
209 
210 /* plane updates */
211 
212 TRACE_EVENT(intel_update_plane,
213 	    TP_PROTO(struct drm_plane *plane, struct intel_crtc *crtc),
214 	    TP_ARGS(plane, crtc),
215 
216 	    TP_STRUCT__entry(
217 			     __field(enum pipe, pipe)
218 			     __field(const char *, name)
219 			     __field(u32, frame)
220 			     __field(u32, scanline)
221 			     __array(int, src, 4)
222 			     __array(int, dst, 4)
223 			     ),
224 
225 	    TP_fast_assign(
226 			   __entry->pipe = crtc->pipe;
227 			   __entry->name = plane->name;
228 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
229 										       crtc->pipe);
230 			   __entry->scanline = intel_get_crtc_scanline(crtc);
231 			   memcpy(__entry->src, &plane->state->src, sizeof(__entry->src));
232 			   memcpy(__entry->dst, &plane->state->dst, sizeof(__entry->dst));
233 			   ),
234 
235 	    TP_printk("pipe %c, plane %s, frame=%u, scanline=%u, " DRM_RECT_FP_FMT " -> " DRM_RECT_FMT,
236 		      pipe_name(__entry->pipe), __entry->name,
237 		      __entry->frame, __entry->scanline,
238 		      DRM_RECT_FP_ARG((const struct drm_rect *)__entry->src),
239 		      DRM_RECT_ARG((const struct drm_rect *)__entry->dst))
240 );
241 
242 TRACE_EVENT(intel_disable_plane,
243 	    TP_PROTO(struct drm_plane *plane, struct intel_crtc *crtc),
244 	    TP_ARGS(plane, crtc),
245 
246 	    TP_STRUCT__entry(
247 			     __field(enum pipe, pipe)
248 			     __field(const char *, name)
249 			     __field(u32, frame)
250 			     __field(u32, scanline)
251 			     ),
252 
253 	    TP_fast_assign(
254 			   __entry->pipe = crtc->pipe;
255 			   __entry->name = plane->name;
256 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
257 										       crtc->pipe);
258 			   __entry->scanline = intel_get_crtc_scanline(crtc);
259 			   ),
260 
261 	    TP_printk("pipe %c, plane %s, frame=%u, scanline=%u",
262 		      pipe_name(__entry->pipe), __entry->name,
263 		      __entry->frame, __entry->scanline)
264 );
265 
266 /* pipe updates */
267 
268 TRACE_EVENT(i915_pipe_update_start,
269 	    TP_PROTO(struct intel_crtc *crtc),
270 	    TP_ARGS(crtc),
271 
272 	    TP_STRUCT__entry(
273 			     __field(enum pipe, pipe)
274 			     __field(u32, frame)
275 			     __field(u32, scanline)
276 			     __field(u32, min)
277 			     __field(u32, max)
278 			     ),
279 
280 	    TP_fast_assign(
281 			   __entry->pipe = crtc->pipe;
282 			   __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
283 										       crtc->pipe);
284 			   __entry->scanline = intel_get_crtc_scanline(crtc);
285 			   __entry->min = crtc->debug.min_vbl;
286 			   __entry->max = crtc->debug.max_vbl;
287 			   ),
288 
289 	    TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
290 		      pipe_name(__entry->pipe), __entry->frame,
291 		       __entry->scanline, __entry->min, __entry->max)
292 );
293 
294 TRACE_EVENT(i915_pipe_update_vblank_evaded,
295 	    TP_PROTO(struct intel_crtc *crtc),
296 	    TP_ARGS(crtc),
297 
298 	    TP_STRUCT__entry(
299 			     __field(enum pipe, pipe)
300 			     __field(u32, frame)
301 			     __field(u32, scanline)
302 			     __field(u32, min)
303 			     __field(u32, max)
304 			     ),
305 
306 	    TP_fast_assign(
307 			   __entry->pipe = crtc->pipe;
308 			   __entry->frame = crtc->debug.start_vbl_count;
309 			   __entry->scanline = crtc->debug.scanline_start;
310 			   __entry->min = crtc->debug.min_vbl;
311 			   __entry->max = crtc->debug.max_vbl;
312 			   ),
313 
314 	    TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
315 		      pipe_name(__entry->pipe), __entry->frame,
316 		       __entry->scanline, __entry->min, __entry->max)
317 );
318 
319 TRACE_EVENT(i915_pipe_update_end,
320 	    TP_PROTO(struct intel_crtc *crtc, u32 frame, int scanline_end),
321 	    TP_ARGS(crtc, frame, scanline_end),
322 
323 	    TP_STRUCT__entry(
324 			     __field(enum pipe, pipe)
325 			     __field(u32, frame)
326 			     __field(u32, scanline)
327 			     ),
328 
329 	    TP_fast_assign(
330 			   __entry->pipe = crtc->pipe;
331 			   __entry->frame = frame;
332 			   __entry->scanline = scanline_end;
333 			   ),
334 
335 	    TP_printk("pipe %c, frame=%u, scanline=%u",
336 		      pipe_name(__entry->pipe), __entry->frame,
337 		      __entry->scanline)
338 );
339 
340 /* object tracking */
341 
342 TRACE_EVENT(i915_gem_object_create,
343 	    TP_PROTO(struct drm_i915_gem_object *obj),
344 	    TP_ARGS(obj),
345 
346 	    TP_STRUCT__entry(
347 			     __field(struct drm_i915_gem_object *, obj)
348 			     __field(u64, size)
349 			     ),
350 
351 	    TP_fast_assign(
352 			   __entry->obj = obj;
353 			   __entry->size = obj->base.size;
354 			   ),
355 
356 	    TP_printk("obj=%p, size=0x%llx", __entry->obj, __entry->size)
357 );
358 
359 TRACE_EVENT(i915_gem_shrink,
360 	    TP_PROTO(struct drm_i915_private *i915, unsigned long target, unsigned flags),
361 	    TP_ARGS(i915, target, flags),
362 
363 	    TP_STRUCT__entry(
364 			     __field(int, dev)
365 			     __field(unsigned long, target)
366 			     __field(unsigned, flags)
367 			     ),
368 
369 	    TP_fast_assign(
370 			   __entry->dev = i915->drm.primary->index;
371 			   __entry->target = target;
372 			   __entry->flags = flags;
373 			   ),
374 
375 	    TP_printk("dev=%d, target=%lu, flags=%x",
376 		      __entry->dev, __entry->target, __entry->flags)
377 );
378 
379 TRACE_EVENT(i915_vma_bind,
380 	    TP_PROTO(struct i915_vma *vma, unsigned flags),
381 	    TP_ARGS(vma, flags),
382 
383 	    TP_STRUCT__entry(
384 			     __field(struct drm_i915_gem_object *, obj)
385 			     __field(struct i915_address_space *, vm)
386 			     __field(u64, offset)
387 			     __field(u64, size)
388 			     __field(unsigned, flags)
389 			     ),
390 
391 	    TP_fast_assign(
392 			   __entry->obj = vma->obj;
393 			   __entry->vm = vma->vm;
394 			   __entry->offset = vma->node.start;
395 			   __entry->size = vma->node.size;
396 			   __entry->flags = flags;
397 			   ),
398 
399 	    TP_printk("obj=%p, offset=0x%016llx size=0x%llx%s vm=%p",
400 		      __entry->obj, __entry->offset, __entry->size,
401 		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
402 		      __entry->vm)
403 );
404 
405 TRACE_EVENT(i915_vma_unbind,
406 	    TP_PROTO(struct i915_vma *vma),
407 	    TP_ARGS(vma),
408 
409 	    TP_STRUCT__entry(
410 			     __field(struct drm_i915_gem_object *, obj)
411 			     __field(struct i915_address_space *, vm)
412 			     __field(u64, offset)
413 			     __field(u64, size)
414 			     ),
415 
416 	    TP_fast_assign(
417 			   __entry->obj = vma->obj;
418 			   __entry->vm = vma->vm;
419 			   __entry->offset = vma->node.start;
420 			   __entry->size = vma->node.size;
421 			   ),
422 
423 	    TP_printk("obj=%p, offset=0x%016llx size=0x%llx vm=%p",
424 		      __entry->obj, __entry->offset, __entry->size, __entry->vm)
425 );
426 
427 TRACE_EVENT(i915_gem_object_pwrite,
428 	    TP_PROTO(struct drm_i915_gem_object *obj, u64 offset, u64 len),
429 	    TP_ARGS(obj, offset, len),
430 
431 	    TP_STRUCT__entry(
432 			     __field(struct drm_i915_gem_object *, obj)
433 			     __field(u64, offset)
434 			     __field(u64, len)
435 			     ),
436 
437 	    TP_fast_assign(
438 			   __entry->obj = obj;
439 			   __entry->offset = offset;
440 			   __entry->len = len;
441 			   ),
442 
443 	    TP_printk("obj=%p, offset=0x%llx, len=0x%llx",
444 		      __entry->obj, __entry->offset, __entry->len)
445 );
446 
447 TRACE_EVENT(i915_gem_object_pread,
448 	    TP_PROTO(struct drm_i915_gem_object *obj, u64 offset, u64 len),
449 	    TP_ARGS(obj, offset, len),
450 
451 	    TP_STRUCT__entry(
452 			     __field(struct drm_i915_gem_object *, obj)
453 			     __field(u64, offset)
454 			     __field(u64, len)
455 			     ),
456 
457 	    TP_fast_assign(
458 			   __entry->obj = obj;
459 			   __entry->offset = offset;
460 			   __entry->len = len;
461 			   ),
462 
463 	    TP_printk("obj=%p, offset=0x%llx, len=0x%llx",
464 		      __entry->obj, __entry->offset, __entry->len)
465 );
466 
467 TRACE_EVENT(i915_gem_object_fault,
468 	    TP_PROTO(struct drm_i915_gem_object *obj, u64 index, bool gtt, bool write),
469 	    TP_ARGS(obj, index, gtt, write),
470 
471 	    TP_STRUCT__entry(
472 			     __field(struct drm_i915_gem_object *, obj)
473 			     __field(u64, index)
474 			     __field(bool, gtt)
475 			     __field(bool, write)
476 			     ),
477 
478 	    TP_fast_assign(
479 			   __entry->obj = obj;
480 			   __entry->index = index;
481 			   __entry->gtt = gtt;
482 			   __entry->write = write;
483 			   ),
484 
485 	    TP_printk("obj=%p, %s index=%llu %s",
486 		      __entry->obj,
487 		      __entry->gtt ? "GTT" : "CPU",
488 		      __entry->index,
489 		      __entry->write ? ", writable" : "")
490 );
491 
492 DECLARE_EVENT_CLASS(i915_gem_object,
493 	    TP_PROTO(struct drm_i915_gem_object *obj),
494 	    TP_ARGS(obj),
495 
496 	    TP_STRUCT__entry(
497 			     __field(struct drm_i915_gem_object *, obj)
498 			     ),
499 
500 	    TP_fast_assign(
501 			   __entry->obj = obj;
502 			   ),
503 
504 	    TP_printk("obj=%p", __entry->obj)
505 );
506 
507 DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
508 	     TP_PROTO(struct drm_i915_gem_object *obj),
509 	     TP_ARGS(obj)
510 );
511 
512 DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
513 	    TP_PROTO(struct drm_i915_gem_object *obj),
514 	    TP_ARGS(obj)
515 );
516 
517 TRACE_EVENT(i915_gem_evict,
518 	    TP_PROTO(struct i915_address_space *vm, u64 size, u64 align, unsigned int flags),
519 	    TP_ARGS(vm, size, align, flags),
520 
521 	    TP_STRUCT__entry(
522 			     __field(u32, dev)
523 			     __field(struct i915_address_space *, vm)
524 			     __field(u64, size)
525 			     __field(u64, align)
526 			     __field(unsigned int, flags)
527 			    ),
528 
529 	    TP_fast_assign(
530 			   __entry->dev = vm->i915->drm.primary->index;
531 			   __entry->vm = vm;
532 			   __entry->size = size;
533 			   __entry->align = align;
534 			   __entry->flags = flags;
535 			  ),
536 
537 	    TP_printk("dev=%d, vm=%p, size=0x%llx, align=0x%llx %s",
538 		      __entry->dev, __entry->vm, __entry->size, __entry->align,
539 		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
540 );
541 
542 TRACE_EVENT(i915_gem_evict_node,
543 	    TP_PROTO(struct i915_address_space *vm, struct drm_mm_node *node, unsigned int flags),
544 	    TP_ARGS(vm, node, flags),
545 
546 	    TP_STRUCT__entry(
547 			     __field(u32, dev)
548 			     __field(struct i915_address_space *, vm)
549 			     __field(u64, start)
550 			     __field(u64, size)
551 			     __field(unsigned long, color)
552 			     __field(unsigned int, flags)
553 			    ),
554 
555 	    TP_fast_assign(
556 			   __entry->dev = vm->i915->drm.primary->index;
557 			   __entry->vm = vm;
558 			   __entry->start = node->start;
559 			   __entry->size = node->size;
560 			   __entry->color = node->color;
561 			   __entry->flags = flags;
562 			  ),
563 
564 	    TP_printk("dev=%d, vm=%p, start=0x%llx size=0x%llx, color=0x%lx, flags=%x",
565 		      __entry->dev, __entry->vm,
566 		      __entry->start, __entry->size,
567 		      __entry->color, __entry->flags)
568 );
569 
570 TRACE_EVENT(i915_gem_evict_vm,
571 	    TP_PROTO(struct i915_address_space *vm),
572 	    TP_ARGS(vm),
573 
574 	    TP_STRUCT__entry(
575 			     __field(u32, dev)
576 			     __field(struct i915_address_space *, vm)
577 			    ),
578 
579 	    TP_fast_assign(
580 			   __entry->dev = vm->i915->drm.primary->index;
581 			   __entry->vm = vm;
582 			  ),
583 
584 	    TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
585 );
586 
587 TRACE_EVENT(i915_request_queue,
588 	    TP_PROTO(struct i915_request *rq, u32 flags),
589 	    TP_ARGS(rq, flags),
590 
591 	    TP_STRUCT__entry(
592 			     __field(u32, dev)
593 			     __field(u32, hw_id)
594 			     __field(u64, ctx)
595 			     __field(u16, class)
596 			     __field(u16, instance)
597 			     __field(u32, seqno)
598 			     __field(u32, flags)
599 			     ),
600 
601 	    TP_fast_assign(
602 			   __entry->dev = rq->i915->drm.primary->index;
603 			   __entry->hw_id = rq->gem_context->hw_id;
604 			   __entry->class = rq->engine->uabi_class;
605 			   __entry->instance = rq->engine->instance;
606 			   __entry->ctx = rq->fence.context;
607 			   __entry->seqno = rq->fence.seqno;
608 			   __entry->flags = flags;
609 			   ),
610 
611 	    TP_printk("dev=%u, engine=%u:%u, hw_id=%u, ctx=%llu, seqno=%u, flags=0x%x",
612 		      __entry->dev, __entry->class, __entry->instance,
613 		      __entry->hw_id, __entry->ctx, __entry->seqno,
614 		      __entry->flags)
615 );
616 
617 DECLARE_EVENT_CLASS(i915_request,
618 	    TP_PROTO(struct i915_request *rq),
619 	    TP_ARGS(rq),
620 
621 	    TP_STRUCT__entry(
622 			     __field(u32, dev)
623 			     __field(u32, hw_id)
624 			     __field(u64, ctx)
625 			     __field(u16, class)
626 			     __field(u16, instance)
627 			     __field(u32, seqno)
628 			     __field(u32, global)
629 			     ),
630 
631 	    TP_fast_assign(
632 			   __entry->dev = rq->i915->drm.primary->index;
633 			   __entry->hw_id = rq->gem_context->hw_id;
634 			   __entry->class = rq->engine->uabi_class;
635 			   __entry->instance = rq->engine->instance;
636 			   __entry->ctx = rq->fence.context;
637 			   __entry->seqno = rq->fence.seqno;
638 			   __entry->global = rq->global_seqno;
639 			   ),
640 
641 	    TP_printk("dev=%u, engine=%u:%u, hw_id=%u, ctx=%llu, seqno=%u, global=%u",
642 		      __entry->dev, __entry->class, __entry->instance,
643 		      __entry->hw_id, __entry->ctx, __entry->seqno,
644 		      __entry->global)
645 );
646 
647 DEFINE_EVENT(i915_request, i915_request_add,
648 	    TP_PROTO(struct i915_request *rq),
649 	    TP_ARGS(rq)
650 );
651 
652 #if defined(CONFIG_DRM_I915_LOW_LEVEL_TRACEPOINTS)
653 DEFINE_EVENT(i915_request, i915_request_submit,
654 	     TP_PROTO(struct i915_request *rq),
655 	     TP_ARGS(rq)
656 );
657 
658 DEFINE_EVENT(i915_request, i915_request_execute,
659 	     TP_PROTO(struct i915_request *rq),
660 	     TP_ARGS(rq)
661 );
662 
663 TRACE_EVENT(i915_request_in,
664 	    TP_PROTO(struct i915_request *rq, unsigned int port),
665 	    TP_ARGS(rq, port),
666 
667 	    TP_STRUCT__entry(
668 			     __field(u32, dev)
669 			     __field(u32, hw_id)
670 			     __field(u64, ctx)
671 			     __field(u16, class)
672 			     __field(u16, instance)
673 			     __field(u32, seqno)
674 			     __field(u32, global_seqno)
675 			     __field(u32, port)
676 			     __field(u32, prio)
677 			    ),
678 
679 	    TP_fast_assign(
680 			   __entry->dev = rq->i915->drm.primary->index;
681 			   __entry->hw_id = rq->gem_context->hw_id;
682 			   __entry->class = rq->engine->uabi_class;
683 			   __entry->instance = rq->engine->instance;
684 			   __entry->ctx = rq->fence.context;
685 			   __entry->seqno = rq->fence.seqno;
686 			   __entry->global_seqno = rq->global_seqno;
687 			   __entry->prio = rq->sched.attr.priority;
688 			   __entry->port = port;
689 			   ),
690 
691 	    TP_printk("dev=%u, engine=%u:%u, hw_id=%u, ctx=%llu, seqno=%u, prio=%u, global=%u, port=%u",
692 		      __entry->dev, __entry->class, __entry->instance,
693 		      __entry->hw_id, __entry->ctx, __entry->seqno,
694 		      __entry->prio, __entry->global_seqno, __entry->port)
695 );
696 
697 TRACE_EVENT(i915_request_out,
698 	    TP_PROTO(struct i915_request *rq),
699 	    TP_ARGS(rq),
700 
701 	    TP_STRUCT__entry(
702 			     __field(u32, dev)
703 			     __field(u32, hw_id)
704 			     __field(u64, ctx)
705 			     __field(u16, class)
706 			     __field(u16, instance)
707 			     __field(u32, seqno)
708 			     __field(u32, global_seqno)
709 			     __field(u32, completed)
710 			    ),
711 
712 	    TP_fast_assign(
713 			   __entry->dev = rq->i915->drm.primary->index;
714 			   __entry->hw_id = rq->gem_context->hw_id;
715 			   __entry->class = rq->engine->uabi_class;
716 			   __entry->instance = rq->engine->instance;
717 			   __entry->ctx = rq->fence.context;
718 			   __entry->seqno = rq->fence.seqno;
719 			   __entry->global_seqno = rq->global_seqno;
720 			   __entry->completed = i915_request_completed(rq);
721 			   ),
722 
723 		    TP_printk("dev=%u, engine=%u:%u, hw_id=%u, ctx=%llu, seqno=%u, global=%u, completed?=%u",
724 			      __entry->dev, __entry->class, __entry->instance,
725 			      __entry->hw_id, __entry->ctx, __entry->seqno,
726 			      __entry->global_seqno, __entry->completed)
727 );
728 
729 #else
730 #if !defined(TRACE_HEADER_MULTI_READ)
731 static inline void
732 trace_i915_request_submit(struct i915_request *rq)
733 {
734 }
735 
736 static inline void
737 trace_i915_request_execute(struct i915_request *rq)
738 {
739 }
740 
741 static inline void
742 trace_i915_request_in(struct i915_request *rq, unsigned int port)
743 {
744 }
745 
746 static inline void
747 trace_i915_request_out(struct i915_request *rq)
748 {
749 }
750 #endif
751 #endif
752 
753 DEFINE_EVENT(i915_request, i915_request_retire,
754 	    TP_PROTO(struct i915_request *rq),
755 	    TP_ARGS(rq)
756 );
757 
758 TRACE_EVENT(i915_request_wait_begin,
759 	    TP_PROTO(struct i915_request *rq, unsigned int flags),
760 	    TP_ARGS(rq, flags),
761 
762 	    TP_STRUCT__entry(
763 			     __field(u32, dev)
764 			     __field(u32, hw_id)
765 			     __field(u64, ctx)
766 			     __field(u16, class)
767 			     __field(u16, instance)
768 			     __field(u32, seqno)
769 			     __field(u32, global)
770 			     __field(unsigned int, flags)
771 			     ),
772 
773 	    /* NB: the blocking information is racy since mutex_is_locked
774 	     * doesn't check that the current thread holds the lock. The only
775 	     * other option would be to pass the boolean information of whether
776 	     * or not the class was blocking down through the stack which is
777 	     * less desirable.
778 	     */
779 	    TP_fast_assign(
780 			   __entry->dev = rq->i915->drm.primary->index;
781 			   __entry->hw_id = rq->gem_context->hw_id;
782 			   __entry->class = rq->engine->uabi_class;
783 			   __entry->instance = rq->engine->instance;
784 			   __entry->ctx = rq->fence.context;
785 			   __entry->seqno = rq->fence.seqno;
786 			   __entry->global = rq->global_seqno;
787 			   __entry->flags = flags;
788 			   ),
789 
790 	    TP_printk("dev=%u, engine=%u:%u, hw_id=%u, ctx=%llu, seqno=%u, global=%u, blocking=%u, flags=0x%x",
791 		      __entry->dev, __entry->class, __entry->instance,
792 		      __entry->hw_id, __entry->ctx, __entry->seqno,
793 		      __entry->global, !!(__entry->flags & I915_WAIT_LOCKED),
794 		      __entry->flags)
795 );
796 
797 DEFINE_EVENT(i915_request, i915_request_wait_end,
798 	    TP_PROTO(struct i915_request *rq),
799 	    TP_ARGS(rq)
800 );
801 
802 TRACE_EVENT_CONDITION(i915_reg_rw,
803 	TP_PROTO(bool write, i915_reg_t reg, u64 val, int len, bool trace),
804 
805 	TP_ARGS(write, reg, val, len, trace),
806 
807 	TP_CONDITION(trace),
808 
809 	TP_STRUCT__entry(
810 		__field(u64, val)
811 		__field(u32, reg)
812 		__field(u16, write)
813 		__field(u16, len)
814 		),
815 
816 	TP_fast_assign(
817 		__entry->val = (u64)val;
818 		__entry->reg = i915_mmio_reg_offset(reg);
819 		__entry->write = write;
820 		__entry->len = len;
821 		),
822 
823 	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
824 		__entry->write ? "write" : "read",
825 		__entry->reg, __entry->len,
826 		(u32)(__entry->val & 0xffffffff),
827 		(u32)(__entry->val >> 32))
828 );
829 
830 TRACE_EVENT(intel_gpu_freq_change,
831 	    TP_PROTO(u32 freq),
832 	    TP_ARGS(freq),
833 
834 	    TP_STRUCT__entry(
835 			     __field(u32, freq)
836 			     ),
837 
838 	    TP_fast_assign(
839 			   __entry->freq = freq;
840 			   ),
841 
842 	    TP_printk("new_freq=%u", __entry->freq)
843 );
844 
845 /**
846  * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
847  *
848  * With full ppgtt enabled each process using drm will allocate at least one
849  * translation table. With these traces it is possible to keep track of the
850  * allocation and of the lifetime of the tables; this can be used during
851  * testing/debug to verify that we are not leaking ppgtts.
852  * These traces identify the ppgtt through the vm pointer, which is also printed
853  * by the i915_vma_bind and i915_vma_unbind tracepoints.
854  */
855 DECLARE_EVENT_CLASS(i915_ppgtt,
856 	TP_PROTO(struct i915_address_space *vm),
857 	TP_ARGS(vm),
858 
859 	TP_STRUCT__entry(
860 			__field(struct i915_address_space *, vm)
861 			__field(u32, dev)
862 	),
863 
864 	TP_fast_assign(
865 			__entry->vm = vm;
866 			__entry->dev = vm->i915->drm.primary->index;
867 	),
868 
869 	TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
870 )
871 
872 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
873 	TP_PROTO(struct i915_address_space *vm),
874 	TP_ARGS(vm)
875 );
876 
877 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
878 	TP_PROTO(struct i915_address_space *vm),
879 	TP_ARGS(vm)
880 );
881 
882 /**
883  * DOC: i915_context_create and i915_context_free tracepoints
884  *
885  * These tracepoints are used to track creation and deletion of contexts.
886  * If full ppgtt is enabled, they also print the address of the vm assigned to
887  * the context.
888  */
889 DECLARE_EVENT_CLASS(i915_context,
890 	TP_PROTO(struct i915_gem_context *ctx),
891 	TP_ARGS(ctx),
892 
893 	TP_STRUCT__entry(
894 			__field(u32, dev)
895 			__field(struct i915_gem_context *, ctx)
896 			__field(u32, hw_id)
897 			__field(struct i915_address_space *, vm)
898 	),
899 
900 	TP_fast_assign(
901 			__entry->dev = ctx->i915->drm.primary->index;
902 			__entry->ctx = ctx;
903 			__entry->hw_id = ctx->hw_id;
904 			__entry->vm = ctx->ppgtt ? &ctx->ppgtt->vm : NULL;
905 	),
906 
907 	TP_printk("dev=%u, ctx=%p, ctx_vm=%p, hw_id=%u",
908 		  __entry->dev, __entry->ctx, __entry->vm, __entry->hw_id)
909 )
910 
911 DEFINE_EVENT(i915_context, i915_context_create,
912 	TP_PROTO(struct i915_gem_context *ctx),
913 	TP_ARGS(ctx)
914 );
915 
916 DEFINE_EVENT(i915_context, i915_context_free,
917 	TP_PROTO(struct i915_gem_context *ctx),
918 	TP_ARGS(ctx)
919 );
920 
921 #endif /* _I915_TRACE_H_ */
922 
923 /* This part must be outside protection */
924 #undef TRACE_INCLUDE_PATH
925 #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/i915
926 #include <trace/define_trace.h>
927