Normally last_unlocked lives on the same entity (vm->delayed) as the
SDMA commit so they would use the same slot, but in this case handle_fault
calls update_range in immediate mode, making the SDMA commit live in the
immediate entity.

Since the two fences are not in the same entity, we need to reserve two
fence slots here.

Fixes: 2b665c3735b3 ("drm/amdgpu: reserve fence slot to update page table")
Signed-off-by: Benjamin Cheng <[email protected]>
---
v3:
(Christian)
- No TLB fence or TTM_NUM_MOVE_FENCES need to be added here.
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 4d31c41fb684..b1d2779a2aee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3187,7 +3187,11 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, 
u32 pasid,
                value = 0;
        }
 
-       r = dma_resv_reserve_fences(vm->root.bo->tbo.base.resv, 1);
+       /* update_range operates in immediate mode here meaning the SDMA commit
+        * is on the immediate entity, while the last_unlocked comes from the
+        * delayed entity.
+        */
+       r = dma_resv_reserve_fences(vm->root.bo->tbo.base.resv, 2);
        if (r) {
                pr_debug("failed %d to reserve fence slot\n", r);
                goto error_unlock;
-- 
2.56.1

Reply via email to