From: Prike Liang Date: Tue, 26 May 2026 08:42:14 +0000 (+0800) Subject: drm/amdgpu: reserve TTM move fences slot for rearming eviction fences X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=113fa3ca614a865776f81759bb245dabf99859a7;p=thirdparty%2Flinux.git drm/amdgpu: reserve TTM move fences slot for rearming eviction fences The eviction rearming does not cover possible TTM move fences. If TTM moves the BO and consumes move fence slots, the later eviction fence add can hit the dma_resv_add_fence() BUG. Signed-off-by: Prike Liang Reviewed-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 1120f8225ac02..212c14d99f6b5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -249,7 +249,7 @@ static int amdgpu_gem_object_open(struct drm_gem_object *obj, drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0); drm_exec_until_all_locked(&exec) { - r = drm_exec_prepare_obj(&exec, &abo->tbo.base, 1); + r = drm_exec_prepare_obj(&exec, &abo->tbo.base, TTM_NUM_MOVE_FENCES + 1); drm_exec_retry_on_contention(&exec); if (unlikely(r)) goto out_unlock; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c index 5438d5fde8786..e07d936b8f8df 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -975,7 +975,7 @@ retry_lock: if (unlikely(ret)) goto unlock_all; - ret = amdgpu_vm_lock_individual(vm, &exec, 1); + ret = amdgpu_vm_lock_individual(vm, &exec, TTM_NUM_MOVE_FENCES + 1); drm_exec_retry_on_contention(&exec); if (unlikely(ret)) goto unlock_all; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 4558a5663c66e..96da18e5b1386 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -484,7 +484,7 @@ int amdgpu_vm_lock_individual(struct amdgpu_vm *vm, struct drm_exec *exec, amdgpu_bo_ref(bo); spin_unlock(&vm->individual_lock); - ret = drm_exec_prepare_obj(exec, &bo->tbo.base, 1); + ret = drm_exec_prepare_obj(exec, &bo->tbo.base, num_fences); amdgpu_bo_unref(&bo); if (unlikely(ret)) return ret;