From: "Khatri, Sunil" <sukhatri@amd.com>
To: christian.koenig@amd.com, alexander.deucher@amd.com,
Prike.Liang@amd.com, jesse.zhang@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/8] drm/amdgpu: remove almost all calls to amdgpu_userq_detect_and_reset_queues
Date: Tue, 28 Apr 2026 15:07:27 +0530 [thread overview]
Message-ID: <d48d5800-9abb-43e3-b87a-b073abaad9ba@amd.com> (raw)
In-Reply-To: <20260427182723.1715-4-christian.koenig@amd.com>
Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
On 27-04-2026 11:57 pm, Christian König wrote:
> Well the reset handling seems broken on multiple levels.
>
> As first step of fixing this remove most calls to the hang detection.
> That function should only be called after we run into a timeout! And *NOT*
> as random check spread over the code in multiple places.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Reviewed-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 38 +++++++++--------------
> 1 file changed, 14 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 62d155d6e4ed..fb3c0425cf22 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -345,23 +345,18 @@ static int amdgpu_userq_preempt_helper(struct amdgpu_usermode_queue *queue)
> struct amdgpu_device *adev = uq_mgr->adev;
> const struct amdgpu_userq_funcs *userq_funcs =
> adev->userq_funcs[queue->queue_type];
> - bool found_hung_queue = false;
> - int r = 0;
> + int r;
>
> if (queue->state == AMDGPU_USERQ_STATE_MAPPED) {
> r = userq_funcs->preempt(queue);
> if (r) {
> queue->state = AMDGPU_USERQ_STATE_HUNG;
> - found_hung_queue = true;
> + return r;
> } else {
> queue->state = AMDGPU_USERQ_STATE_PREEMPTED;
> }
> }
> -
> - if (found_hung_queue)
> - amdgpu_userq_detect_and_reset_queues(uq_mgr);
> -
> - return r;
> + return 0;
> }
>
> static int amdgpu_userq_restore_helper(struct amdgpu_usermode_queue *queue)
> @@ -390,24 +385,21 @@ static int amdgpu_userq_unmap_helper(struct amdgpu_usermode_queue *queue)
> struct amdgpu_device *adev = uq_mgr->adev;
> const struct amdgpu_userq_funcs *userq_funcs =
> adev->userq_funcs[queue->queue_type];
> - bool found_hung_queue = false;
> - int r = 0;
> + int r;
>
> if ((queue->state == AMDGPU_USERQ_STATE_MAPPED) ||
> - (queue->state == AMDGPU_USERQ_STATE_PREEMPTED)) {
> + (queue->state == AMDGPU_USERQ_STATE_PREEMPTED)) {
> +
> r = userq_funcs->unmap(queue);
> if (r) {
> queue->state = AMDGPU_USERQ_STATE_HUNG;
> - found_hung_queue = true;
> + return r;
> } else {
> queue->state = AMDGPU_USERQ_STATE_UNMAPPED;
> }
> }
>
> - if (found_hung_queue)
> - amdgpu_userq_detect_and_reset_queues(uq_mgr);
> -
> - return r;
> + return 0;
> }
>
> static int amdgpu_userq_map_helper(struct amdgpu_usermode_queue *queue)
> @@ -416,19 +408,19 @@ static int amdgpu_userq_map_helper(struct amdgpu_usermode_queue *queue)
> struct amdgpu_device *adev = uq_mgr->adev;
> const struct amdgpu_userq_funcs *userq_funcs =
> adev->userq_funcs[queue->queue_type];
> - int r = 0;
> + int r;
>
> if (queue->state == AMDGPU_USERQ_STATE_UNMAPPED) {
> r = userq_funcs->map(queue);
> if (r) {
> queue->state = AMDGPU_USERQ_STATE_HUNG;
> - amdgpu_userq_detect_and_reset_queues(uq_mgr);
> + return r;
> } else {
> queue->state = AMDGPU_USERQ_STATE_MAPPED;
> }
> }
>
> - return r;
> + return 0;
> }
>
> static void amdgpu_userq_wait_for_last_fence(struct amdgpu_usermode_queue *queue)
> @@ -654,7 +646,6 @@ amdgpu_userq_destroy(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_que
> #if defined(CONFIG_DEBUG_FS)
> debugfs_remove_recursive(queue->debugfs_queue);
> #endif
> - amdgpu_userq_detect_and_reset_queues(uq_mgr);
> r = amdgpu_userq_unmap_helper(queue);
> /*TODO: It requires a reset for userq hw unmap error*/
> if (r) {
> @@ -1270,7 +1261,6 @@ amdgpu_userq_evict_all(struct amdgpu_userq_mgr *uq_mgr)
> unsigned long queue_id;
> int ret = 0, r;
>
> - amdgpu_userq_detect_and_reset_queues(uq_mgr);
> /* Try to unmap all the queues in this process ctx */
> xa_for_each(&uq_mgr->userq_xa, queue_id, queue) {
> r = amdgpu_userq_preempt_helper(queue);
> @@ -1278,9 +1268,11 @@ amdgpu_userq_evict_all(struct amdgpu_userq_mgr *uq_mgr)
> ret = r;
> }
>
> - if (ret)
> + if (ret) {
> drm_file_err(uq_mgr->file,
> "Couldn't unmap all the queues, eviction failed ret=%d\n", ret);
> + amdgpu_userq_detect_and_reset_queues(uq_mgr);
> + }
> return ret;
> }
>
> @@ -1380,7 +1372,6 @@ int amdgpu_userq_suspend(struct amdgpu_device *adev)
> uqm = queue->userq_mgr;
> cancel_delayed_work_sync(&uqm->resume_work);
> guard(mutex)(&uqm->userq_mutex);
> - amdgpu_userq_detect_and_reset_queues(uqm);
> if (adev->in_s0ix)
> r = amdgpu_userq_preempt_helper(queue);
> else
> @@ -1439,7 +1430,6 @@ int amdgpu_userq_stop_sched_for_enforce_isolation(struct amdgpu_device *adev,
> if (((queue->queue_type == AMDGPU_HW_IP_GFX) ||
> (queue->queue_type == AMDGPU_HW_IP_COMPUTE)) &&
> (queue->xcp_id == idx)) {
> - amdgpu_userq_detect_and_reset_queues(uqm);
> r = amdgpu_userq_preempt_helper(queue);
> if (r)
> ret = r;
next prev parent reply other threads:[~2026-04-28 9:37 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 18:27 [PATCH 1/8] drm/amdgpu: nuke amdgpu_userq_fence_slab Christian König
2026-04-27 18:27 ` [PATCH 2/8] drm/amdgpu: remove deadlocks from amdgpu_userq_pre_reset Christian König
2026-04-28 6:51 ` Liang, Prike
2026-04-28 8:15 ` Khatri, Sunil
2026-04-27 18:27 ` [PATCH 3/8] drm/amdgpu: rework amdgpu_userq_signal_ioctl v2 Christian König
2026-04-28 8:49 ` Liang, Prike
2026-05-04 12:33 ` Christian König
2026-04-28 9:35 ` Khatri, Sunil
2026-05-04 12:37 ` Christian König
2026-04-27 18:27 ` [PATCH 4/8] drm/amdgpu: remove almost all calls to amdgpu_userq_detect_and_reset_queues Christian König
2026-04-28 9:37 ` Khatri, Sunil [this message]
2026-04-29 3:16 ` Liang, Prike
2026-04-27 18:27 ` [PATCH 5/8] drm/amdgpu: fix userq hang detection and reset Christian König
2026-04-29 8:30 ` Liang, Prike
2026-04-27 18:27 ` [PATCH 6/8] drm/amdgpu: rework userq reset work handling Christian König
2026-04-30 6:37 ` Liang, Prike
2026-04-27 18:27 ` [PATCH 7/8] drm/amdgpu: fix handling in amdgpu_userq_create Christian König
2026-04-28 11:26 ` Khatri, Sunil
2026-05-07 6:13 ` Liang, Prike
2026-04-27 18:27 ` [PATCH 8/8] drm/amdgpu: restructure VM state machine v2 Christian König
2026-04-28 12:20 ` Khatri, Sunil
2026-05-08 2:24 ` Liang, Prike
2026-05-08 8:21 ` Christian König
2026-05-25 23:29 ` Timur Kristóf
2026-05-26 8:51 ` Christian König
2026-05-26 10:11 ` Timur Kristóf
2026-05-26 10:44 ` Christian König
2026-04-28 6:15 ` [PATCH 1/8] drm/amdgpu: nuke amdgpu_userq_fence_slab Liang, Prike
2026-04-28 8:06 ` Christian König
2026-04-28 7:57 ` Khatri, Sunil
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=d48d5800-9abb-43e3-b87a-b073abaad9ba@amd.com \
--to=sukhatri@amd.com \
--cc=Prike.Liang@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=jesse.zhang@amd.com \
/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.