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