]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: lock bo before calling amdgpu_vm_bo_update_shared
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 28 Oct 2025 13:09:05 +0000 (14:09 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 4 Nov 2025 16:53:21 +0000 (11:53 -0500)
BO's reservation object must be locked before using
amdgpu_vm_bo_update_shared otherwise dma_resv_assert_held will
complain in amdgpu_vm_update_shared.

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

index 8561ad7f61800027aec56affa3283f22947368b3..268d69d862e01d8a1946415fac39fd5502a9c5c6 100644 (file)
@@ -81,13 +81,20 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
        struct drm_gem_object *obj = dmabuf->priv;
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+       int r;
 
        if (!amdgpu_dmabuf_is_xgmi_accessible(attach_adev, bo) &&
            pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0)
                attach->peer2peer = false;
 
+       r = dma_resv_lock(bo->tbo.base.resv, NULL);
+       if (r)
+               return r;
+
        amdgpu_vm_bo_update_shared(bo);
 
+       dma_resv_unlock(bo->tbo.base.resv);
+
        return 0;
 }