drm/amdgpu: gfx 12.1 cleanups
Subsystems (2)
Alex Deucher
maintainerPATCH 1/2 drm/amdgpu: gfx 12.1 cleanups
Remove some remnants from when the code was forked from gfx 12.0.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +2 -14
@@ -3630,12 +3630,6 @@ static int gfx_v12_1_eop_irq(struct amdgpu_device *adev,return -EINVAL ;switch (me_id) { -case 0 : -if (pipe_id ==0 ) -amdgpu_fence_process (&adev->gfx.gfx_ring[0 ]); -else -amdgpu_fence_process (&adev->gfx.gfx_ring[1 ]); -break ;case 1 :case 2 :for (i =0 ; i < adev->gfx.num_compute_rings; i++) {
@@ -3652,6 +3646,8 @@ static int gfx_v12_1_eop_irq(struct amdgpu_device *adev,amdgpu_fence_process (ring); }break ; +default : +break ; } }
@@ -3720,14 +3716,6 @@ static void gfx_v12_1_handle_priv_fault(struct amdgpu_device *adev,return ;switch (me_id) { -case 0 : -for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { - ring = &adev->gfx.gfx_ring[i]; -/* we only enabled 1 gfx queue per pipe for now */ -if (ring->me == me_id && ring->pipe == pipe_id) -drm_sched_fault (&ring->sched); - } -break ;case 1 :case 2 :for (i =0 ; i < adev->gfx.num_compute_rings; i++) {
Signature · 1 line
2.53.0
Alex Deucher
maintainerPATCH 2/2 drm/amdgpu/gfx12.1: add support for disable_kq
Plumb in support for disabling kernel queues and make it the default. For testing, kernel queues can be re-enabled by setting amdgpu.user_queue=0
v2: integrate feedback from Lijo
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 90 ++++++++++++++++++++------ 1 file changed, 71 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +71 -19
@@ -1155,11 +1155,13 @@ static int gfx_v12_1_sw_init(struct amdgpu_ip_block *ip_block)break ; } -/* recalculate compute rings to use based on hardware configuration */ - num_compute_rings = (adev->gfx.mec.num_pipe_per_mec * - adev->gfx.mec.num_queue_per_pipe) /2 ; - adev->gfx.num_compute_rings =min (adev->gfx.num_compute_rings, - num_compute_rings); +if (adev->gfx.num_compute_rings) { +/* recalculate compute rings to use based on hardware configuration */ + num_compute_rings = (adev->gfx.mec.num_pipe_per_mec * + adev->gfx.mec.num_queue_per_pipe) /2 ; + adev->gfx.num_compute_rings =min (adev->gfx.num_compute_rings, + num_compute_rings); + } num_xcc =NUM_XCC (adev->gfx.xcc_mask);
@@ -2794,6 +2796,33 @@ static void gfx_v12_1_xcc_fini(struct amdgpu_device *adev,gfx_v12_1_xcc_enable_gui_idle_interrupt (adev, false, xcc_id); } +static int gfx_v12_1_set_userq_eop_interrupts (struct amdgpu_device *adev, +bool enable) +{ +unsigned int irq_type; +int m, p, r; + +if (adev->gfx.disable_kq) { +for (m =0 ; m < adev->gfx.mec.num_mec; ++m) { +for (p =0 ; p < adev->gfx.mec.num_pipe_per_mec; p++) { + irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + + (m * adev->gfx.mec.num_pipe_per_mec) + + p; +if (enable) + r =amdgpu_irq_get (adev, &adev->gfx.eop_irq, + irq_type); +else + r =amdgpu_irq_put (adev, &adev->gfx.eop_irq, + irq_type); +if (r) +return r; + } + } + } + +return 0 ; +} +static int gfx_v12_1_hw_fini (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev;
@@ -2801,6 +2830,7 @@ static int gfx_v12_1_hw_fini(struct amdgpu_ip_block *ip_block)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +gfx_v12_1_set_userq_eop_interrupts (adev, false); num_xcc =NUM_XCC (adev->gfx.xcc_mask);for (i =0 ; i < num_xcc; i++) {
@@ -2868,10 +2898,26 @@ static int gfx_v12_1_early_init(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; + +switch (amdgpu_user_queue) { +case -1 : +default : + adev->gfx.disable_kq = true; + adev->gfx.disable_uq = true; +break ; +case 0 : + adev->gfx.disable_kq = false; + adev->gfx.disable_uq = true; +break ; + } + adev->gfx.funcs = &gfx_v12_1_gfx_funcs; - adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev), -AMDGPU_MAX_COMPUTE_RINGS ); +if (adev->gfx.disable_kq) + adev->gfx.num_compute_rings =0 ; +else + adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev), +AMDGPU_MAX_COMPUTE_RINGS );gfx_v12_1_set_kiq_pm4_funcs (adev);gfx_v12_1_set_ring_funcs (adev);
@@ -2898,6 +2944,10 @@ static int gfx_v12_1_late_init(struct amdgpu_ip_block *ip_block)if (r)return r; + r =gfx_v12_1_set_userq_eop_interrupts (adev, true); +if (r) +return r; +return 0 ; }
@@ -3715,21 +3765,23 @@ static void gfx_v12_1_handle_priv_fault(struct amdgpu_device *adev,if (xcc_id == -EINVAL )return ; -switch (me_id) { -case 1 : -case 2 : -for (i =0 ; i < adev->gfx.num_compute_rings; i++) { - ring = &adev->gfx.compute_ring +if (!adev->gfx.disable_kq) { +switch (me_id) { +case 1 : +case 2 : +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + ring = &adev->gfx.compute_ring [i + xcc_id * adev->gfx.num_compute_rings]; -if (ring->me == me_id && ring->pipe == pipe_id && - ring->queue == queue_id) -drm_sched_fault (&ring->sched); +if (ring->me == me_id && ring->pipe == pipe_id && + ring->queue == queue_id) +drm_sched_fault (&ring->sched); + } +break ; +default : +BUG (); +break ; } -break ; -default : -BUG (); -break ; } }
Signature · 1 line
2.53.0
Re: [PATCH 2/2] drm/amdgpu/gfx12.1: add support for disable_kq
Quoted 7 lines · Alex Deucher
Plumb in support for disabling kernel queues and make it the default. For testing, kernel queues can be re-enabled by setting amdgpu.user_queue=0
v2: integrate feedback from Lijo
Signed-off-by Alex Deucher <[email protected]>
A couple of minor comments below unrelated to this patch -
Quoted 14 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 90 ++++++++++++++++++++------ 1 file changed, 71 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0
-2@@ -1155,11 +1155,13 @@ static int gfx_v12_1_sw_init(struct amdgpu_ip_block *ip_block)break ; } -/* recalculate compute rings to use based on hardware configuration */ - num_compute_rings = (adev->gfx.mec.num_pipe_per_mec *
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_sw_init(struct amdgpu_ip_block *ip_block) · line 1164
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +7
-3- adev->gfx.mec.num_queue_per_pipe) / 2; - adev->gfx.num_compute_rings =min (adev->gfx.num_compute_rings, - num_compute_rings); +if (adev->gfx.num_compute_rings) { +/* recalculate compute rings to use based on hardware configuration */ + num_compute_rings = (adev->gfx.mec.num_pipe_per_mec * + adev->gfx.mec.num_queue_per_pipe) /2 ; + adev->gfx.num_compute_rings =min (adev->gfx.num_compute_rings, + num_compute_rings); + }
IP version is known during early init. Ideally, this calculation could be done in early_init itself, not required to be scattered across.
Quoted 102 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +56
-7num_xcc =NUM_XCC (adev->gfx.xcc_mask);@@ -2794,6 +2796,33 @@ static void gfx_v12_1_xcc_fini(struct amdgpu_device *adev,gfx_v12_1_xcc_enable_gui_idle_interrupt (adev, false, xcc_id); } +static int gfx_v12_1_set_userq_eop_interrupts (struct amdgpu_device *adev, +bool enable) +{ +unsigned int irq_type; +int m, p, r; + +if (adev->gfx.disable_kq) { +for (m =0 ; m < adev->gfx.mec.num_mec; ++m) { +for (p =0 ; p < adev->gfx.mec.num_pipe_per_mec; p++) { + irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + + (m * adev->gfx.mec.num_pipe_per_mec) + + p; +if (enable) + r =amdgpu_irq_get (adev, &adev->gfx.eop_irq, + irq_type); +else + r =amdgpu_irq_put (adev, &adev->gfx.eop_irq, + irq_type); +if (r) +return r; + } + } + } + +return 0 ; +} +static int gfx_v12_1_hw_fini (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev;@@ -2801,6 +2830,7 @@ static int gfx_v12_1_hw_fini(struct amdgpu_ip_block *ip_block)amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); +gfx_v12_1_set_userq_eop_interrupts (adev, false); num_xcc =NUM_XCC (adev->gfx.xcc_mask);for (i =0 ; i < num_xcc; i++) {@@ -2868,10 +2898,26 @@ static int gfx_v12_1_early_init(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; + +switch (amdgpu_user_queue) { +case -1 : +default : + adev->gfx.disable_kq = true; + adev->gfx.disable_uq = true; +break ; +case 0 : + adev->gfx.disable_kq = false; + adev->gfx.disable_uq = true; +break ; + } + adev->gfx.funcs = &gfx_v12_1_gfx_funcs; - adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev), -AMDGPU_MAX_COMPUTE_RINGS ); +if (adev->gfx.disable_kq) + adev->gfx.num_compute_rings =0 ; +else + adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev), +AMDGPU_MAX_COMPUTE_RINGS );gfx_v12_1_set_kiq_pm4_funcs (adev);gfx_v12_1_set_ring_funcs (adev);@@ -2898,6 +2944,10 @@ static int gfx_v12_1_late_init(struct amdgpu_ip_block *ip_block)if (r)return r; + r =gfx_v12_1_set_userq_eop_interrupts (adev, true); +if (r) +return r; +return 0 ; }@@ -3715,21 +3765,23 @@ static void gfx_v12_1_handle_priv_fault(struct amdgpu_device *adev,if (xcc_id == -EINVAL )return ; -switch (me_id) { -case 1 : -case 2 : -for (i =0 ; i < adev->gfx.num_compute_rings; i++) { - ring = &adev->gfx.compute_ring +if (!adev->gfx.disable_kq) { +switch (me_id) { +case 1 : +case 2 : +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + ring = &adev->gfx.compute_ring [i + xcc_id * adev->gfx.num_compute_rings];
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static void gfx_v12_1_handle_priv_fault(struct amdgpu_device *adev, · line 3782
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +7
-3-if (ring->me == me_id && ring->pipe == pipe_id && - ring->queue == queue_id) -drm_sched_fault (&ring->sched); +if (ring->me == me_id && ring->pipe == pipe_id && + ring->queue == queue_id) +drm_sched_fault (&ring->sched); + } +break ; +default : +BUG ();
It's not required to crash the kernel.
Thanks,
Lijo
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1
-4+break ; } -break ; -default : -BUG (); -break ; } }
Quoted 4 lines · Alex Deucher
Remove some remnants from when the code was forked from gfx 12.0.
Signed-off-by Alex Deucher <[email protected]>
One minor comment below for consideration.
Quoted 22 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +0
-6@@ -3630,12 +3630,6 @@ static int gfx_v12_1_eop_irq(struct amdgpu_device *adev,return -EINVAL ;switch (me_id) { -case 0 : -if (pipe_id ==0 ) -amdgpu_fence_process (&adev->gfx.gfx_ring[0 ]); -else -amdgpu_fence_process (&adev->gfx.gfx_ring[1 ]); -break ;case 1 :case 2 :for (i =0 ; i < adev->gfx.num_compute_rings; i++) {
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c static int gfx_v12_1_eop_irq(struct amdgpu_device *adev, · line 3649
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1
-0@@ -3652,6 +3646,8 @@ static int gfx_v12_1_eop_irq(struct amdgpu_device *adev,amdgpu_fence_process (ring); }break ; +default :
Adding a dev_dbg may be helpful though it's not expected to take this path with disable_kq.
Thanks,
Lijo
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1
-8+break ; } }@@ -3720,14 +3716,6 @@ static void gfx_v12_1_handle_priv_fault(struct amdgpu_device *adev,return ;switch (me_id) { -case 0 : -for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { - ring = &adev->gfx.gfx_ring[i]; -/* we only enabled 1 gfx queue per pipe for now */ -if (ring->me == me_id && ring->pipe == pipe_id) -drm_sched_fault (&ring->sched); - } -break ;case 1 :case 2 :for (i =0 ; i < adev->gfx.num_compute_rings; i++) {