From: "Christian König" <christian.koenig@amd.com>
To: Prike Liang <Prike.Liang@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Alexander.Deucher@amd.com, Lijo.Lazar@amd.com, Vitaly.Prosyak@amd.com
Subject: Re: [PATCH 7/9] drm/amdgpu/userq: take reset_domain->sem before userq_mutex in destroy
Date: Tue, 13 Oct 2026 11:30:51 +0200 [thread overview]
Message-ID: <5d41fc4b-ca95-4cb2-b0a4-649614548882@amd.com> (raw)
In-Reply-To: <20261013082457.2492273-7-Prike.Liang@amd.com>
On 10/13/26 10:24, Prike Liang wrote:
> amdgpu_userq_destroy() takes reset_domain->sem for read in
> amdgpu_userq_detach_doorbell() while holding userq_mutex.
Yeah that is correct behavior.
> GPU recovery
> holds reset_domain->sem for write and then takes clientlist_mutex in
> drm_client_dev_suspend(),
That is completely broken behavior and need to be fixed.
The GPU reset can *NEVER* call drm_client_dev_suspend(), who came up with that nonsense?
Regards,
Christian.
> which already depends on userq_mutex through
> the fbdev reservation and userq restore paths. Lockdep reports:
>
> Chain exists of:
> &dev->clientlist_mutex --> &userq_mgr->userq_mutex --> &reset_domain->sem
>
> Keep waiting for the last fence under userq_mutex only, as the fence of a
> hung queue is only force-completed by the reset, then take
> reset_domain->sem before re-acquiring userq_mutex for the doorbell
> detach, unmap and fence driver teardown. This also keeps the MES unmap
> from racing with an in-progress GPU reset.
>
> Fixes: f18719ef4bb7 ("drm/amdgpu: Convert amdgpu userqueue management from IDR to XArray")
> Signed-off-by: Prike Liang <Prike.Liang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> index 5fef0cc7703c..a34ea8ecd700 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
> @@ -415,15 +415,6 @@ static void amdgpu_userq_wait_for_last_fence(struct amdgpu_usermode_queue *queue
> dma_fence_wait(f, false);
> }
>
> -static void amdgpu_userq_detach_doorbell(struct amdgpu_usermode_queue *queue)
> -{
> - struct amdgpu_device *adev = queue->userq_mgr->adev;
> -
> - down_read(&adev->reset_domain->sem);
> - xa_erase_irq(&adev->userq_doorbell_xa, queue->doorbell_index);
> - up_read(&adev->reset_domain->sem);
> -}
> -
> /**
> * amdgpu_userq_ensure_ev_fence - ensure a valid, unsignaled eviction fence exists
> * @uq_mgr: the usermode queue manager for this process
> @@ -547,8 +538,12 @@ amdgpu_userq_destroy(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_que
>
> mutex_lock(&uq_mgr->userq_mutex);
> amdgpu_userq_wait_for_last_fence(queue);
> + mutex_unlock(&uq_mgr->userq_mutex);
>
> - amdgpu_userq_detach_doorbell(queue);
> + /* GPU recovery takes userq_mutex under reset_domain->sem, keep that order */
> + down_read(&adev->reset_domain->sem);
> + mutex_lock(&uq_mgr->userq_mutex);
> + xa_erase_irq(&adev->userq_doorbell_xa, queue->doorbell_index);
>
> #if defined(CONFIG_DEBUG_FS)
> debugfs_remove_recursive(queue->debugfs_queue);
> @@ -558,6 +553,7 @@ amdgpu_userq_destroy(struct amdgpu_userq_mgr *uq_mgr, struct amdgpu_usermode_que
> amdgpu_userq_fence_driver_free(queue);
> queue->fence_drv = NULL;
> mutex_unlock(&uq_mgr->userq_mutex);
> + up_read(&adev->reset_domain->sem);
>
> /*
> * A failed unmap means MES could not remove the hung queue and is now
next prev parent reply other threads:[~2026-10-13 9:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 8:24 [PATCH 1/9] drm/amdgpu: defer GPU recovery after userq eviction failure Prike Liang
2026-10-13 8:24 ` [PATCH 2/9] drm/amdgpu: skip VKMS mode-config helpers during GPU reset Prike Liang
2026-10-13 9:27 ` Christian König
2026-10-15 3:45 ` Liang, Prike
2026-10-15 8:32 ` Christian König
2026-10-13 8:24 ` [PATCH 3/9] drm/amdgpu: skip VMHUB fault handling while the device is inaccessible Prike Liang
2026-10-13 8:24 ` [PATCH 4/9] drm/amdgpu/userq: complete hung queue fences after successful removal Prike Liang
2026-10-13 8:24 ` [PATCH 5/9] drm/amdgpu: finish GPU recovery callbacks before restarting schedulers Prike Liang
2026-10-13 8:24 ` [PATCH 6/9] drm/amdgpu: serialize JPEG and VCN idle work with GPU reset Prike Liang
2026-10-13 9:28 ` Christian König
2026-10-13 8:24 ` [PATCH 7/9] drm/amdgpu/userq: take reset_domain->sem before userq_mutex in destroy Prike Liang
2026-10-13 9:30 ` Christian König [this message]
2026-10-15 6:38 ` Liang, Prike
2026-10-13 8:24 ` [PATCH 8/9] drm/amdgpu/userq: take reset_domain->sem before userq_mutex in create Prike Liang
2026-10-13 8:24 ` [PATCH 9/9] drm/amdgpu/mes: skip unmap queue notification during GPU reset Prike Liang
2026-10-13 9:26 ` [PATCH 1/9] drm/amdgpu: defer GPU recovery after userq eviction failure Christian König
2026-10-14 9:02 ` Liang, Prike
2026-10-14 10:56 ` Christian König
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=5d41fc4b-ca95-4cb2-b0a4-649614548882@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Lijo.Lazar@amd.com \
--cc=Prike.Liang@amd.com \
--cc=Vitaly.Prosyak@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox