[PATCH] drm/amdgpu: add new amdgpu_vm_bo_trace_cs() function
Andrey Grodzovsky
Andrey.Grodzovsky at amd.com
Fri Jul 27 18:35:33 UTC 2018
Reviewed-and-tested-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
Andrey
On 07/27/2018 10:57 AM, Christian König wrote:
> This allows us to trace all VM ranges which should be valid inside a CS.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 5 +++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 30 ++++++++++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 +
> 4 files changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 8a49c3b97bd4..871401cd9997 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -1220,6 +1220,7 @@ static void amdgpu_cs_post_dependencies(struct amdgpu_cs_parser *p)
> static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
> union drm_amdgpu_cs *cs)
> {
> + struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
> struct amdgpu_ring *ring = p->ring;
> struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity;
> enum drm_sched_priority priority;
> @@ -1272,6 +1273,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
> amdgpu_job_free_resources(job);
>
> trace_amdgpu_cs_ioctl(job);
> + amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
> priority = job->base.s_priority;
> drm_sched_entity_push_job(&job->base, entity);
>
> 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,
> TP_ARGS(mapping)
> );
>
> +DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
> + TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
> + TP_ARGS(mapping)
> +);
> +
> TRACE_EVENT(amdgpu_vm_set_ptes,
> TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
> 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..7aedf3184e36 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2343,6 +2343,36 @@ struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
> return amdgpu_vm_it_iter_first(&vm->va, addr, addr);
> }
>
> +/**
> + * amdgpu_vm_bo_trace_cs - trace all reserved mappings
> + *
> + * @vm: the requested vm
> + * @ticket: CS ticket
> + *
> + * Trace all mappings of BOs reserved during a command submission.
> + */
> +void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket)
> +{
> + struct amdgpu_bo_va_mapping *mapping;
> +
> + if (!trace_amdgpu_vm_bo_cs_enabled())
> + return;
> +
> + for (mapping = amdgpu_vm_it_iter_first(&vm->va, 0, U64_MAX); mapping;
> + mapping = amdgpu_vm_it_iter_next(mapping, 0, U64_MAX)) {
> + struct amdgpu_bo *bo;
> +
> + if (!mapping->bo_va || !mapping->bo_va->base.bo)
> + continue;
> +
> + bo = mapping->bo_va->base.bo;
> + if (READ_ONCE(bo->tbo.resv->lock.ctx) != ticket)
> + continue;
> +
> + trace_amdgpu_vm_bo_cs(mapping);
> + }
> +}
> +
> /**
> * amdgpu_vm_bo_rmv - remove a bo to a specific vm
> *
> 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,
> uint64_t saddr, uint64_t size);
> struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
> uint64_t addr);
> +void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket);
> void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
> struct amdgpu_bo_va *bo_va);
> void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size,
More information about the amd-gfx
mailing list