* Re: [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized
2026-11-25 3:02 [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized Prike Liang
@ 2026-11-25 3:09 ` sashiko-bot
2026-11-25 3:36 ` Liang, Prike
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-25 3:09 UTC (permalink / raw)
To: Prike Liang, amd-gfx
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/amdgpu/userq: race allowing resume_work after
amdgpu_userq_suspend() [1]
--
commit a80bb08812a1d7a481e2390eeabf02bdbae59d10
Author: Prike Liang <Prike.Liang@amd.com>
drm/amdgpu: only save VKMS modeset state if VKMS is initialized
This commit introduces amdgpu_device_has_vkms() to verify that both
enable_virtual_display and mode_config_initialized are set before saving
and restoring VKMS modeset state during device suspend and resume.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 7cf3a4cbac27c..9b0ef3ab5f53a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
[ ... ]
> @@ -4605,7 +4615,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
> amdgpu_ras_suspend(adev);
>
> /* VKMS modeset state is saved here, never from the reset path */
> - if (adev->enable_virtual_display) {
> + if (amdgpu_device_has_vkms(adev)) {
> r = drm_mode_config_helper_suspend(dev);
> if (r)
> goto unwind_smartshift;
[Severity: High]
This problem wasn't introduced by this patch, but can amdgpu_device_suspend()
leave uqm->resume_work scheduled after amdgpu_userq_suspend() returns
[1]?
During system suspend, amdgpu_userq_suspend() can race with
amdgpu_eviction_fence_suspend_worker():
kworker CPU0
amdgpu_eviction_fence_suspend_worker()
mutex_lock(&uq_mgr->userq_mutex)
...
dma_fence_signal(ev_fence)
amdgpu_device_prepare()
amdgpu_device_suspend()
amdgpu_userq_suspend()
cancel_delayed_work_sync(
&uqm->resume_work)
schedule_delayed_work(
&uq_mgr->resume_work, 0)
mutex_unlock(&uq_mgr->userq_mutex)
guard(mutex)(&uqm->userq_mutex)
amdgpu_userq_unmap_helper()
...
amdgpu_userq_restore_worker() <-- runs on suspended GPU
amdgpu_eviction_fence_suspend_worker() signals ev_fence before queuing
resume_work and releasing userq_mutex, while amdgpu_userq_suspend() calls
cancel_delayed_work_sync(&uqm->resume_work) before taking userq_mutex and
without flushing evf_mgr->suspend_work.
In addition, amdgpu_device_suspend() calls amdgpu_userq_suspend() before
amdgpu_device_evict_resources():
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:amdgpu_device_suspend() {
...
r = amdgpu_userq_suspend(adev);
if (r)
goto unwind_ip_phase1;
r = amdgpu_device_evict_resources(adev);
if (r)
goto unwind_userq;
...
}
If ev_fence is still unsignaled at that point, evicting resources triggers
evf_mgr->suspend_work, which schedules uqm->resume_work after
amdgpu_userq_suspend() has already finished.
In either case, amdgpu_userq_restore_worker() can run after TTM buffer
functions, fence drivers and GPU IP blocks are suspended, causing failed
page table updates, MES command timeouts or hardware access to a suspended
device.
[1] https://sashiko.dev/#/bug/linux-f4cce3e7-09c5-44f6-b753-c17f5780e3fb
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125030255.767185-1-Prike.Liang@amd.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized
2026-11-25 3:02 [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized Prike Liang
2026-11-25 3:09 ` sashiko-bot
@ 2026-11-25 3:36 ` Liang, Prike
1 sibling, 0 replies; 3+ messages in thread
From: Liang, Prike @ 2026-11-25 3:36 UTC (permalink / raw)
To: amd-gfx@lists.freedesktop.org, Min, Frank
Cc: Deucher, Alexander, Koenig, Christian, Li, Sun peng (Leo),
Limonciello, Mario, Lazar, Lijo
AMD General
Since @Min, Frank has a similar fix, I will drop this patch for the moment.
Regards,
Prike
> -----Original Message-----
> From: Liang, Prike <Prike.Liang@amd.com>
> Sent: Wednesday, November 25, 2026 11:03 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>;
> Limonciello, Mario <Mario.Limonciello@amd.com>; Lazar, Lijo
> <Lijo.Lazar@amd.com>; Liang, Prike <Prike.Liang@amd.com>
> Subject: [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized
>
> Commit 11a08cd5ab25 ("drm/amdgpu: save VKMS modeset state from the system
> PM path only") moved drm_mode_config_helper_suspend()/resume() from the
> VKMS IP block callbacks into amdgpu_device_suspend()/resume(), keyed on
> adev->enable_virtual_display.
>
> That flag does not mean a VKMS IP block exists. amdgpu_virt_init_setting() sets it
> on SR-IOV VFs from the common block's early init, after the IP blocks were added. A
> VF without a usable display IP gets no VKMS block, so its mode config has no
> funcs, but enable_virtual_display is still true.
> The old .suspend callback was never reached on such a device. Now
> drm_atomic_helper_suspend() runs and drm_atomic_state_alloc() dereferences the
> NULL dev->mode_config.funcs.
>
> amdgpu_pci_shutdown() calls amdgpu_device_suspend(), so the guest oopses on
> every shutdown and reboot, after it requested full access for FINI and before it
> releases it. On a Navi32 (Radeon PRO V710) VF the host times the full access out
> and resets the VF:
>
> Received Event: VF1, event = 0x3(REQ_GPU_FINI)
> VF1 entered full access mode.
> VF1 full access timed out!
> Issuing FLR on vf: 1.
>
> After repeated timeouts the host ignores the VF's REQ_GPU_INIT_DATA and
> REQ_GPU_INIT, and the next boot fails to probe:
>
> amdgpu 0000:06:00.0: Doesn't get msg:1 from pf, error=-62
> amdgpu 0000:06:00.0: probe with driver amdgpu failed with error -62
>
> Check mode_info.mode_config_initialized too, as amdgpu_device_fini_hw() does
> before it shuts the mode config down.
>
> Fixes: 11a08cd5ab25 ("drm/amdgpu: save VKMS modeset state from the system
> PM path only")
> Signed-off-by: Prike Liang <Prike.Liang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 0254b5531238..700d7517f22e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -4603,6 +4603,16 @@ void amdgpu_device_complete(struct drm_device *dev)
> }
> }
>
> +/*
> + * enable_virtual_display is also set on SR-IOV VFs that have no
> +display IP,
> + * where no VKMS IP block was added and the mode config was never set up.
> + */
> +static bool amdgpu_device_has_vkms(struct amdgpu_device *adev) {
> + return adev->enable_virtual_display &&
> + adev->mode_info.mode_config_initialized;
> +}
> +
> /**
> * amdgpu_device_suspend - initiate device suspend
> *
> @@ -4644,7 +4654,7 @@ int amdgpu_device_suspend(struct drm_device *dev,
> bool notify_clients)
> amdgpu_ras_suspend(adev);
>
> /* VKMS modeset state is saved here, never from the reset path */
> - if (adev->enable_virtual_display) {
> + if (amdgpu_device_has_vkms(adev)) {
> r = drm_mode_config_helper_suspend(dev);
> if (r)
> goto unwind_smartshift;
> @@ -4701,7 +4711,7 @@ int amdgpu_device_suspend(struct drm_device *dev,
> bool notify_clients)
> }
>
> unwind_vkms:
> - if (adev->enable_virtual_display)
> + if (amdgpu_device_has_vkms(adev))
> drm_mode_config_helper_resume(dev);
>
> unwind_smartshift:
> @@ -4803,7 +4813,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool
> notify_clients)
> goto exit;
> }
>
> - if (adev->enable_virtual_display) {
> + if (amdgpu_device_has_vkms(adev)) {
> r = drm_mode_config_helper_resume(dev);
> if (r)
> goto exit;
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread