All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: use DRM_GPUVM_RESV_PROTECTED locking scheme
@ 2025-08-12 17:01 Danilo Krummrich
  0 siblings, 0 replies; only message in thread
From: Danilo Krummrich @ 2025-08-12 17:01 UTC (permalink / raw)
  To: lyude, airlied, simona; +Cc: dri-devel, nouveau, Danilo Krummrich, Alice Ryhl

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 <aliceryhl@google.com>
Signed-off-by: Danilo Krummrich <dakr@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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-12 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 17:01 [PATCH] drm/nouveau: use DRM_GPUVM_RESV_PROTECTED locking scheme Danilo Krummrich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.