amdgpu_trace.h 12.3 KB
Newer Older
A
Alex Deucher 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#if !defined(_AMDGPU_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _AMDGPU_TRACE_H_

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

#include <drm/drmP.h>

#undef TRACE_SYSTEM
#define TRACE_SYSTEM amdgpu
#define TRACE_INCLUDE_FILE amdgpu_trace

14 15 16
#define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
	 job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)

17 18 19 20 21 22 23 24 25 26 27 28 29
TRACE_EVENT(amdgpu_mm_rreg,
	    TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
	    TP_ARGS(did, reg, value),
	    TP_STRUCT__entry(
				__field(unsigned, did)
				__field(uint32_t, reg)
				__field(uint32_t, value)
			    ),
	    TP_fast_assign(
			   __entry->did = did;
			   __entry->reg = reg;
			   __entry->value = value;
			   ),
30
	    TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
		      (unsigned long)__entry->did,
		      (unsigned long)__entry->reg,
		      (unsigned long)__entry->value)
);

TRACE_EVENT(amdgpu_mm_wreg,
	    TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
	    TP_ARGS(did, reg, value),
	    TP_STRUCT__entry(
				__field(unsigned, did)
				__field(uint32_t, reg)
				__field(uint32_t, value)
			    ),
	    TP_fast_assign(
			   __entry->did = did;
			   __entry->reg = reg;
			   __entry->value = value;
			   ),
49
	    TP_printk("0x%04lx, 0x%08lx, 0x%08lx",
50 51 52 53 54
		      (unsigned long)__entry->did,
		      (unsigned long)__entry->reg,
		      (unsigned long)__entry->value)
);

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
TRACE_EVENT(amdgpu_iv,
	    TP_PROTO(struct amdgpu_iv_entry *iv),
	    TP_ARGS(iv),
	    TP_STRUCT__entry(
			     __field(unsigned, client_id)
			     __field(unsigned, src_id)
			     __field(unsigned, ring_id)
			     __field(unsigned, vm_id)
			     __field(unsigned, vm_id_src)
			     __field(uint64_t, timestamp)
			     __field(unsigned, timestamp_src)
			     __field(unsigned, pas_id)
			     __array(unsigned, src_data, 4)
			    ),
	    TP_fast_assign(
			   __entry->client_id = iv->client_id;
			   __entry->src_id = iv->src_id;
			   __entry->ring_id = iv->ring_id;
			   __entry->vm_id = iv->vm_id;
			   __entry->vm_id_src = iv->vm_id_src;
			   __entry->timestamp = iv->timestamp;
			   __entry->timestamp_src = iv->timestamp_src;
			   __entry->pas_id = iv->pas_id;
			   __entry->src_data[0] = iv->src_data[0];
			   __entry->src_data[1] = iv->src_data[1];
			   __entry->src_data[2] = iv->src_data[2];
			   __entry->src_data[3] = iv->src_data[3];
			   ),
	    TP_printk("client_id:%u src_id:%u ring:%u vm_id:%u timestamp: %llu pas_id:%u src_data: %08x %08x %08x %08x\n",
		      __entry->client_id, __entry->src_id,
		      __entry->ring_id, __entry->vm_id,
		      __entry->timestamp, __entry->pas_id,
		      __entry->src_data[0], __entry->src_data[1],
		      __entry->src_data[2], __entry->src_data[3])
);


A
Alex Deucher 已提交
92 93 94 95 96 97
TRACE_EVENT(amdgpu_bo_create,
	    TP_PROTO(struct amdgpu_bo *bo),
	    TP_ARGS(bo),
	    TP_STRUCT__entry(
			     __field(struct amdgpu_bo *, bo)
			     __field(u32, pages)
98 99 100 101
			     __field(u32, type)
			     __field(u32, prefer)
			     __field(u32, allow)
			     __field(u32, visible)
A
Alex Deucher 已提交
102 103 104 105 106
			     ),

	    TP_fast_assign(
			   __entry->bo = bo;
			   __entry->pages = bo->tbo.num_pages;
107 108 109 110
			   __entry->type = bo->tbo.mem.mem_type;
			   __entry->prefer = bo->prefered_domains;
			   __entry->allow = bo->allowed_domains;
			   __entry->visible = bo->flags;
A
Alex Deucher 已提交
111
			   ),
112

113
	    TP_printk("bo=%p, pages=%u, type=%d, prefered=%d, allowed=%d, visible=%d",
114 115
		       __entry->bo, __entry->pages, __entry->type,
		       __entry->prefer, __entry->allow, __entry->visible)
A
Alex Deucher 已提交
116 117 118 119 120 121
);

TRACE_EVENT(amdgpu_cs,
	    TP_PROTO(struct amdgpu_cs_parser *p, int i),
	    TP_ARGS(p, i),
	    TP_STRUCT__entry(
122
			     __field(struct amdgpu_bo_list *, bo_list)
A
Alex Deucher 已提交
123 124 125 126 127 128
			     __field(u32, ring)
			     __field(u32, dw)
			     __field(u32, fences)
			     ),

	    TP_fast_assign(
129
			   __entry->bo_list = p->bo_list;
130
			   __entry->ring = p->job->ring->idx;
131
			   __entry->dw = p->job->ibs[i].length_dw;
A
Alex Deucher 已提交
132
			   __entry->fences = amdgpu_fence_count_emitted(
133
				p->job->ring);
A
Alex Deucher 已提交
134
			   ),
135 136
	    TP_printk("bo_list=%p, ring=%u, dw=%u, fences=%u",
		      __entry->bo_list, __entry->ring, __entry->dw,
A
Alex Deucher 已提交
137 138 139
		      __entry->fences)
);

140 141 142 143
TRACE_EVENT(amdgpu_cs_ioctl,
	    TP_PROTO(struct amdgpu_job *job),
	    TP_ARGS(job),
	    TP_STRUCT__entry(
144
			     __field(uint64_t, sched_job_id)
145
			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
146 147
			     __field(unsigned int, context)
			     __field(unsigned int, seqno)
148
			     __field(struct dma_fence *, fence)
149 150 151 152 153
			     __field(char *, ring_name)
			     __field(u32, num_ibs)
			     ),

	    TP_fast_assign(
154
			   __entry->sched_job_id = job->base.id;
155
			   __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
156 157
			   __entry->context = job->base.s_fence->finished.context;
			   __entry->seqno = job->base.s_fence->finished.seqno;
158
			   __entry->ring_name = job->ring->name;
159 160
			   __entry->num_ibs = job->num_ibs;
			   ),
161 162 163
	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
		      __entry->sched_job_id, __get_str(timeline), __entry->context,
		      __entry->seqno, __entry->ring_name, __entry->num_ibs)
164 165 166 167 168 169
);

TRACE_EVENT(amdgpu_sched_run_job,
	    TP_PROTO(struct amdgpu_job *job),
	    TP_ARGS(job),
	    TP_STRUCT__entry(
170
			     __field(uint64_t, sched_job_id)
171
			     __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
172 173
			     __field(unsigned int, context)
			     __field(unsigned int, seqno)
174 175 176 177 178
			     __field(char *, ring_name)
			     __field(u32, num_ibs)
			     ),

	    TP_fast_assign(
179
			   __entry->sched_job_id = job->base.id;
180
			   __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))
181 182
			   __entry->context = job->base.s_fence->finished.context;
			   __entry->seqno = job->base.s_fence->finished.seqno;
183
			   __entry->ring_name = job->ring->name;
184 185
			   __entry->num_ibs = job->num_ibs;
			   ),
186 187 188
	    TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",
		      __entry->sched_job_id, __get_str(timeline), __entry->context,
		      __entry->seqno, __entry->ring_name, __entry->num_ibs)
189 190 191
);


A
Alex Deucher 已提交
192
TRACE_EVENT(amdgpu_vm_grab_id,
193 194
	    TP_PROTO(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
		     struct amdgpu_job *job),
195
	    TP_ARGS(vm, ring, job),
A
Alex Deucher 已提交
196
	    TP_STRUCT__entry(
197
			     __field(struct amdgpu_vm *, vm)
A
Alex Deucher 已提交
198
			     __field(u32, ring)
199 200
			     __field(u32, vm_id)
			     __field(u32, vm_hub)
201
			     __field(u64, pd_addr)
202
			     __field(u32, needs_flush)
A
Alex Deucher 已提交
203 204 205
			     ),

	    TP_fast_assign(
206
			   __entry->vm = vm;
207 208 209
			   __entry->ring = ring->idx;
			   __entry->vm_id = job->vm_id;
			   __entry->vm_hub = ring->funcs->vmhub,
210 211
			   __entry->pd_addr = job->vm_pd_addr;
			   __entry->needs_flush = job->vm_needs_flush;
A
Alex Deucher 已提交
212
			   ),
213 214 215
	    TP_printk("vm=%p, ring=%u, id=%u, hub=%u, pd_addr=%010Lx needs_flush=%u",
		      __entry->vm, __entry->ring, __entry->vm_id,
		      __entry->vm_hub, __entry->pd_addr, __entry->needs_flush)
A
Alex Deucher 已提交
216 217
);

218 219 220 221 222 223 224 225 226
TRACE_EVENT(amdgpu_vm_bo_map,
	    TP_PROTO(struct amdgpu_bo_va *bo_va,
		     struct amdgpu_bo_va_mapping *mapping),
	    TP_ARGS(bo_va, mapping),
	    TP_STRUCT__entry(
			     __field(struct amdgpu_bo *, bo)
			     __field(long, start)
			     __field(long, last)
			     __field(u64, offset)
227
			     __field(u64, flags)
228 229 230
			     ),

	    TP_fast_assign(
231
			   __entry->bo = bo_va ? bo_va->bo : NULL;
232 233
			   __entry->start = mapping->start;
			   __entry->last = mapping->last;
234 235 236
			   __entry->offset = mapping->offset;
			   __entry->flags = mapping->flags;
			   ),
237
	    TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
238 239 240 241 242 243 244 245 246 247 248 249 250
		      __entry->bo, __entry->start, __entry->last,
		      __entry->offset, __entry->flags)
);

TRACE_EVENT(amdgpu_vm_bo_unmap,
	    TP_PROTO(struct amdgpu_bo_va *bo_va,
		     struct amdgpu_bo_va_mapping *mapping),
	    TP_ARGS(bo_va, mapping),
	    TP_STRUCT__entry(
			     __field(struct amdgpu_bo *, bo)
			     __field(long, start)
			     __field(long, last)
			     __field(u64, offset)
251
			     __field(u64, flags)
252 253 254 255
			     ),

	    TP_fast_assign(
			   __entry->bo = bo_va->bo;
256 257
			   __entry->start = mapping->start;
			   __entry->last = mapping->last;
258 259 260
			   __entry->offset = mapping->offset;
			   __entry->flags = mapping->flags;
			   ),
261
	    TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, flags=%llx",
262 263 264 265
		      __entry->bo, __entry->start, __entry->last,
		      __entry->offset, __entry->flags)
);

266
DECLARE_EVENT_CLASS(amdgpu_vm_mapping,
A
Alex Deucher 已提交
267 268 269 270 271
	    TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
	    TP_ARGS(mapping),
	    TP_STRUCT__entry(
			     __field(u64, soffset)
			     __field(u64, eoffset)
272
			     __field(u64, flags)
A
Alex Deucher 已提交
273 274 275
			     ),

	    TP_fast_assign(
276 277
			   __entry->soffset = mapping->start;
			   __entry->eoffset = mapping->last + 1;
A
Alex Deucher 已提交
278 279
			   __entry->flags = mapping->flags;
			   ),
280
	    TP_printk("soffs=%010llx, eoffs=%010llx, flags=%llx",
A
Alex Deucher 已提交
281 282 283
		      __entry->soffset, __entry->eoffset, __entry->flags)
);

284 285 286 287 288 289 290 291 292 293
DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_update,
	    TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
	    TP_ARGS(mapping)
);

DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_mapping,
	    TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
	    TP_ARGS(mapping)
);

294
TRACE_EVENT(amdgpu_vm_set_ptes,
A
Alex Deucher 已提交
295
	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
296
		     uint32_t incr, uint64_t flags),
A
Alex Deucher 已提交
297 298 299 300 301 302
	    TP_ARGS(pe, addr, count, incr, flags),
	    TP_STRUCT__entry(
			     __field(u64, pe)
			     __field(u64, addr)
			     __field(u32, count)
			     __field(u32, incr)
303
			     __field(u64, flags)
A
Alex Deucher 已提交
304 305 306 307 308 309 310 311 312
			     ),

	    TP_fast_assign(
			   __entry->pe = pe;
			   __entry->addr = addr;
			   __entry->count = count;
			   __entry->incr = incr;
			   __entry->flags = flags;
			   ),
313
	    TP_printk("pe=%010Lx, addr=%010Lx, incr=%u, flags=%llx, count=%u",
A
Alex Deucher 已提交
314 315 316 317
		      __entry->pe, __entry->addr, __entry->incr,
		      __entry->flags, __entry->count)
);

318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
TRACE_EVENT(amdgpu_vm_copy_ptes,
	    TP_PROTO(uint64_t pe, uint64_t src, unsigned count),
	    TP_ARGS(pe, src, count),
	    TP_STRUCT__entry(
			     __field(u64, pe)
			     __field(u64, src)
			     __field(u32, count)
			     ),

	    TP_fast_assign(
			   __entry->pe = pe;
			   __entry->src = src;
			   __entry->count = count;
			   ),
	    TP_printk("pe=%010Lx, src=%010Lx, count=%u",
		      __entry->pe, __entry->src, __entry->count)
);

A
Alex Deucher 已提交
336
TRACE_EVENT(amdgpu_vm_flush,
337 338 339
	    TP_PROTO(struct amdgpu_ring *ring, unsigned vm_id,
		     uint64_t pd_addr),
	    TP_ARGS(ring, vm_id, pd_addr),
A
Alex Deucher 已提交
340 341
	    TP_STRUCT__entry(
			     __field(u32, ring)
342 343 344
			     __field(u32, vm_id)
			     __field(u32, vm_hub)
			     __field(u64, pd_addr)
A
Alex Deucher 已提交
345 346 347
			     ),

	    TP_fast_assign(
348 349 350
			   __entry->ring = ring->idx;
			   __entry->vm_id = vm_id;
			   __entry->vm_hub = ring->funcs->vmhub;
A
Alex Deucher 已提交
351 352
			   __entry->pd_addr = pd_addr;
			   ),
353 354 355
	    TP_printk("ring=%u, id=%u, hub=%u, pd_addr=%010Lx",
		      __entry->ring, __entry->vm_id,
		      __entry->vm_hub,__entry->pd_addr)
A
Alex Deucher 已提交
356 357
);

358 359 360 361 362 363
TRACE_EVENT(amdgpu_bo_list_set,
	    TP_PROTO(struct amdgpu_bo_list *list, struct amdgpu_bo *bo),
	    TP_ARGS(list, bo),
	    TP_STRUCT__entry(
			     __field(struct amdgpu_bo_list *, list)
			     __field(struct amdgpu_bo *, bo)
364
			     __field(u64, bo_size)
365 366 367 368 369
			     ),

	    TP_fast_assign(
			   __entry->list = list;
			   __entry->bo = bo;
370
			   __entry->bo_size = amdgpu_bo_size(bo);
371
			   ),
372
	    TP_printk("list=%p, bo=%p, bo_size=%Ld",
373 374 375
		      __entry->list,
		      __entry->bo,
		      __entry->bo_size)
376 377
);

378 379 380 381 382 383 384 385 386 387 388 389
TRACE_EVENT(amdgpu_cs_bo_status,
	    TP_PROTO(uint64_t total_bo, uint64_t total_size),
	    TP_ARGS(total_bo, total_size),
	    TP_STRUCT__entry(
			__field(u64, total_bo)
			__field(u64, total_size)
			),

	    TP_fast_assign(
			__entry->total_bo = total_bo;
			__entry->total_size = total_size;
			),
390
	    TP_printk("total_bo_size=%Ld, total_bo_count=%Ld",
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
			__entry->total_bo, __entry->total_size)
);

TRACE_EVENT(amdgpu_ttm_bo_move,
	    TP_PROTO(struct amdgpu_bo* bo, uint32_t new_placement, uint32_t old_placement),
	    TP_ARGS(bo, new_placement, old_placement),
	    TP_STRUCT__entry(
			__field(struct amdgpu_bo *, bo)
			__field(u64, bo_size)
			__field(u32, new_placement)
			__field(u32, old_placement)
			),

	    TP_fast_assign(
			__entry->bo      = bo;
			__entry->bo_size = amdgpu_bo_size(bo);
			__entry->new_placement = new_placement;
			__entry->old_placement = old_placement;
			),
410
	    TP_printk("bo=%p, from=%d, to=%d, size=%Ld",
411 412 413 414
			__entry->bo, __entry->old_placement,
			__entry->new_placement, __entry->bo_size)
);

415
#undef AMDGPU_JOB_GET_TIMELINE_NAME
A
Alex Deucher 已提交
416 417 418 419 420 421
#endif

/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#include <trace/define_trace.h>