All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Mu, Zihao" <Zihao.Mu@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
	Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Subject: Re: [RFC PATCH v3 4/5] drm/amdgpu: restart VM updates around page-table allocation
Date: Wed, 18 Nov 2026 09:39:13 +0100	[thread overview]
Message-ID: <54e51223-26e1-465a-8d6d-e4ebf4110c87@amd.com> (raw)
In-Reply-To: <MW3PR12MB4572986213556B63A708CA4F9E7B2@MW3PR12MB4572.namprd12.prod.outlook.com>

On 11/17/26 12:40, Mu, Zihao wrote:
> From: Zihao Mu <zmu@amd.com>
> 
> Commit the current phase before dropping the eviction lock to allocate
> a page table. After clearing the new table, prepare another phase with
> the original sync and the context's original job ID.
> 
> The eviction lock prevents table movement during a prepared phase.
> pt_alloc() drops that lock for allocation, so it must end the phase
> first. pt_clear() validates the new table before its own prepare; the
> outer prepare then covers move dependencies before resumed writes.
> All these submissions preserve immediate and use the same entity.
> 
> Finish the nested clear's current job even if its update fails, keeping
> the original error. An empty job is freed by commit; a submitted clear
> completion is already transferred to the range context for finalization.
> 
> Keep an initialized table installed if the outer prepare fails. Failed
> initialization uses the existing teardown prerequisite, rather than
> introducing another copy of that fix here. Existing tables still return
> without ending or restarting the current phase.
> 
> Signed-off-by: Zihao Mu <zmu@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c          | 1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h | 5 +++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c       | 8 ++++----
>  3 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 3f3c5a82fc1..df65e02bfa2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1204,6 +1204,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>  	params.vm = vm;
>  	params.immediate = immediate;
>  	params.pages_addr = pages_addr;
> +	params.sync = sync;
>  	params.unlocked = unlocked;
>  	params.needs_flush = flush_tlb;
>  	params.override_pte = allow_override && adev->gmc.override_pte;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> index 9bd71f4d5b9..cdf14f69376 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_internal.h
> @@ -87,6 +87,11 @@ struct amdgpu_vm_update_params {
>  	 */
>  	struct dma_fence *last_update;
>  
> +	/**
> +	 * @sync: original dependencies to preserve across prepare calls
> +	 */
> +	struct amdgpu_sync *sync;
> +

That is nonsense. Only the first prepare call needs the dependencies.

>  	/**
>  	 * @num_dw_left: number of dw left for the IB
>  	 */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> index 7b7a576d95f..1a2352c8c8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
> @@ -426,9 +426,6 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>  
>  	r = vm->update_funcs->update(&params, vmbo, addr, 0, entries,
>  				     value, flags);
> -	if (r)
> -		goto exit;
> -
>  	vm->update_funcs->commit(&params, &vm->last_update);
>  exit:
>  	if (last_update && params.last_update)
> @@ -532,6 +529,9 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_vm_update_params *p,
>  	if (entry->bo)
>  		return 0;
>  
> +	/* Allocation can add move dependencies while the lock is dropped. */

No it doesn't. What can be is that we have more page tables clears but those execute sequenctially with the PTE updates.

> +	p->vm->update_funcs->commit(p, NULL);

We need Thadeu's patch to ignore commits with empty IBs for this to work correctly.

Additional to that the returned fence parameter should be dropped from the commit function.

Regards,
Christian.

> +
>  	amdgpu_vm_end_critical(p);
>  	r = amdgpu_vm_pt_create(p->adev, p->vm, cursor->level, p->immediate,
>  				&pt, p->vm->root.bo->xcp_id);
> @@ -558,7 +558,7 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_vm_update_params *p,
>  		return r;
>  	}
>  
> -	return 0;
> +	return p->vm->update_funcs->prepare(p, p->sync);
>  
>  error_unpin:
>  	if (p->vm->is_npa)


  reply	other threads:[~2026-11-18  8:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 10:29 [RFC] drm/amdgpu: handling PTE backend update errors Mu, Zihao
2026-11-10 12:26 ` Christian König
2026-11-11  5:39   ` [RFC PATCH] drm/amdgpu: make CPU page-table update waits uninterruptible Mu, Zihao
2026-11-11  9:06     ` Christian König
2026-11-11 11:55       ` [RFC PATCH v2 0/6] drm/amdgpu: prepare updates across page-table allocation Mu, Zihao
2026-11-11 11:55       ` [RFC PATCH v2 1/6] drm/amdgpu: handle missing or empty SDMA VM update jobs Mu, Zihao
2026-11-11 11:55       ` [RFC PATCH v2 2/6] drm/amdgpu: track internal completion of SDMA VM updates Mu, Zihao
2026-11-11 11:55       ` [RFC PATCH v2 3/6] drm/amdgpu: finalize partial VM range updates on error Mu, Zihao
2026-11-11 12:44         ` Thadeu Lima de Souza Cascardo
2026-11-11 11:55       ` [RFC PATCH v2 4/6] drm/amdgpu: unwind failed page-table initialization Mu, Zihao
2026-11-11 13:10         ` Christian König
2026-11-11 11:55       ` [RFC PATCH v2 5/6] drm/amdgpu: restart VM updates around page-table allocation Mu, Zihao
2026-11-11 12:56         ` Thadeu Lima de Souza Cascardo
2026-11-11 11:56       ` [RFC PATCH v2 6/6] drm/amdgpu: wait for page-table moves in CPU prepare Mu, Zihao
2026-11-11 13:14         ` Christian König
2026-11-17 11:39           ` [RFC PATCH v3 0/5] drm/amdgpu: prepare updates across page-table allocation Mu, Zihao
2026-11-17 11:39           ` [RFC PATCH v3 1/5] drm/amdgpu: pass job id as part of amdgpu_vm_update_params Mu, Zihao
2026-11-17 14:56             ` Christian König
2026-11-17 11:39           ` [RFC PATCH v3 2/5] drm/amdgpu: track internal completion of SDMA VM updates Mu, Zihao
2026-11-18  8:21             ` Christian König
2026-11-17 11:39           ` [RFC PATCH v3 3/5] drm/amdgpu: finalize partial VM range updates on error Mu, Zihao
2026-11-18  8:34             ` Christian König
2026-11-17 11:40           ` [RFC PATCH v3 4/5] drm/amdgpu: restart VM updates around page-table allocation Mu, Zihao
2026-11-18  8:39             ` Christian König [this message]
2026-11-17 11:40           ` [RFC PATCH v3 5/5] drm/amdgpu: wait uninterruptibly for page-table moves in CPU prepare Mu, Zihao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54e51223-26e1-465a-8d6d-e4ebf4110c87@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Zihao.Mu@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=cascardo@igalia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.