Skip to contentSkip to conversation

drm/amdgpu/gfx7: align mqd settings with KFD

PATCH In review Alex Deucher 4 participants 23 messages Mar 18 – Apr 17

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/16 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.

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

---
 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/16 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.

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

---
 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/16 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.

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

---
 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 95be105671ece..2eb32f92a77c4 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/16 drm/amdgpu/gfx9.4.3: 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_4_3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +5 -1
index ad4d442e7345e..d0b8fb9317201 100644
@@ -1943,7 +1943,11 @@ static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
 
 	/* set static priority for a queue/ring */
 	gfx_v9_4_3_mqd_set_priority(ring, mqd);
-	mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_QUANTUM);
+	tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_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
#4 lore raw

Re: [PATCH 04/16] drm/amdgpu/gfx9.4.3: align mqd settings with KFD

ping?

Quoted 29 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_v9_4_3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +5 -2
index ad4d442e7345e..d0b8fb9317201 100644
@@ -1943,7 +1943,11 @@ static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
 
        /* set static priority for a queue/ring */
        gfx_v9_4_3_mqd_set_priority(ring, mqd);
-       mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_QUANTUM);
+       tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_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.
--

2.53.0

#5 lore raw

Re: [PATCH 04/16] drm/amdgpu/gfx9.4.3: align mqd settings with KFD

Ping?

Quoted 33 lines · Alex Deucher

ping?

Quoted 29 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_v9_4_3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +5 -2
index ad4d442e7345e..d0b8fb9317201 100644
@@ -1943,7 +1943,11 @@ static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
 
        /* set static priority for a queue/ring */
        gfx_v9_4_3_mqd_set_priority(ring, mqd);
-       mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_QUANTUM);
+       tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_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.
--

2.53.0

Reviewed-by
#6 lore raw

RE: [PATCH 04/16] drm/amdgpu/gfx9.4.3: align mqd settings with KFD

[Public]

Quoted 51 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, April 17, 2026 1:55 PM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 04/16] drm/amdgpu/gfx9.4.3: align mqd settings with KFD

Ping?

Quoted 4 lines · Alex Deucher

ping?

On Wed, Mar 18, 2026 at 10:34 AM Alex Deucher <[email protected]>

Quoted 10 lines · wrote:

Review

Quoted 10 lines

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_4_3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static int gfx_v9_4_3_xcc_mqd_init(struct

Quoted 4 lines

index ad4d442e7345e..d0b8fb9317201 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -0
@@ -1943,7 +1943,11 @@ static int gfx_v9_4_3_xcc_mqd_init(struct

amdgpu_ring *ring, int xcc_id)

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -1
        /* set static priority for a queue/ring */
        gfx_v9_4_3_mqd_set_priority(ring, mqd);
-       mqd->cp_hqd_quantum = RREG32_SOC15(GC, GET_INST(GC, xcc_id),

regCP_HQD_QUANTUM);

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static int gfx_v9_4_3_xcc_mqd_init(struct · line 1945

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
+       tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id),

regCP_HQD_QUANTUM);

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static int gfx_v9_4_3_xcc_mqd_init(struct · line 1947

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +2 -0
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE,

1);

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c static int gfx_v9_4_3_xcc_mqd_init(struct · line 1948

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -0
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM,

QUANTUM_DURATION, 1);

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
+       mqd->cp_hqd_quantum = tmp;
 
        /* map_queues packet doesn't need activate the queue,
         * so only kiq need set this field.
--

2.53.0

author maintainer
#7 lore raw

PATCH 5/16 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.

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

---
 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 8b60299b73ef7..58c69dcb527f7 100644
@@ -7011,6 +7011,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
#8 lore raw

PATCH 6/16 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.

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

---
 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 78d1f3eb522ed..121290f8b4930 100644
@@ -4398,6 +4398,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
#9 lore raw

PATCH 7/16 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.

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

---
 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 a418ae609c363..cd7b1ab2233f1 100644
@@ -3268,6 +3268,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
author maintainer
#10 lore raw

PATCH 8/16 drm/amdgpu/gfx12.1: 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_1.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +5 -0
index db49582a211f7..98dc6582b7aa6 100644
@@ -2246,6 +2246,11 @@ static int gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,
 	mqd->cp_mqd_stride_size = prop->mqd_stride_size ? prop->mqd_stride_size :
 		AMDGPU_MQD_SIZE_ALIGN(adev->mqds[AMDGPU_HW_IP_COMPUTE].mqd_size);
 
+	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;
 
 	return 0;
Signature · 1 line
2.53.0
#11 lore raw

Re: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

Ping?

Quoted 28 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_v12_1.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +5 -1
index db49582a211f7..98dc6582b7aa6 100644
@@ -2246,6 +2246,11 @@ static int gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,
        mqd->cp_mqd_stride_size = prop->mqd_stride_size ? prop->mqd_stride_size :
                AMDGPU_MQD_SIZE_ALIGN(adev->mqds[AMDGPU_HW_IP_COMPUTE].mqd_size);
 
+       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;
 
        return 0;
--

2.53.0

#12 lore raw

Re: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

ping?

Quoted 32 lines · Alex Deucher

Ping?

Quoted 28 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_v12_1.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +5 -1
index db49582a211f7..98dc6582b7aa6 100644
@@ -2246,6 +2246,11 @@ static int gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,
        mqd->cp_mqd_stride_size = prop->mqd_stride_size ? prop->mqd_stride_size :
                AMDGPU_MQD_SIZE_ALIGN(adev->mqds[AMDGPU_HW_IP_COMPUTE].mqd_size);
 
+       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;
 
        return 0;
--

2.53.0

Reviewed-by
#13 lore raw

RE: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 50 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, April 17, 2026 1:55 PM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

ping?

Quoted 4 lines · Alex Deucher

Ping?

On Wed, Mar 18, 2026 at 10:19 AM Alex Deucher <[email protected]>

Quoted 10 lines · wrote:

Review

Quoted 10 lines

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_1.c | 5 +++++
 1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_compute_mqd_init(struct

Quoted 4 lines

index db49582a211f7..98dc6582b7aa6 100644

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -0
@@ -2246,6 +2246,11 @@ static int gfx_v12_1_compute_mqd_init(struct

amdgpu_device *adev, void *m,

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_compute_mqd_init(struct · line 2246

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -0
        mqd->cp_mqd_stride_size = prop->mqd_stride_size ? prop-

mqd_stride_size :

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_compute_mqd_init(struct · line 2247

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -0
                AMDGPU_MQD_SIZE_ALIGN(adev-

mqds[AMDGPU_HW_IP_COMPUTE].mqd_size);

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -0
+       tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE,

1);

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_compute_mqd_init(struct · line 2250

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -0
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM,

QUANTUM_DURATION, 1);

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -1
+       mqd->cp_hqd_quantum = tmp;
+
        mqd->cp_hqd_active = prop->hqd_active;
 
        return 0;
--

2.53.0

Reviewed-by
#14 lore raw

RE: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

In reply to Alex Deucher

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 53 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, April 17, 2026 1:55 PM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 08/16] drm/amdgpu/gfx12.1: align mqd settings with KFD

ping?

Quoted 4 lines · Alex Deucher

Ping?

On Wed, Mar 18, 2026 at 10:19 AM Alex Deucher

Quoted 9 lines · <[email protected]> wrote:
Quoted 9 lines

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_1.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -0
index db49582a211f7..98dc6582b7aa6 100644
@@ -2246,6 +2246,11 @@ static int

gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int · line 2246

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0 -0
        mqd->cp_mqd_stride_size = prop->mqd_stride_size ? prop-

mqd_stride_size :

Quoted 2 lines

AMDGPU_MQD_SIZE_ALIGN(adev-

mqds[AMDGPU_HW_IP_COMPUTE].mqd_size);

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -0
+       tmp = REG_SET_FIELD(0, CP_HQD_QUANTUM, QUANTUM_EN, 1);
+       tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE,

1);

Quoted 1 line
Quoted 1 line

+ tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM,

QUANTUM_DURATION, 1);

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -1
+       mqd->cp_hqd_quantum = tmp;
+
        mqd->cp_hqd_active = prop->hqd_active;
 
        return 0;
--

2.53.0

author maintainer
#15 lore raw

PATCH 9/16 drm/amdgpu/gfx8: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +4 -1
index 130196859ff3f..49999bdb13499 100644
@@ -4535,7 +4535,10 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)
 	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);
+	if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 20);
+	else
+		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,
Signature · 1 line
2.53.0
author maintainer
#16 lore raw

PATCH 10/16 drm/amdgpu/gfx9: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -1
index 2eb32f92a77c4..aaf75c82b1bf5 100644
@@ -3670,7 +3670,10 @@ static int gfx_v9_0_mqd_init(struct amdgpu_ring *ring)
 	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);
+	if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		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,
Signature · 1 line
2.53.0
author maintainer
#17 lore raw

PATCH 11/16 drm/amdgpu/gfx9.4.3: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +4 -1
index d0b8fb9317201..e843793112638 100644
@@ -1946,7 +1946,10 @@ static int gfx_v9_4_3_xcc_mqd_init(struct amdgpu_ring *ring, int xcc_id)
 	tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_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);
+	if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		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,
Signature · 1 line
2.53.0
author maintainer
#18 lore raw

PATCH 12/16 drm/amdgpu/gfx10: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +12 -1
index 58c69dcb527f7..3618e68222458 100644
@@ -6794,6 +6794,12 @@ static int gfx_v10_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 	/* set up time quantum */
 	tmp = RREG32_SOC15(GC, 0, mmCP_GFX_HQD_QUANTUM);
 	tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_EN, 1);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 20);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 10);
 	mqd->cp_gfx_hqd_quantum = tmp;
 
 	/* set up gfx hqd base. this is similar as CP_RB_BASE */
@@ -7013,7 +7019,12 @@ static int gfx_v10_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 
 	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);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
 	mqd->cp_hqd_quantum = tmp;
 
 	/* set static priority for a compute queue/ring */
Signature · 1 line
2.53.0
author maintainer
#19 lore raw

PATCH 13/16 drm/amdgpu/gfx11: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +12 -1
index 121290f8b4930..6426270e9eb55 100644
@@ -4130,6 +4130,12 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 	/* set up time quantum */
 	tmp = regCP_GFX_HQD_QUANTUM_DEFAULT;
 	tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_EN, 1);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 20);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 10);
 	mqd->cp_gfx_hqd_quantum = tmp;
 
 	/* set up gfx hqd base. this is similar as CP_RB_BASE */
@@ -4400,7 +4406,12 @@ static int gfx_v11_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 
 	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);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
 	mqd->cp_hqd_quantum = tmp;
 
 	mqd->cp_hqd_active = prop->hqd_active;
Signature · 1 line
2.53.0
author maintainer
#20 lore raw

PATCH 14/16 drm/amdgpu/gfx12: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +12 -1
index cd7b1ab2233f1..66d058a40cc32 100644
@@ -3003,6 +3003,12 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,
 	/* set up time quantum */
 	tmp = regCP_GFX_HQD_QUANTUM_DEFAULT;
 	tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_EN, 1);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 20);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_QUANTUM, QUANTUM_DURATION, 10);
 	mqd->cp_gfx_hqd_quantum = tmp;
 
 	/* set up gfx hqd base. this is similar as CP_RB_BASE */
@@ -3270,7 +3276,12 @@ static int gfx_v12_0_compute_mqd_init(struct amdgpu_device *adev, void *m,
 
 	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);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
 	mqd->cp_hqd_quantum = tmp;
 
 	mqd->cp_hqd_active = prop->hqd_active;
Signature · 1 line
2.53.0
author maintainer
#21 lore raw

PATCH 15/16 drm/amdgpu/gfx12.1: rework kernel queue priority handling

In reply to Alex Deucher

Rather than setting a higher queue priority which could starve a lower priority queue, enable longer quantums for high priority kernel queues. This will avoid starvation, but provide longer runtime for high priority queues.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -1
index 98dc6582b7aa6..2fac3f99da644 100644
@@ -2248,7 +2248,12 @@ static int gfx_v12_1_compute_mqd_init(struct amdgpu_device *adev, void *m,
 
 	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);
+	/* increase the duration of a high priority kernel queue */
+	if (prop->kernel_queue &&
+	    (prop->hqd_pipe_priority == AMDGPU_GFX_PIPE_PRIO_HIGH))
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 2);
+	else
+		tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 1);
 	mqd->cp_hqd_quantum = tmp;
 
 	mqd->cp_hqd_active = prop->hqd_active;
Signature · 1 line
2.53.0
author maintainer
#22 lore raw

PATCH 16/16 drm/amdgpu: don't set queue priorities for kernel queues

In reply to Alex Deucher

Align with KFD and don't set queue priorities for kernel queues. This can result in starvation of lower priority queues.

v2: fix GC 8 and 9

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 4 +---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c    | 2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c    | 2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c  | 2 --
 4 files changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 -3
index 83750ab4e81b5..ccfbb6fc5f440 100644
@@ -780,10 +780,8 @@ static void amdgpu_ring_to_mqd_prop(struct amdgpu_ring *ring,
 	prop->hqd_active = ring->funcs->type == AMDGPU_RING_TYPE_KIQ;
 
 	prop->allow_tunneling = is_high_prio_compute;
-	if (is_high_prio_compute || is_high_prio_gfx) {
+	if (is_high_prio_compute || is_high_prio_gfx)
 		prop->hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH;
-		prop->hqd_queue_priority = AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;
-	}
 }
 
 int amdgpu_ring_init_mqd(struct amdgpu_ring *ring)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -2
index 49999bdb13499..b29dde9297b20 100644
@@ -4390,8 +4390,6 @@ static void gfx_v8_0_mqd_set_priority(struct amdgpu_ring *ring, struct vi_mqd *m
 	if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) {
 		if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) {
 			mqd->cp_hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH;
-			mqd->cp_hqd_queue_priority =
-				AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;
 		}
 	}
 }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -2
index aaf75c82b1bf5..150040625c440 100644
@@ -3540,8 +3540,6 @@ static void gfx_v9_0_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd *m
 	if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) {
 		if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) {
 			mqd->cp_hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH;
-			mqd->cp_hqd_queue_priority =
-				AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;
 		}
 	}
 }
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +0 -2
index e843793112638..cec64a8f21ebd 100644
@@ -1817,8 +1817,6 @@ static void gfx_v9_4_3_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd
 	if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) {
 		if (amdgpu_gfx_is_high_priority_compute_queue(adev, ring)) {
 			mqd->cp_hqd_pipe_priority = AMDGPU_GFX_PIPE_PRIO_HIGH;
-			mqd->cp_hqd_queue_priority =
-				AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM;
 		}
 	}
 }
Signature · 1 line
2.53.0