drm/amdgpu/gfx8: rework kernel queue priority handling
Subsystems (2)
Alex Deucher
maintainerPATCH 1/8 drm/amdgpu/gfx8: rework kernel queue priority handling
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
@@ -4542,7 +4542,10 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)if (ring != &adev->gfx.kiq[0 ].ring) { 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;
Signature · 1 line
2.56.0
Alex Deucher
maintainerPATCH 2/8 drm/amdgpu/gfx9: rework kernel queue priority handling
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
@@ -3668,7 +3668,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.56.0
Alex Deucher
maintainerPATCH 3/8 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
@@ -1885,7 +1885,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.56.0
Alex Deucher
maintainerPATCH 4/8 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
@@ -6800,6 +6800,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 */
@@ -7019,7 +7025,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.56.0
Alex Deucher
maintainerPATCH 5/8 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
@@ -4238,6 +4238,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 */
@@ -4509,7 +4515,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.56.0
Alex Deucher
maintainerPATCH 6/8 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
@@ -2945,6 +2945,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 */
@@ -3213,7 +3219,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.56.0
Alex Deucher
maintainerPATCH 7/8 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
@@ -2362,7 +2362,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.56.0
Alex Deucher
maintainerPATCH 8/8 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
@@ -830,10 +830,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
@@ -4396,8 +4396,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
@@ -3538,8 +3538,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
@@ -1756,8 +1756,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.56.0