ASoC: Use card field to indicate whether a component is bound
[linux-2.6-block.git] / drivers / gpu / drm / i915 / i915_trace.h
1 #if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
2 #define _I915_TRACE_H_
3
4 #include <linux/stringify.h>
5 #include <linux/types.h>
6 #include <linux/tracepoint.h>
7
8 #include <drm/drmP.h>
9 #include "i915_drv.h"
10 #include "intel_drv.h"
11 #include "intel_ringbuffer.h"
12
13 #undef TRACE_SYSTEM
14 #define TRACE_SYSTEM i915
15 #define TRACE_INCLUDE_FILE i915_trace
16
17 /* pipe updates */
18
19 TRACE_EVENT(i915_pipe_update_start,
20             TP_PROTO(struct intel_crtc *crtc, u32 min, u32 max),
21             TP_ARGS(crtc, min, max),
22
23             TP_STRUCT__entry(
24                              __field(enum pipe, pipe)
25                              __field(u32, frame)
26                              __field(u32, scanline)
27                              __field(u32, min)
28                              __field(u32, max)
29                              ),
30
31             TP_fast_assign(
32                            __entry->pipe = crtc->pipe;
33                            __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
34                                                                                        crtc->pipe);
35                            __entry->scanline = intel_get_crtc_scanline(crtc);
36                            __entry->min = min;
37                            __entry->max = max;
38                            ),
39
40             TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
41                       pipe_name(__entry->pipe), __entry->frame,
42                        __entry->scanline, __entry->min, __entry->max)
43 );
44
45 TRACE_EVENT(i915_pipe_update_vblank_evaded,
46             TP_PROTO(struct intel_crtc *crtc, u32 min, u32 max, u32 frame),
47             TP_ARGS(crtc, min, max, frame),
48
49             TP_STRUCT__entry(
50                              __field(enum pipe, pipe)
51                              __field(u32, frame)
52                              __field(u32, scanline)
53                              __field(u32, min)
54                              __field(u32, max)
55                              ),
56
57             TP_fast_assign(
58                            __entry->pipe = crtc->pipe;
59                            __entry->frame = frame;
60                            __entry->scanline = intel_get_crtc_scanline(crtc);
61                            __entry->min = min;
62                            __entry->max = max;
63                            ),
64
65             TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
66                       pipe_name(__entry->pipe), __entry->frame,
67                        __entry->scanline, __entry->min, __entry->max)
68 );
69
70 TRACE_EVENT(i915_pipe_update_end,
71             TP_PROTO(struct intel_crtc *crtc, u32 frame),
72             TP_ARGS(crtc, frame),
73
74             TP_STRUCT__entry(
75                              __field(enum pipe, pipe)
76                              __field(u32, frame)
77                              __field(u32, scanline)
78                              ),
79
80             TP_fast_assign(
81                            __entry->pipe = crtc->pipe;
82                            __entry->frame = frame;
83                            __entry->scanline = intel_get_crtc_scanline(crtc);
84                            ),
85
86             TP_printk("pipe %c, frame=%u, scanline=%u",
87                       pipe_name(__entry->pipe), __entry->frame,
88                       __entry->scanline)
89 );
90
91 /* object tracking */
92
93 TRACE_EVENT(i915_gem_object_create,
94             TP_PROTO(struct drm_i915_gem_object *obj),
95             TP_ARGS(obj),
96
97             TP_STRUCT__entry(
98                              __field(struct drm_i915_gem_object *, obj)
99                              __field(u32, size)
100                              ),
101
102             TP_fast_assign(
103                            __entry->obj = obj;
104                            __entry->size = obj->base.size;
105                            ),
106
107             TP_printk("obj=%p, size=%u", __entry->obj, __entry->size)
108 );
109
110 TRACE_EVENT(i915_vma_bind,
111             TP_PROTO(struct i915_vma *vma, unsigned flags),
112             TP_ARGS(vma, flags),
113
114             TP_STRUCT__entry(
115                              __field(struct drm_i915_gem_object *, obj)
116                              __field(struct i915_address_space *, vm)
117                              __field(u64, offset)
118                              __field(u32, size)
119                              __field(unsigned, flags)
120                              ),
121
122             TP_fast_assign(
123                            __entry->obj = vma->obj;
124                            __entry->vm = vma->vm;
125                            __entry->offset = vma->node.start;
126                            __entry->size = vma->node.size;
127                            __entry->flags = flags;
128                            ),
129
130             TP_printk("obj=%p, offset=%016llx size=%x%s vm=%p",
131                       __entry->obj, __entry->offset, __entry->size,
132                       __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
133                       __entry->vm)
134 );
135
136 TRACE_EVENT(i915_vma_unbind,
137             TP_PROTO(struct i915_vma *vma),
138             TP_ARGS(vma),
139
140             TP_STRUCT__entry(
141                              __field(struct drm_i915_gem_object *, obj)
142                              __field(struct i915_address_space *, vm)
143                              __field(u64, offset)
144                              __field(u32, size)
145                              ),
146
147             TP_fast_assign(
148                            __entry->obj = vma->obj;
149                            __entry->vm = vma->vm;
150                            __entry->offset = vma->node.start;
151                            __entry->size = vma->node.size;
152                            ),
153
154             TP_printk("obj=%p, offset=%016llx size=%x vm=%p",
155                       __entry->obj, __entry->offset, __entry->size, __entry->vm)
156 );
157
158 #define VM_TO_TRACE_NAME(vm) \
159         (i915_is_ggtt(vm) ? "G" : \
160                       "P")
161
162 DECLARE_EVENT_CLASS(i915_va,
163         TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
164         TP_ARGS(vm, start, length, name),
165
166         TP_STRUCT__entry(
167                 __field(struct i915_address_space *, vm)
168                 __field(u64, start)
169                 __field(u64, end)
170                 __string(name, name)
171         ),
172
173         TP_fast_assign(
174                 __entry->vm = vm;
175                 __entry->start = start;
176                 __entry->end = start + length - 1;
177                 __assign_str(name, name);
178         ),
179
180         TP_printk("vm=%p (%s), 0x%llx-0x%llx",
181                   __entry->vm, __get_str(name),  __entry->start, __entry->end)
182 );
183
184 DEFINE_EVENT(i915_va, i915_va_alloc,
185              TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
186              TP_ARGS(vm, start, length, name)
187 );
188
189 DECLARE_EVENT_CLASS(i915_page_table_entry,
190         TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
191         TP_ARGS(vm, pde, start, pde_shift),
192
193         TP_STRUCT__entry(
194                 __field(struct i915_address_space *, vm)
195                 __field(u32, pde)
196                 __field(u64, start)
197                 __field(u64, end)
198         ),
199
200         TP_fast_assign(
201                 __entry->vm = vm;
202                 __entry->pde = pde;
203                 __entry->start = start;
204                 __entry->end = ((start + (1ULL << pde_shift)) & ~((1ULL << pde_shift)-1)) - 1;
205         ),
206
207         TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
208                   __entry->vm, __entry->pde, __entry->start, __entry->end)
209 );
210
211 DEFINE_EVENT(i915_page_table_entry, i915_page_table_entry_alloc,
212              TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
213              TP_ARGS(vm, pde, start, pde_shift)
214 );
215
216 /* Avoid extra math because we only support two sizes. The format is defined by
217  * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
218 #define TRACE_PT_SIZE(bits) \
219         ((((bits) == 1024) ? 288 : 144) + 1)
220
221 DECLARE_EVENT_CLASS(i915_page_table_entry_update,
222         TP_PROTO(struct i915_address_space *vm, u32 pde,
223                  struct i915_page_table *pt, u32 first, u32 count, u32 bits),
224         TP_ARGS(vm, pde, pt, first, count, bits),
225
226         TP_STRUCT__entry(
227                 __field(struct i915_address_space *, vm)
228                 __field(u32, pde)
229                 __field(u32, first)
230                 __field(u32, last)
231                 __dynamic_array(char, cur_ptes, TRACE_PT_SIZE(bits))
232         ),
233
234         TP_fast_assign(
235                 __entry->vm = vm;
236                 __entry->pde = pde;
237                 __entry->first = first;
238                 __entry->last = first + count - 1;
239                 scnprintf(__get_str(cur_ptes),
240                           TRACE_PT_SIZE(bits),
241                           "%*pb",
242                           bits,
243                           pt->used_ptes);
244         ),
245
246         TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
247                   __entry->vm, __entry->pde, __entry->last, __entry->first,
248                   __get_str(cur_ptes))
249 );
250
251 DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_map,
252         TP_PROTO(struct i915_address_space *vm, u32 pde,
253                  struct i915_page_table *pt, u32 first, u32 count, u32 bits),
254         TP_ARGS(vm, pde, pt, first, count, bits)
255 );
256
257 TRACE_EVENT(i915_gem_object_change_domain,
258             TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
259             TP_ARGS(obj, old_read, old_write),
260
261             TP_STRUCT__entry(
262                              __field(struct drm_i915_gem_object *, obj)
263                              __field(u32, read_domains)
264                              __field(u32, write_domain)
265                              ),
266
267             TP_fast_assign(
268                            __entry->obj = obj;
269                            __entry->read_domains = obj->base.read_domains | (old_read << 16);
270                            __entry->write_domain = obj->base.write_domain | (old_write << 16);
271                            ),
272
273             TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
274                       __entry->obj,
275                       __entry->read_domains >> 16,
276                       __entry->read_domains & 0xffff,
277                       __entry->write_domain >> 16,
278                       __entry->write_domain & 0xffff)
279 );
280
281 TRACE_EVENT(i915_gem_object_pwrite,
282             TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
283             TP_ARGS(obj, offset, len),
284
285             TP_STRUCT__entry(
286                              __field(struct drm_i915_gem_object *, obj)
287                              __field(u32, offset)
288                              __field(u32, len)
289                              ),
290
291             TP_fast_assign(
292                            __entry->obj = obj;
293                            __entry->offset = offset;
294                            __entry->len = len;
295                            ),
296
297             TP_printk("obj=%p, offset=%u, len=%u",
298                       __entry->obj, __entry->offset, __entry->len)
299 );
300
301 TRACE_EVENT(i915_gem_object_pread,
302             TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
303             TP_ARGS(obj, offset, len),
304
305             TP_STRUCT__entry(
306                              __field(struct drm_i915_gem_object *, obj)
307                              __field(u32, offset)
308                              __field(u32, len)
309                              ),
310
311             TP_fast_assign(
312                            __entry->obj = obj;
313                            __entry->offset = offset;
314                            __entry->len = len;
315                            ),
316
317             TP_printk("obj=%p, offset=%u, len=%u",
318                       __entry->obj, __entry->offset, __entry->len)
319 );
320
321 TRACE_EVENT(i915_gem_object_fault,
322             TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
323             TP_ARGS(obj, index, gtt, write),
324
325             TP_STRUCT__entry(
326                              __field(struct drm_i915_gem_object *, obj)
327                              __field(u32, index)
328                              __field(bool, gtt)
329                              __field(bool, write)
330                              ),
331
332             TP_fast_assign(
333                            __entry->obj = obj;
334                            __entry->index = index;
335                            __entry->gtt = gtt;
336                            __entry->write = write;
337                            ),
338
339             TP_printk("obj=%p, %s index=%u %s",
340                       __entry->obj,
341                       __entry->gtt ? "GTT" : "CPU",
342                       __entry->index,
343                       __entry->write ? ", writable" : "")
344 );
345
346 DECLARE_EVENT_CLASS(i915_gem_object,
347             TP_PROTO(struct drm_i915_gem_object *obj),
348             TP_ARGS(obj),
349
350             TP_STRUCT__entry(
351                              __field(struct drm_i915_gem_object *, obj)
352                              ),
353
354             TP_fast_assign(
355                            __entry->obj = obj;
356                            ),
357
358             TP_printk("obj=%p", __entry->obj)
359 );
360
361 DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
362              TP_PROTO(struct drm_i915_gem_object *obj),
363              TP_ARGS(obj)
364 );
365
366 DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
367             TP_PROTO(struct drm_i915_gem_object *obj),
368             TP_ARGS(obj)
369 );
370
371 TRACE_EVENT(i915_gem_evict,
372             TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
373             TP_ARGS(dev, size, align, flags),
374
375             TP_STRUCT__entry(
376                              __field(u32, dev)
377                              __field(u32, size)
378                              __field(u32, align)
379                              __field(unsigned, flags)
380                             ),
381
382             TP_fast_assign(
383                            __entry->dev = dev->primary->index;
384                            __entry->size = size;
385                            __entry->align = align;
386                            __entry->flags = flags;
387                           ),
388
389             TP_printk("dev=%d, size=%d, align=%d %s",
390                       __entry->dev, __entry->size, __entry->align,
391                       __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
392 );
393
394 TRACE_EVENT(i915_gem_evict_everything,
395             TP_PROTO(struct drm_device *dev),
396             TP_ARGS(dev),
397
398             TP_STRUCT__entry(
399                              __field(u32, dev)
400                             ),
401
402             TP_fast_assign(
403                            __entry->dev = dev->primary->index;
404                           ),
405
406             TP_printk("dev=%d", __entry->dev)
407 );
408
409 TRACE_EVENT(i915_gem_evict_vm,
410             TP_PROTO(struct i915_address_space *vm),
411             TP_ARGS(vm),
412
413             TP_STRUCT__entry(
414                              __field(u32, dev)
415                              __field(struct i915_address_space *, vm)
416                             ),
417
418             TP_fast_assign(
419                            __entry->dev = vm->dev->primary->index;
420                            __entry->vm = vm;
421                           ),
422
423             TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
424 );
425
426 TRACE_EVENT(i915_gem_ring_sync_to,
427             TP_PROTO(struct intel_engine_cs *from,
428                      struct intel_engine_cs *to,
429                      struct drm_i915_gem_request *req),
430             TP_ARGS(from, to, req),
431
432             TP_STRUCT__entry(
433                              __field(u32, dev)
434                              __field(u32, sync_from)
435                              __field(u32, sync_to)
436                              __field(u32, seqno)
437                              ),
438
439             TP_fast_assign(
440                            __entry->dev = from->dev->primary->index;
441                            __entry->sync_from = from->id;
442                            __entry->sync_to = to->id;
443                            __entry->seqno = i915_gem_request_get_seqno(req);
444                            ),
445
446             TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
447                       __entry->dev,
448                       __entry->sync_from, __entry->sync_to,
449                       __entry->seqno)
450 );
451
452 TRACE_EVENT(i915_gem_ring_dispatch,
453             TP_PROTO(struct drm_i915_gem_request *req, u32 flags),
454             TP_ARGS(req, flags),
455
456             TP_STRUCT__entry(
457                              __field(u32, dev)
458                              __field(u32, ring)
459                              __field(u32, seqno)
460                              __field(u32, flags)
461                              ),
462
463             TP_fast_assign(
464                            struct intel_engine_cs *ring =
465                                                 i915_gem_request_get_ring(req);
466                            __entry->dev = ring->dev->primary->index;
467                            __entry->ring = ring->id;
468                            __entry->seqno = i915_gem_request_get_seqno(req);
469                            __entry->flags = flags;
470                            i915_trace_irq_get(ring, req);
471                            ),
472
473             TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
474                       __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
475 );
476
477 TRACE_EVENT(i915_gem_ring_flush,
478             TP_PROTO(struct intel_engine_cs *ring, u32 invalidate, u32 flush),
479             TP_ARGS(ring, invalidate, flush),
480
481             TP_STRUCT__entry(
482                              __field(u32, dev)
483                              __field(u32, ring)
484                              __field(u32, invalidate)
485                              __field(u32, flush)
486                              ),
487
488             TP_fast_assign(
489                            __entry->dev = ring->dev->primary->index;
490                            __entry->ring = ring->id;
491                            __entry->invalidate = invalidate;
492                            __entry->flush = flush;
493                            ),
494
495             TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
496                       __entry->dev, __entry->ring,
497                       __entry->invalidate, __entry->flush)
498 );
499
500 DECLARE_EVENT_CLASS(i915_gem_request,
501             TP_PROTO(struct drm_i915_gem_request *req),
502             TP_ARGS(req),
503
504             TP_STRUCT__entry(
505                              __field(u32, dev)
506                              __field(u32, ring)
507                              __field(u32, seqno)
508                              ),
509
510             TP_fast_assign(
511                            struct intel_engine_cs *ring =
512                                                 i915_gem_request_get_ring(req);
513                            __entry->dev = ring->dev->primary->index;
514                            __entry->ring = ring->id;
515                            __entry->seqno = i915_gem_request_get_seqno(req);
516                            ),
517
518             TP_printk("dev=%u, ring=%u, seqno=%u",
519                       __entry->dev, __entry->ring, __entry->seqno)
520 );
521
522 DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
523             TP_PROTO(struct drm_i915_gem_request *req),
524             TP_ARGS(req)
525 );
526
527 TRACE_EVENT(i915_gem_request_notify,
528             TP_PROTO(struct intel_engine_cs *ring),
529             TP_ARGS(ring),
530
531             TP_STRUCT__entry(
532                              __field(u32, dev)
533                              __field(u32, ring)
534                              __field(u32, seqno)
535                              ),
536
537             TP_fast_assign(
538                            __entry->dev = ring->dev->primary->index;
539                            __entry->ring = ring->id;
540                            __entry->seqno = ring->get_seqno(ring, false);
541                            ),
542
543             TP_printk("dev=%u, ring=%u, seqno=%u",
544                       __entry->dev, __entry->ring, __entry->seqno)
545 );
546
547 DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
548             TP_PROTO(struct drm_i915_gem_request *req),
549             TP_ARGS(req)
550 );
551
552 DEFINE_EVENT(i915_gem_request, i915_gem_request_complete,
553             TP_PROTO(struct drm_i915_gem_request *req),
554             TP_ARGS(req)
555 );
556
557 TRACE_EVENT(i915_gem_request_wait_begin,
558             TP_PROTO(struct drm_i915_gem_request *req),
559             TP_ARGS(req),
560
561             TP_STRUCT__entry(
562                              __field(u32, dev)
563                              __field(u32, ring)
564                              __field(u32, seqno)
565                              __field(bool, blocking)
566                              ),
567
568             /* NB: the blocking information is racy since mutex_is_locked
569              * doesn't check that the current thread holds the lock. The only
570              * other option would be to pass the boolean information of whether
571              * or not the class was blocking down through the stack which is
572              * less desirable.
573              */
574             TP_fast_assign(
575                            struct intel_engine_cs *ring =
576                                                 i915_gem_request_get_ring(req);
577                            __entry->dev = ring->dev->primary->index;
578                            __entry->ring = ring->id;
579                            __entry->seqno = i915_gem_request_get_seqno(req);
580                            __entry->blocking =
581                                      mutex_is_locked(&ring->dev->struct_mutex);
582                            ),
583
584             TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
585                       __entry->dev, __entry->ring,
586                       __entry->seqno, __entry->blocking ?  "yes (NB)" : "no")
587 );
588
589 DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
590             TP_PROTO(struct drm_i915_gem_request *req),
591             TP_ARGS(req)
592 );
593
594 TRACE_EVENT(i915_flip_request,
595             TP_PROTO(int plane, struct drm_i915_gem_object *obj),
596
597             TP_ARGS(plane, obj),
598
599             TP_STRUCT__entry(
600                     __field(int, plane)
601                     __field(struct drm_i915_gem_object *, obj)
602                     ),
603
604             TP_fast_assign(
605                     __entry->plane = plane;
606                     __entry->obj = obj;
607                     ),
608
609             TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
610 );
611
612 TRACE_EVENT(i915_flip_complete,
613             TP_PROTO(int plane, struct drm_i915_gem_object *obj),
614
615             TP_ARGS(plane, obj),
616
617             TP_STRUCT__entry(
618                     __field(int, plane)
619                     __field(struct drm_i915_gem_object *, obj)
620                     ),
621
622             TP_fast_assign(
623                     __entry->plane = plane;
624                     __entry->obj = obj;
625                     ),
626
627             TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
628 );
629
630 TRACE_EVENT_CONDITION(i915_reg_rw,
631         TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
632
633         TP_ARGS(write, reg, val, len, trace),
634
635         TP_CONDITION(trace),
636
637         TP_STRUCT__entry(
638                 __field(u64, val)
639                 __field(u32, reg)
640                 __field(u16, write)
641                 __field(u16, len)
642                 ),
643
644         TP_fast_assign(
645                 __entry->val = (u64)val;
646                 __entry->reg = reg;
647                 __entry->write = write;
648                 __entry->len = len;
649                 ),
650
651         TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
652                 __entry->write ? "write" : "read",
653                 __entry->reg, __entry->len,
654                 (u32)(__entry->val & 0xffffffff),
655                 (u32)(__entry->val >> 32))
656 );
657
658 TRACE_EVENT(intel_gpu_freq_change,
659             TP_PROTO(u32 freq),
660             TP_ARGS(freq),
661
662             TP_STRUCT__entry(
663                              __field(u32, freq)
664                              ),
665
666             TP_fast_assign(
667                            __entry->freq = freq;
668                            ),
669
670             TP_printk("new_freq=%u", __entry->freq)
671 );
672
673 /**
674  * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
675  *
676  * With full ppgtt enabled each process using drm will allocate at least one
677  * translation table. With these traces it is possible to keep track of the
678  * allocation and of the lifetime of the tables; this can be used during
679  * testing/debug to verify that we are not leaking ppgtts.
680  * These traces identify the ppgtt through the vm pointer, which is also printed
681  * by the i915_vma_bind and i915_vma_unbind tracepoints.
682  */
683 DECLARE_EVENT_CLASS(i915_ppgtt,
684         TP_PROTO(struct i915_address_space *vm),
685         TP_ARGS(vm),
686
687         TP_STRUCT__entry(
688                         __field(struct i915_address_space *, vm)
689                         __field(u32, dev)
690         ),
691
692         TP_fast_assign(
693                         __entry->vm = vm;
694                         __entry->dev = vm->dev->primary->index;
695         ),
696
697         TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
698 )
699
700 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
701         TP_PROTO(struct i915_address_space *vm),
702         TP_ARGS(vm)
703 );
704
705 DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
706         TP_PROTO(struct i915_address_space *vm),
707         TP_ARGS(vm)
708 );
709
710 /**
711  * DOC: i915_context_create and i915_context_free tracepoints
712  *
713  * These tracepoints are used to track creation and deletion of contexts.
714  * If full ppgtt is enabled, they also print the address of the vm assigned to
715  * the context.
716  */
717 DECLARE_EVENT_CLASS(i915_context,
718         TP_PROTO(struct intel_context *ctx),
719         TP_ARGS(ctx),
720
721         TP_STRUCT__entry(
722                         __field(u32, dev)
723                         __field(struct intel_context *, ctx)
724                         __field(struct i915_address_space *, vm)
725         ),
726
727         TP_fast_assign(
728                         __entry->ctx = ctx;
729                         __entry->vm = ctx->ppgtt ? &ctx->ppgtt->base : NULL;
730                         __entry->dev = ctx->file_priv->dev_priv->dev->primary->index;
731         ),
732
733         TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
734                   __entry->dev, __entry->ctx, __entry->vm)
735 )
736
737 DEFINE_EVENT(i915_context, i915_context_create,
738         TP_PROTO(struct intel_context *ctx),
739         TP_ARGS(ctx)
740 );
741
742 DEFINE_EVENT(i915_context, i915_context_free,
743         TP_PROTO(struct intel_context *ctx),
744         TP_ARGS(ctx)
745 );
746
747 /**
748  * DOC: switch_mm tracepoint
749  *
750  * This tracepoint allows tracking of the mm switch, which is an important point
751  * in the lifetime of the vm in the legacy submission path. This tracepoint is
752  * called only if full ppgtt is enabled.
753  */
754 TRACE_EVENT(switch_mm,
755         TP_PROTO(struct intel_engine_cs *ring, struct intel_context *to),
756
757         TP_ARGS(ring, to),
758
759         TP_STRUCT__entry(
760                         __field(u32, ring)
761                         __field(struct intel_context *, to)
762                         __field(struct i915_address_space *, vm)
763                         __field(u32, dev)
764         ),
765
766         TP_fast_assign(
767                         __entry->ring = ring->id;
768                         __entry->to = to;
769                         __entry->vm = to->ppgtt? &to->ppgtt->base : NULL;
770                         __entry->dev = ring->dev->primary->index;
771         ),
772
773         TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
774                   __entry->dev, __entry->ring, __entry->to, __entry->vm)
775 );
776
777 #endif /* _I915_TRACE_H_ */
778
779 /* This part must be outside protection */
780 #undef TRACE_INCLUDE_PATH
781 #define TRACE_INCLUDE_PATH .
782 #include <trace/define_trace.h>