On 2026-11-17 14: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.
>
> 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);

Hi Shahyan,

Since reserve_fences() does increase the capacity (it only increases capacity 
if it finds there is not enough room) this is insufficient.

We can either reserve everywhere, or reserve everything up front. It seems 
Christian favours the latter.

See 
https://lore.kernel.org/amd-gfx/[email protected]/ 
for example. I will be sending out v2 of that patchset soon, and I guess it 
should fix this issue too.

Thanks,

Ben

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