Skip to content

drm/amdgpu/userq: fix S3 suspend hang with user queues

Arisa Snowbell amd-gfx sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1drm/amdgpu/userq: don't restore user queues during system sleepdrivers/gpu/drm/amd/amdgpu/amdgpu.h drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c +2 more+79 -41 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] drm/amdgpu/userq: fix S3 suspend hang with user queues

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