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