blob: b3070a4501ab59e3009758cb9ab624af8343a258 [file] [log] [blame]
Chris Wilson1c5d22f2009-08-25 11:15:50 +01001#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>
Chris Wilson05394f32010-11-08 19:18:58 +00009#include "i915_drv.h"
Ville Syrjälä25ef2842014-04-29 13:35:48 +030010#include "intel_drv.h"
Chris Wilsondb53a302011-02-03 11:57:46 +000011#include "intel_ringbuffer.h"
Chris Wilson1c5d22f2009-08-25 11:15:50 +010012
13#undef TRACE_SYSTEM
14#define TRACE_SYSTEM i915
15#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)
16#define TRACE_INCLUDE_FILE i915_trace
17
Ville Syrjälä25ef2842014-04-29 13:35:48 +030018/* pipe updates */
19
20TRACE_EVENT(i915_pipe_update_start,
21 TP_PROTO(struct intel_crtc *crtc, u32 min, u32 max),
22 TP_ARGS(crtc, min, max),
23
24 TP_STRUCT__entry(
25 __field(enum pipe, pipe)
26 __field(u32, frame)
27 __field(u32, scanline)
28 __field(u32, min)
29 __field(u32, max)
30 ),
31
32 TP_fast_assign(
33 __entry->pipe = crtc->pipe;
34 __entry->frame = crtc->base.dev->driver->get_vblank_counter(crtc->base.dev,
35 crtc->pipe);
36 __entry->scanline = intel_get_crtc_scanline(crtc);
37 __entry->min = min;
38 __entry->max = max;
39 ),
40
41 TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
42 pipe_name(__entry->pipe), __entry->frame,
43 __entry->scanline, __entry->min, __entry->max)
44);
45
46TRACE_EVENT(i915_pipe_update_vblank_evaded,
47 TP_PROTO(struct intel_crtc *crtc, u32 min, u32 max, u32 frame),
48 TP_ARGS(crtc, min, max, frame),
49
50 TP_STRUCT__entry(
51 __field(enum pipe, pipe)
52 __field(u32, frame)
53 __field(u32, scanline)
54 __field(u32, min)
55 __field(u32, max)
56 ),
57
58 TP_fast_assign(
59 __entry->pipe = crtc->pipe;
60 __entry->frame = frame;
61 __entry->scanline = intel_get_crtc_scanline(crtc);
62 __entry->min = min;
63 __entry->max = max;
64 ),
65
66 TP_printk("pipe %c, frame=%u, scanline=%u, min=%u, max=%u",
67 pipe_name(__entry->pipe), __entry->frame,
68 __entry->scanline, __entry->min, __entry->max)
69);
70
71TRACE_EVENT(i915_pipe_update_end,
72 TP_PROTO(struct intel_crtc *crtc, u32 frame),
73 TP_ARGS(crtc, frame),
74
75 TP_STRUCT__entry(
76 __field(enum pipe, pipe)
77 __field(u32, frame)
78 __field(u32, scanline)
79 ),
80
81 TP_fast_assign(
82 __entry->pipe = crtc->pipe;
83 __entry->frame = frame;
84 __entry->scanline = intel_get_crtc_scanline(crtc);
85 ),
86
87 TP_printk("pipe %c, frame=%u, scanline=%u",
88 pipe_name(__entry->pipe), __entry->frame,
89 __entry->scanline)
90);
91
Chris Wilson1c5d22f2009-08-25 11:15:50 +010092/* object tracking */
93
94TRACE_EVENT(i915_gem_object_create,
Chris Wilson05394f32010-11-08 19:18:58 +000095 TP_PROTO(struct drm_i915_gem_object *obj),
Chris Wilson1c5d22f2009-08-25 11:15:50 +010096 TP_ARGS(obj),
97
98 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +000099 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100100 __field(u32, size)
101 ),
102
103 TP_fast_assign(
104 __entry->obj = obj;
Chris Wilson05394f32010-11-08 19:18:58 +0000105 __entry->size = obj->base.size;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100106 ),
107
108 TP_printk("obj=%p, size=%u", __entry->obj, __entry->size)
109);
110
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700111TRACE_EVENT(i915_vma_bind,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100112 TP_PROTO(struct i915_vma *vma, unsigned flags),
113 TP_ARGS(vma, flags),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100114
115 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000116 __field(struct drm_i915_gem_object *, obj)
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700117 __field(struct i915_address_space *, vm)
Ben Widawsky33938712015-01-22 17:01:23 +0000118 __field(u64, offset)
Chris Wilsondb53a302011-02-03 11:57:46 +0000119 __field(u32, size)
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100120 __field(unsigned, flags)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100121 ),
122
123 TP_fast_assign(
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700124 __entry->obj = vma->obj;
125 __entry->vm = vma->vm;
126 __entry->offset = vma->node.start;
127 __entry->size = vma->node.size;
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100128 __entry->flags = flags;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100129 ),
130
Ben Widawsky33938712015-01-22 17:01:23 +0000131 TP_printk("obj=%p, offset=%016llx size=%x%s vm=%p",
Chris Wilsondb53a302011-02-03 11:57:46 +0000132 __entry->obj, __entry->offset, __entry->size,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100133 __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700134 __entry->vm)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100135);
136
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700137TRACE_EVENT(i915_vma_unbind,
138 TP_PROTO(struct i915_vma *vma),
139 TP_ARGS(vma),
Chris Wilsondb53a302011-02-03 11:57:46 +0000140
141 TP_STRUCT__entry(
142 __field(struct drm_i915_gem_object *, obj)
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700143 __field(struct i915_address_space *, vm)
Ben Widawsky33938712015-01-22 17:01:23 +0000144 __field(u64, offset)
Chris Wilsondb53a302011-02-03 11:57:46 +0000145 __field(u32, size)
146 ),
147
148 TP_fast_assign(
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700149 __entry->obj = vma->obj;
150 __entry->vm = vma->vm;
151 __entry->offset = vma->node.start;
152 __entry->size = vma->node.size;
Chris Wilsondb53a302011-02-03 11:57:46 +0000153 ),
154
Ben Widawsky33938712015-01-22 17:01:23 +0000155 TP_printk("obj=%p, offset=%016llx size=%x vm=%p",
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700156 __entry->obj, __entry->offset, __entry->size, __entry->vm)
Chris Wilsondb53a302011-02-03 11:57:46 +0000157);
158
Michel Thierry72744cb2015-03-24 15:46:23 +0000159#define VM_TO_TRACE_NAME(vm) \
160 (i915_is_ggtt(vm) ? "G" : \
161 "P")
162
163DECLARE_EVENT_CLASS(i915_va,
164 TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
165 TP_ARGS(vm, start, length, name),
166
167 TP_STRUCT__entry(
168 __field(struct i915_address_space *, vm)
169 __field(u64, start)
170 __field(u64, end)
171 __string(name, name)
172 ),
173
174 TP_fast_assign(
175 __entry->vm = vm;
176 __entry->start = start;
177 __entry->end = start + length - 1;
178 __assign_str(name, name);
179 ),
180
181 TP_printk("vm=%p (%s), 0x%llx-0x%llx",
182 __entry->vm, __get_str(name), __entry->start, __entry->end)
183);
184
185DEFINE_EVENT(i915_va, i915_va_alloc,
186 TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
187 TP_ARGS(vm, start, length, name)
188);
189
190DECLARE_EVENT_CLASS(i915_page_table_entry,
191 TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
192 TP_ARGS(vm, pde, start, pde_shift),
193
194 TP_STRUCT__entry(
195 __field(struct i915_address_space *, vm)
196 __field(u32, pde)
197 __field(u64, start)
198 __field(u64, end)
199 ),
200
201 TP_fast_assign(
202 __entry->vm = vm;
203 __entry->pde = pde;
204 __entry->start = start;
205 __entry->end = ((start + (1ULL << pde_shift)) & ~((1ULL << pde_shift)-1)) - 1;
206 ),
207
208 TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
209 __entry->vm, __entry->pde, __entry->start, __entry->end)
210);
211
212DEFINE_EVENT(i915_page_table_entry, i915_page_table_entry_alloc,
213 TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
214 TP_ARGS(vm, pde, start, pde_shift)
215);
216
217/* Avoid extra math because we only support two sizes. The format is defined by
218 * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
219#define TRACE_PT_SIZE(bits) \
220 ((((bits) == 1024) ? 288 : 144) + 1)
221
222DECLARE_EVENT_CLASS(i915_page_table_entry_update,
223 TP_PROTO(struct i915_address_space *vm, u32 pde,
224 struct i915_page_table_entry *pt, u32 first, u32 count, u32 bits),
225 TP_ARGS(vm, pde, pt, first, count, bits),
226
227 TP_STRUCT__entry(
228 __field(struct i915_address_space *, vm)
229 __field(u32, pde)
230 __field(u32, first)
231 __field(u32, last)
232 __dynamic_array(char, cur_ptes, TRACE_PT_SIZE(bits))
233 ),
234
235 TP_fast_assign(
236 __entry->vm = vm;
237 __entry->pde = pde;
238 __entry->first = first;
239 __entry->last = first + count - 1;
240 scnprintf(__get_str(cur_ptes),
241 TRACE_PT_SIZE(bits),
242 "%*pb",
243 bits,
244 pt->used_ptes);
245 ),
246
247 TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
248 __entry->vm, __entry->pde, __entry->last, __entry->first,
249 __get_str(cur_ptes))
250);
251
252DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_map,
253 TP_PROTO(struct i915_address_space *vm, u32 pde,
254 struct i915_page_table_entry *pt, u32 first, u32 count, u32 bits),
255 TP_ARGS(vm, pde, pt, first, count, bits)
256);
257
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100258TRACE_EVENT(i915_gem_object_change_domain,
Chris Wilsondb53a302011-02-03 11:57:46 +0000259 TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
260 TP_ARGS(obj, old_read, old_write),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100261
262 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000263 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100264 __field(u32, read_domains)
265 __field(u32, write_domain)
266 ),
267
268 TP_fast_assign(
269 __entry->obj = obj;
Chris Wilsondb53a302011-02-03 11:57:46 +0000270 __entry->read_domains = obj->base.read_domains | (old_read << 16);
271 __entry->write_domain = obj->base.write_domain | (old_write << 16);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100272 ),
273
Chris Wilsondb53a302011-02-03 11:57:46 +0000274 TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100275 __entry->obj,
Chris Wilsondb53a302011-02-03 11:57:46 +0000276 __entry->read_domains >> 16,
277 __entry->read_domains & 0xffff,
278 __entry->write_domain >> 16,
279 __entry->write_domain & 0xffff)
280);
281
282TRACE_EVENT(i915_gem_object_pwrite,
283 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
284 TP_ARGS(obj, offset, len),
285
286 TP_STRUCT__entry(
287 __field(struct drm_i915_gem_object *, obj)
288 __field(u32, offset)
289 __field(u32, len)
290 ),
291
292 TP_fast_assign(
293 __entry->obj = obj;
294 __entry->offset = offset;
295 __entry->len = len;
296 ),
297
298 TP_printk("obj=%p, offset=%u, len=%u",
299 __entry->obj, __entry->offset, __entry->len)
300);
301
302TRACE_EVENT(i915_gem_object_pread,
303 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
304 TP_ARGS(obj, offset, len),
305
306 TP_STRUCT__entry(
307 __field(struct drm_i915_gem_object *, obj)
308 __field(u32, offset)
309 __field(u32, len)
310 ),
311
312 TP_fast_assign(
313 __entry->obj = obj;
314 __entry->offset = offset;
315 __entry->len = len;
316 ),
317
318 TP_printk("obj=%p, offset=%u, len=%u",
319 __entry->obj, __entry->offset, __entry->len)
320);
321
322TRACE_EVENT(i915_gem_object_fault,
323 TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
324 TP_ARGS(obj, index, gtt, write),
325
326 TP_STRUCT__entry(
327 __field(struct drm_i915_gem_object *, obj)
328 __field(u32, index)
329 __field(bool, gtt)
330 __field(bool, write)
331 ),
332
333 TP_fast_assign(
334 __entry->obj = obj;
335 __entry->index = index;
336 __entry->gtt = gtt;
337 __entry->write = write;
338 ),
339
340 TP_printk("obj=%p, %s index=%u %s",
341 __entry->obj,
342 __entry->gtt ? "GTT" : "CPU",
343 __entry->index,
344 __entry->write ? ", writable" : "")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100345);
346
Li Zefan903cf202010-03-11 16:41:45 +0800347DECLARE_EVENT_CLASS(i915_gem_object,
Chris Wilson05394f32010-11-08 19:18:58 +0000348 TP_PROTO(struct drm_i915_gem_object *obj),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100349 TP_ARGS(obj),
350
351 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000352 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100353 ),
354
355 TP_fast_assign(
356 __entry->obj = obj;
357 ),
358
359 TP_printk("obj=%p", __entry->obj)
360);
361
Li Zefanf41275e2010-05-24 16:25:44 +0800362DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
Chris Wilsondb53a302011-02-03 11:57:46 +0000363 TP_PROTO(struct drm_i915_gem_object *obj),
364 TP_ARGS(obj)
Li Zefan903cf202010-03-11 16:41:45 +0800365);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100366
Li Zefan903cf202010-03-11 16:41:45 +0800367DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
Chris Wilson05394f32010-11-08 19:18:58 +0000368 TP_PROTO(struct drm_i915_gem_object *obj),
Li Zefan903cf202010-03-11 16:41:45 +0800369 TP_ARGS(obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100370);
371
Chris Wilsondb53a302011-02-03 11:57:46 +0000372TRACE_EVENT(i915_gem_evict,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100373 TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
374 TP_ARGS(dev, size, align, flags),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100375
376 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100377 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000378 __field(u32, size)
379 __field(u32, align)
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100380 __field(unsigned, flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000381 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100382
383 TP_fast_assign(
Chris Wilson4f49be52009-09-24 00:23:33 +0100384 __entry->dev = dev->primary->index;
Chris Wilsondb53a302011-02-03 11:57:46 +0000385 __entry->size = size;
386 __entry->align = align;
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100387 __entry->flags = flags;
Chris Wilsondb53a302011-02-03 11:57:46 +0000388 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100389
Chris Wilsondb53a302011-02-03 11:57:46 +0000390 TP_printk("dev=%d, size=%d, align=%d %s",
391 __entry->dev, __entry->size, __entry->align,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100392 __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100393);
394
Chris Wilsondb53a302011-02-03 11:57:46 +0000395TRACE_EVENT(i915_gem_evict_everything,
Chris Wilson6c085a72012-08-20 11:40:46 +0200396 TP_PROTO(struct drm_device *dev),
397 TP_ARGS(dev),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100398
399 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100400 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000401 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100402
403 TP_fast_assign(
Chris Wilson4f49be52009-09-24 00:23:33 +0100404 __entry->dev = dev->primary->index;
Chris Wilsondb53a302011-02-03 11:57:46 +0000405 ),
406
Chris Wilson6c085a72012-08-20 11:40:46 +0200407 TP_printk("dev=%d", __entry->dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000408);
409
Ben Widawskybcccff82013-09-24 09:57:56 -0700410TRACE_EVENT(i915_gem_evict_vm,
411 TP_PROTO(struct i915_address_space *vm),
412 TP_ARGS(vm),
413
414 TP_STRUCT__entry(
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400415 __field(u32, dev)
Ben Widawskybcccff82013-09-24 09:57:56 -0700416 __field(struct i915_address_space *, vm)
417 ),
418
419 TP_fast_assign(
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400420 __entry->dev = vm->dev->primary->index;
Ben Widawskybcccff82013-09-24 09:57:56 -0700421 __entry->vm = vm;
422 ),
423
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400424 TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
Ben Widawskybcccff82013-09-24 09:57:56 -0700425);
426
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100427TRACE_EVENT(i915_gem_ring_sync_to,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100428 TP_PROTO(struct intel_engine_cs *from,
429 struct intel_engine_cs *to,
John Harrison74328ee2014-11-24 18:49:38 +0000430 struct drm_i915_gem_request *req),
431 TP_ARGS(from, to, req),
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100432
433 TP_STRUCT__entry(
434 __field(u32, dev)
435 __field(u32, sync_from)
436 __field(u32, sync_to)
437 __field(u32, seqno)
438 ),
439
440 TP_fast_assign(
441 __entry->dev = from->dev->primary->index;
442 __entry->sync_from = from->id;
443 __entry->sync_to = to->id;
John Harrison74328ee2014-11-24 18:49:38 +0000444 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100445 ),
446
447 TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
448 __entry->dev,
449 __entry->sync_from, __entry->sync_to,
450 __entry->seqno)
451);
452
Chris Wilsondb53a302011-02-03 11:57:46 +0000453TRACE_EVENT(i915_gem_ring_dispatch,
John Harrison74328ee2014-11-24 18:49:38 +0000454 TP_PROTO(struct drm_i915_gem_request *req, u32 flags),
455 TP_ARGS(req, flags),
Chris Wilsondb53a302011-02-03 11:57:46 +0000456
457 TP_STRUCT__entry(
458 __field(u32, dev)
459 __field(u32, ring)
460 __field(u32, seqno)
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100461 __field(u32, flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000462 ),
463
464 TP_fast_assign(
John Harrison74328ee2014-11-24 18:49:38 +0000465 struct intel_engine_cs *ring =
466 i915_gem_request_get_ring(req);
Chris Wilsondb53a302011-02-03 11:57:46 +0000467 __entry->dev = ring->dev->primary->index;
468 __entry->ring = ring->id;
John Harrison74328ee2014-11-24 18:49:38 +0000469 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100470 __entry->flags = flags;
John Harrison581c26e82014-11-24 18:49:39 +0000471 i915_trace_irq_get(ring, req);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100472 ),
473
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100474 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
475 __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000476);
477
478TRACE_EVENT(i915_gem_ring_flush,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100479 TP_PROTO(struct intel_engine_cs *ring, u32 invalidate, u32 flush),
Chris Wilsondb53a302011-02-03 11:57:46 +0000480 TP_ARGS(ring, invalidate, flush),
481
482 TP_STRUCT__entry(
483 __field(u32, dev)
484 __field(u32, ring)
485 __field(u32, invalidate)
486 __field(u32, flush)
487 ),
488
489 TP_fast_assign(
490 __entry->dev = ring->dev->primary->index;
491 __entry->ring = ring->id;
492 __entry->invalidate = invalidate;
493 __entry->flush = flush;
494 ),
495
496 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
497 __entry->dev, __entry->ring,
498 __entry->invalidate, __entry->flush)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100499);
500
Li Zefan903cf202010-03-11 16:41:45 +0800501DECLARE_EVENT_CLASS(i915_gem_request,
John Harrison74328ee2014-11-24 18:49:38 +0000502 TP_PROTO(struct drm_i915_gem_request *req),
503 TP_ARGS(req),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100504
505 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100506 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000507 __field(u32, ring)
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000508 __field(u32, uniq)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100509 __field(u32, seqno)
510 ),
511
512 TP_fast_assign(
John Harrison74328ee2014-11-24 18:49:38 +0000513 struct intel_engine_cs *ring =
514 i915_gem_request_get_ring(req);
Chris Wilsondb53a302011-02-03 11:57:46 +0000515 __entry->dev = ring->dev->primary->index;
516 __entry->ring = ring->id;
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000517 __entry->uniq = req ? req->uniq : 0;
John Harrison74328ee2014-11-24 18:49:38 +0000518 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100519 ),
520
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000521 TP_printk("dev=%u, ring=%u, uniq=%u, seqno=%u",
522 __entry->dev, __entry->ring, __entry->uniq,
523 __entry->seqno)
Chris Wilsondb53a302011-02-03 11:57:46 +0000524);
525
526DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
John Harrison74328ee2014-11-24 18:49:38 +0000527 TP_PROTO(struct drm_i915_gem_request *req),
528 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100529);
530
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000531TRACE_EVENT(i915_gem_request_notify,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100532 TP_PROTO(struct intel_engine_cs *ring),
Chris Wilson814e9b52013-09-23 17:33:19 -0300533 TP_ARGS(ring),
534
535 TP_STRUCT__entry(
536 __field(u32, dev)
537 __field(u32, ring)
538 __field(u32, seqno)
539 ),
540
541 TP_fast_assign(
542 __entry->dev = ring->dev->primary->index;
543 __entry->ring = ring->id;
544 __entry->seqno = ring->get_seqno(ring, false);
545 ),
546
547 TP_printk("dev=%u, ring=%u, seqno=%u",
548 __entry->dev, __entry->ring, __entry->seqno)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100549);
550
Li Zefan903cf202010-03-11 16:41:45 +0800551DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
John Harrison74328ee2014-11-24 18:49:38 +0000552 TP_PROTO(struct drm_i915_gem_request *req),
553 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100554);
555
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000556DEFINE_EVENT(i915_gem_request, i915_gem_request_complete,
557 TP_PROTO(struct drm_i915_gem_request *req),
558 TP_ARGS(req)
559);
560
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700561TRACE_EVENT(i915_gem_request_wait_begin,
John Harrison74328ee2014-11-24 18:49:38 +0000562 TP_PROTO(struct drm_i915_gem_request *req),
563 TP_ARGS(req),
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700564
565 TP_STRUCT__entry(
566 __field(u32, dev)
567 __field(u32, ring)
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000568 __field(u32, uniq)
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700569 __field(u32, seqno)
570 __field(bool, blocking)
571 ),
572
573 /* NB: the blocking information is racy since mutex_is_locked
574 * doesn't check that the current thread holds the lock. The only
575 * other option would be to pass the boolean information of whether
576 * or not the class was blocking down through the stack which is
577 * less desirable.
578 */
579 TP_fast_assign(
John Harrison74328ee2014-11-24 18:49:38 +0000580 struct intel_engine_cs *ring =
581 i915_gem_request_get_ring(req);
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700582 __entry->dev = ring->dev->primary->index;
583 __entry->ring = ring->id;
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000584 __entry->uniq = req ? req->uniq : 0;
John Harrison74328ee2014-11-24 18:49:38 +0000585 __entry->seqno = i915_gem_request_get_seqno(req);
586 __entry->blocking =
587 mutex_is_locked(&ring->dev->struct_mutex);
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700588 ),
589
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000590 TP_printk("dev=%u, ring=%u, uniq=%u, seqno=%u, blocking=%s",
591 __entry->dev, __entry->ring, __entry->uniq,
592 __entry->seqno, __entry->blocking ? "yes (NB)" : "no")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100593);
594
Li Zefan903cf202010-03-11 16:41:45 +0800595DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
John Harrison74328ee2014-11-24 18:49:38 +0000596 TP_PROTO(struct drm_i915_gem_request *req),
597 TP_ARGS(req)
Li Zefan903cf202010-03-11 16:41:45 +0800598);
599
600DECLARE_EVENT_CLASS(i915_ring,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100601 TP_PROTO(struct intel_engine_cs *ring),
Chris Wilsondb53a302011-02-03 11:57:46 +0000602 TP_ARGS(ring),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100603
604 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100605 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000606 __field(u32, ring)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100607 ),
608
609 TP_fast_assign(
Chris Wilsondb53a302011-02-03 11:57:46 +0000610 __entry->dev = ring->dev->primary->index;
611 __entry->ring = ring->id;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100612 ),
613
Chris Wilsondb53a302011-02-03 11:57:46 +0000614 TP_printk("dev=%u, ring=%u", __entry->dev, __entry->ring)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100615);
616
Li Zefan903cf202010-03-11 16:41:45 +0800617DEFINE_EVENT(i915_ring, i915_ring_wait_begin,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100618 TP_PROTO(struct intel_engine_cs *ring),
Chris Wilsondb53a302011-02-03 11:57:46 +0000619 TP_ARGS(ring)
Li Zefan903cf202010-03-11 16:41:45 +0800620);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100621
Li Zefan903cf202010-03-11 16:41:45 +0800622DEFINE_EVENT(i915_ring, i915_ring_wait_end,
Oscar Mateoa4872ba2014-05-22 14:13:33 +0100623 TP_PROTO(struct intel_engine_cs *ring),
Chris Wilsondb53a302011-02-03 11:57:46 +0000624 TP_ARGS(ring)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100625);
626
Jesse Barnese5510fa2010-07-01 16:48:37 -0700627TRACE_EVENT(i915_flip_request,
Chris Wilson05394f32010-11-08 19:18:58 +0000628 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700629
630 TP_ARGS(plane, obj),
631
632 TP_STRUCT__entry(
633 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000634 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700635 ),
636
637 TP_fast_assign(
638 __entry->plane = plane;
639 __entry->obj = obj;
640 ),
641
642 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
643);
644
645TRACE_EVENT(i915_flip_complete,
Chris Wilson05394f32010-11-08 19:18:58 +0000646 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700647
648 TP_ARGS(plane, obj),
649
650 TP_STRUCT__entry(
651 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000652 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700653 ),
654
655 TP_fast_assign(
656 __entry->plane = plane;
657 __entry->obj = obj;
658 ),
659
660 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
661);
662
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100663TRACE_EVENT_CONDITION(i915_reg_rw,
664 TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800665
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100666 TP_ARGS(write, reg, val, len, trace),
667
668 TP_CONDITION(trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800669
Akshay Joshi0206e352011-08-16 15:34:10 -0400670 TP_STRUCT__entry(
671 __field(u64, val)
672 __field(u32, reg)
673 __field(u16, write)
674 __field(u16, len)
675 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800676
Akshay Joshi0206e352011-08-16 15:34:10 -0400677 TP_fast_assign(
678 __entry->val = (u64)val;
679 __entry->reg = reg;
680 __entry->write = write;
681 __entry->len = len;
682 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800683
Akshay Joshi0206e352011-08-16 15:34:10 -0400684 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
685 __entry->write ? "write" : "read",
686 __entry->reg, __entry->len,
687 (u32)(__entry->val & 0xffffffff),
688 (u32)(__entry->val >> 32))
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800689);
690
Daniel Vetterbe2cde9a2012-08-30 13:26:48 +0200691TRACE_EVENT(intel_gpu_freq_change,
692 TP_PROTO(u32 freq),
693 TP_ARGS(freq),
694
695 TP_STRUCT__entry(
696 __field(u32, freq)
697 ),
698
699 TP_fast_assign(
700 __entry->freq = freq;
701 ),
702
703 TP_printk("new_freq=%u", __entry->freq)
704);
705
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000706/**
707 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
708 *
709 * With full ppgtt enabled each process using drm will allocate at least one
710 * translation table. With these traces it is possible to keep track of the
711 * allocation and of the lifetime of the tables; this can be used during
712 * testing/debug to verify that we are not leaking ppgtts.
713 * These traces identify the ppgtt through the vm pointer, which is also printed
714 * by the i915_vma_bind and i915_vma_unbind tracepoints.
715 */
716DECLARE_EVENT_CLASS(i915_ppgtt,
717 TP_PROTO(struct i915_address_space *vm),
718 TP_ARGS(vm),
719
720 TP_STRUCT__entry(
721 __field(struct i915_address_space *, vm)
722 __field(u32, dev)
723 ),
724
725 TP_fast_assign(
726 __entry->vm = vm;
727 __entry->dev = vm->dev->primary->index;
728 ),
729
730 TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
731)
732
733DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
734 TP_PROTO(struct i915_address_space *vm),
735 TP_ARGS(vm)
736);
737
738DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
739 TP_PROTO(struct i915_address_space *vm),
740 TP_ARGS(vm)
741);
742
743/**
744 * DOC: i915_context_create and i915_context_free tracepoints
745 *
746 * These tracepoints are used to track creation and deletion of contexts.
747 * If full ppgtt is enabled, they also print the address of the vm assigned to
748 * the context.
749 */
750DECLARE_EVENT_CLASS(i915_context,
751 TP_PROTO(struct intel_context *ctx),
752 TP_ARGS(ctx),
753
754 TP_STRUCT__entry(
755 __field(u32, dev)
756 __field(struct intel_context *, ctx)
757 __field(struct i915_address_space *, vm)
758 ),
759
760 TP_fast_assign(
761 __entry->ctx = ctx;
762 __entry->vm = ctx->ppgtt ? &ctx->ppgtt->base : NULL;
763 __entry->dev = ctx->file_priv->dev_priv->dev->primary->index;
764 ),
765
766 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
767 __entry->dev, __entry->ctx, __entry->vm)
768)
769
770DEFINE_EVENT(i915_context, i915_context_create,
771 TP_PROTO(struct intel_context *ctx),
772 TP_ARGS(ctx)
773);
774
775DEFINE_EVENT(i915_context, i915_context_free,
776 TP_PROTO(struct intel_context *ctx),
777 TP_ARGS(ctx)
778);
779
780/**
781 * DOC: switch_mm tracepoint
782 *
783 * This tracepoint allows tracking of the mm switch, which is an important point
784 * in the lifetime of the vm in the legacy submission path. This tracepoint is
785 * called only if full ppgtt is enabled.
786 */
787TRACE_EVENT(switch_mm,
788 TP_PROTO(struct intel_engine_cs *ring, struct intel_context *to),
789
790 TP_ARGS(ring, to),
791
792 TP_STRUCT__entry(
793 __field(u32, ring)
794 __field(struct intel_context *, to)
795 __field(struct i915_address_space *, vm)
796 __field(u32, dev)
797 ),
798
799 TP_fast_assign(
800 __entry->ring = ring->id;
801 __entry->to = to;
802 __entry->vm = to->ppgtt? &to->ppgtt->base : NULL;
803 __entry->dev = ring->dev->primary->index;
804 ),
805
806 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
807 __entry->dev, __entry->ring, __entry->to, __entry->vm)
808);
809
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100810#endif /* _I915_TRACE_H_ */
811
812/* This part must be outside protection */
813#undef TRACE_INCLUDE_PATH
Peter Cliftona7c54272010-05-03 13:24:41 +0100814#define TRACE_INCLUDE_PATH .
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100815#include <trace/define_trace.h>