Given that nouveau does not update the GPUVA space from the DMA fence
signalling critical path, we are able to use the DRM_GPUVM_RESV_PROTECTED
locking scheme, rather than relying on the spinlock dance for the
external and evicted object list.

Except for the call to drm_gpuvm_bo_extobj_add() add other relevant call
are already protected by the corresponding dma-resv locks.

Hence, move drm_gpuvm_bo_extobj_add into the same lock context as
drm_gpuvm_bo_obtain() and enable DRM_GPUVM_RESV_PROTECTED.

Cc: Alice Ryhl <alicer...@google.com>
Signed-off-by: Danilo Krummrich <d...@kernel.org>
---
 drivers/gpu/drm/nouveau/nouveau_uvmm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c 
b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index ddfc46bc1b3e..9d9e82628053 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -1208,11 +1208,13 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
 
                        dma_resv_lock(obj->resv, NULL);
                        op->vm_bo = drm_gpuvm_bo_obtain(&uvmm->base, obj);
-                       dma_resv_unlock(obj->resv);
-                       if (IS_ERR(op->vm_bo))
+                       if (IS_ERR(op->vm_bo)) {
+                               dma_resv_unlock(obj->resv);
                                return PTR_ERR(op->vm_bo);
+                       }
 
                        drm_gpuvm_bo_extobj_add(op->vm_bo);
+                       dma_resv_unlock(obj->resv);
                }
 
                ret = bind_validate_op(job, op);
@@ -1857,7 +1859,9 @@ nouveau_uvmm_ioctl_vm_init(struct drm_device *dev,
        mt_init_flags(&uvmm->region_mt, MT_FLAGS_LOCK_EXTERN);
        mt_set_external_lock(&uvmm->region_mt, &uvmm->mutex);
 
-       drm_gpuvm_init(&uvmm->base, cli->name, 0, drm, r_obj,
+       drm_gpuvm_init(&uvmm->base, cli->name,
+                      DRM_GPUVM_RESV_PROTECTED,
+                      drm, r_obj,
                       NOUVEAU_VA_SPACE_START,
                       NOUVEAU_VA_SPACE_END,
                       init->kernel_managed_addr,

base-commit: fb357dbadbebc7a9ca3c5ef26f6c792b0e8e1278
-- 
2.50.1

Reply via email to