All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues
@ 2026-11-24  2:32 Arisa Snowbell
  2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24  2:32 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König, Arisa Snowbell

Hi,

I've been testing user queues on my RX 9070 XT (amdgpu.user_queue=1,
with AMD_USERQ=1 for everything I run through Steam) and came across a
suspend hang. After a few hours of uptime, S3 suspend sometimes never
finishes, and I have to reboot the machine by hand. What I see depends
on how the suspend started:

- When the screen locks in parallel with the suspend, the machine
  freezes on the lock screen.
- When it locks first, the screens turn off and the suspend starts
  after that, the screens stay off; the machine looks asleep but never
  wakes up.

Either way it never actually sleeps. Short sessions suspend and resume
fine.

In short: while amdgpu_device_prepare() evicts VRAM for suspend, the
user queue restore worker starts and moves the same BOs back. One
restore worker got stuck waiting on a page table update fence while
holding the BO locks, and the suspend waited for those locks forever.

The patch keeps the restore worker out of system sleep; the details are
in its commit message. It builds cleanly with W=1 against v7.4-rc4 and
passes checkpatch. I'm running it now: S3 suspend and resume work, also
with a game on user queues running, which keeps running after resume,
so the restore worker maps the queues again. It hasn't seen enough long
sessions with suspends yet to show that the hang is gone, so I'm sending
it for review first and will report back once I have more runtime on
it.

System:

  GPU:      RX 9070 XT, Navi 48 [1002:7550] rev c0, gfx12, MES fw 0x97
  Kernel:   7.4.0-rc4 (linux-mainline)
  Firmware: linux-firmware-amdgpu 20261019
  Mesa:     mesa-git 27.0.0_devel.234528.a54c80d04d3 (RADV)
  Options:  amdgpu ppfeaturemask=0xfff7ffff user_queue=1 runpm=0

What I saw:

The suspend started about 11 hours after boot and never finished. About
4 hours later I pressed SysRq w, s and c, and efi-pstore kept the dump.
22 tasks were blocked:

- systemd-sleep, in ttm_bo_evict_first() waiting for a BO lock
- 3 amdgpu_userq_restore_worker: one waiting on a page table update
  fence, two waiting for its locks
- 12 amdgpu_tlb_fence_work, waiting on their page table update fences
- 5 ttm_bo_delayed_delete, waiting on BO fences

All the workers except one TLB fence worker have higher PIDs than
systemd-sleep, so they started after the suspend did.

The earlier suspends of that boot worked. The only amdgpu error before
the hang was one "MES(1) failed to respond to msg=INVALIDATE_TLBS"
about 1.5 hours before it; the desktop kept working after it, and I
don't know if it's related.

systemd-sleep:

[31192.858314] task:systemd-sleep   state:D stack:0     pid:466006 tgid:466006 ppid:1      task_flags:0x80400100 flags:0x00080800
[31192.858315] Call Trace:
[31192.858315]  <TASK>
[31192.858315]  __schedule+0x400/0x1770
[31192.858317]  schedule+0x28/0xa0
[31192.858317]  schedule_preempt_disabled+0x16/0x30
[31192.858318]  __ww_mutex_lock.constprop.0+0x7cb/0xd40
[31192.858320]  ttm_bo_evict_first+0x14e/0x240 [ttm]
[31192.858323]  ? __pfx_pci_pm_prepare+0x10/0x10
[31192.858325]  ttm_resource_manager_evict_all+0x55/0x220 [ttm]
[31192.858329]  amdgpu_device_evict_resources+0x32/0x80 [amdgpu]
[31192.858430]  amdgpu_device_prepare+0x2f/0xe0 [amdgpu]
[31192.858532]  ? amdgpu_pmops_prepare+0x5b/0xb0 [amdgpu]
[31192.858632]  pci_pm_prepare+0x33/0x80
[31192.858633]  dpm_prepare+0x187/0x4e0
[31192.858635]  dpm_suspend_start+0x1e/0x60
[31192.858636]  suspend_devices_and_enter+0x131/0x8b0
[31192.858638]  pm_suspend.cold+0x2bc/0x336
[31192.858639]  state_store+0x7f/0xf0
[31192.858640]  kernfs_fop_write_iter+0x16b/0x210
[31192.858642]  vfs_write+0x258/0x540
[31192.858644]  ksys_write+0x7b/0x110
[31192.858645]  do_syscall_64+0xce/0x580
[31192.858647]  ? do_user_addr_fault+0x235/0x760
[31192.858648]  ? do_syscall_64+0x35/0x580
[31192.858649]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[31192.858662]  </TASK>

The stuck restore worker:

[31192.862190] task:kworker/0:12    state:D stack:0     pid:466979 tgid:466979 ppid:2      task_flags:0x4208060 flags:0x00080000
[31192.862191] Workqueue: events amdgpu_userq_restore_worker [amdgpu]
[31192.862307] Call Trace:
[31192.862307]  <TASK>
[31192.862307]  __schedule+0x400/0x1770
[31192.862309]  schedule+0x28/0xa0
[31192.862310]  schedule_timeout+0xce/0x120
[31192.862311]  dma_fence_default_wait+0x19b/0x2f0
[31192.862312]  ? __pfx_dma_fence_default_wait_cb+0x10/0x10
[31192.862313]  dma_fence_wait_timeout+0xee/0x1b0
[31192.862314]  amdgpu_userq_vm_validate_and_restore_queue+0x702/0x990 [amdgpu]
[31192.862432]  amdgpu_userq_restore_worker+0xb3/0x1a0 [amdgpu]
[31192.862547]  process_one_work+0x1d6/0x3b0
[31192.862548]  worker_thread+0x1aa/0x310
[31192.862549]  ? __pfx_worker_thread+0x10/0x10
[31192.862550]  kthread+0xe9/0x120
[31192.862551]  ? __pfx_kthread+0x10/0x10
[31192.862551]  ret_from_fork+0x2a9/0x340
[31192.862552]  ? __pfx_kthread+0x10/0x10
[31192.862552]  ret_from_fork_asm+0x1a/0x30
[31192.862554]  </TASK>

I can send the full pstore dump if it helps; the journal of that boot
has nothing beyond the MES timeout above. I'm also happy to test other
patches or collect more data.

Thanks,
Arisa

Arisa Snowbell (1):
  drm/amdgpu/userq: don't restore user queues during system sleep

 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       | 13 +++-
 .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 64 ++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h     |  3 +
 5 files changed, 79 insertions(+), 4 deletions(-)

--
2.56.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep
  2026-11-24  2:32 [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Arisa Snowbell
@ 2026-11-24  2:32 ` Arisa Snowbell
  2026-11-24  8:56   ` sashiko-bot
  2026-11-24 12:15 ` [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Christian König
  2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
  2 siblings, 1 reply; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24  2:32 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alex Deucher, Christian König, Arisa Snowbell

Before system sleep, amdgpu_device_prepare() moves all BOs out of VRAM.
When it evicts a BO of a process with user queues, the eviction fence of
that process signals, and amdgpu_eviction_fence_suspend_worker() queues
the restore worker right away. So the restore worker runs while the
eviction is still going on and does the opposite: it locks the VM and
its BOs, moves them back into VRAM and waits for the page table updates
while still holding the locks. amdgpu_userq_suspend() cancels the
restore worker, but only later, in amdgpu_device_suspend().

On an RX 9070 XT (gfx12) this hung S3 suspend for good after a few hours
of uptime. A restore worker waited forever on a page table update fence
while holding the reservations, and systemd-sleep waited in
ttm_bo_evict_first() for one of them. Why the fence never signaled is
not known, but the eviction should not depend on the restore at all.

Keep the restore out of system sleep:

- Prepare sets a flag that stops the eviction worker from queuing the
  restore, then cancels any restore already queued. The worker checks
  the flag under the userq_mutex, so prepare also takes and releases
  each userq_mutex to wait for a worker that checked it just before.

- amdgpu_userq_resume() does not map the queues of a process whose BOs
  were evicted, as its page tables are out of date. It queues the
  restore worker instead, which validates the BOs, rearms the eviction
  fence and maps the queues. It decides this under the userq_mutex,
  which the eviction worker holds while it signals.

- Complete clears the flag and queues the restore for evicted processes,
  unless the device is still suspended, as it is after the hibernation
  snapshot. A failed prepare does the same.

- The restore worker runs on system_freezable_wq, like the amdkfd
  restore workers, so a restore queued during resume waits until the
  system is thawed.

The flag is needed besides the freezable workqueue because for
hibernation dpm_prepare() runs before freeze_kernel_threads().
amdgpu_userq_ensure_ev_fence() still queues the restore directly, since
only ioctls reach it and user space is frozen by then.

A restore worker that was already stuck before suspend started still
blocks it: hibernation waits for it in amdgpu_userq_block_restore(),
and for S3 and s2idle the freezer gives up after 20 seconds and aborts
the suspend instead of hanging.

Fixes: 44cfdf368fb7 ("drm/amdgpu: resume gfx userqueues")
Signed-off-by: Arisa Snowbell <arisa.snowbell@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       | 13 +++-
 .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 64 ++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h     |  3 +
 5 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c7577b608f3e..db1800421e37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -975,6 +975,7 @@ struct amdgpu_device {
 	bool                            apu_prefer_gtt;
 
 	bool                            userq_halt_for_enforce_isolation;
+	bool                            userq_restore_blocked;
 	struct amdgpu_uid *uid_info;
 
 	struct amdgpu_uma_carveout_info uma_info;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index e3b3a2eebd95..01458a613e21 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2647,6 +2647,7 @@ static int amdgpu_pmops_prepare(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
+	int r;
 
 	/* device maybe not resumed here, return immediately in this case */
 	if (adev->in_s4 && adev->in_suspend)
@@ -2665,12 +2666,20 @@ static int amdgpu_pmops_prepare(struct device *dev)
 	    !amdgpu_acpi_is_s3_active(adev))
 		return 1;
 
-	return amdgpu_device_prepare(drm_dev);
+	amdgpu_userq_block_restore(adev);
+	r = amdgpu_device_prepare(drm_dev);
+	if (r)
+		amdgpu_userq_unblock_restore(adev);
+
+	return r;
 }
 
 static void amdgpu_pmops_complete(struct device *dev)
 {
-	amdgpu_device_complete(dev_get_drvdata(dev));
+	struct drm_device *drm_dev = dev_get_drvdata(dev);
+
+	amdgpu_device_complete(drm_dev);
+	amdgpu_userq_unblock_restore(drm_to_adev(drm_dev));
 }
 
 static int amdgpu_pmops_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index f8652fd0525d..6c06c93d7f7f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
 	dma_fence_put(ev_fence);
 
 	if (!evf_mgr->shutdown)
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		amdgpu_userq_schedule_resume(uq_mgr);
 
 	mutex_unlock(&uq_mgr->userq_mutex);
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 9fc8e9e97595..4dfe2d1e1b5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -428,6 +428,17 @@ static void amdgpu_userq_detach_doorbell(struct amdgpu_usermode_queue *queue)
 	up_read(&adev->reset_domain->sem);
 }
 
+static void amdgpu_userq_queue_restore(struct amdgpu_userq_mgr *uq_mgr)
+{
+	queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
+}
+
+void amdgpu_userq_schedule_resume(struct amdgpu_userq_mgr *uq_mgr)
+{
+	if (!READ_ONCE(uq_mgr->adev->userq_restore_blocked))
+		amdgpu_userq_queue_restore(uq_mgr);
+}
+
 /**
  * amdgpu_userq_ensure_ev_fence - ensure a valid, unsignaled eviction fence exists
  * @uq_mgr: the usermode queue manager for this process
@@ -456,7 +467,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
 		 * Looks like there was no pending resume work,
 		 * add one now to create a valid eviction fence
 		 */
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		amdgpu_userq_queue_restore(uq_mgr);
 		goto retry;
 	}
 	dma_fence_put(ev_fence);
@@ -1428,6 +1439,51 @@ int amdgpu_userq_suspend(struct amdgpu_device *adev)
 	return 0;
 }
 
+static bool amdgpu_userq_evicted(struct amdgpu_userq_mgr *uq_mgr)
+{
+	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
+	struct dma_fence *ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
+	bool evicted = dma_fence_is_signaled(ev_fence);
+
+	dma_fence_put(ev_fence);
+	return evicted;
+}
+
+void amdgpu_userq_block_restore(struct amdgpu_device *adev)
+{
+	struct amdgpu_usermode_queue *queue;
+	struct amdgpu_userq_mgr *uqm;
+	unsigned long queue_id;
+
+	WRITE_ONCE(adev->userq_restore_blocked, true);
+
+	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
+		uqm = queue->userq_mgr;
+		/* Wait out an eviction worker that missed the flag */
+		mutex_lock(&uqm->userq_mutex);
+		mutex_unlock(&uqm->userq_mutex);
+		cancel_delayed_work_sync(&uqm->resume_work);
+	}
+}
+
+void amdgpu_userq_unblock_restore(struct amdgpu_device *adev)
+{
+	struct amdgpu_usermode_queue *queue;
+	struct amdgpu_userq_mgr *uqm;
+	unsigned long queue_id;
+
+	WRITE_ONCE(adev->userq_restore_blocked, false);
+	if (adev->in_suspend)
+		return;
+
+	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
+		uqm = queue->userq_mgr;
+		guard(mutex)(&uqm->userq_mutex);
+		if (amdgpu_userq_evicted(uqm))
+			amdgpu_userq_queue_restore(uqm);
+	}
+}
+
 int amdgpu_userq_resume(struct amdgpu_device *adev)
 {
 	struct amdgpu_usermode_queue *queue;
@@ -1438,6 +1494,12 @@ int amdgpu_userq_resume(struct amdgpu_device *adev)
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		guard(mutex)(&uqm->userq_mutex);
+
+		if (amdgpu_userq_evicted(uqm)) {
+			amdgpu_userq_queue_restore(uqm);
+			continue;
+		}
+
 		if (adev->in_s0ix)
 			r = amdgpu_userq_restore_helper(queue);
 		else
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
index 488dc21d7c81..41d26f95a306 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
@@ -160,6 +160,7 @@ int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *f
 
 void amdgpu_userq_mgr_cancel_reset_work(struct amdgpu_device *adev);
 void amdgpu_userq_mgr_cancel_resume(struct amdgpu_userq_mgr *userq_mgr);
+void amdgpu_userq_schedule_resume(struct amdgpu_userq_mgr *uq_mgr);
 void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr);
 
 void amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr);
@@ -173,6 +174,8 @@ bool amdgpu_userq_enabled(struct drm_device *dev);
 
 int amdgpu_userq_suspend(struct amdgpu_device *adev);
 int amdgpu_userq_resume(struct amdgpu_device *adev);
+void amdgpu_userq_block_restore(struct amdgpu_device *adev);
+void amdgpu_userq_unblock_restore(struct amdgpu_device *adev);
 
 int amdgpu_userq_stop_sched_for_enforce_isolation(struct amdgpu_device *adev,
 						  u32 idx);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep
  2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
@ 2026-11-24  8:56   ` sashiko-bot
  2026-11-24 10:43     ` Arisa Snowbell
  0 siblings, 1 reply; 12+ messages in thread
From: sashiko-bot @ 2026-11-24  8:56 UTC (permalink / raw)
  To: Arisa Snowbell, 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: infinite retry loop in
  amdgpu_userq_ensure_ev_fence() [1]
--

commit 1073e972cefe081a3547954bcb099da6f1184516
Author: Arisa Snowbell <arisa.snowbell@gmail.com>

drm/amdgpu/userq: don't restore user queues during system sleep

This commit blocks user queue restore work from being scheduled during
system sleep preparation and moves the restore worker to
system_freezable_wq so restores do not race with VRAM eviction.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index ed6f3b67e8720..7960341f7f84f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c

[ ... ]

> @@ -453,7 +464,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
>  		 * Looks like there was no pending resume work,
>  		 * add one now to create a valid eviction fence
>  		 */
> -		schedule_delayed_work(&uq_mgr->resume_work, 0);
> +		amdgpu_userq_queue_restore(uq_mgr);
>  		goto retry;

[Severity: High]
This problem wasn't introduced by this patch, but can
amdgpu_userq_ensure_ev_fence() loop forever [1] if
amdgpu_userq_restore_worker() fails to install a new eviction fence?

When amdgpu_userq_vm_validate_and_restore_queue() fails (for example
with -ENOMEM), amdgpu_userq_restore_worker() exits without replacing
the signaled eviction fence:

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_restore_worker() {
    ...
	ret = amdgpu_userq_vm_validate_and_restore_queue(uq_mgr);
	if (ret) {
		drm_file_err(uq_mgr->file, "Failed to validate BOs to restore ret=%d\n", ret);
		goto put_fence;
	}
    ...
}

amdgpu_userq_ensure_ev_fence() then sees the same signaled fence on the
next iteration and re-queues resume_work in an unkillable loop.

[1] https://sashiko.dev/#/bug/linux-d9fc724f-ccb0-417c-8973-b83fdfc48280

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795482456.git.arisa.snowbell@gmail.com?part=1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep
  2026-11-24  8:56   ` sashiko-bot
@ 2026-11-24 10:43     ` Arisa Snowbell
  0 siblings, 0 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 10:43 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: amd-gfx

It needs ensure_ev_fence() to return an error to its ioctl callers. I
can look at it as a separate patch.

On Tue, Nov 24, 2026 at 9:56 AM <sashiko-bot@kernel.org> wrote:
>
> 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: infinite retry loop in
>   amdgpu_userq_ensure_ev_fence() [1]
> --
>
> commit 1073e972cefe081a3547954bcb099da6f1184516
> Author: Arisa Snowbell <arisa.snowbell@gmail.com>
>
> drm/amdgpu/userq: don't restore user queues during system sleep
>
> This commit blocks user queue restore work from being scheduled during
> system sleep preparation and moves the restore worker to
> system_freezable_wq so restores do not race with VRAM eviction.
>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> > index ed6f3b67e8720..7960341f7f84f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>
> [ ... ]
>
> > @@ -453,7 +464,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
> >                * Looks like there was no pending resume work,
> >                * add one now to create a valid eviction fence
> >                */
> > -             schedule_delayed_work(&uq_mgr->resume_work, 0);
> > +             amdgpu_userq_queue_restore(uq_mgr);
> >               goto retry;
>
> [Severity: High]
> This problem wasn't introduced by this patch, but can
> amdgpu_userq_ensure_ev_fence() loop forever [1] if
> amdgpu_userq_restore_worker() fails to install a new eviction fence?
>
> When amdgpu_userq_vm_validate_and_restore_queue() fails (for example
> with -ENOMEM), amdgpu_userq_restore_worker() exits without replacing
> the signaled eviction fence:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_restore_worker() {
>     ...
>         ret = amdgpu_userq_vm_validate_and_restore_queue(uq_mgr);
>         if (ret) {
>                 drm_file_err(uq_mgr->file, "Failed to validate BOs to restore ret=%d\n", ret);
>                 goto put_fence;
>         }
>     ...
> }
>
> amdgpu_userq_ensure_ev_fence() then sees the same signaled fence on the
> next iteration and re-queues resume_work in an unkillable loop.
>
> [1] https://sashiko.dev/#/bug/linux-d9fc724f-ccb0-417c-8973-b83fdfc48280
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795482456.git.arisa.snowbell@gmail.com?part=1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues
  2026-11-24  2:32 [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Arisa Snowbell
  2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
@ 2026-11-24 12:15 ` Christian König
  2026-11-24 13:01   ` Arisa Snowbell
  2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
  2 siblings, 1 reply; 12+ messages in thread
From: Christian König @ 2026-11-24 12:15 UTC (permalink / raw)
  To: Arisa Snowbell, Mario Limonciello, Prosyak, Vitaly, Khatri, Sunil
  Cc: Alex Deucher, amd-gfx

Hi Arisa,

On 11/24/26 03:32, Arisa Snowbell wrote:
> Hi,
> 
> I've been testing user queues on my RX 9070 XT (amdgpu.user_queue=1,
> with AMD_USERQ=1 for everything I run through Steam) and came across a
> suspend hang. After a few hours of uptime, S3 suspend sometimes never
> finishes, and I have to reboot the machine by hand. What I see depends
> on how the suspend started:
> 
> - When the screen locks in parallel with the suspend, the machine
>   freezes on the lock screen.
> - When it locks first, the screens turn off and the suspend starts
>   after that, the screens stay off; the machine looks asleep but never
>   wakes up.
> 
> Either way it never actually sleeps. Short sessions suspend and resume
> fine.

well first of all thanks a lot for testing user queues we haven't got much feedback so far.

So I also have the question if you have encountered any other problems except suspend/resume?

> In short: while amdgpu_device_prepare() evicts VRAM for suspend, the
> user queue restore worker starts and moves the same BOs back. One
> restore worker got stuck waiting on a page table update fence while
> holding the BO locks, and the suspend waited for those locks forever.

Yeah we haven't tested suspend/resume with userqueues yet and I don't think we have a test case for that.

@Vitaly is that right? If yes we should probably create a test case.

> The patch keeps the restore worker out of system sleep; the details are
> in its commit message. It builds cleanly with W=1 against v7.4-rc4 and
> passes checkpatch. I'm running it now: S3 suspend and resume work, also
> with a game on user queues running, which keeps running after resume,
> so the restore worker maps the queues again. It hasn't seen enough long
> sessions with suspends yet to show that the hang is gone, so I'm sending
> it for review first and will report back once I have more runtime on
> it.

That approach looks a bit to complicated, in theory it should work out of the box.

In general the workqueue who executes the restore should been frozen during suspend, so evicting VRAM can then do it's work without userspace interfering.

What could be is that Mario's work to evict VRAM before swapping is disabled somehow broke that.

Or it could be that we are submitting the restore work to a non-freezeable workqeueu.

Either way Sunil should probably take a look after he's back from vacation.

Regards,
Christian.

> 
> System:
> 
>   GPU:      RX 9070 XT, Navi 48 [1002:7550] rev c0, gfx12, MES fw 0x97
>   Kernel:   7.4.0-rc4 (linux-mainline)
>   Firmware: linux-firmware-amdgpu 20261019
>   Mesa:     mesa-git 27.0.0_devel.234528.a54c80d04d3 (RADV)
>   Options:  amdgpu ppfeaturemask=0xfff7ffff user_queue=1 runpm=0
> 
> What I saw:
> 
> The suspend started about 11 hours after boot and never finished. About
> 4 hours later I pressed SysRq w, s and c, and efi-pstore kept the dump.
> 22 tasks were blocked:
> 
> - systemd-sleep, in ttm_bo_evict_first() waiting for a BO lock
> - 3 amdgpu_userq_restore_worker: one waiting on a page table update
>   fence, two waiting for its locks
> - 12 amdgpu_tlb_fence_work, waiting on their page table update fences
> - 5 ttm_bo_delayed_delete, waiting on BO fences
> 
> All the workers except one TLB fence worker have higher PIDs than
> systemd-sleep, so they started after the suspend did.
> 
> The earlier suspends of that boot worked. The only amdgpu error before
> the hang was one "MES(1) failed to respond to msg=INVALIDATE_TLBS"
> about 1.5 hours before it; the desktop kept working after it, and I
> don't know if it's related.
> 
> systemd-sleep:
> 
> [31192.858314] task:systemd-sleep   state:D stack:0     pid:466006 tgid:466006 ppid:1      task_flags:0x80400100 flags:0x00080800
> [31192.858315] Call Trace:
> [31192.858315]  <TASK>
> [31192.858315]  __schedule+0x400/0x1770
> [31192.858317]  schedule+0x28/0xa0
> [31192.858317]  schedule_preempt_disabled+0x16/0x30
> [31192.858318]  __ww_mutex_lock.constprop.0+0x7cb/0xd40
> [31192.858320]  ttm_bo_evict_first+0x14e/0x240 [ttm]
> [31192.858323]  ? __pfx_pci_pm_prepare+0x10/0x10
> [31192.858325]  ttm_resource_manager_evict_all+0x55/0x220 [ttm]
> [31192.858329]  amdgpu_device_evict_resources+0x32/0x80 [amdgpu]
> [31192.858430]  amdgpu_device_prepare+0x2f/0xe0 [amdgpu]
> [31192.858532]  ? amdgpu_pmops_prepare+0x5b/0xb0 [amdgpu]
> [31192.858632]  pci_pm_prepare+0x33/0x80
> [31192.858633]  dpm_prepare+0x187/0x4e0
> [31192.858635]  dpm_suspend_start+0x1e/0x60
> [31192.858636]  suspend_devices_and_enter+0x131/0x8b0
> [31192.858638]  pm_suspend.cold+0x2bc/0x336
> [31192.858639]  state_store+0x7f/0xf0
> [31192.858640]  kernfs_fop_write_iter+0x16b/0x210
> [31192.858642]  vfs_write+0x258/0x540
> [31192.858644]  ksys_write+0x7b/0x110
> [31192.858645]  do_syscall_64+0xce/0x580
> [31192.858647]  ? do_user_addr_fault+0x235/0x760
> [31192.858648]  ? do_syscall_64+0x35/0x580
> [31192.858649]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
> [31192.858662]  </TASK>
> 
> The stuck restore worker:
> 
> [31192.862190] task:kworker/0:12    state:D stack:0     pid:466979 tgid:466979 ppid:2      task_flags:0x4208060 flags:0x00080000
> [31192.862191] Workqueue: events amdgpu_userq_restore_worker [amdgpu]
> [31192.862307] Call Trace:
> [31192.862307]  <TASK>
> [31192.862307]  __schedule+0x400/0x1770
> [31192.862309]  schedule+0x28/0xa0
> [31192.862310]  schedule_timeout+0xce/0x120
> [31192.862311]  dma_fence_default_wait+0x19b/0x2f0
> [31192.862312]  ? __pfx_dma_fence_default_wait_cb+0x10/0x10
> [31192.862313]  dma_fence_wait_timeout+0xee/0x1b0
> [31192.862314]  amdgpu_userq_vm_validate_and_restore_queue+0x702/0x990 [amdgpu]
> [31192.862432]  amdgpu_userq_restore_worker+0xb3/0x1a0 [amdgpu]
> [31192.862547]  process_one_work+0x1d6/0x3b0
> [31192.862548]  worker_thread+0x1aa/0x310
> [31192.862549]  ? __pfx_worker_thread+0x10/0x10
> [31192.862550]  kthread+0xe9/0x120
> [31192.862551]  ? __pfx_kthread+0x10/0x10
> [31192.862551]  ret_from_fork+0x2a9/0x340
> [31192.862552]  ? __pfx_kthread+0x10/0x10
> [31192.862552]  ret_from_fork_asm+0x1a/0x30
> [31192.862554]  </TASK>
> 
> I can send the full pstore dump if it helps; the journal of that boot
> has nothing beyond the MES timeout above. I'm also happy to test other
> patches or collect more data.
> 
> Thanks,
> Arisa
> 
> Arisa Snowbell (1):
>   drm/amdgpu/userq: don't restore user queues during system sleep
> 
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       | 13 +++-
>  .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 64 ++++++++++++++++++-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h     |  3 +
>  5 files changed, 79 insertions(+), 4 deletions(-)
> 
> --
> 2.56.1
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues
  2026-11-24 12:15 ` [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Christian König
@ 2026-11-24 13:01   ` Arisa Snowbell
  0 siblings, 0 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 13:01 UTC (permalink / raw)
  To: Christian König
  Cc: Mario Limonciello, Prosyak, Vitaly, Khatri, Sunil, Alex Deucher,
	amd-gfx

Hi Christian,

On 11/24/26, Christian König wrote:
> So I also have the question if you have encountered any other problems
> except suspend/resume?

Apart from the suspend hang, two things:

- "MES(1) failed to respond to msg=INVALIDATE_TLBS", like the one
  before the hang in the report. It has shown up a few times under
  different kinds of heavy load, also when nothing was using user
  queues, but I never saw it before I enabled amdgpu.user_queue=1. The
  desktop kept working each time.

- After S3 resume, a D3D12 game (Hunt: Showdown 1896 through
  vkd3d-proton) keeps running but renders wrong until it is restarted.
  It happens with kernel queues too, so it doesn't look like a user
  queue problem, though the artifacts look different with user queues.

Otherwise games and the desktop have run fine on user queues so far.
Maybe that's why there's so little feedback: it just works pretty well.

> In general the workqueue who executes the restore should been frozen
> during suspend, so evicting VRAM can then do it's work without
> userspace interfering.
[...]
> Or it could be that we are submitting the restore work to a
> non-freezeable workqeueu.

Oh I see, amdgpu_eviction_fence_suspend_worker() and
amdgpu_userq_ensure_ev_fence() queue resume_work with
schedule_delayed_work(), so it runs on system_wq. The stuck worker in
the dump shows "Workqueue: events amdgpu_userq_restore_worker", and the
eviction there comes from amdgpu_device_prepare(), which runs after
freeze_kernel_threads(), so a freezable workqueue would have held the
restore back.

I took a quick look and I think the patch can be simplified a lot. In
v1 I also claimed that hibernation calls dpm_prepare() before freezing
kernel threads, and that was the only reason for the extra flag. I'll
send a v2 that only moves the restore worker to system_freezable_wq.

One thing v1 also changed and v2 will leave alone: amdgpu_userq_resume()
maps the queues again even when the BOs of the process were evicted
before suspend, while only the restore worker validates them and
updates the page tables. With v2 nothing queues that restore at resume;
it runs with the next signal ioctl. Is it fine for the queues to run
before that, or should resume queue the restore instead of mapping?

Thanks,
Arisa

On Tue, Nov 24, 2026 at 1:15 PM Christian König
<christian.koenig@amd.com> wrote:
>
> Hi Arisa,
>
> On 11/24/26 03:32, Arisa Snowbell wrote:
> > Hi,
> >
> > I've been testing user queues on my RX 9070 XT (amdgpu.user_queue=1,
> > with AMD_USERQ=1 for everything I run through Steam) and came across a
> > suspend hang. After a few hours of uptime, S3 suspend sometimes never
> > finishes, and I have to reboot the machine by hand. What I see depends
> > on how the suspend started:
> >
> > - When the screen locks in parallel with the suspend, the machine
> >   freezes on the lock screen.
> > - When it locks first, the screens turn off and the suspend starts
> >   after that, the screens stay off; the machine looks asleep but never
> >   wakes up.
> >
> > Either way it never actually sleeps. Short sessions suspend and resume
> > fine.
>
> well first of all thanks a lot for testing user queues we haven't got much feedback so far.
>
> So I also have the question if you have encountered any other problems except suspend/resume?
>
> > In short: while amdgpu_device_prepare() evicts VRAM for suspend, the
> > user queue restore worker starts and moves the same BOs back. One
> > restore worker got stuck waiting on a page table update fence while
> > holding the BO locks, and the suspend waited for those locks forever.
>
> Yeah we haven't tested suspend/resume with userqueues yet and I don't think we have a test case for that.
>
> @Vitaly is that right? If yes we should probably create a test case.
>
> > The patch keeps the restore worker out of system sleep; the details are
> > in its commit message. It builds cleanly with W=1 against v7.4-rc4 and
> > passes checkpatch. I'm running it now: S3 suspend and resume work, also
> > with a game on user queues running, which keeps running after resume,
> > so the restore worker maps the queues again. It hasn't seen enough long
> > sessions with suspends yet to show that the hang is gone, so I'm sending
> > it for review first and will report back once I have more runtime on
> > it.
>
> That approach looks a bit to complicated, in theory it should work out of the box.
>
> In general the workqueue who executes the restore should been frozen during suspend, so evicting VRAM can then do it's work without userspace interfering.
>
> What could be is that Mario's work to evict VRAM before swapping is disabled somehow broke that.
>
> Or it could be that we are submitting the restore work to a non-freezeable workqeueu.
>
> Either way Sunil should probably take a look after he's back from vacation.
>
> Regards,
> Christian.
>
> >
> > System:
> >
> >   GPU:      RX 9070 XT, Navi 48 [1002:7550] rev c0, gfx12, MES fw 0x97
> >   Kernel:   7.4.0-rc4 (linux-mainline)
> >   Firmware: linux-firmware-amdgpu 20261019
> >   Mesa:     mesa-git 27.0.0_devel.234528.a54c80d04d3 (RADV)
> >   Options:  amdgpu ppfeaturemask=0xfff7ffff user_queue=1 runpm=0
> >
> > What I saw:
> >
> > The suspend started about 11 hours after boot and never finished. About
> > 4 hours later I pressed SysRq w, s and c, and efi-pstore kept the dump.
> > 22 tasks were blocked:
> >
> > - systemd-sleep, in ttm_bo_evict_first() waiting for a BO lock
> > - 3 amdgpu_userq_restore_worker: one waiting on a page table update
> >   fence, two waiting for its locks
> > - 12 amdgpu_tlb_fence_work, waiting on their page table update fences
> > - 5 ttm_bo_delayed_delete, waiting on BO fences
> >
> > All the workers except one TLB fence worker have higher PIDs than
> > systemd-sleep, so they started after the suspend did.
> >
> > The earlier suspends of that boot worked. The only amdgpu error before
> > the hang was one "MES(1) failed to respond to msg=INVALIDATE_TLBS"
> > about 1.5 hours before it; the desktop kept working after it, and I
> > don't know if it's related.
> >
> > systemd-sleep:
> >
> > [31192.858314] task:systemd-sleep   state:D stack:0     pid:466006 tgid:466006 ppid:1      task_flags:0x80400100 flags:0x00080800
> > [31192.858315] Call Trace:
> > [31192.858315]  <TASK>
> > [31192.858315]  __schedule+0x400/0x1770
> > [31192.858317]  schedule+0x28/0xa0
> > [31192.858317]  schedule_preempt_disabled+0x16/0x30
> > [31192.858318]  __ww_mutex_lock.constprop.0+0x7cb/0xd40
> > [31192.858320]  ttm_bo_evict_first+0x14e/0x240 [ttm]
> > [31192.858323]  ? __pfx_pci_pm_prepare+0x10/0x10
> > [31192.858325]  ttm_resource_manager_evict_all+0x55/0x220 [ttm]
> > [31192.858329]  amdgpu_device_evict_resources+0x32/0x80 [amdgpu]
> > [31192.858430]  amdgpu_device_prepare+0x2f/0xe0 [amdgpu]
> > [31192.858532]  ? amdgpu_pmops_prepare+0x5b/0xb0 [amdgpu]
> > [31192.858632]  pci_pm_prepare+0x33/0x80
> > [31192.858633]  dpm_prepare+0x187/0x4e0
> > [31192.858635]  dpm_suspend_start+0x1e/0x60
> > [31192.858636]  suspend_devices_and_enter+0x131/0x8b0
> > [31192.858638]  pm_suspend.cold+0x2bc/0x336
> > [31192.858639]  state_store+0x7f/0xf0
> > [31192.858640]  kernfs_fop_write_iter+0x16b/0x210
> > [31192.858642]  vfs_write+0x258/0x540
> > [31192.858644]  ksys_write+0x7b/0x110
> > [31192.858645]  do_syscall_64+0xce/0x580
> > [31192.858647]  ? do_user_addr_fault+0x235/0x760
> > [31192.858648]  ? do_syscall_64+0x35/0x580
> > [31192.858649]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
> > [31192.858662]  </TASK>
> >
> > The stuck restore worker:
> >
> > [31192.862190] task:kworker/0:12    state:D stack:0     pid:466979 tgid:466979 ppid:2      task_flags:0x4208060 flags:0x00080000
> > [31192.862191] Workqueue: events amdgpu_userq_restore_worker [amdgpu]
> > [31192.862307] Call Trace:
> > [31192.862307]  <TASK>
> > [31192.862307]  __schedule+0x400/0x1770
> > [31192.862309]  schedule+0x28/0xa0
> > [31192.862310]  schedule_timeout+0xce/0x120
> > [31192.862311]  dma_fence_default_wait+0x19b/0x2f0
> > [31192.862312]  ? __pfx_dma_fence_default_wait_cb+0x10/0x10
> > [31192.862313]  dma_fence_wait_timeout+0xee/0x1b0
> > [31192.862314]  amdgpu_userq_vm_validate_and_restore_queue+0x702/0x990 [amdgpu]
> > [31192.862432]  amdgpu_userq_restore_worker+0xb3/0x1a0 [amdgpu]
> > [31192.862547]  process_one_work+0x1d6/0x3b0
> > [31192.862548]  worker_thread+0x1aa/0x310
> > [31192.862549]  ? __pfx_worker_thread+0x10/0x10
> > [31192.862550]  kthread+0xe9/0x120
> > [31192.862551]  ? __pfx_kthread+0x10/0x10
> > [31192.862551]  ret_from_fork+0x2a9/0x340
> > [31192.862552]  ? __pfx_kthread+0x10/0x10
> > [31192.862552]  ret_from_fork_asm+0x1a/0x30
> > [31192.862554]  </TASK>
> >
> > I can send the full pstore dump if it helps; the journal of that boot
> > has nothing beyond the MES timeout above. I'm also happy to test other
> > patches or collect more data.
> >
> > Thanks,
> > Arisa
> >
> > Arisa Snowbell (1):
> >   drm/amdgpu/userq: don't restore user queues during system sleep
> >
> >  drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       | 13 +++-
> >  .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 64 ++++++++++++++++++-
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h     |  3 +
> >  5 files changed, 79 insertions(+), 4 deletions(-)
> >
> > --
> > 2.56.1
> >
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue
  2026-11-24  2:32 [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Arisa Snowbell
  2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
  2026-11-24 12:15 ` [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Christian König
@ 2026-11-24 13:02 ` Arisa Snowbell
  2026-11-24 13:51   ` Arisa Snowbell
                     ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 13:02 UTC (permalink / raw)
  To: amd-gfx
  Cc: Mario Limonciello, Vitaly Prosyak, Sunil Khatri, Alex Deucher,
	Christian König, Arisa Snowbell

Before system sleep, amdgpu_device_prepare() moves all BOs out of VRAM.
When it evicts a BO of a process with user queues, the eviction fence of
that process signals, and amdgpu_eviction_fence_suspend_worker() queues
the restore worker on system_wq. That workqueue is not frozen, so the
restore worker runs while the eviction is still going on and moves the
BOs back into VRAM, waiting for the page table updates while it holds
their reservations.

On an RX 9070 XT (gfx12) this hung S3 suspend for good after a few hours
of uptime. A restore worker waited forever on a page table update fence
while holding the reservations, and systemd-sleep waited in
ttm_bo_evict_first() for one of them.

Queue the restore worker on system_freezable_wq, like the amdkfd restore
workers. Its work is frozen before dpm_prepare(), so a restore queued
during the eviction stays pending until amdgpu_userq_suspend() cancels
it.

Fixes: 44cfdf368fb7 ("drm/amdgpu: resume gfx userqueues")
Signed-off-by: Arisa Snowbell <arisa.snowbell@gmail.com>
---
v2: drop the restore block flag and the resume changes, only move the
    restore worker to system_freezable_wq (Christian). v1 claimed that
    for hibernation dpm_prepare() runs before freeze_kernel_threads(),
    which is wrong.

 drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index f8652fd0525d..18b11d7f457e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
 	dma_fence_put(ev_fence);
 
 	if (!evf_mgr->shutdown)
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
 
 	mutex_unlock(&uq_mgr->userq_mutex);
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 9fc8e9e97595..f52c2096c5b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -456,7 +456,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
 		 * Looks like there was no pending resume work,
 		 * add one now to create a valid eviction fence
 		 */
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
 		goto retry;
 	}
 	dma_fence_put(ev_fence);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue
  2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
@ 2026-11-24 13:51   ` Arisa Snowbell
  2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
  2026-11-24 16:14   ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue sashiko-bot
  2 siblings, 0 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 13:51 UTC (permalink / raw)
  To: amd-gfx
  Cc: Mario Limonciello, Vitaly Prosyak, Sunil Khatri, Alex Deucher,
	Christian König

Hi,

Turns out I found the answer to my own question while testing, sorry
for the extra mail. v2 on its own isn't enough: with Hyprland on user
queues, the first S3 resume failed when amdgpu_userq_resume() mapped
the queues again:

  MES(0) failed to respond to msg=ADD_QUEUE fence_wait_ret=0 status=0x0_0
  [drm:mes_userq_map [amdgpu]] *ERROR* Failed to map queue in HW, err (-110)
  amdgpu 0000:03:00.0: PM: dpm_run_callback(): pci_pm_resume returns -110

With the restore worker frozen, the BOs are still evicted at that
point. Queuing the restore worker for evicted processes, instead of
mapping their queues in resume, fixes it for me: the desktop and a game,
both on user queues, came back fine after resume. I'll send that as v3
after a few more suspends.

Thanks,
Arisa

On Tue, Nov 24, 2026 at 2:04 PM Arisa Snowbell <arisa.snowbell@gmail.com> wrote:
>
> Before system sleep, amdgpu_device_prepare() moves all BOs out of VRAM.
> When it evicts a BO of a process with user queues, the eviction fence of
> that process signals, and amdgpu_eviction_fence_suspend_worker() queues
> the restore worker on system_wq. That workqueue is not frozen, so the
> restore worker runs while the eviction is still going on and moves the
> BOs back into VRAM, waiting for the page table updates while it holds
> their reservations.
>
> On an RX 9070 XT (gfx12) this hung S3 suspend for good after a few hours
> of uptime. A restore worker waited forever on a page table update fence
> while holding the reservations, and systemd-sleep waited in
> ttm_bo_evict_first() for one of them.
>
> Queue the restore worker on system_freezable_wq, like the amdkfd restore
> workers. Its work is frozen before dpm_prepare(), so a restore queued
> during the eviction stays pending until amdgpu_userq_suspend() cancels
> it.
>
> Fixes: 44cfdf368fb7 ("drm/amdgpu: resume gfx userqueues")
> Signed-off-by: Arisa Snowbell <arisa.snowbell@gmail.com>
> ---
> v2: drop the restore block flag and the resume changes, only move the
>     restore worker to system_freezable_wq (Christian). v1 claimed that
>     for hibernation dpm_prepare() runs before freeze_kernel_threads(),
>     which is wrong.
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> index f8652fd0525d..18b11d7f457e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> @@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
>         dma_fence_put(ev_fence);
>
>         if (!evf_mgr->shutdown)
> -               schedule_delayed_work(&uq_mgr->resume_work, 0);
> +               queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>
>         mutex_unlock(&uq_mgr->userq_mutex);
>  }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 9fc8e9e97595..f52c2096c5b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -456,7 +456,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
>                  * Looks like there was no pending resume work,
>                  * add one now to create a valid eviction fence
>                  */
> -               schedule_delayed_work(&uq_mgr->resume_work, 0);
> +               queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>                 goto retry;
>         }
>         dma_fence_put(ev_fence);
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep
  2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
  2026-11-24 13:51   ` Arisa Snowbell
@ 2026-11-24 14:14   ` Arisa Snowbell
  2026-11-24 14:16     ` Arisa Snowbell
  2026-11-24 16:23     ` sashiko-bot
  2026-11-24 16:14   ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue sashiko-bot
  2 siblings, 2 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 14:14 UTC (permalink / raw)
  To: amd-gfx
  Cc: Christian König, Alex Deucher, Mario Limonciello,
	Vitaly Prosyak, Sunil Khatri, Arisa Snowbell

Before system sleep, amdgpu_device_prepare() moves all BOs out of VRAM.
When it evicts a BO of a process with user queues, the eviction fence of
that process signals, and amdgpu_eviction_fence_suspend_worker() queues
the restore worker on system_wq. That workqueue is not frozen, so the
restore worker runs while the eviction is still going on and moves the
BOs back into VRAM, waiting for the page table updates while it holds
their reservations.

On an RX 9070 XT (gfx12) this hung S3 suspend for good after a few hours
of uptime. A restore worker waited forever on a page table update fence
while holding the reservations, and systemd-sleep waited in
ttm_bo_evict_first() for one of them.

Queue the restore worker on system_freezable_wq, like the amdkfd restore
workers. Its work is frozen before dpm_prepare(), so a restore queued
during the eviction stays pending until amdgpu_userq_suspend() cancels
it.

The processes are then still evicted at resume, so amdgpu_userq_resume()
must not map their queues: their BOs are not validated and their page
tables are out of date. Mapping them made MES time out on ADD_QUEUE and
the resume fail with -110. Queue the restore worker for them instead,
which validates the BOs, rearms the eviction fence and maps the queues
once the system is thawed.

Fixes: 44cfdf368fb7 ("drm/amdgpu: resume gfx userqueues")
Signed-off-by: Arisa Snowbell <arisa.snowbell@gmail.com>
---
v3: bring back the resume change from v1: amdgpu_userq_resume() does not
    map the queues of processes whose BOs are evicted, and queues the
    restore worker for them instead. With v2 alone, resume mapped them
    with the BOs still evicted, MES timed out on ADD_QUEUE and the resume
    failed with -110.

v2: drop the restore block flag and the resume changes, only move the
    restore worker to system_freezable_wq (Christian). v1 claimed that
    for hibernation dpm_prepare() runs before freeze_kernel_threads(),
    which is wrong.

Tested with S3 on an RX 9070 XT, with the desktop (Hyprland) and a game
on user queues: suspend and resume complete and the queues keep running.
Rendering after resume is still corrupted (the game, and small artifacts
on the desktop), but that also happens with kernel queues; I'll report
it separately.

 .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
index f8652fd0525d..18b11d7f457e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
@@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
 	dma_fence_put(ev_fence);
 
 	if (!evf_mgr->shutdown)
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
 
 	mutex_unlock(&uq_mgr->userq_mutex);
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index 9fc8e9e97595..4f41163a0a55 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -456,7 +456,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
 		 * Looks like there was no pending resume work,
 		 * add one now to create a valid eviction fence
 		 */
-		schedule_delayed_work(&uq_mgr->resume_work, 0);
+		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
 		goto retry;
 	}
 	dma_fence_put(ev_fence);
@@ -1428,6 +1428,16 @@ int amdgpu_userq_suspend(struct amdgpu_device *adev)
 	return 0;
 }
 
+static bool amdgpu_userq_evicted(struct amdgpu_userq_mgr *uq_mgr)
+{
+	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
+	struct dma_fence *ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
+	bool evicted = dma_fence_is_signaled(ev_fence);
+
+	dma_fence_put(ev_fence);
+	return evicted;
+}
+
 int amdgpu_userq_resume(struct amdgpu_device *adev)
 {
 	struct amdgpu_usermode_queue *queue;
@@ -1438,6 +1448,13 @@ int amdgpu_userq_resume(struct amdgpu_device *adev)
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		guard(mutex)(&uqm->userq_mutex);
+
+		/* The BOs moved, let the restore worker validate them first */
+		if (amdgpu_userq_evicted(uqm)) {
+			queue_delayed_work(system_freezable_wq, &uqm->resume_work, 0);
+			continue;
+		}
+
 		if (adev->in_s0ix)
 			r = amdgpu_userq_restore_helper(queue);
 		else
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep
  2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
@ 2026-11-24 14:16     ` Arisa Snowbell
  2026-11-24 16:23     ` sashiko-bot
  1 sibling, 0 replies; 12+ messages in thread
From: Arisa Snowbell @ 2026-11-24 14:16 UTC (permalink / raw)
  To: amd-gfx
  Cc: Christian König, Alex Deucher, Mario Limonciello,
	Vitaly Prosyak, Sunil Khatri

Hi,

Now that suspend works with user queues, I ran into another userq bug.
About ten minutes after a clean resume, while I was moving a window, the
eviction of Firefox's video decoder process failed because MES stopped
answering REMOVE_QUEUE:

  MES(0) failed to respond to msg=REMOVE_QUEUE fence_wait_ret=453176
status=0x81000301_0
  [drm:mes_userq_unmap [amdgpu]] *ERROR* Failed to unmap queue in HW, err (-110)
  comm: RDD Process pid: 6022 client-id:44 client: Unset ... Couldn't
unmap all the queues, eviction failed ret=-110

After the GPU reset that followed, the desktop locked up: the eviction
fence suspend worker sat in amdgpu_userq_wait_for_signal() holding the
userq_mutex, and Hyprland blocked on that mutex in
amdgpu_userq_ensure_ev_fence().

This patch doesn't touch that path, and I've seen MES time out under
heavy load without any suspend before, so I don't think the suspend
caused it. It's a separate bug, but suspend with user queues should be
working now. I'll try to reproduce it without suspending and grab the
devcoredump, then report it separately.

Sorry again for all the extra mails.

Thanks,
Arisa

On Tue, Nov 24, 2026 at 3:14 PM Arisa Snowbell <arisa.snowbell@gmail.com> wrote:
>
> Before system sleep, amdgpu_device_prepare() moves all BOs out of VRAM.
> When it evicts a BO of a process with user queues, the eviction fence of
> that process signals, and amdgpu_eviction_fence_suspend_worker() queues
> the restore worker on system_wq. That workqueue is not frozen, so the
> restore worker runs while the eviction is still going on and moves the
> BOs back into VRAM, waiting for the page table updates while it holds
> their reservations.
>
> On an RX 9070 XT (gfx12) this hung S3 suspend for good after a few hours
> of uptime. A restore worker waited forever on a page table update fence
> while holding the reservations, and systemd-sleep waited in
> ttm_bo_evict_first() for one of them.
>
> Queue the restore worker on system_freezable_wq, like the amdkfd restore
> workers. Its work is frozen before dpm_prepare(), so a restore queued
> during the eviction stays pending until amdgpu_userq_suspend() cancels
> it.
>
> The processes are then still evicted at resume, so amdgpu_userq_resume()
> must not map their queues: their BOs are not validated and their page
> tables are out of date. Mapping them made MES time out on ADD_QUEUE and
> the resume fail with -110. Queue the restore worker for them instead,
> which validates the BOs, rearms the eviction fence and maps the queues
> once the system is thawed.
>
> Fixes: 44cfdf368fb7 ("drm/amdgpu: resume gfx userqueues")
> Signed-off-by: Arisa Snowbell <arisa.snowbell@gmail.com>
> ---
> v3: bring back the resume change from v1: amdgpu_userq_resume() does not
>     map the queues of processes whose BOs are evicted, and queues the
>     restore worker for them instead. With v2 alone, resume mapped them
>     with the BOs still evicted, MES timed out on ADD_QUEUE and the resume
>     failed with -110.
>
> v2: drop the restore block flag and the resume changes, only move the
>     restore worker to system_freezable_wq (Christian). v1 claimed that
>     for hibernation dpm_prepare() runs before freeze_kernel_threads(),
>     which is wrong.
>
> Tested with S3 on an RX 9070 XT, with the desktop (Hyprland) and a game
> on user queues: suspend and resume complete and the queues keep running.
> Rendering after resume is still corrupted (the game, and small artifacts
> on the desktop), but that also happens with kernel queues; I'll report
> it separately.
>
>  .../drm/amd/amdgpu/amdgpu_eviction_fence.c    |  2 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c     | 19 ++++++++++++++++++-
>  2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> index f8652fd0525d..18b11d7f457e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> @@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
>         dma_fence_put(ev_fence);
>
>         if (!evf_mgr->shutdown)
> -               schedule_delayed_work(&uq_mgr->resume_work, 0);
> +               queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>
>         mutex_unlock(&uq_mgr->userq_mutex);
>  }
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 9fc8e9e97595..4f41163a0a55 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -456,7 +456,7 @@ amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *uq_mgr,
>                  * Looks like there was no pending resume work,
>                  * add one now to create a valid eviction fence
>                  */
> -               schedule_delayed_work(&uq_mgr->resume_work, 0);
> +               queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>                 goto retry;
>         }
>         dma_fence_put(ev_fence);
> @@ -1428,6 +1428,16 @@ int amdgpu_userq_suspend(struct amdgpu_device *adev)
>         return 0;
>  }
>
> +static bool amdgpu_userq_evicted(struct amdgpu_userq_mgr *uq_mgr)
> +{
> +       struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
> +       struct dma_fence *ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
> +       bool evicted = dma_fence_is_signaled(ev_fence);
> +
> +       dma_fence_put(ev_fence);
> +       return evicted;
> +}
> +
>  int amdgpu_userq_resume(struct amdgpu_device *adev)
>  {
>         struct amdgpu_usermode_queue *queue;
> @@ -1438,6 +1448,13 @@ int amdgpu_userq_resume(struct amdgpu_device *adev)
>         xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
>                 uqm = queue->userq_mgr;
>                 guard(mutex)(&uqm->userq_mutex);
> +
> +               /* The BOs moved, let the restore worker validate them first */
> +               if (amdgpu_userq_evicted(uqm)) {
> +                       queue_delayed_work(system_freezable_wq, &uqm->resume_work, 0);
> +                       continue;
> +               }
> +
>                 if (adev->in_s0ix)
>                         r = amdgpu_userq_restore_helper(queue);
>                 else
> --
> 2.56.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue
  2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
  2026-11-24 13:51   ` Arisa Snowbell
  2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
@ 2026-11-24 16:14   ` sashiko-bot
  2 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-24 16:14 UTC (permalink / raw)
  To: Arisa Snowbell, amd-gfx

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu/userq: canceled resume_work leaves VM unvalidated in
  amdgpu_userq_resume()
--

commit 5bc8d4302fb0871c6ac59bea95139558edabb658
Author: Arisa Snowbell <arisa.snowbell@gmail.com>

drm/amdgpu/userq: queue the restore worker on a freezable workqueue

This commit moves the userqueue restore worker from system_wq to
system_freezable_wq so it does not run concurrently with VRAM BO eviction
during amdgpu_device_prepare().

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> index 2924f34da316a..358a6c8ce45f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> @@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
>  	dma_fence_put(ev_fence);
>  
>  	if (!evf_mgr->shutdown)
> -		schedule_delayed_work(&uq_mgr->resume_work, 0);
> +		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>  
>  	mutex_unlock(&uq_mgr->userq_mutex);
>  }

[Severity: High]
Does canceling uq_mgr->resume_work in amdgpu_userq_suspend() leave the
process's VM unvalidated and its eviction fence signaled on resume?

When amdgpu_device_prepare() evicts VRAM BOs,
amdgpu_eviction_fence_suspend_worker() unmaps the user queues, signals
ev_fence, and queues uq_mgr->resume_work on system_freezable_wq.  Because
system_freezable_wq is already frozen, uq_mgr->resume_work stays pending
while the remaining BOs (including vm->root.bo and page tables) are
evicted, and amdgpu_userq_suspend() then cancels it:

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_suspend() {
    ...
	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
		uqm = queue->userq_mgr;
		cancel_delayed_work_sync(&uqm->resume_work);
    ...
}

On resume, amdgpu_userq_resume() never re-queues uqm->resume_work or
calls amdgpu_userq_vm_validate_and_restore_queue():

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c:amdgpu_userq_resume() {
    ...
	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
		uqm = queue->userq_mgr;
		guard(mutex)(&uqm->userq_mutex);
		if (adev->in_s0ix)
			r = amdgpu_userq_restore_helper(queue);
		else
			r = amdgpu_userq_map_helper(queue);
    ...
}

For S3 and S4, amdgpu_userq_map_helper() maps the queue in MES while the
VM BOs and page tables are still evicted and ev_fence remains signaled,
causing GPU page faults or MES mapping failures.  In addition, because
amdgpu_userq_map_helper() sets queue->state to AMDGPU_USERQ_STATE_MAPPED,
a later resume_work run that moves vm->root.bo back to VRAM will see
queue->state != AMDGPU_USERQ_STATE_UNMAPPED and skip updating MES with
the new page table base address.  For dGPU S0ix, queue->state was already
set to AMDGPU_USERQ_STATE_UNMAPPED during amdgpu_device_prepare(), so
amdgpu_userq_restore_helper() (which only restores
AMDGPU_USERQ_STATE_PREEMPTED queues) is a no-op and the queue stays
unmapped.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124130258.1270242-1-arisa.snowbell@gmail.com?part=1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep
  2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
  2026-11-24 14:16     ` Arisa Snowbell
@ 2026-11-24 16:23     ` sashiko-bot
  1 sibling, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-24 16:23 UTC (permalink / raw)
  To: Arisa Snowbell, amd-gfx

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amdgpu/userq: system_freezable_wq is not frozen during
  hibernation dpm_prepare()
--

commit f10cd6c65f3801c912d63876fd1a81a692e96c5a
Author: Arisa Snowbell <arisa.snowbell@gmail.com>

drm/amdgpu/userq: keep the restore worker out of system sleep

This commit moves the user queue restore worker (resume_work) to
system_freezable_wq and skips mapping evicted queues in
amdgpu_userq_resume(), queuing the restore worker for them instead.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> index 2924f34da316a..358a6c8ce45f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
> @@ -91,7 +91,7 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work)
>  	dma_fence_put(ev_fence);
>  
>  	if (!evf_mgr->shutdown)
> -		schedule_delayed_work(&uq_mgr->resume_work, 0);
> +		queue_delayed_work(system_freezable_wq, &uq_mgr->resume_work, 0);
>  
>  	mutex_unlock(&uq_mgr->userq_mutex);
>  }

[Severity: High]
Can uq_mgr->resume_work still run during amdgpu_device_prepare() on the
hibernation (S4) path?

In hibernate(), freeze_processes() passes user_only = true to
try_to_freeze_tasks(), which skips freeze_workqueues_begin().
hibernation_snapshot() then calls dpm_prepare(PMSG_FREEZE) before
freeze_kernel_threads() freezes freezable workqueues:

kernel/power/hibernate.c:hibernation_snapshot() {
	...
	error = dpm_prepare(PMSG_FREEZE);
	if (error)
		goto Complete;

	/* Preallocate image memory before freezing kernel threads and shutting down devices. */
	error = hibernate_preallocate_memory();
	if (error)
		goto Complete;

	error = freeze_kernel_threads();
	...
}

When amdgpu_pmops_prepare() -> amdgpu_device_prepare() ->
amdgpu_device_evict_resources() evicts a user queue BO during hibernation
prepare, system_freezable_wq is not frozen yet, so uq_mgr->resume_work
runs immediately and can still deadlock with ttm_bo_evict_first() on the
BO reservations or move evicted BOs back into VRAM before
freeze_kernel_threads() runs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124141416.11034-1-arisa.snowbell@gmail.com?part=1

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-11-24 16:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  2:32 [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Arisa Snowbell
2026-11-24  2:32 ` [PATCH 1/1] drm/amdgpu/userq: don't restore user queues during system sleep Arisa Snowbell
2026-11-24  8:56   ` sashiko-bot
2026-11-24 10:43     ` Arisa Snowbell
2026-11-24 12:15 ` [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues Christian König
2026-11-24 13:01   ` Arisa Snowbell
2026-11-24 13:02 ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue Arisa Snowbell
2026-11-24 13:51   ` Arisa Snowbell
2026-11-24 14:14   ` [PATCH v3] drm/amdgpu/userq: keep the restore worker out of system sleep Arisa Snowbell
2026-11-24 14:16     ` Arisa Snowbell
2026-11-24 16:23     ` sashiko-bot
2026-11-24 16:14   ` [PATCH v2] drm/amdgpu/userq: queue the restore worker on a freezable workqueue sashiko-bot

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.