i915_trace.h 12.6 KB
Newer Older
C
Chris Wilson 已提交
1 2 3 4 5 6 7 8
#if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _I915_TRACE_H_

#include <linux/stringify.h>
#include <linux/types.h>
#include <linux/tracepoint.h>

#include <drm/drmP.h>
9
#include "i915_drv.h"
C
Chris Wilson 已提交
10
#include "intel_ringbuffer.h"
C
Chris Wilson 已提交
11 12 13 14 15 16 17 18 19

#undef TRACE_SYSTEM
#define TRACE_SYSTEM i915
#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)
#define TRACE_INCLUDE_FILE i915_trace

/* object tracking */

TRACE_EVENT(i915_gem_object_create,
20
	    TP_PROTO(struct drm_i915_gem_object *obj),
C
Chris Wilson 已提交
21 22 23
	    TP_ARGS(obj),

	    TP_STRUCT__entry(
24
			     __field(struct drm_i915_gem_object *, obj)
C
Chris Wilson 已提交
25 26 27 28 29
			     __field(u32, size)
			     ),

	    TP_fast_assign(
			   __entry->obj = obj;
30
			   __entry->size = obj->base.size;
C
Chris Wilson 已提交
31 32 33 34 35
			   ),

	    TP_printk("obj=%p, size=%u", __entry->obj, __entry->size)
);

36
TRACE_EVENT(i915_vma_bind,
37 38
	    TP_PROTO(struct i915_vma *vma, unsigned flags),
	    TP_ARGS(vma, flags),
C
Chris Wilson 已提交
39 40

	    TP_STRUCT__entry(
41
			     __field(struct drm_i915_gem_object *, obj)
42
			     __field(struct i915_address_space *, vm)
C
Chris Wilson 已提交
43 44
			     __field(u32, offset)
			     __field(u32, size)
45
			     __field(unsigned, flags)
C
Chris Wilson 已提交
46 47 48
			     ),

	    TP_fast_assign(
49 50 51 52
			   __entry->obj = vma->obj;
			   __entry->vm = vma->vm;
			   __entry->offset = vma->node.start;
			   __entry->size = vma->node.size;
53
			   __entry->flags = flags;
C
Chris Wilson 已提交
54 55
			   ),

56
	    TP_printk("obj=%p, offset=%08x size=%x%s vm=%p",
C
Chris Wilson 已提交
57
		      __entry->obj, __entry->offset, __entry->size,
58
		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "",
59
		      __entry->vm)
C
Chris Wilson 已提交
60 61
);

62 63 64
TRACE_EVENT(i915_vma_unbind,
	    TP_PROTO(struct i915_vma *vma),
	    TP_ARGS(vma),
C
Chris Wilson 已提交
65 66 67

	    TP_STRUCT__entry(
			     __field(struct drm_i915_gem_object *, obj)
68
			     __field(struct i915_address_space *, vm)
C
Chris Wilson 已提交
69 70 71
			     __field(u32, offset)
			     __field(u32, size)
			     ),
C
Chris Wilson 已提交
72

C
Chris Wilson 已提交
73
	    TP_fast_assign(
74 75 76 77
			   __entry->obj = vma->obj;
			   __entry->vm = vma->vm;
			   __entry->offset = vma->node.start;
			   __entry->size = vma->node.size;
C
Chris Wilson 已提交
78
			   ),
C
Chris Wilson 已提交
79

80 81
	    TP_printk("obj=%p, offset=%08x size=%x vm=%p",
		      __entry->obj, __entry->offset, __entry->size, __entry->vm)
C
Chris Wilson 已提交
82 83 84 85 86
);

TRACE_EVENT(i915_gem_object_change_domain,
	    TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write),
	    TP_ARGS(obj, old_read, old_write),
C
Chris Wilson 已提交
87 88

	    TP_STRUCT__entry(
89
			     __field(struct drm_i915_gem_object *, obj)
C
Chris Wilson 已提交
90 91 92 93 94 95
			     __field(u32, read_domains)
			     __field(u32, write_domain)
			     ),

	    TP_fast_assign(
			   __entry->obj = obj;
C
Chris Wilson 已提交
96 97
			   __entry->read_domains = obj->base.read_domains | (old_read << 16);
			   __entry->write_domain = obj->base.write_domain | (old_write << 16);
C
Chris Wilson 已提交
98 99
			   ),

C
Chris Wilson 已提交
100
	    TP_printk("obj=%p, read=%02x=>%02x, write=%02x=>%02x",
C
Chris Wilson 已提交
101
		      __entry->obj,
C
Chris Wilson 已提交
102 103 104 105
		      __entry->read_domains >> 16,
		      __entry->read_domains & 0xffff,
		      __entry->write_domain >> 16,
		      __entry->write_domain & 0xffff)
C
Chris Wilson 已提交
106 107
);

C
Chris Wilson 已提交
108 109 110
TRACE_EVENT(i915_gem_object_pwrite,
	    TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
	    TP_ARGS(obj, offset, len),
C
Chris Wilson 已提交
111

C
Chris Wilson 已提交
112 113 114 115 116
	    TP_STRUCT__entry(
			     __field(struct drm_i915_gem_object *, obj)
			     __field(u32, offset)
			     __field(u32, len)
			     ),
C
Chris Wilson 已提交
117

C
Chris Wilson 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130
	    TP_fast_assign(
			   __entry->obj = obj;
			   __entry->offset = offset;
			   __entry->len = len;
			   ),

	    TP_printk("obj=%p, offset=%u, len=%u",
		      __entry->obj, __entry->offset, __entry->len)
);

TRACE_EVENT(i915_gem_object_pread,
	    TP_PROTO(struct drm_i915_gem_object *obj, u32 offset, u32 len),
	    TP_ARGS(obj, offset, len),
C
Chris Wilson 已提交
131 132

	    TP_STRUCT__entry(
133
			     __field(struct drm_i915_gem_object *, obj)
C
Chris Wilson 已提交
134 135
			     __field(u32, offset)
			     __field(u32, len)
C
Chris Wilson 已提交
136 137 138 139
			     ),

	    TP_fast_assign(
			   __entry->obj = obj;
C
Chris Wilson 已提交
140 141
			   __entry->offset = offset;
			   __entry->len = len;
C
Chris Wilson 已提交
142 143
			   ),

C
Chris Wilson 已提交
144 145
	    TP_printk("obj=%p, offset=%u, len=%u",
		      __entry->obj, __entry->offset, __entry->len)
C
Chris Wilson 已提交
146 147
);

C
Chris Wilson 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
TRACE_EVENT(i915_gem_object_fault,
	    TP_PROTO(struct drm_i915_gem_object *obj, u32 index, bool gtt, bool write),
	    TP_ARGS(obj, index, gtt, write),

	    TP_STRUCT__entry(
			     __field(struct drm_i915_gem_object *, obj)
			     __field(u32, index)
			     __field(bool, gtt)
			     __field(bool, write)
			     ),

	    TP_fast_assign(
			   __entry->obj = obj;
			   __entry->index = index;
			   __entry->gtt = gtt;
			   __entry->write = write;
			   ),
165

C
Chris Wilson 已提交
166 167 168 169 170 171 172 173
	    TP_printk("obj=%p, %s index=%u %s",
		      __entry->obj,
		      __entry->gtt ? "GTT" : "CPU",
		      __entry->index,
		      __entry->write ? ", writable" : "")
);

DECLARE_EVENT_CLASS(i915_gem_object,
174
	    TP_PROTO(struct drm_i915_gem_object *obj),
C
Chris Wilson 已提交
175
	    TP_ARGS(obj),
176

C
Chris Wilson 已提交
177 178 179 180 181 182 183 184 185
	    TP_STRUCT__entry(
			     __field(struct drm_i915_gem_object *, obj)
			     ),

	    TP_fast_assign(
			   __entry->obj = obj;
			   ),

	    TP_printk("obj=%p", __entry->obj)
186 187
);

C
Chris Wilson 已提交
188 189 190 191
DEFINE_EVENT(i915_gem_object, i915_gem_object_clflush,
	     TP_PROTO(struct drm_i915_gem_object *obj),
	     TP_ARGS(obj)
);
C
Chris Wilson 已提交
192

C
Chris Wilson 已提交
193
DEFINE_EVENT(i915_gem_object, i915_gem_object_destroy,
194
	    TP_PROTO(struct drm_i915_gem_object *obj),
195 196
	    TP_ARGS(obj)
);
C
Chris Wilson 已提交
197

C
Chris Wilson 已提交
198
TRACE_EVENT(i915_gem_evict,
199 200
	    TP_PROTO(struct drm_device *dev, u32 size, u32 align, unsigned flags),
	    TP_ARGS(dev, size, align, flags),
C
Chris Wilson 已提交
201

C
Chris Wilson 已提交
202 203 204 205
	    TP_STRUCT__entry(
			     __field(u32, dev)
			     __field(u32, size)
			     __field(u32, align)
206
			     __field(unsigned, flags)
C
Chris Wilson 已提交
207
			    ),
C
Chris Wilson 已提交
208

C
Chris Wilson 已提交
209 210 211 212
	    TP_fast_assign(
			   __entry->dev = dev->primary->index;
			   __entry->size = size;
			   __entry->align = align;
213
			   __entry->flags = flags;
C
Chris Wilson 已提交
214 215 216 217
			  ),

	    TP_printk("dev=%d, size=%d, align=%d %s",
		      __entry->dev, __entry->size, __entry->align,
218
		      __entry->flags & PIN_MAPPABLE ? ", mappable" : "")
C
Chris Wilson 已提交
219 220
);

C
Chris Wilson 已提交
221
TRACE_EVENT(i915_gem_evict_everything,
C
Chris Wilson 已提交
222 223
	    TP_PROTO(struct drm_device *dev),
	    TP_ARGS(dev),
C
Chris Wilson 已提交
224

C
Chris Wilson 已提交
225 226 227 228 229 230 231
	    TP_STRUCT__entry(
			     __field(u32, dev)
			    ),

	    TP_fast_assign(
			   __entry->dev = dev->primary->index;
			  ),
C
Chris Wilson 已提交
232

C
Chris Wilson 已提交
233
	    TP_printk("dev=%d", __entry->dev)
C
Chris Wilson 已提交
234
);
C
Chris Wilson 已提交
235

236 237 238 239 240
TRACE_EVENT(i915_gem_evict_vm,
	    TP_PROTO(struct i915_address_space *vm),
	    TP_ARGS(vm),

	    TP_STRUCT__entry(
241
			     __field(u32, dev)
242 243 244 245
			     __field(struct i915_address_space *, vm)
			    ),

	    TP_fast_assign(
246
			   __entry->dev = vm->dev->primary->index;
247 248 249
			   __entry->vm = vm;
			  ),

250
	    TP_printk("dev=%d, vm=%p", __entry->dev, __entry->vm)
251 252
);

253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
TRACE_EVENT(i915_gem_ring_sync_to,
	    TP_PROTO(struct intel_ring_buffer *from,
		     struct intel_ring_buffer *to,
		     u32 seqno),
	    TP_ARGS(from, to, seqno),

	    TP_STRUCT__entry(
			     __field(u32, dev)
			     __field(u32, sync_from)
			     __field(u32, sync_to)
			     __field(u32, seqno)
			     ),

	    TP_fast_assign(
			   __entry->dev = from->dev->primary->index;
			   __entry->sync_from = from->id;
			   __entry->sync_to = to->id;
			   __entry->seqno = seqno;
			   ),

	    TP_printk("dev=%u, sync-from=%u, sync-to=%u, seqno=%u",
		      __entry->dev,
		      __entry->sync_from, __entry->sync_to,
		      __entry->seqno)
);

C
Chris Wilson 已提交
279
TRACE_EVENT(i915_gem_ring_dispatch,
280 281
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno, u32 flags),
	    TP_ARGS(ring, seqno, flags),
C
Chris Wilson 已提交
282 283

	    TP_STRUCT__entry(
284
			     __field(u32, dev)
C
Chris Wilson 已提交
285
			     __field(u32, ring)
C
Chris Wilson 已提交
286
			     __field(u32, seqno)
287
			     __field(u32, flags)
C
Chris Wilson 已提交
288 289 290
			     ),

	    TP_fast_assign(
C
Chris Wilson 已提交
291 292
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
C
Chris Wilson 已提交
293
			   __entry->seqno = seqno;
294
			   __entry->flags = flags;
C
Chris Wilson 已提交
295
			   i915_trace_irq_get(ring, seqno);
C
Chris Wilson 已提交
296 297
			   ),

298 299
	    TP_printk("dev=%u, ring=%u, seqno=%u, flags=%x",
		      __entry->dev, __entry->ring, __entry->seqno, __entry->flags)
C
Chris Wilson 已提交
300 301
);

C
Chris Wilson 已提交
302 303 304
TRACE_EVENT(i915_gem_ring_flush,
	    TP_PROTO(struct intel_ring_buffer *ring, u32 invalidate, u32 flush),
	    TP_ARGS(ring, invalidate, flush),
C
Chris Wilson 已提交
305 306

	    TP_STRUCT__entry(
307
			     __field(u32, dev)
C
Chris Wilson 已提交
308 309 310
			     __field(u32, ring)
			     __field(u32, invalidate)
			     __field(u32, flush)
C
Chris Wilson 已提交
311 312 313
			     ),

	    TP_fast_assign(
C
Chris Wilson 已提交
314 315 316 317
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
			   __entry->invalidate = invalidate;
			   __entry->flush = flush;
C
Chris Wilson 已提交
318 319
			   ),

C
Chris Wilson 已提交
320 321 322
	    TP_printk("dev=%u, ring=%x, invalidate=%04x, flush=%04x",
		      __entry->dev, __entry->ring,
		      __entry->invalidate, __entry->flush)
C
Chris Wilson 已提交
323 324
);

325
DECLARE_EVENT_CLASS(i915_gem_request,
C
Chris Wilson 已提交
326 327
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
	    TP_ARGS(ring, seqno),
C
Chris Wilson 已提交
328 329

	    TP_STRUCT__entry(
330
			     __field(u32, dev)
C
Chris Wilson 已提交
331
			     __field(u32, ring)
C
Chris Wilson 已提交
332 333 334 335
			     __field(u32, seqno)
			     ),

	    TP_fast_assign(
C
Chris Wilson 已提交
336 337
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
C
Chris Wilson 已提交
338 339 340
			   __entry->seqno = seqno;
			   ),

C
Chris Wilson 已提交
341 342
	    TP_printk("dev=%u, ring=%u, seqno=%u",
		      __entry->dev, __entry->ring, __entry->seqno)
C
Chris Wilson 已提交
343 344
);

C
Chris Wilson 已提交
345 346 347 348
DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
	    TP_ARGS(ring, seqno)
);
C
Chris Wilson 已提交
349

350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
TRACE_EVENT(i915_gem_request_complete,
	    TP_PROTO(struct intel_ring_buffer *ring),
	    TP_ARGS(ring),

	    TP_STRUCT__entry(
			     __field(u32, dev)
			     __field(u32, ring)
			     __field(u32, seqno)
			     ),

	    TP_fast_assign(
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
			   __entry->seqno = ring->get_seqno(ring, false);
			   ),

	    TP_printk("dev=%u, ring=%u, seqno=%u",
		      __entry->dev, __entry->ring, __entry->seqno)
C
Chris Wilson 已提交
368 369
);

370
DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
C
Chris Wilson 已提交
371 372
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
	    TP_ARGS(ring, seqno)
C
Chris Wilson 已提交
373 374
);

375
TRACE_EVENT(i915_gem_request_wait_begin,
C
Chris Wilson 已提交
376
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
	    TP_ARGS(ring, seqno),

	    TP_STRUCT__entry(
			     __field(u32, dev)
			     __field(u32, ring)
			     __field(u32, seqno)
			     __field(bool, blocking)
			     ),

	    /* NB: the blocking information is racy since mutex_is_locked
	     * doesn't check that the current thread holds the lock. The only
	     * other option would be to pass the boolean information of whether
	     * or not the class was blocking down through the stack which is
	     * less desirable.
	     */
	    TP_fast_assign(
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
			   __entry->seqno = seqno;
			   __entry->blocking = mutex_is_locked(&ring->dev->struct_mutex);
			   ),

	    TP_printk("dev=%u, ring=%u, seqno=%u, blocking=%s",
		      __entry->dev, __entry->ring, __entry->seqno,
		      __entry->blocking ?  "yes (NB)" : "no")
402
);
C
Chris Wilson 已提交
403

404
DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
C
Chris Wilson 已提交
405 406
	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
	    TP_ARGS(ring, seqno)
C
Chris Wilson 已提交
407 408
);

409
DECLARE_EVENT_CLASS(i915_ring,
C
Chris Wilson 已提交
410 411
	    TP_PROTO(struct intel_ring_buffer *ring),
	    TP_ARGS(ring),
C
Chris Wilson 已提交
412 413

	    TP_STRUCT__entry(
414
			     __field(u32, dev)
C
Chris Wilson 已提交
415
			     __field(u32, ring)
C
Chris Wilson 已提交
416 417 418
			     ),

	    TP_fast_assign(
C
Chris Wilson 已提交
419 420
			   __entry->dev = ring->dev->primary->index;
			   __entry->ring = ring->id;
C
Chris Wilson 已提交
421 422
			   ),

C
Chris Wilson 已提交
423
	    TP_printk("dev=%u, ring=%u", __entry->dev, __entry->ring)
C
Chris Wilson 已提交
424 425
);

426
DEFINE_EVENT(i915_ring, i915_ring_wait_begin,
C
Chris Wilson 已提交
427 428
	    TP_PROTO(struct intel_ring_buffer *ring),
	    TP_ARGS(ring)
429
);
C
Chris Wilson 已提交
430

431
DEFINE_EVENT(i915_ring, i915_ring_wait_end,
C
Chris Wilson 已提交
432 433
	    TP_PROTO(struct intel_ring_buffer *ring),
	    TP_ARGS(ring)
C
Chris Wilson 已提交
434 435
);

436
TRACE_EVENT(i915_flip_request,
437
	    TP_PROTO(int plane, struct drm_i915_gem_object *obj),
438 439 440 441 442

	    TP_ARGS(plane, obj),

	    TP_STRUCT__entry(
		    __field(int, plane)
443
		    __field(struct drm_i915_gem_object *, obj)
444 445 446 447 448 449 450 451 452 453 454
		    ),

	    TP_fast_assign(
		    __entry->plane = plane;
		    __entry->obj = obj;
		    ),

	    TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
);

TRACE_EVENT(i915_flip_complete,
455
	    TP_PROTO(int plane, struct drm_i915_gem_object *obj),
456 457 458 459 460

	    TP_ARGS(plane, obj),

	    TP_STRUCT__entry(
		    __field(int, plane)
461
		    __field(struct drm_i915_gem_object *, obj)
462 463 464 465 466 467 468 469 470 471
		    ),

	    TP_fast_assign(
		    __entry->plane = plane;
		    __entry->obj = obj;
		    ),

	    TP_printk("plane=%d, obj=%p", __entry->plane, __entry->obj)
);

472 473
TRACE_EVENT_CONDITION(i915_reg_rw,
	TP_PROTO(bool write, u32 reg, u64 val, int len, bool trace),
474

475 476 477
	TP_ARGS(write, reg, val, len, trace),

	TP_CONDITION(trace),
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497

	TP_STRUCT__entry(
		__field(u64, val)
		__field(u32, reg)
		__field(u16, write)
		__field(u16, len)
		),

	TP_fast_assign(
		__entry->val = (u64)val;
		__entry->reg = reg;
		__entry->write = write;
		__entry->len = len;
		),

	TP_printk("%s reg=0x%x, len=%d, val=(0x%x, 0x%x)",
		__entry->write ? "write" : "read",
		__entry->reg, __entry->len,
		(u32)(__entry->val & 0xffffffff),
		(u32)(__entry->val >> 32))
498 499
);

500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
TRACE_EVENT(intel_gpu_freq_change,
	    TP_PROTO(u32 freq),
	    TP_ARGS(freq),

	    TP_STRUCT__entry(
			     __field(u32, freq)
			     ),

	    TP_fast_assign(
			   __entry->freq = freq;
			   ),

	    TP_printk("new_freq=%u", __entry->freq)
);

C
Chris Wilson 已提交
515 516 517 518
#endif /* _I915_TRACE_H_ */

/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
P
Peter Clifton 已提交
519
#define TRACE_INCLUDE_PATH .
C
Chris Wilson 已提交
520
#include <trace/define_trace.h>