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