On Wed, Nov 11, 2026 at 11:55:51AM +0000, Mu, Zihao wrote:
> From: Thadeu Lima de Souza Cascardo <[email protected]>
> 
> A PTE walk can fail after earlier batches changed page tables or queued
> SDMA commands. Its current early exit bypasses the final commit, TLB
> handling and draining of the stack-local tlb_flush_waitlist.
> 
> Stop the range walk on failure, then finish the existing commit, TLB
> and page-table cleanup sequence. Preserve the first update error so
> that successful finalization cannot turn an incomplete mapping into
> success. Preparation failures keep their existing early exit.
> 
> The preceding internal-completion tracking keeps the latest submitted
> IB available to TLB finalization, including immediate updates and failed
> replacement-job allocations. Finalization does not rely on a caller
> output fence being present or updated.
> 
> [zmu: Adapt to the int-returning commit API and tracked completion.]
> Link: 
> https://lore.kernel.org/amd-gfx/[email protected]/
> Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
> Signed-off-by: Zihao Mu <[email protected]>

If you apply this patch [1], you don't need to adjust for the int API, and
it makes both this and the next patch cleaner.

Is there any reason not to apply it?

I am sending another cleanup in response to one of the patches for
comments, if they look fine, I can send it properly.

Thanks.
Cascardo.

[1] 
https://lore.kernel.org/amd-gfx/20260924-amdgpu_vm_update_funcs_commit_void-v1-1-9ad7a8283...@igalia.com/

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 1e41f159ced..f76459f8312 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1179,7 +1179,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
> struct amdgpu_vm *vm,
>       struct amdgpu_vm_tlb_seq_struct *tlb_cb;
>       struct amdgpu_vm_update_params params;
>       struct amdgpu_res_cursor cursor;
> -     int r, idx;
> +     int r, commit_r, idx;
>  
>       if (!drm_dev_enter(adev_to_drm(adev), &idx))
>               return -ENODEV;
> @@ -1278,14 +1278,17 @@ int amdgpu_vm_update_range(struct amdgpu_device 
> *adev, struct amdgpu_vm *vm,
>               tmp = start + num_entries;
>               r = amdgpu_vm_ptes_update(&params, start, tmp, addr, flags);
>               if (r)
> -                     goto error_free;
> +                     break;
>  
>               amdgpu_res_next(&cursor, num_entries * AMDGPU_GPU_PAGE_SIZE);
>               start = tmp;
>       }
>  
> -     r = vm->update_funcs->commit(&params, fence);
> -     if (r)
> +     /* Finish partial work without hiding the original update error. */
> +     commit_r = vm->update_funcs->commit(&params, fence);
> +     if (!r)
> +             r = commit_r;
> +     if (commit_r)
>               goto error_free;
>  
>       if (params.needs_flush) {
> -- 
> 2.43.0
> 

Reply via email to