]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/amd/amdgpu: lock reservation object while creating shadow bo
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 10 Jan 2017 18:06:00 +0000 (19:06 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 27 Jan 2017 16:13:28 +0000 (11:13 -0500)
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@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> (v1)
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index d94cdeff061795e68fc759f8afb210b6abae56ea..ac6b074b8821a789be7f6993f9ce4ab12388c9c6 100644 (file)
@@ -472,7 +472,16 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
                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);
        }