All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Prike Liang" <Prike.Liang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: only save VKMS modeset state if VKMS is initialized
Date: Wed, 25 Nov 2026 03:09:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-232453@kernel.org> (raw)
In-Reply-To: <20261125030255.767185-1-Prike.Liang@amd.com>

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

  reply	other threads:[~2026-11-25  3:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-25  3:36 ` Liang, Prike

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=sashiko-outbox-232453@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Prike.Liang@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.