On 11/17/26 20:54, Shahyan Soltani wrote:
> 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.

Yeah that is not correct.

Fence slots are reserved when the root PD is locked, see function 
amdgpu_vm_lock_pd():

        /* We need at least two fences for the VM PD/PT updates */
        return drm_exec_prepare_obj(exec, &vm->root.bo->tbo.base,
                                    2 + num_fences);

Since all page tables share the same dma_resv object with the root PD that 
should be sufficient for all use cases.

Have you encountered an actual problem with this or is that just a precaution?

Regards,
Christian.


> 
> 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;

Reply via email to