From: "Christian König" <christian.koenig@amd.com>
To: "Liang, Prike" <Prike.Liang@amd.com>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: Re: [PATCH v6 03/11] drm/amdgpu: rework the userq doorbell object destroy
Date: Tue, 15 Jul 2025 10:49:26 +0200 [thread overview]
Message-ID: <c6fb3051-a182-417b-9e20-0b1fae6dc81c@amd.com> (raw)
In-Reply-To: <DS7PR12MB600518AE6EC29FDD741B825DFB57A@DS7PR12MB6005.namprd12.prod.outlook.com>
On 15.07.25 10:07, Liang, Prike wrote:
> [Public]
>
> Regards,
> Prike
>
>> -----Original Message-----
>> From: Koenig, Christian <Christian.Koenig@amd.com>
>> Sent: Friday, July 11, 2025 8:01 PM
>> To: Liang, Prike <Prike.Liang@amd.com>; amd-gfx@lists.freedesktop.org
>> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>
>> Subject: Re: [PATCH v6 03/11] drm/amdgpu: rework the userq doorbell object
>> destroy
>>
>> On 11.07.25 11:39, Prike Liang wrote:
>>> This patch aims to unify and destroy the userq doorbell objects at
>>> mes_userq_mqd_destroy(), and this change will also help with unpinning
>>> and destroying the userq doorbell objects for amdgpu_userq_mgr_fini()
>>> during releasing the drm files.
>>>
>>> Signed-off-by: Prike Liang <Prike.Liang@amd.com>
>>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ------
>>> drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 7 +++++++
>>> 2 files changed, 7 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> index 3d2a7f8946cf..15e833b1b3e3 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
>>> @@ -312,12 +312,6 @@ amdgpu_userq_destroy(struct drm_file *filp, int
>> queue_id)
>>> return -EINVAL;
>>> }
>>> amdgpu_userq_wait_for_last_fence(uq_mgr, queue);
>>> - r = amdgpu_bo_reserve(queue->db_obj.obj, true);
>>> - if (!r) {
>>> - amdgpu_bo_unpin(queue->db_obj.obj);
>>> - amdgpu_bo_unreserve(queue->db_obj.obj);
>>> - }
>>> - amdgpu_bo_unref(&queue->db_obj.obj);
>>> r = amdgpu_userq_unmap_helper(uq_mgr, queue);
>>> /*TODO: It requires a reset for userq hw unmap error*/
>>> if (unlikely(r != AMDGPU_USERQ_STATE_UNMAPPED)) { diff --git
>>> a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
>>> b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
>>> index 1457fb49a794..15aa1ca67a11 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
>>> @@ -336,6 +336,13 @@ mes_userq_mqd_destroy(struct amdgpu_userq_mgr
>> *uq_mgr,
>>> struct amdgpu_usermode_queue *queue) {
>>> amdgpu_userq_destroy_object(uq_mgr, &queue->fw_obj);
>>> +
>>> + if (!amdgpu_bo_reserve(queue->db_obj.obj, true)) {
>>> + amdgpu_bo_unpin(queue->db_obj.obj);
>>> + amdgpu_bo_unreserve(queue->db_obj.obj);
>>> + amdgpu_userq_destroy_object(uq_mgr, &queue->db_obj);
>>> + }
>>> +
>>
>> That makes no sense to do here. The pinning isn't done in mes_userq_mqd_create()
>> either.
> Yes, but the doorbell BO is pinned by amdgpu_userq_get_doorbell_index(), which is still
> Invoked during userq BOs creation phase. This patch wants to free the doorbell object like some
> other userq objects at the unified place of mes_userq_mqd_destroy().
Yeah and exactly that is not a good idea.
The doorbell object is provided by userspace and not allocated by the kernel like the MQD.
So destroying it here makes no sense at all. You are most likely messing up the doorbell reference count with that.
>> In general we should avoid pinning the MQD in the first place, that buffer needs to be
>> fences instead.
> If here not pin the userq doorbell BO, then will the doorbell index be changed when the doorbell
> BO is moved?
Correct, yes. The doorbell index needs to be updated on each resume of the userqueue.
We haven't implemented that yet since we weren't sure if the MES FW could handle that (and because the eviction fences wasn't ready at that time).
Regards,
Christian.
>
>> Regards,
>> Christian.
>>
>>> kfree(queue->userq_prop);
>>> amdgpu_userq_destroy_object(uq_mgr, &queue->mqd); }
>
next prev parent reply other threads:[~2025-07-15 8:49 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 9:39 [PATCH v6 01/11] drm/amdgpu: validate userq input args Prike Liang
2025-07-11 9:39 ` [PATCH v6 02/11] drm/amdgpu: validate userq hw unmap status for destroying userq Prike Liang
2025-07-11 9:39 ` [PATCH v6 03/11] drm/amdgpu: rework the userq doorbell object destroy Prike Liang
2025-07-11 12:00 ` Christian König
2025-07-15 8:07 ` Liang, Prike
2025-07-15 8:49 ` Christian König [this message]
2025-07-16 7:03 ` Liang, Prike
2025-07-11 9:39 ` [PATCH v6 04/11] drm/amdgpu: validate userq buffer virtual address and size Prike Liang
2025-07-11 12:08 ` Christian König
2025-07-15 8:19 ` Liang, Prike
2025-07-15 8:41 ` Christian König
2025-07-11 9:39 ` [PATCH v6 05/11] drm/amdgpu: add userq object va track helpers Prike Liang
2025-07-11 9:39 ` [PATCH v6 06/11] drm/amdgpu: track the userq bo va for its obj management Prike Liang
2025-07-11 12:11 ` Christian König
2025-07-15 12:05 ` Liang, Prike
2025-07-15 12:17 ` Christian König
2025-07-16 6:54 ` Liang, Prike
2025-07-11 9:39 ` [PATCH v6 07/11] drm/amdgpu: validate userq's last fence prior to destroying Prike Liang
2025-07-11 12:12 ` Christian König
2025-07-15 11:50 ` Liang, Prike
2025-07-15 12:15 ` Christian König
2025-07-11 9:39 ` [PATCH v6 08/11] drm/amdgpu: clean up the amdgpu_userq_active() Prike Liang
2025-07-11 9:39 ` [PATCH v6 09/11] drm/amdgpu: validate the shared bo for tracking usage size Prike Liang
2025-07-11 12:14 ` Christian König
2025-07-11 13:43 ` Liang, Prike
2025-07-11 9:39 ` [PATCH v6 10/11] drm/amdgpu: validate the queue va for resuming the queue Prike Liang
2025-07-11 12:18 ` Christian König
2025-07-11 9:39 ` [PATCH v6 11/11] drm/amdgpu: validate userq va for GEM unmap Prike Liang
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=c6fb3051-a182-417b-9e20-0b1fae6dc81c@amd.com \
--to=christian.koenig@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Prike.Liang@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 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.