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 <[email protected]>
---
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