[PATCH] drm/amdgpu: only lock the valid list of invalidated bo

Prike Liang Prike.Liang at amd.com
Thu Mar 27 09:27:51 UTC 2025


Before locking and traversing the user queue invalidated BO list,
it requires ensuring the VM done list is available.

Signed-off-by: Prike Liang <Prike.Liang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index ecd49cf15b2a..cb6b89da73c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -479,15 +479,17 @@ amdgpu_userqueue_validate_bos(struct amdgpu_userq_mgr *uq_mgr)
 		}
 
 		/* Lock the done list */
-		list_for_each_entry(bo_va, &vm->done, base.vm_status) {
-			bo = bo_va->base.bo;
-			if (!bo)
-				continue;
-
-			ret = drm_exec_lock_obj(&exec, &bo->tbo.base);
-			drm_exec_retry_on_contention(&exec);
-			if (unlikely(ret))
-				goto unlock_all;
+		if (!list_empty(&vm->done)) {
+			list_for_each_entry(bo_va, &vm->done, base.vm_status) {
+				bo = bo_va->base.bo;
+				if (!bo)
+					continue;
+
+				ret = drm_exec_lock_obj(&exec, &bo->tbo.base);
+				drm_exec_retry_on_contention(&exec);
+				if (unlikely(ret))
+					goto unlock_all;
+			}
 		}
 	}
 
-- 
2.34.1



More information about the amd-gfx mailing list