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