* [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers
@ 2026-09-07 1:45 Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 2/8] drm/amdgpu: add mqd_prop modify flag for queue MODIFY Jesse Zhang
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
Split the inlined compute path out of mes_userq_mqd_update() into
mes_userq_compute_mqd_update() and turn the former into a dispatcher that
switches on queue_type, giving other IPs an obvious place to hook in.
No functional change.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index ad72ced472dd..82bb4369451e 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -681,7 +681,8 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
return r;
}
-static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct drm_amdgpu_userq_in *args_in)
+static int mes_userq_compute_mqd_update(struct amdgpu_usermode_queue *queue,
+ struct drm_amdgpu_userq_in *args_in)
{
int retval = 0;
struct amdgpu_device *adev = queue->userq_mgr->adev;
@@ -689,12 +690,6 @@ static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct drm_
struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];
struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd_v11;
- if (!queue || !userq_props)
- return -EINVAL;
-
- if (queue->queue_type != AMDGPU_HW_IP_COMPUTE)
- return -EINVAL;
-
if (args_in->mqd_size != sizeof(*compute_mqd_v11)) {
DRM_ERROR("Invalid compute IP MQD size\n");
return -EINVAL;
@@ -720,6 +715,19 @@ static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct drm_
return retval;
}
+static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct drm_amdgpu_userq_in *args_in)
+{
+ if (!queue || !queue->userq_prop)
+ return -EINVAL;
+
+ switch (queue->queue_type) {
+ case AMDGPU_HW_IP_COMPUTE:
+ return mes_userq_compute_mqd_update(queue, args_in);
+ default:
+ return -EINVAL;
+ }
+}
+
static void mes_userq_mqd_destroy(struct amdgpu_usermode_queue *queue)
{
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/8] drm/amdgpu: add mqd_prop modify flag for queue MODIFY
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 3/8] drm/amdgpu/gfx11: honor mqd_prop modify flag in init_mqd Jesse Zhang
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
Add a modify flag to struct amdgpu_mqd_prop. When set, init_mqd patches
the MQD in place, keeping the ring rptr/wptr that firmware context-saved
into it on unmap. KFD already patches the MQD in place for the same
disable/re-enable sequence.
v3: use an mqd_prop modify flag consumed by init_mqd instead of a
separate per-IP update_mqd callback, per review.
v4: drop the user_wptr field - firmware context-saves the wptr into the
MQD on unmap, so init_mqd just keeps it rather than restoring a value
read back from the wptr BO.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
index 63670b41c26c..d231d5d283df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
@@ -494,6 +494,7 @@ struct amdgpu_mqd_prop {
uint64_t ctx_save_area_addr;
uint32_t ctx_save_area_size;
uint32_t ctl_stack_size;
+ bool modify;
};
struct amdgpu_mqd {
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 3/8] drm/amdgpu/gfx11: honor mqd_prop modify flag in init_mqd
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 2/8] drm/amdgpu: add mqd_prop modify flag for queue MODIFY Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 4/8] drm/amdgpu/gfx12: " Jesse Zhang
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
On a queue MODIFY (prop->modify) the gfx11 GFX and compute init_mqd keep
the ring rptr/wptr that firmware context-saved into the MQD, so a
re-enabled queue resumes at the first un-consumed packet.
v2: rebuild the HQD via init_mqd and save/restore the rptr, matching the
SDMA update_mqd style, instead of patching individual MQD fields in
place. Keeps all update_mqd callbacks consistent.
v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
separate gfx11 update_mqd callback, per review.
v4: also keep the context-saved wptr instead of programming a user_wptr,
per review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 27 ++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index a447562977ab..301f7ab30bdf 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -4167,9 +4167,11 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
uint32_t tmp;
uint32_t rb_bufsz;
- /* set up gfx hqd wptr */
- mqd->cp_gfx_hqd_wptr = 0;
- mqd->cp_gfx_hqd_wptr_hi = 0;
+ /* MODIFY keeps the firmware-saved wptr; otherwise start at 0 */
+ if (!prop->modify) {
+ mqd->cp_gfx_hqd_wptr = 0;
+ mqd->cp_gfx_hqd_wptr_hi = 0;
+ }
/* set the pointer to the MQD */
mqd->cp_mqd_base_addr = prop->mqd_gpu_addr & 0xfffffffc;
@@ -4237,8 +4239,9 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
DOORBELL_EN, 0);
mqd->cp_rb_doorbell_control = tmp;
- /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
- mqd->cp_gfx_hqd_rptr = regCP_GFX_HQD_RPTR_DEFAULT;
+ /* MODIFY keeps the firmware-saved rptr; otherwise reset it */
+ if (!prop->modify)
+ mqd->cp_gfx_hqd_rptr = regCP_GFX_HQD_RPTR_DEFAULT;
/* active the queue */
mqd->cp_gfx_hqd_active = 1;
@@ -4379,9 +4382,12 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
/* disable the queue if it's active */
mqd->cp_hqd_dequeue_request = 0;
- mqd->cp_hqd_pq_rptr = 0;
- mqd->cp_hqd_pq_wptr_lo = 0;
- mqd->cp_hqd_pq_wptr_hi = 0;
+ /* MODIFY keeps the firmware-saved rptr/wptr; otherwise start at 0 */
+ if (!prop->modify) {
+ mqd->cp_hqd_pq_rptr = 0;
+ mqd->cp_hqd_pq_wptr_lo = 0;
+ mqd->cp_hqd_pq_wptr_hi = 0;
+ }
/* set the pointer to the MQD */
mqd->cp_mqd_base_addr_lo = prop->mqd_gpu_addr & 0xfffffffc;
@@ -4442,8 +4448,9 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
mqd->cp_hqd_pq_doorbell_control = tmp;
- /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
- mqd->cp_hqd_pq_rptr = regCP_HQD_PQ_RPTR_DEFAULT;
+ /* MODIFY keeps the firmware-saved rptr; otherwise reset it */
+ if (!prop->modify)
+ mqd->cp_hqd_pq_rptr = regCP_HQD_PQ_RPTR_DEFAULT;
/* set the vmid for the queue */
mqd->cp_hqd_vmid = 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 4/8] drm/amdgpu/gfx12: honor mqd_prop modify flag in init_mqd
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 2/8] drm/amdgpu: add mqd_prop modify flag for queue MODIFY Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 3/8] drm/amdgpu/gfx11: honor mqd_prop modify flag in init_mqd Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 5/8] drm/amdgpu/sdma6: " Jesse Zhang
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
On a queue MODIFY (prop->modify) the gfx12 GFX and compute init_mqd keep
the ring rptr/wptr that firmware context-saved into the MQD, so a
re-enabled queue resumes at the first un-consumed packet.
v2: rebuild the HQD via init_mqd and save/restore the rptr, matching the
SDMA update_mqd style, instead of patching individual MQD fields in
place. Keeps all update_mqd callbacks consistent.
v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
separate gfx12 update_mqd callback, per review.
v4: also keep the context-saved wptr instead of programming a user_wptr,
per review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index a434b665d913..b2d210681224 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -3006,9 +3006,11 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
uint32_t tmp;
uint32_t rb_bufsz;
- /* set up gfx hqd wptr */
- mqd->cp_gfx_hqd_wptr = 0;
- mqd->cp_gfx_hqd_wptr_hi = 0;
+ /* MODIFY keeps the firmware-saved wptr; otherwise start at 0 */
+ if (!prop->modify) {
+ mqd->cp_gfx_hqd_wptr = 0;
+ mqd->cp_gfx_hqd_wptr_hi = 0;
+ }
/* set the pointer to the MQD */
mqd->cp_mqd_base_addr = prop->mqd_gpu_addr & 0xfffffffc;
@@ -3079,8 +3081,9 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
DOORBELL_EN, 0);
mqd->cp_rb_doorbell_control = tmp;
- /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
- mqd->cp_gfx_hqd_rptr = regCP_GFX_HQD_RPTR_DEFAULT;
+ /* MODIFY keeps the firmware-saved rptr; otherwise reset it */
+ if (!prop->modify)
+ mqd->cp_gfx_hqd_rptr = regCP_GFX_HQD_RPTR_DEFAULT;
/* active the queue */
mqd->cp_gfx_hqd_active = 1;
@@ -3212,10 +3215,12 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
/* disable the queue if it's active */
mqd->cp_hqd_dequeue_request = 0;
- /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
- mqd->cp_hqd_pq_rptr = regCP_HQD_PQ_RPTR_DEFAULT;
- mqd->cp_hqd_pq_wptr_lo = 0;
- mqd->cp_hqd_pq_wptr_hi = 0;
+ /* MODIFY keeps the firmware-saved rptr/wptr; otherwise start at 0 */
+ if (!prop->modify) {
+ mqd->cp_hqd_pq_rptr = regCP_HQD_PQ_RPTR_DEFAULT;
+ mqd->cp_hqd_pq_wptr_lo = 0;
+ mqd->cp_hqd_pq_wptr_hi = 0;
+ }
/* set the pointer to the MQD */
mqd->cp_mqd_base_addr_lo = prop->mqd_gpu_addr & 0xfffffffc;
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 5/8] drm/amdgpu/sdma6: honor mqd_prop modify flag in init_mqd
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
` (2 preceding siblings ...)
2026-09-07 1:45 ` [PATCH v4 4/8] drm/amdgpu/gfx12: " Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 6/8] drm/amdgpu/sdma7: " Jesse Zhang
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
On a queue MODIFY (prop->modify) sdma6 init_mqd keeps the ring rptr/wptr
that firmware context-saved into the MQD, so a re-enabled queue resumes
at the first un-consumed packet. It also forces IB_ENABLE back on, since
ib_cntl reads back IB_ENABLE=0 on a stopped queue.
v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
separate sdma6 update_mqd callback, per review.
v4: also keep the context-saved wptr instead of programming a user_wptr,
per review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
index 3fd3e530c76b..a7dac93386db 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c
@@ -881,6 +881,14 @@ static int sdma_v6_0_mqd_init(struct amdgpu_device *adev, void *mqd,
m->sdmax_rlcx_f32_dbg0 = lower_32_bits(prop->fence_address);
m->sdmax_rlcx_f32_dbg1 = upper_32_bits(prop->fence_address);
+ if (prop->modify) {
+ /*
+ * MODIFY keeps the firmware-saved rptr/wptr (left untouched above);
+ * ib_cntl read back IB_ENABLE=0 on the stopped queue, so force it on.
+ */
+ m->sdmax_rlcx_ib_cntl |= SDMA0_QUEUE0_IB_CNTL__IB_ENABLE_MASK;
+ }
+
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 6/8] drm/amdgpu/sdma7: honor mqd_prop modify flag in init_mqd
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
` (3 preceding siblings ...)
2026-09-07 1:45 ` [PATCH v4 5/8] drm/amdgpu/sdma6: " Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 7/8] drm/amdgpu/sdma7_1: " Jesse Zhang
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
On a queue MODIFY (prop->modify) sdma7 init_mqd keeps the ring rptr/wptr
that firmware context-saved into the MQD, so a re-enabled queue resumes
at the first un-consumed packet. It also forces IB_ENABLE back on, since
ib_cntl reads back IB_ENABLE=0 on a stopped queue.
v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
separate sdma7 update_mqd callback, per review.
v4: also keep the context-saved wptr instead of programming a user_wptr,
per review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
index 2068e2e6e3d6..20c2423a0c4d 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
@@ -902,6 +902,14 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd,
m->sdmax_rlcx_mcu_dbg0 = lower_32_bits(prop->fence_address);
m->sdmax_rlcx_mcu_dbg1 = upper_32_bits(prop->fence_address);
+ if (prop->modify) {
+ /*
+ * MODIFY keeps the firmware-saved rptr/wptr (left untouched above);
+ * ib_cntl read back IB_ENABLE=0 on the stopped queue, so force it on.
+ */
+ m->sdmax_rlcx_ib_cntl |= SDMA0_QUEUE0_IB_CNTL__IB_ENABLE_MASK;
+ }
+
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 7/8] drm/amdgpu/sdma7_1: honor mqd_prop modify flag in init_mqd
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
` (4 preceding siblings ...)
2026-09-07 1:45 ` [PATCH v4 6/8] drm/amdgpu/sdma7: " Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 8/8] drm/amdgpu/mes_userqueue: add SDMA MODIFY support Jesse Zhang
2026-09-10 3:03 ` [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Zhang, Jesse(Jie)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
On a queue MODIFY (prop->modify) sdma7_1 init_mqd keeps the ring rptr/wptr
that firmware context-saved into the MQD, so a re-enabled queue resumes
at the first un-consumed packet. It also forces IB_ENABLE back on, since
ib_cntl reads back IB_ENABLE=0 on a stopped queue.
v3: consume the mqd_prop modify flag inside init_mqd instead of adding a
separate sdma7_1 update_mqd callback, per review.
v4: also keep the context-saved wptr instead of programming a user_wptr,
per review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c b/drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
index e9a3bcfd7775..0af11841b727 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
@@ -886,6 +886,14 @@ static int sdma_v7_1_mqd_init(struct amdgpu_device *adev, void *mqd,
m->sdmax_rlcx_csa_addr_lo = lower_32_bits(prop->csa_addr);
m->sdmax_rlcx_csa_addr_hi = upper_32_bits(prop->csa_addr);
+ if (prop->modify) {
+ /*
+ * MODIFY keeps the firmware-saved rptr/wptr (left untouched above);
+ * ib_cntl read back IB_ENABLE=0 on the stopped queue, so force it on.
+ */
+ m->sdmax_rlcx_ib_cntl |= SDMA0_SDMA_QUEUE0_IB_CNTL__IB_ENABLE_MASK;
+ }
+
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 8/8] drm/amdgpu/mes_userqueue: add SDMA MODIFY support
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
` (5 preceding siblings ...)
2026-09-07 1:45 ` [PATCH v4 7/8] drm/amdgpu/sdma7_1: " Jesse Zhang
@ 2026-09-07 1:45 ` Jesse Zhang
2026-09-10 3:03 ` [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Zhang, Jesse(Jie)
7 siblings, 0 replies; 9+ messages in thread
From: Jesse Zhang @ 2026-09-07 1:45 UTC (permalink / raw)
To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Jesse Zhang
Add mes_userq_sdma_mqd_update() to update an SDMA queue's MQD from a
drm_amdgpu_userq_mqd_sdma_gfx11 (csa address, queue size, ring base),
re-init it in place via prop->modify, and wire it into the queue_type
dispatcher. This aligns KGD user queues with KFD's update_mqd_sdma.
v3: re-init the MQD via the mqd_prop modify flag instead of a separate
update_mqd callback, per review.
v4: keep the context-saved wptr instead of forwarding a user_wptr, per
review.
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alexander Deucher <Alexander.Deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 1 +
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 104 ++++++++++++++++++++-
include/uapi/drm/amdgpu_drm.h | 12 +++
3 files changed, 116 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 686c92e96025..5210ec381be7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -840,6 +840,7 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,
prop->use_doorbell = ring->use_doorbell;
prop->doorbell_index = ring->doorbell_index;
prop->kernel_queue = true;
+ prop->modify = false;
/* map_queues packet doesn't need activate the queue,
* so only kiq need set this field.
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 82bb4369451e..5b53e6ec8897 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -479,6 +479,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
userq_props->use_doorbell = true;
userq_props->doorbell_index = queue->doorbell_index;
userq_props->fence_address = queue->fence_drv->gpu_addr;
+ userq_props->modify = false;
if (queue->queue_type == AMDGPU_HW_IP_COMPUTE) {
struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd;
@@ -573,8 +574,16 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
goto free_mqd;
}
+ if (mqd_gfx_v11->queue_percentage > AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE) {
+ DRM_ERROR("Queue percentage must be between 0 to AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE.\n");
+ r = -EINVAL;
+ kfree(mqd_gfx_v11);
+ goto free_mqd;
+ }
+
userq_props->shadow_addr = mqd_gfx_v11->shadow_va;
userq_props->csa_addr = mqd_gfx_v11->csa_va;
+ userq_props->queue_percentage = mqd_gfx_v11->queue_percentage;
userq_props->tmz_queue =
mqd_user->flags & AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE;
@@ -618,6 +627,13 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
goto free_mqd;
}
+ if (mqd_sdma_v11->queue_percentage > AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE) {
+ DRM_ERROR("Queue percentage must be between 0 to AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE.\n");
+ r = -EINVAL;
+ kfree(mqd_sdma_v11);
+ goto free_mqd;
+ }
+
r = amdgpu_bo_reserve(queue->vm->root.bo, false);
if (r) {
kfree(mqd_sdma_v11);
@@ -633,6 +649,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
}
userq_props->csa_addr = mqd_sdma_v11->csa_va;
+ userq_props->queue_percentage = mqd_sdma_v11->queue_percentage;
kfree(mqd_sdma_v11);
}
@@ -681,6 +698,85 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
return r;
}
+static int mes_userq_sdma_mqd_update(struct amdgpu_usermode_queue *queue,
+ struct drm_amdgpu_userq_in *args_in)
+{
+ int retval = 0;
+ struct amdgpu_device *adev = queue->userq_mgr->adev;
+ struct amdgpu_mqd_prop *userq_props = queue->userq_prop;
+ struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];
+ struct drm_amdgpu_userq_mqd_sdma_gfx11 *sdma_mqd_v11;
+
+ if (args_in->mqd_size != sizeof(*sdma_mqd_v11)) {
+ DRM_ERROR("Invalid SDMA IP MQD size\n");
+ return -EINVAL;
+ }
+
+ sdma_mqd_v11 = memdup_user(u64_to_user_ptr(args_in->mqd), args_in->mqd_size);
+ if (IS_ERR(sdma_mqd_v11)) {
+ DRM_ERROR("Failed to read user MQD\n");
+ return -ENOMEM;
+ }
+
+ if (sdma_mqd_v11->queue_percentage > AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE) {
+ DRM_ERROR("Queue percentage must be between 0 to AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE.\n");
+ kfree(sdma_mqd_v11);
+ return -EINVAL;
+ }
+
+ userq_props->csa_addr = sdma_mqd_v11->csa_va;
+ userq_props->queue_size = args_in->queue_size;
+ userq_props->hqd_base_gpu_addr = args_in->queue_va;
+ userq_props->queue_percentage = sdma_mqd_v11->queue_percentage;
+ userq_props->modify = true;
+
+ retval = mqd_hw_default->init_mqd(adev, (void *)queue->mqd.cpu_ptr,
+ userq_props);
+
+ kfree(sdma_mqd_v11);
+ return retval;
+}
+
+static int mes_userq_gfx_mqd_update(struct amdgpu_usermode_queue *queue,
+ struct drm_amdgpu_userq_in *args_in)
+{
+ int retval = 0;
+ struct amdgpu_device *adev = queue->userq_mgr->adev;
+ struct amdgpu_mqd_prop *userq_props = queue->userq_prop;
+ struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue->queue_type];
+ struct drm_amdgpu_userq_mqd_gfx11 *gfx_mqd_v11;
+
+ if (args_in->mqd_size != sizeof(*gfx_mqd_v11)) {
+ DRM_ERROR("Invalid GFX IP MQD size\n");
+ return -EINVAL;
+ }
+
+ gfx_mqd_v11 = memdup_user(u64_to_user_ptr(args_in->mqd), args_in->mqd_size);
+ if (IS_ERR(gfx_mqd_v11)) {
+ DRM_ERROR("Failed to read user MQD\n");
+ return -ENOMEM;
+ }
+
+ if (gfx_mqd_v11->queue_percentage > AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE) {
+ DRM_ERROR("Queue percentage must be between 0 to AMDGPU_USERQ_MAX_QUEUE_PERCENTAGE.\n");
+ kfree(gfx_mqd_v11);
+ return -EINVAL;
+ }
+
+ userq_props->shadow_addr = gfx_mqd_v11->shadow_va;
+ userq_props->csa_addr = gfx_mqd_v11->csa_va;
+ userq_props->queue_size = args_in->queue_size;
+ userq_props->hqd_base_gpu_addr = args_in->queue_va;
+ userq_props->queue_percentage = gfx_mqd_v11->queue_percentage;
+ userq_props->modify = true;
+
+ retval = mqd_hw_default->init_mqd(adev, (void *)queue->mqd.cpu_ptr,
+ userq_props);
+
+ kfree(gfx_mqd_v11);
+ return retval;
+}
+
static int mes_userq_compute_mqd_update(struct amdgpu_usermode_queue *queue,
struct drm_amdgpu_userq_in *args_in)
{
@@ -707,8 +803,10 @@ static int mes_userq_compute_mqd_update(struct amdgpu_usermode_queue *queue,
userq_props->queue_size = args_in->queue_size;
userq_props->hqd_base_gpu_addr = args_in->queue_va;
+ userq_props->modify = true;
- retval = mqd_hw_default->init_mqd(adev, (void *)queue->mqd.cpu_ptr, userq_props);
+ retval = mqd_hw_default->init_mqd(adev, (void *)queue->mqd.cpu_ptr,
+ userq_props);
free:
kfree(compute_mqd_v11);
@@ -723,6 +821,10 @@ static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct drm_
switch (queue->queue_type) {
case AMDGPU_HW_IP_COMPUTE:
return mes_userq_compute_mqd_update(queue, args_in);
+ case AMDGPU_HW_IP_GFX:
+ return mes_userq_gfx_mqd_update(queue, args_in);
+ case AMDGPU_HW_IP_DMA:
+ return mes_userq_sdma_mqd_update(queue, args_in);
default:
return -EINVAL;
}
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 2de47ff7c4d0..94497d1217b8 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -449,6 +449,12 @@ struct drm_amdgpu_userq_mqd_gfx11 {
* Use AMDGPU_INFO_IOCTL to find the exact size of the object.
*/
__u64 csa_va;
+ /**
+ * @queue_percentage: Queue resource allocation percentage (0-100)
+ * Defines the percentage of GPU resources allocated to this queue.
+ * A value of 0 marks the queue inactive and it will not be mapped.
+ */
+ __u32 queue_percentage;
};
/* GFX V11 SDMA IP specific MQD parameters */
@@ -459,6 +465,12 @@ struct drm_amdgpu_userq_mqd_sdma_gfx11 {
* to get the size.
*/
__u64 csa_va;
+ /**
+ * @queue_percentage: Queue resource allocation percentage (0-100)
+ * Defines the percentage of GPU resources allocated to this queue.
+ * A value of 0 marks the queue inactive and it will not be mapped.
+ */
+ __u32 queue_percentage;
};
/* GFX V11 Compute IP specific MQD parameters */
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
` (6 preceding siblings ...)
2026-09-07 1:45 ` [PATCH v4 8/8] drm/amdgpu/mes_userqueue: add SDMA MODIFY support Jesse Zhang
@ 2026-09-10 3:03 ` Zhang, Jesse(Jie)
7 siblings, 0 replies; 9+ messages in thread
From: Zhang, Jesse(Jie) @ 2026-09-10 3:03 UTC (permalink / raw)
To: Zhang, Jesse(Jie), amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander, Koenig, Christian
AMD General
Ping ..
> -----Original Message-----
> From: Jesse Zhang <Jesse.Zhang@amd.com>
> Sent: Monday, September 7, 2026 9:45 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Zhang, Jesse(Jie) <Jesse.Zhang@amd.com>
> Subject: [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into
> per-IP helpers
>
> Split the inlined compute path out of mes_userq_mqd_update() into
> mes_userq_compute_mqd_update() and turn the former into a dispatcher that
> switches on queue_type, giving other IPs an obvious place to hook in.
>
> No functional change.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> index ad72ced472dd..82bb4369451e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
> @@ -681,7 +681,8 @@ static int mes_userq_mqd_create(struct
> amdgpu_usermode_queue *queue,
> return r;
> }
>
> -static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue, struct
> drm_amdgpu_userq_in *args_in)
> +static int mes_userq_compute_mqd_update(struct amdgpu_usermode_queue
> *queue,
> + struct drm_amdgpu_userq_in *args_in)
> {
> int retval = 0;
> struct amdgpu_device *adev = queue->userq_mgr->adev; @@ -689,12
> +690,6 @@ static int mes_userq_mqd_update(struct amdgpu_usermode_queue
> *queue, struct drm_
> struct amdgpu_mqd *mqd_hw_default = &adev->mqds[queue-
> >queue_type];
> struct drm_amdgpu_userq_mqd_compute_gfx11 *compute_mqd_v11;
>
> - if (!queue || !userq_props)
> - return -EINVAL;
> -
> - if (queue->queue_type != AMDGPU_HW_IP_COMPUTE)
> - return -EINVAL;
> -
> if (args_in->mqd_size != sizeof(*compute_mqd_v11)) {
> DRM_ERROR("Invalid compute IP MQD size\n");
> return -EINVAL;
> @@ -720,6 +715,19 @@ static int mes_userq_mqd_update(struct
> amdgpu_usermode_queue *queue, struct drm_
> return retval;
> }
>
> +static int mes_userq_mqd_update(struct amdgpu_usermode_queue *queue,
> +struct drm_amdgpu_userq_in *args_in) {
> + if (!queue || !queue->userq_prop)
> + return -EINVAL;
> +
> + switch (queue->queue_type) {
> + case AMDGPU_HW_IP_COMPUTE:
> + return mes_userq_compute_mqd_update(queue, args_in);
> + default:
> + return -EINVAL;
> + }
> +}
> +
> static void mes_userq_mqd_destroy(struct amdgpu_usermode_queue *queue) {
>
> --
> 2.49.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-09-10 3:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07 1:45 [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 2/8] drm/amdgpu: add mqd_prop modify flag for queue MODIFY Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 3/8] drm/amdgpu/gfx11: honor mqd_prop modify flag in init_mqd Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 4/8] drm/amdgpu/gfx12: " Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 5/8] drm/amdgpu/sdma6: " Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 6/8] drm/amdgpu/sdma7: " Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 7/8] drm/amdgpu/sdma7_1: " Jesse Zhang
2026-09-07 1:45 ` [PATCH v4 8/8] drm/amdgpu/mes_userqueue: add SDMA MODIFY support Jesse Zhang
2026-09-10 3:03 ` [PATCH v4 1/8] drm/amdgpu/mes_userqueue: refactor mqd_update into per-IP helpers Zhang, Jesse(Jie)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox