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