blob: 923cf6e4d8b6202a3732e8fcda54ec78ac6e96da [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(
121 __entry->dev = i915->dev->primary->index;
122 __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(
465 __entry->dev = from->dev->primary->index;
466 __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(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000489 struct intel_engine_cs *engine =
John Harrison74328ee2014-11-24 18:49:38 +0000490 i915_gem_request_get_ring(req);
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000491 __entry->dev = engine->dev->primary->index;
492 __entry->ring = engine->id;
John Harrison74328ee2014-11-24 18:49:38 +0000493 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100494 __entry->flags = flags;
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000495 i915_trace_irq_get(engine, req);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100496 ),
497
Chris Wilsond7d4eed2012-10-17 12:09:54 +0100498 TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
499 __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
Chris Wilsondb53a302011-02-03 11:57:46 +0000500);
501
502TRACE_EVENT(i915_gem_ring_flush,
John Harrisona84c3ae2015-05-29 17:43:57 +0100503 TP_PROTO(struct drm_i915_gem_request *req, u32 invalidate, u32 flush),
504 TP_ARGS(req, invalidate, flush),
Chris Wilsondb53a302011-02-03 11:57:46 +0000505
506 TP_STRUCT__entry(
507 __field(u32, dev)
508 __field(u32, ring)
509 __field(u32, invalidate)
510 __field(u32, flush)
511 ),
512
513 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000514 __entry->dev = req->engine->dev->primary->index;
515 __entry->ring = req->engine->id;
Chris Wilsondb53a302011-02-03 11:57:46 +0000516 __entry->invalidate = invalidate;
517 __entry->flush = flush;
518 ),
519
520 TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
521 __entry->dev, __entry->ring,
522 __entry->invalidate, __entry->flush)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100523);
524
Li Zefan903cf202010-03-11 16:41:45 +0800525DECLARE_EVENT_CLASS(i915_gem_request,
John Harrison74328ee2014-11-24 18:49:38 +0000526 TP_PROTO(struct drm_i915_gem_request *req),
527 TP_ARGS(req),
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100528
529 TP_STRUCT__entry(
Chris Wilson4f49be52009-09-24 00:23:33 +0100530 __field(u32, dev)
Chris Wilsondb53a302011-02-03 11:57:46 +0000531 __field(u32, ring)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100532 __field(u32, seqno)
533 ),
534
535 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000536 struct intel_engine_cs *engine =
John Harrison74328ee2014-11-24 18:49:38 +0000537 i915_gem_request_get_ring(req);
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000538 __entry->dev = engine->dev->primary->index;
539 __entry->ring = engine->id;
John Harrison74328ee2014-11-24 18:49:38 +0000540 __entry->seqno = i915_gem_request_get_seqno(req);
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100541 ),
542
Chris Wilsond7b9ca22015-04-07 16:21:09 +0100543 TP_printk("dev=%u, ring=%u, seqno=%u",
544 __entry->dev, __entry->ring, __entry->seqno)
Chris Wilsondb53a302011-02-03 11:57:46 +0000545);
546
547DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
John Harrison74328ee2014-11-24 18:49:38 +0000548 TP_PROTO(struct drm_i915_gem_request *req),
549 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100550);
551
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000552TRACE_EVENT(i915_gem_request_notify,
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000553 TP_PROTO(struct intel_engine_cs *engine),
554 TP_ARGS(engine),
Chris Wilson814e9b52013-09-23 17:33:19 -0300555
556 TP_STRUCT__entry(
557 __field(u32, dev)
558 __field(u32, ring)
559 __field(u32, seqno)
560 ),
561
562 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000563 __entry->dev = engine->dev->primary->index;
564 __entry->ring = engine->id;
565 __entry->seqno = engine->get_seqno(engine, false);
Chris Wilson814e9b52013-09-23 17:33:19 -0300566 ),
567
568 TP_printk("dev=%u, ring=%u, seqno=%u",
569 __entry->dev, __entry->ring, __entry->seqno)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100570);
571
Li Zefan903cf202010-03-11 16:41:45 +0800572DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
John Harrison74328ee2014-11-24 18:49:38 +0000573 TP_PROTO(struct drm_i915_gem_request *req),
574 TP_ARGS(req)
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100575);
576
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000577DEFINE_EVENT(i915_gem_request, i915_gem_request_complete,
578 TP_PROTO(struct drm_i915_gem_request *req),
579 TP_ARGS(req)
580);
581
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700582TRACE_EVENT(i915_gem_request_wait_begin,
John Harrison74328ee2014-11-24 18:49:38 +0000583 TP_PROTO(struct drm_i915_gem_request *req),
584 TP_ARGS(req),
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700585
586 TP_STRUCT__entry(
587 __field(u32, dev)
588 __field(u32, ring)
589 __field(u32, seqno)
590 __field(bool, blocking)
591 ),
592
593 /* NB: the blocking information is racy since mutex_is_locked
594 * doesn't check that the current thread holds the lock. The only
595 * other option would be to pass the boolean information of whether
596 * or not the class was blocking down through the stack which is
597 * less desirable.
598 */
599 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000600 struct intel_engine_cs *engine =
John Harrison74328ee2014-11-24 18:49:38 +0000601 i915_gem_request_get_ring(req);
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000602 __entry->dev = engine->dev->primary->index;
603 __entry->ring = engine->id;
John Harrison74328ee2014-11-24 18:49:38 +0000604 __entry->seqno = i915_gem_request_get_seqno(req);
605 __entry->blocking =
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000606 mutex_is_locked(&engine->dev->struct_mutex);
Ben Widawskyf3fd3762012-05-24 15:03:09 -0700607 ),
608
Chris Wilsond7b9ca22015-04-07 16:21:09 +0100609 TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
610 __entry->dev, __entry->ring,
John Harrisonbcfcc8b2014-12-05 13:49:36 +0000611 __entry->seqno, __entry->blocking ? "yes (NB)" : "no")
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100612);
613
Li Zefan903cf202010-03-11 16:41:45 +0800614DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
John Harrison74328ee2014-11-24 18:49:38 +0000615 TP_PROTO(struct drm_i915_gem_request *req),
616 TP_ARGS(req)
Li Zefan903cf202010-03-11 16:41:45 +0800617);
618
Jesse Barnese5510fa2010-07-01 16:48:37 -0700619TRACE_EVENT(i915_flip_request,
Chris Wilson05394f32010-11-08 19:18:58 +0000620 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700621
622 TP_ARGS(plane, obj),
623
624 TP_STRUCT__entry(
625 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000626 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700627 ),
628
629 TP_fast_assign(
630 __entry->plane = plane;
631 __entry->obj = obj;
632 ),
633
634 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
635);
636
637TRACE_EVENT(i915_flip_complete,
Chris Wilson05394f32010-11-08 19:18:58 +0000638 TP_PROTO(int plane, struct drm_i915_gem_object *obj),
Jesse Barnese5510fa2010-07-01 16:48:37 -0700639
640 TP_ARGS(plane, obj),
641
642 TP_STRUCT__entry(
643 __field(int, plane)
Chris Wilson05394f32010-11-08 19:18:58 +0000644 __field(struct drm_i915_gem_object *, obj)
Jesse Barnese5510fa2010-07-01 16:48:37 -0700645 ),
646
647 TP_fast_assign(
648 __entry->plane = plane;
649 __entry->obj = obj;
650 ),
651
652 TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
653);
654
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100655TRACE_EVENT_CONDITION(i915_reg_rw,
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200656 TP_PROTO(bool write, i915_reg_t reg, u64 val, int len, bool trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800657
Chris Wilsoned71f1b2013-07-19 20:36:56 +0100658 TP_ARGS(write, reg, val, len, trace),
659
660 TP_CONDITION(trace),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800661
Akshay Joshi0206e352011-08-16 15:34:10 -0400662 TP_STRUCT__entry(
663 __field(u64, val)
664 __field(u32, reg)
665 __field(u16, write)
666 __field(u16, len)
667 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800668
Akshay Joshi0206e352011-08-16 15:34:10 -0400669 TP_fast_assign(
670 __entry->val = (u64)val;
Ville Syrjäläf0f59a02015-11-18 15:33:26 +0200671 __entry->reg = i915_mmio_reg_offset(reg);
Akshay Joshi0206e352011-08-16 15:34:10 -0400672 __entry->write = write;
673 __entry->len = len;
674 ),
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800675
Akshay Joshi0206e352011-08-16 15:34:10 -0400676 TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
677 __entry->write ? "write" : "read",
678 __entry->reg, __entry->len,
679 (u32)(__entry->val & 0xffffffff),
680 (u32)(__entry->val >> 32))
Yuanhan Liuba4f01a2010-11-08 17:09:41 +0800681);
682
Daniel Vetterbe2cde92012-08-30 13:26:48 +0200683TRACE_EVENT(intel_gpu_freq_change,
684 TP_PROTO(u32 freq),
685 TP_ARGS(freq),
686
687 TP_STRUCT__entry(
688 __field(u32, freq)
689 ),
690
691 TP_fast_assign(
692 __entry->freq = freq;
693 ),
694
695 TP_printk("new_freq=%u", __entry->freq)
696);
697
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000698/**
699 * DOC: i915_ppgtt_create and i915_ppgtt_release tracepoints
700 *
701 * With full ppgtt enabled each process using drm will allocate at least one
702 * translation table. With these traces it is possible to keep track of the
703 * allocation and of the lifetime of the tables; this can be used during
704 * testing/debug to verify that we are not leaking ppgtts.
705 * These traces identify the ppgtt through the vm pointer, which is also printed
706 * by the i915_vma_bind and i915_vma_unbind tracepoints.
707 */
708DECLARE_EVENT_CLASS(i915_ppgtt,
709 TP_PROTO(struct i915_address_space *vm),
710 TP_ARGS(vm),
711
712 TP_STRUCT__entry(
713 __field(struct i915_address_space *, vm)
714 __field(u32, dev)
715 ),
716
717 TP_fast_assign(
718 __entry->vm = vm;
719 __entry->dev = vm->dev->primary->index;
720 ),
721
722 TP_printk("dev=%u, vm=%p", __entry->dev, __entry->vm)
723)
724
725DEFINE_EVENT(i915_ppgtt, i915_ppgtt_create,
726 TP_PROTO(struct i915_address_space *vm),
727 TP_ARGS(vm)
728);
729
730DEFINE_EVENT(i915_ppgtt, i915_ppgtt_release,
731 TP_PROTO(struct i915_address_space *vm),
732 TP_ARGS(vm)
733);
734
735/**
736 * DOC: i915_context_create and i915_context_free tracepoints
737 *
738 * These tracepoints are used to track creation and deletion of contexts.
739 * If full ppgtt is enabled, they also print the address of the vm assigned to
740 * the context.
741 */
742DECLARE_EVENT_CLASS(i915_context,
743 TP_PROTO(struct intel_context *ctx),
744 TP_ARGS(ctx),
745
746 TP_STRUCT__entry(
747 __field(u32, dev)
748 __field(struct intel_context *, ctx)
749 __field(struct i915_address_space *, vm)
750 ),
751
752 TP_fast_assign(
753 __entry->ctx = ctx;
754 __entry->vm = ctx->ppgtt ? &ctx->ppgtt->base : NULL;
Chris Wilson9ea4fee2015-05-05 09:17:29 +0100755 __entry->dev = ctx->i915->dev->primary->index;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000756 ),
757
758 TP_printk("dev=%u, ctx=%p, ctx_vm=%p",
759 __entry->dev, __entry->ctx, __entry->vm)
760)
761
762DEFINE_EVENT(i915_context, i915_context_create,
763 TP_PROTO(struct intel_context *ctx),
764 TP_ARGS(ctx)
765);
766
767DEFINE_EVENT(i915_context, i915_context_free,
768 TP_PROTO(struct intel_context *ctx),
769 TP_ARGS(ctx)
770);
771
772/**
773 * DOC: switch_mm tracepoint
774 *
775 * This tracepoint allows tracking of the mm switch, which is an important point
776 * in the lifetime of the vm in the legacy submission path. This tracepoint is
777 * called only if full ppgtt is enabled.
778 */
779TRACE_EVENT(switch_mm,
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000780 TP_PROTO(struct intel_engine_cs *engine, struct intel_context *to),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000781
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000782 TP_ARGS(engine, to),
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000783
784 TP_STRUCT__entry(
785 __field(u32, ring)
786 __field(struct intel_context *, to)
787 __field(struct i915_address_space *, vm)
788 __field(u32, dev)
789 ),
790
791 TP_fast_assign(
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000792 __entry->ring = engine->id;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000793 __entry->to = to;
794 __entry->vm = to->ppgtt? &to->ppgtt->base : NULL;
Tvrtko Ursulin4a570db2016-03-16 11:00:38 +0000795 __entry->dev = engine->dev->primary->index;
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +0000796 ),
797
798 TP_printk("dev=%u, ring=%u, ctx=%p, ctx_vm=%p",
799 __entry->dev, __entry->ring, __entry->to, __entry->vm)
800);
801
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100802#endif /* _I915_TRACE_H_ */
803
804/* This part must be outside protection */
805#undef TRACE_INCLUDE_PATH
Peter Cliftona7c54272010-05-03 13:24:41 +0100806#define TRACE_INCLUDE_PATH .
Chris Wilson1c5d22f2009-08-25 11:15:50 +0100807#include <trace/define_trace.h>