Skip to contentSkip to conversation

drm/amdgpu/gfx7: align mqd settings with KFD

PATCH In review Alex Deucher 3 participants 8 messages Feb 18 – Mar 18

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/6 drm/amdgpu/gfx7: align mqd settings with KFD

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +6 -1
index 2b691452775bc..65b8497ad5f02 100644
@@ -2819,6 +2819,7 @@ static void gfx_v7_0_mqd_init(struct amdgpu_device *adev,
 {
 	u64 hqd_gpu_addr;
 	u64 wb_gpu_addr;
+	u32 tmp;
 
 	/* init the mqd struct */
 	memset(mqd, 0, sizeof(struct cik_mqd));
@@ -2923,7 +2924,11 @@ static void gfx_v7_0_mqd_init(struct amdgpu_device *adev,
 	mqd->cp_hqd_atomic1_preop_lo = RREG32(mmCP_HQD_ATOMIC1_PREOP_LO);
 	mqd->cp_hqd_atomic1_preop_hi = RREG32(mmCP_HQD_ATOMIC1_PREOP_HI);
 	mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
-	mqd->cp_hqd_quantum = RREG32(mmCP_HQD_QUANTUM);
+	tmp = RREG32(mmCP_HQD_QUANTUM);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10);
+	mqd->cp_hqd_quantum = tmp;
 	mqd->cp_hqd_pipe_priority = RREG32(mmCP_HQD_PIPE_PRIORITY);
 	mqd->cp_hqd_queue_priority = RREG32(mmCP_HQD_QUEUE_PRIORITY);
 	mqd->cp_hqd_iq_rptr = RREG32(mmCP_HQD_IQ_RPTR);
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 2/6 drm/amdgpu/gfx8: align mqd settings with KFD

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +5 -1
index a6b4c8f41dc11..130196859ff3f 100644
@@ -4532,7 +4532,11 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)
 
 	/* set static priority for a queue/ring */
 	gfx_v8_0_mqd_set_priority(ring, mqd);
-	mqd->cp_hqd_quantum = RREG32(mmCP_HQD_QUANTUM);
+	tmp = RREG32(mmCP_HQD_QUANTUM);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10);
+	mqd->cp_hqd_quantum = tmp;
 
 	/* map_queues packet doesn't need activate the queue,
 	 * so only kiq need set this field.
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 3/6 drm/amdgpu/gfx9: align mqd settings with KFD

In reply to Alex Deucher

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +5 -1
index 7e9d753f4a808..a03c638efb99c 100644
@@ -3667,7 +3667,11 @@ static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)
 
 	/* set static priority for a queue/ring */
 	gfx_v9_0_mqd_set_priority(ring, mqd);
-	mqd->cp_hqd_quantum = RREG32_SOC15(GC, 0, mmCP_HQD_QUANTUM);
+	tmp = RREG32_SOC15(GC, 0, mmCP_HQD_QUANTUM);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
+	mqd->cp_hqd_quantum = tmp;
 
 	/* map_queues packet doesn't need activate the queue,
 	 * so only kiq need set this field.
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 4/6 drm/amdgpu/gfx10: align mqd settings with KFD

In reply to Alex Deucher

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +5 -0
index ef7d91a4437ec..afa9cb46ffd21 100644
@@ -7014,6 +7014,11 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 	tmp = REG_SET_FIELD(tmp, CP_HQD_IB_CONTROL, MIN_IB_AVAIL_SIZE, 3);
 	mqd->cp_hqd_ib_control = tmp;
 
+	tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
+	mqd->cp_hqd_quantum = tmp;
+
 	/* set static priority for a compute queue/ring */
 	mqd->cp_hqd_pipe_priority = prop->hqd_pipe_priority;
 	mqd->cp_hqd_queue_priority = prop->hqd_queue_priority;
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH 5/6 drm/amdgpu/gfx11: align mqd settings with KFD

In reply to Alex Deucher

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -0
index e7ee112330ad0..61be7996775e4 100644
@@ -4408,6 +4408,11 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 	mqd->cp_hqd_pipe_priority = prop->hqd_pipe_priority;
 	mqd->cp_hqd_queue_priority = prop->hqd_queue_priority;
 
+	tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
+	mqd->cp_hqd_quantum = tmp;
+
 	mqd->cp_hqd_active = prop->hqd_active;
 
 	/* set UQ fenceaddress */
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH 6/6 drm/amdgpu/gfx12: align mqd settings with KFD

In reply to Alex Deucher

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
index c902e20960b02..c8c9ebe127654 100644
@@ -3279,6 +3279,11 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 	mqd->cp_hqd_pipe_priority = prop->hqd_pipe_priority;
 	mqd->cp_hqd_queue_priority = prop->hqd_queue_priority;
 
+	tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+	tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
+	mqd->cp_hqd_quantum = tmp;
+
 	mqd->cp_hqd_active = prop->hqd_active;
 
 	/* set UQ fenceaddress */
Signature · 1 line
2.53.0
#6 lore raw

RE: [PATCH 6/6] drm/amdgpu/gfx12: align mqd settings with KFD

[AMD Official Use Only - AMD Internal Distribution Only]

Series is:
Reviewed-by:Jesse Zhang <[email protected]>

Should we enable this feature for SDMA?

Quoted 38 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, February 19, 2026 3:34 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 6/6] drm/amdgpu/gfx12: align mqd settings with KFD

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
index c902e20960b02..c8c9ebe127654 100644
@@ -3279,6 +3279,11 @@ static int gfx_v12_0_compute_mqd_init(struct
 amdgpu_device *adev, void *m,
      mqd->cp_hqd_pipe_priority = prop->hqd_pipe_priority;
      mqd->cp_hqd_queue_priority = prop->hqd_queue_priority;
 
+     tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+     tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE,
 1);
+     tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM,
 QUANTUM_DURATION, 1);
+     mqd->cp_hqd_quantum = tmp;
+
      mqd->cp_hqd_active = prop->hqd_active;

      /* set UQ fenceaddress */

--
2.53.0

#7 lore raw
In reply to Alex Deucher

Ping on this series.

Alex

Quoted 37 lines · Alex Deucher

Make sure to set the quantum bits in the compute MQD for better fairness across queues of the same priority.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +6 -2
index 2b691452775bc..65b8497ad5f02 100644
@@ -2819,6 +2819,7 @@ static void gfx_v7_0_mqd_init(struct amdgpu_device *adev,
 {
        u64 hqd_gpu_addr;
        u64 wb_gpu_addr;
+       u32 tmp;
 
        /* init the mqd struct */
        memset(mqd, 0, sizeof(struct cik_mqd));
@@ -2923,7 +2924,11 @@ static void gfx_v7_0_mqd_init(struct amdgpu_device *adev,
        mqd->cp_hqd_atomic1_preop_lo = RREG32(mmCP_HQD_ATOMIC1_PREOP_LO);
        mqd->cp_hqd_atomic1_preop_hi = RREG32(mmCP_HQD_ATOMIC1_PREOP_HI);
        mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
-       mqd->cp_hqd_quantum = RREG32(mmCP_HQD_QUANTUM);
+       tmp = RREG32(mmCP_HQD_QUANTUM);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10);
+       mqd->cp_hqd_quantum = tmp;
        mqd->cp_hqd_pipe_priority = RREG32(mmCP_HQD_PIPE_PRIORITY);
        mqd->cp_hqd_queue_priority = RREG32(mmCP_HQD_QUEUE_PRIORITY);
        mqd->cp_hqd_iq_rptr = RREG32(mmCP_HQD_IQ_RPTR);
--

2.53.0