diff options
author | Christian König <christian.koenig@amd.com> | 2018-07-27 10:56:34 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-07-31 17:58:17 -0400 |
commit | 8ab19ea619aeed8ca4a36c124e8edfd9b9491aba (patch) | |
tree | f501dc6ad07b6c642e883a9fbbbc639d204f32c0 /drivers/gpu | |
parent | 0cb7c1f03bfb3991120313c5927c1749041ef800 (diff) |
drm/amdgpu: add new amdgpu_vm_bo_trace_cs() function v2
This allows us to trace all VM ranges which should be valid inside a CS.
v2: dump mappings without BO as well
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-and-tested-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> (v1)
Reviewed-by: Huang Rui <ray.huang@amd.com> (v1)
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 29 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 |
4 files changed, 37 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index d41cea78e4aa..0295666968da 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -1223,6 +1223,7 @@ static void amdgpu_cs_post_dependencies(struct amdgpu_cs_parser *p) | |||
1223 | static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | 1223 | static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, |
1224 | union drm_amdgpu_cs *cs) | 1224 | union drm_amdgpu_cs *cs) |
1225 | { | 1225 | { |
1226 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; | ||
1226 | struct amdgpu_ring *ring = p->ring; | 1227 | struct amdgpu_ring *ring = p->ring; |
1227 | struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity; | 1228 | struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity; |
1228 | enum drm_sched_priority priority; | 1229 | enum drm_sched_priority priority; |
@@ -1275,6 +1276,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1275 | amdgpu_job_free_resources(job); | 1276 | amdgpu_job_free_resources(job); |
1276 | 1277 | ||
1277 | trace_amdgpu_cs_ioctl(job); | 1278 | trace_amdgpu_cs_ioctl(job); |
1279 | amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket); | ||
1278 | priority = job->base.s_priority; | 1280 | priority = job->base.s_priority; |
1279 | drm_sched_entity_push_job(&job->base, entity); | 1281 | drm_sched_entity_push_job(&job->base, entity); |
1280 | 1282 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h index 11f262f15200..7206a0025b17 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | |||
@@ -314,6 +314,11 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_mapping, | |||
314 | TP_ARGS(mapping) | 314 | TP_ARGS(mapping) |
315 | ); | 315 | ); |
316 | 316 | ||
317 | DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, | ||
318 | TP_PROTO(struct amdgpu_bo_va_mapping *mapping), | ||
319 | TP_ARGS(mapping) | ||
320 | ); | ||
321 | |||
317 | TRACE_EVENT(amdgpu_vm_set_ptes, | 322 | TRACE_EVENT(amdgpu_vm_set_ptes, |
318 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, | 323 | TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, |
319 | uint32_t incr, uint64_t flags), | 324 | uint32_t incr, uint64_t flags), |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 5d7d7900ccab..015613b4f98b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -2344,6 +2344,35 @@ struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm, | |||
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | /** | 2346 | /** |
2347 | * amdgpu_vm_bo_trace_cs - trace all reserved mappings | ||
2348 | * | ||
2349 | * @vm: the requested vm | ||
2350 | * @ticket: CS ticket | ||
2351 | * | ||
2352 | * Trace all mappings of BOs reserved during a command submission. | ||
2353 | */ | ||
2354 | void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket) | ||
2355 | { | ||
2356 | struct amdgpu_bo_va_mapping *mapping; | ||
2357 | |||
2358 | if (!trace_amdgpu_vm_bo_cs_enabled()) | ||
2359 | return; | ||
2360 | |||
2361 | for (mapping = amdgpu_vm_it_iter_first(&vm->va, 0, U64_MAX); mapping; | ||
2362 | mapping = amdgpu_vm_it_iter_next(mapping, 0, U64_MAX)) { | ||
2363 | if (mapping->bo_va && mapping->bo_va->base.bo) { | ||
2364 | struct amdgpu_bo *bo; | ||
2365 | |||
2366 | bo = mapping->bo_va->base.bo; | ||
2367 | if (READ_ONCE(bo->tbo.resv->lock.ctx) != ticket) | ||
2368 | continue; | ||
2369 | } | ||
2370 | |||
2371 | trace_amdgpu_vm_bo_cs(mapping); | ||
2372 | } | ||
2373 | } | ||
2374 | |||
2375 | /** | ||
2347 | * amdgpu_vm_bo_rmv - remove a bo to a specific vm | 2376 | * amdgpu_vm_bo_rmv - remove a bo to a specific vm |
2348 | * | 2377 | * |
2349 | * @adev: amdgpu_device pointer | 2378 | * @adev: amdgpu_device pointer |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index d416f895233d..67a15d439ac0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -318,6 +318,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, | |||
318 | uint64_t saddr, uint64_t size); | 318 | uint64_t saddr, uint64_t size); |
319 | struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm, | 319 | struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm, |
320 | uint64_t addr); | 320 | uint64_t addr); |
321 | void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket); | ||
321 | void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, | 322 | void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, |
322 | struct amdgpu_bo_va *bo_va); | 323 | struct amdgpu_bo_va *bo_va); |
323 | void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, | 324 | void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, |