drm/amdgpu/gfx7: align mqd settings with KFD
Subsystems (2)
Alex Deucher
maintainerPATCH 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
@@ -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
Alex Deucher
maintainerPATCH 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
@@ -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
Alex Deucher
maintainerPATCH 3/16 drm/amdgpu/gfx9: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
Alex Deucher
maintainerPATCH 4/16 drm/amdgpu/gfx9.4.3: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
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.
Signed-off-by Alex Deucher <[email protected]>--- 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@@ -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
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.
Signed-off-by Alex Deucher <[email protected]>--- 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@@ -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
Russell, Kent
Reviewed-byRE: [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 KFDPing?
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.
Signed-off-by Alex Deucher <[email protected]>--- 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.cQuoted 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..d0b8fb9317201100644drivers/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, intxcc_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
Alex Deucher
maintainerPATCH 5/16 drm/amdgpu/gfx10: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
Alex Deucher
maintainerPATCH 6/16 drm/amdgpu/gfx11: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
Alex Deucher
maintainerPATCH 7/16 drm/amdgpu/gfx12: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
Alex Deucher
maintainerPATCH 8/16 drm/amdgpu/gfx12.1: align mqd settings with KFD
In reply to Alex DeucherMake 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
@@ -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
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.
Signed-off-by Alex Deucher <[email protected]>--- 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@@ -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
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.
Signed-off-by Alex Deucher <[email protected]>--- 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@@ -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
Russell, Kent
Reviewed-byRE: [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 KFDping?
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.
Signed-off-by Alex Deucher <[email protected]>--- 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.cQuoted 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..98dc6582b7aa6100644drivers/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
-0mqd->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
-0AMDGPU_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
Joshi, Mukul
Reviewed-byRE: [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 KFDping?
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.
Signed-off-by Alex Deucher <[email protected]>--- 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@@ -2246,6 +2246,11 @@ static intgfx_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
-0mqd->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
Alex Deucher
maintainerPATCH 9/16 drm/amdgpu/gfx8: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 10/16 drm/amdgpu/gfx9: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 11/16 drm/amdgpu/gfx9.4.3: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 12/16 drm/amdgpu/gfx10: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 13/16 drm/amdgpu/gfx11: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 14/16 drm/amdgpu/gfx12: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 15/16 drm/amdgpu/gfx12.1: rework kernel queue priority handling
In reply to Alex DeucherRather 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
@@ -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
Alex Deucher
maintainerPATCH 16/16 drm/amdgpu: don't set queue priorities for kernel queues
In reply to Alex DeucherAlign 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
@@ -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
@@ -4390,8 +4390,6 @@ static void gfx_v8_0_mqd_set_priority(struct amdgpu_ring *ring, struct vi_mqd *mif (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
@@ -3540,8 +3540,6 @@ static void gfx_v9_0_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqd *mif (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
@@ -1817,8 +1817,6 @@ static void gfx_v9_4_3_mqd_set_priority(struct amdgpu_ring *ring, struct v9_mqdif (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