Anytime amdgpu_vm_pt_clear() is called, a job is committed through
vm->update_funcs->commit(). If the GPU is currently using SDMA, this
triggers the function amdgpu_vm_sdma_commit(), which requires a fence
slot due to it utilizing dma_resv_add_fence(). Since this slot is not
provided in amdgpu_vm_validate() a kernel crash can occur.

Reserve a fence slot with dma_resv_reserve_fences() before
amdgpu_vm_pt_clear() is called.

Fixes: ddc3c87584e2 ("drm/amdgpu: clear vm pts upon a vm->generation mismatch")
Signed-off-by: Shahyan Soltani <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 3bcfe0f3b35a..d5b758b5eb82 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -658,6 +658,9 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
                bo_base->moved = true;
 
                if (vm->generation != new_vm_generation) {
+                       r = dma_resv_reserve_fences(bo_base->bo->tbo.base.resv, 
1);
+                       if (r)
+                               return r;
                        r = amdgpu_vm_pt_clear(adev, vm, 
to_amdgpu_bo_vm(bo_base->bo), false);
                        if (r)
                                return r;
-- 
2.56.0

Reply via email to