* [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag
@ 2022-02-22 2:46 Qiang Yu
2022-02-23 7:47 ` Paul Menzel
2022-02-28 17:26 ` youling257
0 siblings, 2 replies; 5+ messages in thread
From: Qiang Yu @ 2022-02-22 2:46 UTC (permalink / raw)
To: Paul Menzel, Alex Deucher, Christian König, Pan, Xinhui,
David Airlie, Daniel Vetter
Cc: Qiang Yu, amd-gfx, dri-devel, linux-kernel
Workstation application ANSA/META v21.1.4 get this error dmesg when
running CI test suite provided by ANSA/META:
[drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't update BO_VA (-16)
This is caused by:
1. create a 256MB buffer in invisible VRAM
2. CPU map the buffer and access it causes vm_fault and try to move
it to visible VRAM
3. force visible VRAM space and traverse all VRAM bos to check if
evicting this bo is valuable
4. when checking a VM bo (in invisible VRAM), amdgpu_vm_evictable()
will set amdgpu_vm->evicting, but latter due to not in visible
VRAM, won't really evict it so not add it to amdgpu_vm->evicted
5. before next CS to clear the amdgpu_vm->evicting, user VM ops
ioctl will pass amdgpu_vm_ready() (check amdgpu_vm->evicted)
but fail in amdgpu_vm_bo_update_mapping() (check
amdgpu_vm->evicting) and get this error log
This error won't affect functionality as next CS will finish the
waiting VM ops. But we'd better clear the error log by checking
the amdgpu_vm->evicting flag in amdgpu_vm_ready() to stop calling
amdgpu_vm_bo_update_mapping() latter.
Another reason is amdgpu_vm->evicted list holds all BOs (both
user buffer and page table), but only page table BOs' eviction
prevent VM ops. amdgpu_vm->evicting flag is set only for page
table BOs, so we should use evicting flag instead of evicted list
in amdgpu_vm_ready().
The side effect of This change is: previously blocked VM op (user
buffer in "evicted" list but no page table in it) gets done
immediately.
v2: update commit comments.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Qiang Yu <qiang.yu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 37acd8911168..2cd9f1a2e5fa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -770,11 +770,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
* Check if all VM PDs/PTs are ready for updates
*
* Returns:
- * True if eviction list is empty.
+ * True if VM is not evicting.
*/
bool amdgpu_vm_ready(struct amdgpu_vm *vm)
{
- return list_empty(&vm->evicted);
+ bool ret;
+
+ amdgpu_vm_eviction_lock(vm);
+ ret = !vm->evicting;
+ amdgpu_vm_eviction_unlock(vm);
+ return ret;
}
/**
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag
2022-02-22 2:46 [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Qiang Yu
@ 2022-02-23 7:47 ` Paul Menzel
2022-02-23 7:54 ` Qiang Yu
2022-02-28 17:26 ` youling257
1 sibling, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2022-02-23 7:47 UTC (permalink / raw)
To: Qiang Yu
Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
Daniel Vetter, dri-devel, amd-gfx, linux-kernel
Dear Qiang,
Am 22.02.22 um 03:46 schrieb Qiang Yu:
> Workstation application ANSA/META v21.1.4 get this error dmesg when
> running CI test suite provided by ANSA/META:
> [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't update BO_VA (-16)
>
> This is caused by:
> 1. create a 256MB buffer in invisible VRAM
> 2. CPU map the buffer and access it causes vm_fault and try to move
> it to visible VRAM
> 3. force visible VRAM space and traverse all VRAM bos to check if
> evicting this bo is valuable
> 4. when checking a VM bo (in invisible VRAM), amdgpu_vm_evictable()
> will set amdgpu_vm->evicting, but latter due to not in visible
> VRAM, won't really evict it so not add it to amdgpu_vm->evicted
> 5. before next CS to clear the amdgpu_vm->evicting, user VM ops
> ioctl will pass amdgpu_vm_ready() (check amdgpu_vm->evicted)
> but fail in amdgpu_vm_bo_update_mapping() (check
> amdgpu_vm->evicting) and get this error log
>
> This error won't affect functionality as next CS will finish the
> waiting VM ops. But we'd better clear the error log by checking
> the amdgpu_vm->evicting flag in amdgpu_vm_ready() to stop calling
> amdgpu_vm_bo_update_mapping() latter.
later
> Another reason is amdgpu_vm->evicted list holds all BOs (both
> user buffer and page table), but only page table BOs' eviction
> prevent VM ops. amdgpu_vm->evicting flag is set only for page
> table BOs, so we should use evicting flag instead of evicted list
> in amdgpu_vm_ready().
>
> The side effect of This change is: previously blocked VM op (user
this
> buffer in "evicted" list but no page table in it) gets done
> immediately.
>
> v2: update commit comments.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Qiang Yu <qiang.yu@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 37acd8911168..2cd9f1a2e5fa 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -770,11 +770,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> * Check if all VM PDs/PTs are ready for updates
> *
> * Returns:
> - * True if eviction list is empty.
> + * True if VM is not evicting.
> */
> bool amdgpu_vm_ready(struct amdgpu_vm *vm)
> {
> - return list_empty(&vm->evicted);
> + bool ret;
> +
> + amdgpu_vm_eviction_lock(vm);
> + ret = !vm->evicting;
> + amdgpu_vm_eviction_unlock(vm);
> + return ret;
> }
>
> /**
Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag
2022-02-23 7:47 ` Paul Menzel
@ 2022-02-23 7:54 ` Qiang Yu
0 siblings, 0 replies; 5+ messages in thread
From: Qiang Yu @ 2022-02-23 7:54 UTC (permalink / raw)
To: Paul Menzel
Cc: Qiang Yu, David Airlie, Xinhui Pan, Linux Kernel Mailing List,
dri-devel, amd-gfx, Alex Deucher, Christian König
On Wed, Feb 23, 2022 at 3:47 PM Paul Menzel <pmenzel@molgen.mpg.de> wrote:
>
> Dear Qiang,
>
>
> Am 22.02.22 um 03:46 schrieb Qiang Yu:
> > Workstation application ANSA/META v21.1.4 get this error dmesg when
> > running CI test suite provided by ANSA/META:
> > [drm:amdgpu_gem_va_ioctl [amdgpu]] *ERROR* Couldn't update BO_VA (-16)
> >
> > This is caused by:
> > 1. create a 256MB buffer in invisible VRAM
> > 2. CPU map the buffer and access it causes vm_fault and try to move
> > it to visible VRAM
> > 3. force visible VRAM space and traverse all VRAM bos to check if
> > evicting this bo is valuable
> > 4. when checking a VM bo (in invisible VRAM), amdgpu_vm_evictable()
> > will set amdgpu_vm->evicting, but latter due to not in visible
> > VRAM, won't really evict it so not add it to amdgpu_vm->evicted
> > 5. before next CS to clear the amdgpu_vm->evicting, user VM ops
> > ioctl will pass amdgpu_vm_ready() (check amdgpu_vm->evicted)
> > but fail in amdgpu_vm_bo_update_mapping() (check
> > amdgpu_vm->evicting) and get this error log
> >
> > This error won't affect functionality as next CS will finish the
> > waiting VM ops. But we'd better clear the error log by checking
> > the amdgpu_vm->evicting flag in amdgpu_vm_ready() to stop calling
> > amdgpu_vm_bo_update_mapping() latter.
>
> later
> > Another reason is amdgpu_vm->evicted list holds all BOs (both
> > user buffer and page table), but only page table BOs' eviction
> > prevent VM ops. amdgpu_vm->evicting flag is set only for page
> > table BOs, so we should use evicting flag instead of evicted list
> > in amdgpu_vm_ready().
> >
> > The side effect of This change is: previously blocked VM op (user
>
> this
>
> > buffer in "evicted" list but no page table in it) gets done
> > immediately.
> >
> > v2: update commit comments.
> >
> > Reviewed-by: Christian König <christian.koenig@amd.com>
> > Signed-off-by: Qiang Yu <qiang.yu@amd.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > index 37acd8911168..2cd9f1a2e5fa 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > @@ -770,11 +770,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> > * Check if all VM PDs/PTs are ready for updates
> > *
> > * Returns:
> > - * True if eviction list is empty.
> > + * True if VM is not evicting.
> > */
> > bool amdgpu_vm_ready(struct amdgpu_vm *vm)
> > {
> > - return list_empty(&vm->evicted);
> > + bool ret;
> > +
> > + amdgpu_vm_eviction_lock(vm);
> > + ret = !vm->evicting;
> > + amdgpu_vm_eviction_unlock(vm);
> > + return ret;
> > }
> >
> > /**
>
> Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
Thanks, will submit with the typo fixed.
Regards,
Qiang
>
> Kind regards,
>
> Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag
2022-02-22 2:46 [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Qiang Yu
2022-02-23 7:47 ` Paul Menzel
@ 2022-02-28 17:26 ` youling257
2022-02-28 17:33 ` youling 257
1 sibling, 1 reply; 5+ messages in thread
From: youling257 @ 2022-02-28 17:26 UTC (permalink / raw)
To: qiang.yu
Cc: pmenzel, christian.koenig, alexander.deucher, airlied, daniel,
amd-gfx, linux-kernel, dri-devel
this patch cause suspend to disk resume amdgpu hang, [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx timeout, signaled seq=8330, emitted seq=8332
https://gitlab.freedesktop.org/drm/amd/-/issues/1915
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag
2022-02-28 17:26 ` youling257
@ 2022-02-28 17:33 ` youling 257
0 siblings, 0 replies; 5+ messages in thread
From: youling 257 @ 2022-02-28 17:33 UTC (permalink / raw)
To: qiang.yu
Cc: pmenzel, christian.koenig, alexander.deucher, airlied, daniel,
amd-gfx, linux-kernel, dri-devel
https://gitlab.freedesktop.org/drm/amd/-/issues/1922
2022-03-01 1:26 GMT+08:00, youling257 <youling257@gmail.com>:
> this patch cause suspend to disk resume amdgpu hang,
> [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx timeout, signaled
> seq=8330, emitted seq=8332
>
> https://gitlab.freedesktop.org/drm/amd/-/issues/1915
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-28 17:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 2:46 [PATCH v2] drm/amdgpu: check vm ready by amdgpu_vm->evicting flag Qiang Yu
2022-02-23 7:47 ` Paul Menzel
2022-02-23 7:54 ` Qiang Yu
2022-02-28 17:26 ` youling257
2022-02-28 17:33 ` youling 257
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).