blob: 534154e05fbe47b70870e4149e8265caf4a89572 [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
Chris Wilson1c5d22f2009-08-25 11:15:50 +010015#define TRACE_INCLUDE_FILE i915_trace
16
Ville Syrjälä25ef2842014-04-29 13:35:48 +030017/* pipe updates */
18
19TRACE_EVENT(i915_pipe_update_start,
Jesse Barnesd637ce32015-09-17 08:08:32 -070020 TP_PROTO(struct intel_crtc *crtc),
21 TP_ARGS(crtc),
Ville Syrjälä25ef2842014-04-29 13:35:48 +030022
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);
Jesse Barnesd637ce32015-09-17 08:08:32 -070036 __entry->min = crtc->debug.min_vbl;
37 __entry->max = crtc->debug.max_vbl;
Ville Syrjälä25ef2842014-04-29 13:35:48 +030038 ),
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
45TRACE_EVENT(i915_pipe_update_vblank_evaded,
Jesse Barnesd637ce32015-09-17 08:08:32 -070046 TP_PROTO(struct intel_crtc *crtc),
47 TP_ARGS(crtc),
Ville Syrjälä25ef2842014-04-29 13:35:48 +030048
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;
Jesse Barnesd637ce32015-09-17 08:08:32 -070059 __entry->frame = crtc->debug.start_vbl_count;
60 __entry->scanline = crtc->debug.scanline_start;
61 __entry->min = crtc->debug.min_vbl;
62 __entry->max = crtc->debug.max_vbl;
Ville Syrjälä25ef2842014-04-29 13:35:48 +030063 ),
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
70TRACE_EVENT(i915_pipe_update_end,
Jesse Barnesd637ce32015-09-17 08:08:32 -070071 TP_PROTO(struct intel_crtc *crtc, u32 frame, int scanline_end),
72 TP_ARGS(crtc, frame, scanline_end),
Ville Syrjälä25ef2842014-04-29 13:35:48 +030073
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;
Jesse Barnesd637ce32015-09-17 08:08:32 -070083 __entry->scanline = scanline_end;
Ville Syrjälä25ef2842014-04-29 13:35:48 +030084 ),
85
86 TP_printk("pipe %c, frame=%u, scanline=%u",
87 pipe_name(__entry->pipe), __entry->frame,
88 __entry->scanline)
89);
90
Chris Wilson1c5d22f2009-08-25 11:15:50 +010091/* object tracking */
92
93TRACE_EVENT(i915_gem_object_create,
Chris Wilson05394f32010-11-08 19:18:58 +000094 TP_PROTO(struct drm_i915_gem_object *obj),
Chris Wilson1c5d22f2009-08-25 11:15:50 +010095 TP_ARGS(obj),
96
97 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +000098 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +010099 __field(u32, size)
100 ),
101
102 TP_fast_assign(
103 __entry->obj = obj;
Chris Wilson05394f32010-11-08 19:18:58 +0000104 __entry->size = obj->base.size;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100105 ),
106
107 TP_printk("obj=%p, size=%u", __entry->obj, __entry->size)
108);
109
Chris Wilson3abafa52015-10-01 12:18:26 +0100110TRACE_EVENT(i915_gem_shrink,
111 TP_PROTO(struct drm_i915_private *i915, unsigned long target, unsigned flags),
112 TP_ARGS(i915, target, flags),
113
114 TP_STRUCT__entry(
115 __field(int, dev)
116 __field(unsigned long, target)
117 __field(unsigned, flags)
118 ),
119
120 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100121 __entry->dev = i915->drm.primary->index;
Chris Wilson3abafa52015-10-01 12:18:26 +0100122 __entry->target = target;
123 __entry->flags = flags;
124 ),
125
126 TP_printk("dev=%d, target=%lu, flags=%x",
127 __entry->dev, __entry->target, __entry->flags)
128);
129
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700130TRACE_EVENT(i915_vma_bind,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100131 TP_PROTO(struct i915_vma *vma, unsigned flags),
132 TP_ARGS(vma, flags),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100133
134 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000135 __field(struct drm_i915_gem_object *, obj)
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700136 __field(struct i915_address_space *, vm)
Ben Widawsky33938712015-01-22 17:01:23 +0000137 __field(u64, offset)
Chris Wilsondb53a302011-02-03 11:57:46 +0000138 __field(u32, size)
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100139 __field(unsigned, flags)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100140 ),
141
142 TP_fast_assign(
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700143 __entry->obj = vma->obj;
144 __entry->vm = vma->vm;
145 __entry->offset = vma->node.start;
146 __entry->size = vma->node.size;
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100147 __entry->flags = flags;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100148 ),
149
Ben Widawsky33938712015-01-22 17:01:23 +0000150 TP_printk("obj=%p, offset=%016llx size=%x%s vm=%p",
Chris Wilsondb53a302011-02-03 11:57:46 +0000151 __entry->obj, __entry->offset, __entry->size,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100152 __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700153 __entry->vm)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100154);
155
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700156TRACE_EVENT(i915_vma_unbind,
157 TP_PROTO(struct i915_vma *vma),
158 TP_ARGS(vma),
Chris Wilsondb53a302011-02-03 11:57:46 +0000159
160 TP_STRUCT__entry(
161 __field(struct drm_i915_gem_object *, obj)
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700162 __field(struct i915_address_space *, vm)
Ben Widawsky33938712015-01-22 17:01:23 +0000163 __field(u64, offset)
Chris Wilsondb53a302011-02-03 11:57:46 +0000164 __field(u32, size)
165 ),
166
167 TP_fast_assign(
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700168 __entry->obj = vma->obj;
169 __entry->vm = vma->vm;
170 __entry->offset = vma->node.start;
171 __entry->size = vma->node.size;
Chris Wilsondb53a302011-02-03 11:57:46 +0000172 ),
173
Ben Widawsky33938712015-01-22 17:01:23 +0000174 TP_printk("obj=%p, offset=%016llx size=%x vm=%p",
Ben Widawsky07fe0b12013-07-31 17:00:10 -0700175 __entry->obj, __entry->offset, __entry->size, __entry->vm)
Chris Wilsondb53a302011-02-03 11:57:46 +0000176);
177
Chris Wilson596c5922016-02-26 11:03:20 +0000178TRACE_EVENT(i915_va_alloc,
179 TP_PROTO(struct i915_vma *vma),
180 TP_ARGS(vma),
Michel Thierry72744cb2015-03-24 15:46:23 +0000181
182 TP_STRUCT__entry(
183 __field(struct i915_address_space *, vm)
184 __field(u64, start)
185 __field(u64, end)
Michel Thierry72744cb2015-03-24 15:46:23 +0000186 ),
187
188 TP_fast_assign(
Chris Wilson596c5922016-02-26 11:03:20 +0000189 __entry->vm = vma->vm;
190 __entry->start = vma->node.start;
191 __entry->end = vma->node.start + vma->node.size - 1;
Michel Thierry72744cb2015-03-24 15:46:23 +0000192 ),
193
Chris Wilson596c5922016-02-26 11:03:20 +0000194 TP_printk("vm=%p (%c), 0x%llx-0x%llx",
195 __entry->vm, i915_is_ggtt(__entry->vm) ? 'G' : 'P', __entry->start, __entry->end)
Michel Thierry72744cb2015-03-24 15:46:23 +0000196);
197
Michel Thierry4c06ec82015-07-29 17:23:49 +0100198DECLARE_EVENT_CLASS(i915_px_entry,
199 TP_PROTO(struct i915_address_space *vm, u32 px, u64 start, u64 px_shift),
200 TP_ARGS(vm, px, start, px_shift),
Michel Thierry72744cb2015-03-24 15:46:23 +0000201
202 TP_STRUCT__entry(
203 __field(struct i915_address_space *, vm)
Michel Thierry4c06ec82015-07-29 17:23:49 +0100204 __field(u32, px)
Michel Thierry72744cb2015-03-24 15:46:23 +0000205 __field(u64, start)
206 __field(u64, end)
207 ),
208
209 TP_fast_assign(
210 __entry->vm = vm;
Michel Thierry4c06ec82015-07-29 17:23:49 +0100211 __entry->px = px;
Michel Thierry72744cb2015-03-24 15:46:23 +0000212 __entry->start = start;
Michel Thierry4c06ec82015-07-29 17:23:49 +0100213 __entry->end = ((start + (1ULL << px_shift)) & ~((1ULL << px_shift)-1)) - 1;
Michel Thierry72744cb2015-03-24 15:46:23 +0000214 ),
215
216 TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)",
Michel Thierry4c06ec82015-07-29 17:23:49 +0100217 __entry->vm, __entry->px, __entry->start, __entry->end)
Michel Thierry72744cb2015-03-24 15:46:23 +0000218);
219
Michel Thierry4c06ec82015-07-29 17:23:49 +0100220DEFINE_EVENT(i915_px_entry, i915_page_table_entry_alloc,
Michel Thierry72744cb2015-03-24 15:46:23 +0000221 TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift),
222 TP_ARGS(vm, pde, start, pde_shift)
223);
224
Michel Thierry4c06ec82015-07-29 17:23:49 +0100225DEFINE_EVENT_PRINT(i915_px_entry, i915_page_directory_entry_alloc,
226 TP_PROTO(struct i915_address_space *vm, u32 pdpe, u64 start, u64 pdpe_shift),
227 TP_ARGS(vm, pdpe, start, pdpe_shift),
228
229 TP_printk("vm=%p, pdpe=%d (0x%llx-0x%llx)",
230 __entry->vm, __entry->px, __entry->start, __entry->end)
231);
232
Michel Thierry762d9932015-07-30 11:05:29 +0100233DEFINE_EVENT_PRINT(i915_px_entry, i915_page_directory_pointer_entry_alloc,
234 TP_PROTO(struct i915_address_space *vm, u32 pml4e, u64 start, u64 pml4e_shift),
235 TP_ARGS(vm, pml4e, start, pml4e_shift),
236
237 TP_printk("vm=%p, pml4e=%d (0x%llx-0x%llx)",
238 __entry->vm, __entry->px, __entry->start, __entry->end)
239);
240
Michel Thierry72744cb2015-03-24 15:46:23 +0000241/* Avoid extra math because we only support two sizes. The format is defined by
242 * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */
243#define TRACE_PT_SIZE(bits) \
244 ((((bits) == 1024) ? 288 : 144) + 1)
245
246DECLARE_EVENT_CLASS(i915_page_table_entry_update,
247 TP_PROTO(struct i915_address_space *vm, u32 pde,
Michel Thierryec565b32015-04-08 12:13:23 +0100248 struct i915_page_table *pt, u32 first, u32 count, u32 bits),
Michel Thierry72744cb2015-03-24 15:46:23 +0000249 TP_ARGS(vm, pde, pt, first, count, bits),
250
251 TP_STRUCT__entry(
252 __field(struct i915_address_space *, vm)
253 __field(u32, pde)
254 __field(u32, first)
255 __field(u32, last)
256 __dynamic_array(char, cur_ptes, TRACE_PT_SIZE(bits))
257 ),
258
259 TP_fast_assign(
260 __entry->vm = vm;
261 __entry->pde = pde;
262 __entry->first = first;
263 __entry->last = first + count - 1;
264 scnprintf(__get_str(cur_ptes),
265 TRACE_PT_SIZE(bits),
266 "%*pb",
267 bits,
268 pt->used_ptes);
269 ),
270
271 TP_printk("vm=%p, pde=%d, updating %u:%u\t%s",
272 __entry->vm, __entry->pde, __entry->last, __entry->first,
273 __get_str(cur_ptes))
274);
275
276DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_map,
277 TP_PROTO(struct i915_address_space *vm, u32 pde,
Michel Thierryec565b32015-04-08 12:13:23 +0100278 struct i915_page_table *pt, u32 first, u32 count, u32 bits),
Michel Thierry72744cb2015-03-24 15:46:23 +0000279 TP_ARGS(vm, pde, pt, first, count, bits)
280);
281
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100282TRACE_EVENT(i915_gem_object_change_domain,
Chris Wilsondb53a302011-02-03 11:57:46 +0000283 TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
284 TP_ARGS(obj, old_read, old_write),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100285
286 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000287 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100288 __field(u32, read_domains)
289 __field(u32, write_domain)
290 ),
291
292 TP_fast_assign(
293 __entry->obj = obj;
Chris Wilsondb53a302011-02-03 11:57:46 +0000294 __entry->read_domains = obj->base.read_domains | (old_read << 16);
295 __entry->write_domain = obj->base.write_domain | (old_write << 16);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100296 ),
297
Chris Wilsondb53a302011-02-03 11:57:46 +0000298 TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100299 __entry->obj,
Chris Wilsondb53a302011-02-03 11:57:46 +0000300 __entry->read_domains >> 16,
301 __entry->read_domains & 0xffff,
302 __entry->write_domain >> 16,
303 __entry->write_domain & 0xffff)
304);
305
306TRACE_EVENT(i915_gem_object_pwrite,
307 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
308 TP_ARGS(obj, offset, len),
309
310 TP_STRUCT__entry(
311 __field(struct drm_i915_gem_object *, obj)
312 __field(u32, offset)
313 __field(u32, len)
314 ),
315
316 TP_fast_assign(
317 __entry->obj = obj;
318 __entry->offset = offset;
319 __entry->len = len;
320 ),
321
322 TP_printk("obj=%p, offset=%u, len=%u",
323 __entry->obj, __entry->offset, __entry->len)
324);
325
326TRACE_EVENT(i915_gem_object_pread,
327 TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
328 TP_ARGS(obj, offset, len),
329
330 TP_STRUCT__entry(
331 __field(struct drm_i915_gem_object *, obj)
332 __field(u32, offset)
333 __field(u32, len)
334 ),
335
336 TP_fast_assign(
337 __entry->obj = obj;
338 __entry->offset = offset;
339 __entry->len = len;
340 ),
341
342 TP_printk("obj=%p, offset=%u, len=%u",
343 __entry->obj, __entry->offset, __entry->len)
344);
345
346TRACE_EVENT(i915_gem_object_fault,
347 TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
348 TP_ARGS(obj, index, gtt, write),
349
350 TP_STRUCT__entry(
351 __field(struct drm_i915_gem_object *, obj)
352 __field(u32, index)
353 __field(bool, gtt)
354 __field(bool, write)
355 ),
356
357 TP_fast_assign(
358 __entry->obj = obj;
359 __entry->index = index;
360 __entry->gtt = gtt;
361 __entry->write = write;
362 ),
363
364 TP_printk("obj=%p, %s index=%u %s",
365 __entry->obj,
366 __entry->gtt ? "GTT" : "CPU",
367 __entry->index,
368 __entry->write ? ", writable" : "")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100369);
370
Li Zefan903cf202010-03-11 16:41:45 +0800371DECLARE_EVENT_CLASS(i915_gem_object,
Chris Wilson05394f32010-11-08 19:18:58 +0000372 TP_PROTO(struct drm_i915_gem_object *obj),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100373 TP_ARGS(obj),
374
375 TP_STRUCT__entry(
Chris Wilson05394f32010-11-08 19:18:58 +0000376 __field(struct drm_i915_gem_object *, obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100377 ),
378
379 TP_fast_assign(
380 __entry->obj = obj;
381 ),
382
383 TP_printk("obj=%p", __entry->obj)
384);
385
Li Zefanf41275e2010-05-24 16:25:44 +0800386DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
Chris Wilsondb53a302011-02-03 11:57:46 +0000387 TP_PROTO(struct drm_i915_gem_object *obj),
388 TP_ARGS(obj)
Li Zefan903cf202010-03-11 16:41:45 +0800389);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100390
Li Zefan903cf202010-03-11 16:41:45 +0800391DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
Chris Wilson05394f32010-11-08 19:18:58 +0000392 TP_PROTO(struct drm_i915_gem_object *obj),
Li Zefan903cf202010-03-11 16:41:45 +0800393 TP_ARGS(obj)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100394);
395
Chris Wilsondb53a302011-02-03 11:57:46 +0000396TRACE_EVENT(i915_gem_evict,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100397 TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
398 TP_ARGS(dev, size, align, flags),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100399
400 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100401 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000402 __field(u32, size)
403 __field(u32, align)
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100404 __field(unsigned, flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000405 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100406
407 TP_fast_assign(
Chris Wilson4f49be52009-09-24 00:23:33 +0100408 __entry->dev = dev->primary->index;
Chris Wilsondb53a302011-02-03 11:57:46 +0000409 __entry->size = size;
410 __entry->align = align;
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100411 __entry->flags = flags;
Chris Wilsondb53a302011-02-03 11:57:46 +0000412 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100413
Chris Wilsondb53a302011-02-03 11:57:46 +0000414 TP_printk("dev=%d, size=%d, align=%d %s",
415 __entry->dev, __entry->size, __entry->align,
Daniel Vetter1ec9e262014-02-14 14:01:11 +0100416 __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100417);
418
Chris Wilsondb53a302011-02-03 11:57:46 +0000419TRACE_EVENT(i915_gem_evict_everything,
Chris Wilson6c085a72012-08-20 11:40:46 +0200420 TP_PROTO(struct drm_device *dev),
421 TP_ARGS(dev),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100422
423 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100424 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000425 ),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100426
427 TP_fast_assign(
Chris Wilson4f49be52009-09-24 00:23:33 +0100428 __entry->dev = dev->primary->index;
Chris Wilsondb53a302011-02-03 11:57:46 +0000429 ),
430
Chris Wilson6c085a72012-08-20 11:40:46 +0200431 TP_printk("dev=%d", __entry->dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000432);
433
Ben Widawskybcccff82013-09-24 09:57:56 -0700434TRACE_EVENT(i915_gem_evict_vm,
435 TP_PROTO(struct i915_address_space *vm),
436 TP_ARGS(vm),
437
438 TP_STRUCT__entry(
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400439 __field(u32, dev)
Ben Widawskybcccff82013-09-24 09:57:56 -0700440 __field(struct i915_address_space *, vm)
441 ),
442
443 TP_fast_assign(
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400444 __entry->dev = vm->dev->primary->index;
Ben Widawskybcccff82013-09-24 09:57:56 -0700445 __entry->vm = vm;
446 ),
447
Steven Rostedt9297ebf2014-03-18 11:27:37 -0400448 TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
Ben Widawskybcccff82013-09-24 09:57:56 -0700449);
450
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100451TRACE_EVENT(i915_gem_ring_sync_to,
John Harrison599d9242015-05-29 17:44:04 +0100452 TP_PROTO(struct drm_i915_gem_request *to_req,
453 struct intel_engine_cs *from,
John Harrison74328ee2014-11-24 18:49:38 +0000454 struct drm_i915_gem_request *req),
John Harrison599d9242015-05-29 17:44:04 +0100455 TP_ARGS(to_req, from, req),
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100456
457 TP_STRUCT__entry(
458 __field(u32, dev)
459 __field(u32, sync_from)
460 __field(u32, sync_to)
461 __field(u32, seqno)
462 ),
463
464 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100465 __entry->dev = from->i915->drm.primary->index;
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100466 __entry->sync_from = from->id;
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000467 __entry->sync_to = to_req->engine->id;
John Harrison74328ee2014-11-24 18:49:38 +0000468 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilsonb52b89d2013-09-25 11:43:28 +0100469 ),
470
471 TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
472 __entry->dev,
473 __entry->sync_from, __entry->sync_to,
474 __entry->seqno)
475);
476
Chris Wilsondb53a302011-02-03 11:57:46 +0000477TRACE_EVENT(i915_gem_ring_dispatch,
John Harrison74328ee2014-11-24 18:49:38 +0000478 TP_PROTO(struct drm_i915_gem_request *req, u32 flags),
479 TP_ARGS(req, flags),
Chris Wilsondb53a302011-02-03 11:57:46 +0000480
481 TP_STRUCT__entry(
482 __field(u32, dev)
483 __field(u32, ring)
484 __field(u32, seqno)
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100485 __field(u32, flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000486 ),
487
488 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100489 __entry->dev = req->i915->drm.primary->index;
Chris Wilsonc0336662016-05-06 15:40:21 +0100490 __entry->ring = req->engine->id;
491 __entry->seqno = req->seqno;
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100492 __entry->flags = flags;
Chris Wilsonc81d4612016-07-01 17:23:25 +0100493 intel_engine_enable_signaling(req);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100494 ),
495
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100496 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
497 __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000498);
499
500TRACE_EVENT(i915_gem_ring_flush,
John Harrisona84c3ae2015-05-29 17:43:57 +0100501 TP_PROTO(struct drm_i915_gem_request *req, u32 invalidate, u32 flush),
502 TP_ARGS(req, invalidate, flush),
Chris Wilsondb53a302011-02-03 11:57:46 +0000503
504 TP_STRUCT__entry(
505 __field(u32, dev)
506 __field(u32, ring)
507 __field(u32, invalidate)
508 __field(u32, flush)
509 ),
510
511 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100512 __entry->dev = req->i915->drm.primary->index;
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000513 __entry->ring = req->engine->id;
Chris Wilsondb53a302011-02-03 11:57:46 +0000514 __entry->invalidate = invalidate;
515 __entry->flush = flush;
516 ),
517
518 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
519 __entry->dev, __entry->ring,
520 __entry->invalidate, __entry->flush)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100521);
522
Li Zefan903cf202010-03-11 16:41:45 +0800523DECLARE_EVENT_CLASS(i915_gem_request,
John Harrison74328ee2014-11-24 18:49:38 +0000524 TP_PROTO(struct drm_i915_gem_request *req),
525 TP_ARGS(req),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100526
527 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100528 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000529 __field(u32, ring)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100530 __field(u32, seqno)
531 ),
532
533 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100534 __entry->dev = req->i915->drm.primary->index;
Chris Wilsonc0336662016-05-06 15:40:21 +0100535 __entry->ring = req->engine->id;
536 __entry->seqno = req->seqno;
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100537 ),
538
Chris Wilsond7b9ca22015-04-07 16:21:09 +0100539 TP_printk("dev=%u, ring=%u, seqno=%u",
540 __entry->dev, __entry->ring, __entry->seqno)
Chris Wilsondb53a302011-02-03 11:57:46 +0000541);
542
543DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
John Harrison74328ee2014-11-24 18:49:38 +0000544 TP_PROTO(struct drm_i915_gem_request *req),
545 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100546);
547
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000548TRACE_EVENT(i915_gem_request_notify,
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000549 TP_PROTO(struct intel_engine_cs *engine),
550 TP_ARGS(engine),
Chris Wilson814e9b52013-09-23 17:33:19 -0300551
552 TP_STRUCT__entry(
553 __field(u32, dev)
554 __field(u32, ring)
555 __field(u32, seqno)
556 ),
557
558 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100559 __entry->dev = engine->i915->drm.primary->index;
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000560 __entry->ring = engine->id;
Chris Wilson1b7744e2016-07-01 17:23:17 +0100561 __entry->seqno = intel_engine_get_seqno(engine);
Chris Wilson814e9b52013-09-23 17:33:19 -0300562 ),
563
564 TP_printk("dev=%u, ring=%u, seqno=%u",
565 __entry->dev, __entry->ring, __entry->seqno)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100566);
567
Li Zefan903cf202010-03-11 16:41:45 +0800568DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
John Harrison74328ee2014-11-24 18:49:38 +0000569 TP_PROTO(struct drm_i915_gem_request *req),
570 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100571);
572
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000573DEFINE_EVENT(i915_gem_request, i915_gem_request_complete,
574 TP_PROTO(struct drm_i915_gem_request *req),
575 TP_ARGS(req)
576);
577
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700578TRACE_EVENT(i915_gem_request_wait_begin,
John Harrison74328ee2014-11-24 18:49:38 +0000579 TP_PROTO(struct drm_i915_gem_request *req),
580 TP_ARGS(req),
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700581
582 TP_STRUCT__entry(
583 __field(u32, dev)
584 __field(u32, ring)
585 __field(u32, seqno)
586 __field(bool, blocking)
587 ),
588
589 /* NB: the blocking information is racy since mutex_is_locked
590 * doesn't check that the current thread holds the lock. The only
591 * other option would be to pass the boolean information of whether
592 * or not the class was blocking down through the stack which is
593 * less desirable.
594 */
595 TP_fast_assign(
Chris Wilson91c8a322016-07-05 10:40:23 +0100596 __entry->dev = req->i915->drm.primary->index;
Chris Wilsonc0336662016-05-06 15:40:21 +0100597 __entry->ring = req->engine->id;
598 __entry->seqno = req->seqno;
John Harrison74328ee2014-11-24 18:49:38 +0000599 __entry->blocking =
Chris Wilson91c8a322016-07-05 10:40:23 +0100600 mutex_is_locked(&req->i915->drm.struct_mutex);
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700601 ),
602
Chris Wilsond7b9ca22015-04-07 16:21:09 +0100603 TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
604 __entry->dev, __entry->ring,
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000605 __entry->seqno, __entry->blocking ? "yes (NB)" : "no")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100606);
607
Li Zefan903cf202010-03-11 16:41:45 +0800608DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
John Harrison74328ee2014-11-24 18:49:38 +0000609 TP_PROTO(struct drm_i915_gem_request *req),
610 TP_ARGS(req)
Li Zefan903cf202010-03-11 16:41:45 +0800611);
612
Jesse Barnese5510fa2010-07-01 16:48:37 -0700613TRACE_EVENT(i915_flip_request,
Chris Wilson05394f32010-11-08 19:18:58 +0000614 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700615
616 TP_ARGS(plane, obj),
617
618 TP_STRUCT__entry(
619 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000620 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700621 ),
622
623 TP_fast_assign(
624 __entry->plane = plane;
625 __entry->obj = obj;
626 ),
627
628 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
629);
630
631TRACE_EVENT(i915_flip_complete,
Chris Wilson05394f32010-11-08 19:18:58 +0000632 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700633
634 TP_ARGS(plane, obj),
635
636 TP_STRUCT__entry(
637 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000638 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700639 ),
640
641 TP_fast_assign(
642 __entry->plane = plane;
643 __entry->obj = obj;
644 ),
645
646 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
647);
648
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100649TRACE_EVENT_CONDITION(i915_reg_rw,
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200650 TP_PROTO(bool write, i915_reg_t reg, u64 val, int len, bool trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800651
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100652 TP_ARGS(write, reg, val, len, trace),
653
654 TP_CONDITION(trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800655
Akshay Joshi0206e352011-08-16 15:34:10 -0400656 TP_STRUCT__entry(
657 __field(u64, val)
658 __field(u32, reg)
659 __field(u16, write)
660 __field(u16, len)
661 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800662
Akshay Joshi0206e352011-08-16 15:34:10 -0400663 TP_fast_assign(
664 __entry->val = (u64)val;
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200665 __entry->reg = i915_mmio_reg_offset(reg);
Akshay Joshi0206e352011-08-16 15:34:10 -0400666 __entry->write = write;
667 __entry->len = len;
668 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800669
Akshay Joshi0206e352011-08-16 15:34:10 -0400670 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
671 __entry->write ? "write" : "read",
672 __entry->reg, __entry->len,
673 (u32)(__entry->val & 0xffffffff),
674 (u32)(__entry->val >> 32))
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800675);
676
Daniel Vetterbe2cde92012-08-30 13:26:48 +0200677TRACE_EVENT(intel_gpu_freq_change,
678 TP_PROTO(u32 freq),
679 TP_ARGS(freq),
680
681 TP_STRUCT__entry(
682 __field(u32, freq)
683 ),
684
685 TP_fast_assign(
686 __entry->freq = freq;
687 ),
688
689 TP_printk("new_freq=%u", __entry->freq)
690);
691
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000692/**
693 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
694 *
695 * With full ppgtt enabled each process using drm will allocate at least one
696 * translation table. With these traces it is possible to keep track of the
697 * allocation and of the lifetime of the tables; this can be used during
698 * testing/debug to verify that we are not leaking ppgtts.
699 * These traces identify the ppgtt through the vm pointer, which is also printed
700 * by the i915_vma_bind and i915_vma_unbind tracepoints.
701 */
702DECLARE_EVENT_CLASS(i915_ppgtt,
703 TP_PROTO(struct i915_address_space *vm),
704 TP_ARGS(vm),
705
706 TP_STRUCT__entry(
707 __field(struct i915_address_space *, vm)
708 __field(u32, dev)
709 ),
710
711 TP_fast_assign(
712 __entry->vm = vm;
713 __entry->dev = vm->dev->primary->index;
714 ),
715
716 TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
717)
718
719DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
720 TP_PROTO(struct i915_address_space *vm),
721 TP_ARGS(vm)
722);
723
724DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
725 TP_PROTO(struct i915_address_space *vm),
726 TP_ARGS(vm)
727);
728
729/**
730 * DOC: i915_context_create and i915_context_free tracepoints
731 *
732 * These tracepoints are used to track creation and deletion of contexts.
733 * If full ppgtt is enabled, they also print the address of the vm assigned to
734 * the context.
735 */
736DECLARE_EVENT_CLASS(i915_context,
Chris Wilsone2efd132016-05-24 14:53:34 +0100737 TP_PROTO(struct i915_gem_context *ctx),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000738 TP_ARGS(ctx),
739
740 TP_STRUCT__entry(
741 __field(u32, dev)
Chris Wilsone2efd132016-05-24 14:53:34 +0100742 __field(struct i915_gem_context *, ctx)
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000743 __field(struct i915_address_space *, vm)
744 ),
745
746 TP_fast_assign(
747 __entry->ctx = ctx;
748 __entry->vm = ctx->ppgtt ? &ctx->ppgtt->base : NULL;
Chris Wilson91c8a322016-07-05 10:40:23 +0100749 __entry->dev = ctx->i915->drm.primary->index;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000750 ),
751
752 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
753 __entry->dev, __entry->ctx, __entry->vm)
754)
755
756DEFINE_EVENT(i915_context, i915_context_create,
Chris Wilsone2efd132016-05-24 14:53:34 +0100757 TP_PROTO(struct i915_gem_context *ctx),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000758 TP_ARGS(ctx)
759);
760
761DEFINE_EVENT(i915_context, i915_context_free,
Chris Wilsone2efd132016-05-24 14:53:34 +0100762 TP_PROTO(struct i915_gem_context *ctx),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000763 TP_ARGS(ctx)
764);
765
766/**
767 * DOC: switch_mm tracepoint
768 *
769 * This tracepoint allows tracking of the mm switch, which is an important point
770 * in the lifetime of the vm in the legacy submission path. This tracepoint is
771 * called only if full ppgtt is enabled.
772 */
773TRACE_EVENT(switch_mm,
Chris Wilsone2efd132016-05-24 14:53:34 +0100774 TP_PROTO(struct intel_engine_cs *engine, struct i915_gem_context *to),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000775
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000776 TP_ARGS(engine, to),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000777
778 TP_STRUCT__entry(
779 __field(u32, ring)
Chris Wilsone2efd132016-05-24 14:53:34 +0100780 __field(struct i915_gem_context *, to)
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000781 __field(struct i915_address_space *, vm)
782 __field(u32, dev)
783 ),
784
785 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000786 __entry->ring = engine->id;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000787 __entry->to = to;
788 __entry->vm = to->ppgtt? &to->ppgtt->base : NULL;
Chris Wilson91c8a322016-07-05 10:40:23 +0100789 __entry->dev = engine->i915->drm.primary->index;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000790 ),
791
792 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
793 __entry->dev, __entry->ring, __entry->to, __entry->vm)
794);
795
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100796#endif /* _I915_TRACE_H_ */
797
798/* This part must be outside protection */
799#undef TRACE_INCLUDE_PATH
Peter Cliftona7c54272010-05-03 13:24:41 +0100800#define TRACE_INCLUDE_PATH .
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100801#include <trace/define_trace.h>