From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: ZhenGuo Yin <zhenguo.yin@amd.com>, amd-gfx@lists.freedesktop.org
Cc: "'Christian König'" <christian.koenig@amd.com>
Subject: Re: [PATCH v2] drm/amdgpu: reset vm state machine after gpu reset(vram lost)
Date: Tue, 23 Jul 2024 09:13:16 +0200 [thread overview]
Message-ID: <5ceac529-39cd-4095-8193-e30932f37dac@gmail.com> (raw)
In-Reply-To: <20240723030548.1283366-1-zhenguo.yin@amd.com>
Am 23.07.24 um 05:05 schrieb ZhenGuo Yin:
> [Why]
> Page table of compute VM in the VRAM will lost after gpu reset.
> VRAM won't be restored since compute VM has no shadows.
>
> [How]
> Use higher 32-bit of vm->generation to record a vram_lost_counter.
> Reset the VM state machine when vm->genertaion is not equal to
> re-generation token.
>
> v2: Check vm->generation instead of calling drm_sched_entity_error
> in amdgpu_vm_validate.
I've just double checked the logic again and as far as I can see this
patch here is still completely superfluous.
When VRAM is lost any submission using the VM entity will fail and so
result in a new page table generation.
What isn't handled are CPU based page table updates, but for those we
could potentially change the condition inside the CPU page tables code.
Regards,
Christian.
>
> Signed-off-by: ZhenGuo Yin <zhenguo.yin@amd.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 3abfa66d72a2..9e2f84c166e7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -434,7 +434,7 @@ uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm)
> if (!vm)
> return result;
>
> - result += vm->generation;
> + result += (vm->generation & 0xFFFFFFFF);
> /* Add one if the page tables will be re-generated on next CS */
> if (drm_sched_entity_error(&vm->delayed))
> ++result;
> @@ -467,9 +467,12 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> struct amdgpu_bo *shadow;
> struct amdgpu_bo *bo;
> int r;
> + uint32_t vram_lost_counter = atomic_read(&adev->vram_lost_counter);
>
> - if (drm_sched_entity_error(&vm->delayed)) {
> - ++vm->generation;
> + if (vm->generation != amdgpu_vm_generation(adev, vm)) {
> + if (drm_sched_entity_error(&vm->delayed))
> + ++vm->generation;
> + vm->generation = (u64)vram_lost_counter << 32 | (vm->generation & 0xFFFFFFFF);
> amdgpu_vm_bo_reset_state_machine(vm);
> amdgpu_vm_fini_entities(vm);
> r = amdgpu_vm_init_entities(adev, vm);
> @@ -2439,7 +2442,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> vm->last_update = dma_fence_get_stub();
> vm->last_unlocked = dma_fence_get_stub();
> vm->last_tlb_flush = dma_fence_get_stub();
> - vm->generation = 0;
> + vm->generation = (u64)atomic_read(&adev->vram_lost_counter) << 32;
>
> mutex_init(&vm->eviction_lock);
> vm->evicting = false;
next prev parent reply other threads:[~2024-07-23 7:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 3:05 [PATCH v2] drm/amdgpu: reset vm state machine after gpu reset(vram lost) ZhenGuo Yin
2024-07-23 7:13 ` Christian König [this message]
2024-07-23 9:04 ` Yin, ZhenGuo (Chris)
2024-07-23 9:48 ` Christian König
2024-07-23 9:51 ` Christian König
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=5ceac529-39cd-4095-8193-e30932f37dac@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=zhenguo.yin@amd.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.