From a2a27745350c7f2d142b3248e12fd3ba182f8766 Mon Sep 17 00:00:00 2001 From: Vitaly Prosyak Date: Wed, 9 Sep 2026 19:23:55 -0400 Subject: [PATCH] drm/amdgpu: reserve root PD fence slots for userq eviction-fence rearm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: - In userq restore/rearm, root PD was locked with amdgpu_vm_lock_pd(vm, &exec, 1). - Later in the same drm_exec context, amdgpu_evf_mgr_rearm() attaches BOOKKEEP eviction fences to all locked BOs. - In this flow, root PD validation/update can also consume move-fence slots, so reserving only +1 at PD lock time is not sufficient under stress. Fix: - Reserve caller-side slots at the actual source by switching to: amdgpu_vm_lock_pd(vm, &exec, TTM_NUM_MOVE_FENCES + 1) This keeps reservation policy in callers, consistent with Christian Konig feedback and with amdgpu_gem_object_open() where callers reserve TTM_NUM_MOVE_FENCES + 1 before attaching eviction fences. Credit: - Christian Konig: confirmed fence-slot reservation belongs to callers and asked to investigate why +1 was still not enough. - Prike Liang: clarified the initial variant was workaround-only and developed that initial version independently. Cc: Prike Liang Cc: Sunil Khatri Cc: Christian König Cc: Alex Deucher Signed-off-by: Vitaly Prosyak Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 3938f7b8ec4b..12fbff02e4b5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -1043,7 +1043,11 @@ amdgpu_userq_vm_validate_and_restore_queue(struct amdgpu_userq_mgr *uq_mgr) retry_lock: drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0); drm_exec_until_all_locked(&exec) { - ret = amdgpu_vm_lock_pd(vm, &exec, 1); + /* + * Rearm adds one BOOKKEEP fence and validation may queue move fences + * on the root PD BO, so reserve caller-side slots accordingly. + */ + ret = amdgpu_vm_lock_pd(vm, &exec, TTM_NUM_MOVE_FENCES + 1); drm_exec_retry_on_contention(&exec); if (unlikely(ret)) goto unlock_all;