* [PATCH] drm/amdgpu/userq: fix indefinite fence wait during GPU reset
@ 2026-07-10 10:01 Jesse Zhang
2026-07-10 10:06 ` Christian König
0 siblings, 1 reply; 2+ messages in thread
From: Jesse Zhang @ 2026-07-10 10:01 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Prike Liang, Jesse Zhang
pre_reset only force-completes fences of MAPPED queues. A queue in any
other state (e.g. mid-eviction) keeps its last_fence pending; after a
GPU reset that fence never signals, so the eviction/suspend worker and
process teardown (amdgpu_evf_mgr_flush_suspend) wait on it forever and
wedge the machine:
INFO: task kworker/6:28 blocked for more than 120 seconds.
Workqueue: events amdgpu_eviction_fence_suspend_worker [amdgpu]
Call Trace:
dma_fence_wait_timeout+0x7e/0x130
amdgpu_userq_evict+0x67/0x140 [amdgpu]
amdgpu_eviction_fence_suspend_worker+0xd8/0x160 [amdgpu]
process_scheduled_works+0xa6/0x420
Force-complete every queue's fence regardless of state. The unmap and
mark-hung step stays gated on MAPPED, since unmapping a queue that is
not mapped is invalid.
Fixes: 290f46cf5726 ("drm/amdgpu: Implement user queue reset functionality")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 25 +++++++++++++----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index aa5cc5642e87..6aa75da27f91 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -1424,18 +1424,21 @@ void amdgpu_userq_pre_reset(struct amdgpu_device *adev)
/* TODO: We probably need a new lock for the queue state */
xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
- if (queue->state != AMDGPU_USERQ_STATE_MAPPED)
- continue;
-
- trace_amdgpu_userq_state_start(queue);
- userq_funcs = adev->userq_funcs[queue->queue_type];
- userq_funcs->unmap(queue);
- /* just mark all queues as hung at this point.
- * if unmap succeeds, we could map again
- * in amdgpu_userq_post_reset() if vram is not lost
+ if (queue->state == AMDGPU_USERQ_STATE_MAPPED) {
+ trace_amdgpu_userq_state_start(queue);
+ userq_funcs = adev->userq_funcs[queue->queue_type];
+ userq_funcs->unmap(queue);
+ /* just mark all queues as hung at this point.
+ * if unmap succeeds, we could map again
+ * in amdgpu_userq_post_reset() if vram is not lost
+ */
+ trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
+ queue->state = AMDGPU_USERQ_STATE_HUNG;
+ }
+ /* Force-complete any pending fence regardless of queue state so
+ * that eviction/suspend and queue teardown waiters don't block
+ * forever on a fence that will never signal after the reset.
*/
- trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
- queue->state = AMDGPU_USERQ_STATE_HUNG;
amdgpu_userq_fence_driver_force_completion(queue);
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu/userq: fix indefinite fence wait during GPU reset
2026-07-10 10:01 [PATCH] drm/amdgpu/userq: fix indefinite fence wait during GPU reset Jesse Zhang
@ 2026-07-10 10:06 ` Christian König
0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-07-10 10:06 UTC (permalink / raw)
To: Jesse Zhang, amd-gfx; +Cc: Alexander.Deucher, Prike Liang
On 7/10/26 12:01, Jesse Zhang wrote:
> pre_reset only force-completes fences of MAPPED queues. A queue in any
> other state (e.g. mid-eviction) keeps its last_fence pending; after a
> GPU reset that fence never signals, so the eviction/suspend worker and
> process teardown (amdgpu_evf_mgr_flush_suspend) wait on it forever and
> wedge the machine:
>
> INFO: task kworker/6:28 blocked for more than 120 seconds.
> Workqueue: events amdgpu_eviction_fence_suspend_worker [amdgpu]
> Call Trace:
> dma_fence_wait_timeout+0x7e/0x130
> amdgpu_userq_evict+0x67/0x140 [amdgpu]
> amdgpu_eviction_fence_suspend_worker+0xd8/0x160 [amdgpu]
> process_scheduled_works+0xa6/0x420
>
> Force-complete every queue's fence regardless of state. The unmap and
> mark-hung step stays gated on MAPPED, since unmapping a queue that is
> not mapped is invalid.
>
> Fixes: 290f46cf5726 ("drm/amdgpu: Implement user queue reset functionality")
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 25 +++++++++++++----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index aa5cc5642e87..6aa75da27f91 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -1424,18 +1424,21 @@ void amdgpu_userq_pre_reset(struct amdgpu_device *adev)
>
> /* TODO: We probably need a new lock for the queue state */
> xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
> - if (queue->state != AMDGPU_USERQ_STATE_MAPPED)
> - continue;
> -
> - trace_amdgpu_userq_state_start(queue);
> - userq_funcs = adev->userq_funcs[queue->queue_type];
> - userq_funcs->unmap(queue);
> - /* just mark all queues as hung at this point.
> - * if unmap succeeds, we could map again
> - * in amdgpu_userq_post_reset() if vram is not lost
> + if (queue->state == AMDGPU_USERQ_STATE_MAPPED) {
> + trace_amdgpu_userq_state_start(queue);
> + userq_funcs = adev->userq_funcs[queue->queue_type];
> + userq_funcs->unmap(queue);
> + /* just mark all queues as hung at this point.
> + * if unmap succeeds, we could map again
> + * in amdgpu_userq_post_reset() if vram is not lost
> + */
> + trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
> + queue->state = AMDGPU_USERQ_STATE_HUNG;
> + }
> + /* Force-complete any pending fence regardless of queue state so
> + * that eviction/suspend and queue teardown waiters don't block
> + * forever on a fence that will never signal after the reset.
> */
> - trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_HUNG);
> - queue->state = AMDGPU_USERQ_STATE_HUNG;
> amdgpu_userq_fence_driver_force_completion(queue);
> }
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-10 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 10:01 [PATCH] drm/amdgpu/userq: fix indefinite fence wait during GPU reset Jesse Zhang
2026-07-10 10:06 ` Christian König
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.