[PATCH v2 1/2] drm/amd/amdgpu: lock reservation object while creating shadow bo
Christian König
deathsimple at vodafone.de
Thu Jan 12 09:40:24 UTC 2017
Am 11.01.2017 um 17:14 schrieb Nicolai Hähnle:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> ttm_bo_init checks that the reservation object is locked. This is
> the caller's responsibility when resv != NULL. Otherwise, the inline
> reservation object of the newly allocated buffer is used and must
> explicitly be locked.
>
> Uninterruptible w/w locks without an acquire context are always
> successful.
>
> v2: use ww_mutex_lock
>
> Signed-off-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
> Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net> (v1)
Reviewed-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 11c12c4d..4b2a5a9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -465,21 +465,30 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
> amdgpu_ttm_placement_init(adev, &placement,
> placements, domain, flags);
>
> r = amdgpu_bo_create_restricted(adev, size, byte_align, kernel,
> domain, flags, sg, &placement,
> resv, bo_ptr);
> if (r)
> return r;
>
> if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) {
> + if (!resv) {
> + r = ww_mutex_lock(&(*bo_ptr)->tbo.resv->lock, NULL);
> + WARN_ON(r != 0);
> + }
> +
> r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr));
> +
> + if (!resv)
> + ww_mutex_unlock(&(*bo_ptr)->tbo.resv->lock);
> +
> if (r)
> amdgpu_bo_unref(bo_ptr);
> }
>
> return r;
> }
>
> int amdgpu_bo_backup_to_shadow(struct amdgpu_device *adev,
> struct amdgpu_ring *ring,
> struct amdgpu_bo *bo,
More information about the amd-gfx
mailing list