drm/amdgpu/jpeg: add flags for disabling KQs/UQs
Subsystems (2)
Alex Deucher
maintainerPATCH 1/9 drm/amdgpu/jpeg: add flags for disabling KQs/UQs
Add flags for handling disabling of kernel queues or user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +3 -0
@@ -149,6 +149,9 @@ struct amdgpu_jpeg {u32 *ip_dump;u32 reg_count;const struct amdgpu_hwip_reg_entry *reg_list; + +bool disable_uq; +bool disable_kq; };int amdgpu_jpeg_sw_init (struct amdgpu_device *adev);
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 2/9 drm/amdgpu/jpeg4.0.3: add support for disabling kernel queues
Allow the user to disable kernel queues. This can be used to free up vmid resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +17 -0
@@ -119,6 +119,19 @@ static int jpeg_v4_0_3_early_init(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->jpeg.disable_kq = false; + adev->jpeg.disable_uq = true; +break ; +case 2 : + adev->jpeg.disable_kq = true; + adev->jpeg.disable_uq = true; +break ; + } + adev->jpeg.num_jpeg_rings =AMDGPU_MAX_JPEG_RINGS_4_0_3 ;jpeg_v4_0_3_set_dec_ring_funcs (adev);
@@ -175,6 +188,10 @@ static int jpeg_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)for (j =0 ; j < adev->jpeg.num_jpeg_rings; ++j) { ring = &adev->jpeg.inst[i].ring_dec[j]; ring->use_doorbell = true; +if (adev->jpeg.disable_kq) { + ring->no_scheduler = true; + ring->no_user_submission = true; + } ring->vm_hub =AMDGPU_MMHUB0 (adev->jpeg.inst[i].aid_id);if (!amdgpu_sriov_vf (adev)) { ring->doorbell_index =
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 3/9 drm/amdgpu/jpeg5.0.1: add support for disabling kernel queues
In reply to Alex DeucherAllow the user to disable kernel queues. This can be used to free up vmid resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c +17 -0
@@ -118,6 +118,19 @@ static int jpeg_v5_0_1_early_init(struct amdgpu_ip_block *ip_block)if (!adev->jpeg.num_jpeg_inst || adev->jpeg.num_jpeg_inst >AMDGPU_MAX_JPEG_INSTANCES )return -ENOENT ; +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->jpeg.disable_kq = false; + adev->jpeg.disable_uq = true; +break ; +case 2 : + adev->jpeg.disable_kq = true; + adev->jpeg.disable_uq = true; +break ; + } + adev->jpeg.num_jpeg_rings =AMDGPU_MAX_JPEG_RINGS ;jpeg_v5_0_1_set_dec_ring_funcs (adev);jpeg_v5_0_1_set_irq_funcs (adev);
@@ -172,6 +185,10 @@ static int jpeg_v5_0_1_sw_init(struct amdgpu_ip_block *ip_block)for (j =0 ; j < adev->jpeg.num_jpeg_rings; ++j) { ring = &adev->jpeg.inst[i].ring_dec[j]; ring->use_doorbell = true; +if (adev->jpeg.disable_kq) { + ring->no_scheduler = true; + ring->no_user_submission = true; + } ring->vm_hub =AMDGPU_MMHUB0 (adev->jpeg.inst[i].aid_id);if (!amdgpu_sriov_vf (adev)) { ring->doorbell_index =
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 4/9 drm/amdgpu/vcn: add flags for disabling KQs/UQs
In reply to Alex DeucherAdd flags for handling disabling of kernel queues or user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +3 -0
@@ -368,6 +368,9 @@ struct amdgpu_vcn {struct mutex workload_profile_mutex;u32 reg_count;const struct amdgpu_hwip_reg_entry *reg_list; + +bool disable_uq; +bool disable_kq; };struct amdgpu_fw_shared_rb_ptrs_struct {
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 5/9 drm/amdgpu/vcn4.0.3: add support for disabling kernel queues
In reply to Alex DeucherAllow the user to disable kernel queues. This can be used to free up vmid resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c +17 -0
@@ -115,6 +115,19 @@ static int vcn_v4_0_3_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int i, r; +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->vcn.disable_kq = false; + adev->vcn.disable_uq = true; +break ; +case 2 : + adev->vcn.disable_kq = true; + adev->vcn.disable_uq = true; +break ; + } +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i)/* re-use enc ring as unified ring */ adev->vcn.inst[i].num_enc_rings =1 ;
@@ -217,6 +230,10 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block) ring = &adev->vcn.inst[i].ring_enc[0 ]; ring->use_doorbell = true; +if (adev->vcn.disable_kq) { + ring->no_scheduler = true; + ring->no_user_submission = true; + }if (!amdgpu_sriov_vf (adev)) ring->doorbell_index =
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 6/9 drm/amdgpu/vcn5.0.1: add support for disabling kernel queues
In reply to Alex DeucherAllow the user to disable kernel queues. This can be used to free up vmid resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c +17 -0
@@ -94,6 +94,19 @@ static int vcn_v5_0_1_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int i, r; +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->vcn.disable_kq = false; + adev->vcn.disable_uq = true; +break ; +case 2 : + adev->vcn.disable_kq = true; + adev->vcn.disable_uq = true; +break ; + } +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i)/* re-use enc ring as unified ring */ adev->vcn.inst[i].num_enc_rings =1 ;
@@ -188,6 +201,10 @@ static int vcn_v5_0_1_sw_init(struct amdgpu_ip_block *ip_block) ring = &adev->vcn.inst[i].ring_enc[0 ]; ring->use_doorbell = true; +if (adev->vcn.disable_kq) { + ring->no_scheduler = true; + ring->no_user_submission = true; + }if (!amdgpu_sriov_vf (adev)) ring->doorbell_index = (adev->doorbell_index.vcn.vcn_ring0_1 << 1) +
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 7/9 drm/amdgpu/sdma4.4.2: add support for disabling kernel queues
In reply to Alex DeucherAllow the user to disable kernel queues. This can be used to free up vmid resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +14 -0
@@ -1359,6 +1359,19 @@ static int sdma_v4_4_2_early_init(struct amdgpu_ip_block *ip_block)struct amdgpu_device *adev = ip_block->adev;int r; +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->sdma.no_user_submission = false; + adev->sdma.disable_uq = true; +break ; +case 2 : + adev->sdma.no_user_submission = true; + adev->sdma.disable_uq = true; +break ; + } + r =sdma_v4_4_2_init_microcode (adev);if (r)return r;
@@ -1478,6 +1491,7 @@ static int sdma_v4_4_2_sw_init(struct amdgpu_ip_block *ip_block)/* doorbell size is 2 dwords, get DWORD offset */ ring->doorbell_index = adev->doorbell_index.sdma_engine[i] <<1 ; ring->vm_hub =AMDGPU_MMHUB0 (aid_id); + ring->no_user_submission = adev->sdma.no_user_submission;sprintf (ring->name,"sdma%d.%d" , aid_id, i % adev->sdma.num_inst_per_aid);
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 8/9 drm/amdgpu/gfx9.4.3: add support for disabling kernel queues
In reply to Alex DeucherAllow the user to disable kernel queues. This can be used to free up vmid and HQD resources if kernel queues are not needed.
Set amdgpu.user_queue=2 to disable kernel queues.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 117 ++++++++++++++++++++---- 1 file changed, 99 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +99 -18
@@ -1107,22 +1107,24 @@ static int gfx_v9_4_3_sw_init(struct amdgpu_ip_block *ip_block)/* set up the compute queues - allocate horizontally across pipes */ for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { ring_id =0 ; -for (i =0 ; i < adev->gfx.mec.num_mec; ++i) { -for (j =0 ; j < adev->gfx.mec.num_queue_per_pipe; j++) { -for (k =0 ; k < adev->gfx.mec.num_pipe_per_mec; - k++) { -if (!amdgpu_gfx_is_mec_queue_enabled ( - adev, xcc_id, i, k, j)) -continue ; - - r =gfx_v9_4_3_compute_ring_init (adev, - ring_id, - xcc_id, - i, k, j); -if (r) -return r; - - ring_id++; +if (!adev->gfx.disable_kq) { +for (i =0 ; i < adev->gfx.mec.num_mec; ++i) { +for (j =0 ; j < adev->gfx.mec.num_queue_per_pipe; j++) { +for (k =0 ; k < adev->gfx.mec.num_pipe_per_mec; + k++) { +if (!amdgpu_gfx_is_mec_queue_enabled ( + adev, xcc_id, i, k, j)) +continue ; + + r =gfx_v9_4_3_compute_ring_init (adev, + ring_id, + xcc_id, + i, k, j); +if (r) +return r; + + ring_id++; + } } } }
@@ -2350,6 +2352,63 @@ static void gfx_v9_4_3_xcc_fini(struct amdgpu_device *adev, int xcc_id)gfx_v9_4_3_xcc_cp_compute_enable (adev, false, xcc_id); } +static int gfx_v9_4_3_set_userq_eop_interrupts (struct amdgpu_device *adev, +bool enable) +{ +int num_xcc =NUM_XCC (adev->gfx.xcc_mask); +unsigned int irq_type; +int m, p, xcc_id, r; + +if (adev->gfx.disable_kq) { +for (xcc_id =0 ; xcc_id < num_xcc; xcc_id++) { +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) { +if (!enable) +return r; + goto err_compute; + } + } + } + } + } + +err_compute: +for (p--; p >=0 ; p--) { + irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + + (m * adev->gfx.mec.num_pipe_per_mec) + p; +amdgpu_irq_put (adev, &adev->gfx.eop_irq, irq_type); + } +for (m--; m >=0 ; m--) { +for (p = adev->gfx.mec.num_pipe_per_mec -1 ; p >=0 ; p--) { + irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + + (m * adev->gfx.mec.num_pipe_per_mec) + p; +amdgpu_irq_put (adev, &adev->gfx.eop_irq, irq_type); + } + } +for (xcc_id--; xcc_id >=0 ; xcc_id--) { +for (m = adev->gfx.mec.num_mec -1 ; m <=0 ; m--) { +for (p = adev->gfx.mec.num_pipe_per_mec -1 ; p >=0 ; p--) { + irq_type =AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + + (m * adev->gfx.mec.num_pipe_per_mec) + p; +amdgpu_irq_put (adev, &adev->gfx.eop_irq, irq_type); + } + } + } + +return r; +} +static int gfx_v9_4_3_hw_init (struct amdgpu_ip_block *ip_block) {int r;
@@ -2382,9 +2441,14 @@ static int gfx_v9_4_3_hw_init(struct amdgpu_ip_block *ip_block) r =amdgpu_irq_get (adev, &adev->gfx.bad_op_irq,0 );if (r) goto err_bad_op; + r =gfx_v9_4_3_set_userq_eop_interrupts (adev, true); +if (r) + goto err_bad_eop;return 0 ; +err_bad_eop: +amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 ); err_bad_op:amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 ); err_priv_inst:
@@ -2467,6 +2531,7 @@ static int gfx_v9_4_3_hw_fini(struct amdgpu_ip_block *ip_block)amdgpu_irq_put (adev, &adev->gfx.bad_op_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_inst_irq,0 );amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 ); +gfx_v9_4_3_set_userq_eop_interrupts (adev, false); num_xcc =NUM_XCC (adev->gfx.xcc_mask);for (i =0 ; i < num_xcc; i++) {
@@ -2612,8 +2677,24 @@ static int gfx_v9_4_3_early_init(struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; - adev->gfx.num_compute_rings =min (amdgpu_gfx_get_num_kcq (adev), -AMDGPU_MAX_COMPUTE_RINGS ); +switch (amdgpu_user_queue) { +case -1 : +case 0 : +default : + adev->gfx.disable_kq = false; + adev->gfx.disable_uq = true; +break ; +case 2 : + adev->gfx.disable_kq = true; + adev->gfx.disable_uq = true; +break ; + } + +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_v9_4_3_set_kiq_pm4_funcs (adev);gfx_v9_4_3_set_ring_funcs (adev);gfx_v9_4_3_set_irq_funcs (adev);
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 9/9 drm/amdgpu/gmc9: make all vmids available to KFD if KQs are disabled
In reply to Alex DeucherIf the user has disabled kernel queues, then make all vmids available to HWS.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +12 -4
@@ -2025,11 +2025,19 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)* The first KFD VMID is 8 for GPUs with graphics, 3 for * compute-only GPUs. On compute-only GPUs that leaves 2 VMIDs * for video processing. +* +* If kernel queues are disabled, allow KFD to use all vmids. */ - adev->vm_manager.first_kfd_vmid = - (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,1 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,2 ) || -amdgpu_is_multi_aid (adev)) ? +if (adev->gfx.disable_kq && + adev->jpeg.disable_kq && + adev->vcn.disable_kq && + adev->sdma.no_user_submission) + adev->vm_manager.first_kfd_vmid =1 ; +else + adev->vm_manager.first_kfd_vmid = + (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,1 ) || +amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,2 ) || +amdgpu_is_multi_aid (adev)) ?3 :8 ;
Signature · 1 line
2.54.0
RE: [PATCH 9/9] drm/amdgpu/gmc9: make all vmids available to KFD if KQs are disabled
AMD General
Series is
Quoted 52 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: June 15, 2026 5:17 PM
To: [email protected]; Russell, Kent <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 9/9] drm/amdgpu/gmc9: make all vmids available to KFD if KQs are disabledIf the user has disabled kernel queues, then make all vmids available to HWS.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-2@@ -2025,11 +2025,19 @@ static int gmc_v9_0_sw_init(structamdgpu_ip_block *ip_block) * The first KFD VMID is 8 for GPUs with graphics, 3 for * compute-only GPUs. On compute-only GPUs that leaves 2 VMIDs * for video processing. +* +* If kernel queues are disabled, allow KFD to use all vmids. */ - adev->vm_manager.first_kfd_vmid = - (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 1)|| - amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 2) ||drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8
-1- amdgpu_is_multi_aid(adev)) ? +if (adev->gfx.disable_kq && + adev->jpeg.disable_kq && + adev->vcn.disable_kq && + adev->sdma.no_user_submission) + adev->vm_manager.first_kfd_vmid =1 ; +else + adev->vm_manager.first_kfd_vmid = + (amdgpu_ip_version(adev, GC_HWIP, 0) ==
IP_VERSION(9, 4, 1)||
+amdgpu_ip_version(adev, GC_HWIP, 0)==IP_VERSION(9, 4, 2)||
+amdgpu_is_multi_aid(adev)) ?3 : 8;--
2.54.0