On 11/11/26 12:56, Mu, Zihao wrote:
> From: Zihao Mu <[email protected]>
> 
> The CPU backend repeats reservation traversal for every PTE batch. An
> interrupted wait can also skip a batch whose result the walker ignores.

That irrelevant.

> Wait for the shared root reservation's KERNEL dependencies in prepare,
> including calls without an explicit sync. Allocation now commits and
> restarts the phase, so dependencies added while the eviction lock was
> dropped are covered before the resumed phase writes entries.
> 
> Preserve the existing interruptible wait policy.

Clear NAK to that. As said before unmap operations triggered by MMU notifiers 
*must* complete and can't be interrupted.

We could add an interruptible flag to the update paramaters but that is most 
likely overkill.

> An interruption now
> fails prepare before that phase writes any entries, while prior phases
> have been committed and receive normal partial-range finalization.
> Keep explicit sync handling and the CPU write/flags/commit tail intact.
> 
> The update callback now only writes entries and returns zero through
> the existing interface. This does not claim that all VM preparation or
> SDMA allocation operations have become non-failing.
> 
> Signed-off-by: Zihao Mu <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c
> index d03b9bbe20c..89e76e18d9e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c
> @@ -52,10 +52,19 @@ static int amdgpu_vm_cpu_prepare(struct 
> amdgpu_vm_update_params *p,
>                                struct amdgpu_sync *sync,
>                                u64 k_job_id)
>  {
> -     if (!sync)
> -             return 0;
> +     struct dma_resv *resv = p->vm->root.bo->tbo.base.resv;
> +     long r;
> +
> +     if (sync) {
> +             r = amdgpu_sync_wait(sync, true);
> +             if (r)
> +                     return r;
> +     }
>  
> -     return amdgpu_sync_wait(sync, true);
> +     /* Allocation restarts prepare before any further page-table writes. */
> +     r = dma_resv_wait_timeout(resv, DMA_RESV_USAGE_KERNEL,
> +                               true, MAX_SCHEDULE_TIMEOUT);
> +     return r < 0 ? r : 0;

That check is unnecessary, MAX_SCHEDULE_TIMEOUT blocks forever.

Regards,
Christian.

>  }
>  
>  /**
> @@ -78,12 +87,6 @@ static int amdgpu_vm_cpu_update(struct 
> amdgpu_vm_update_params *p,
>  {
>       unsigned int i;
>       uint64_t value;
> -     long r;
> -
> -     r = dma_resv_wait_timeout(vmbo->bo.tbo.base.resv, DMA_RESV_USAGE_KERNEL,
> -                               true, MAX_SCHEDULE_TIMEOUT);
> -     if (r < 0)
> -             return r;
>  
>       pe += (unsigned long)amdgpu_bo_kptr(&vmbo->bo);
>  

Reply via email to