drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX11
Subsystems (2)
Alex Deucher
maintainerPATCH v5 1/2 drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX11
From: Srinivasan Shanmugam <[email protected]>
This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in the mes_set_hw_res_pkt structure, allowing for proper synchronization of the cleaner shader execution.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +15 -6
@@ -743,7 +743,9 @@ static int mes_v11_0_set_hw_resources(struct amdgpu_mes *mes)static int mes_v11_0_set_hw_resources_1 (struct amdgpu_mes *mes) { -int size =128 *AMDGPU_GPU_PAGE_SIZE ; +unsigned int hw_rsrc_size =128 *AMDGPU_GPU_PAGE_SIZE ; +/* add a page for the cleaner shader fence */ +unsigned int alloc_size = hw_rsrc_size +AMDGPU_GPU_PAGE_SIZE ;int ret =0 ;struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_pkt;
@@ -754,7 +756,7 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes) mes_set_hw_res_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; mes_set_hw_res_pkt.enable_mes_info_ctx =1 ; - ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE, + ret = amdgpu_bo_create_kernel(adev, alloc_size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, &mes->resource_1, &mes->resource_1_gpu_addr,
@@ -765,7 +767,10 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes) } mes_set_hw_res_pkt.mes_info_ctx_mc_addr = mes->resource_1_gpu_addr; - mes_set_hw_res_pkt.mes_info_ctx_size = mes->resource_1->tbo.base.size; + mes_set_hw_res_pkt.mes_info_ctx_size = hw_rsrc_size; + mes_set_hw_res_pkt.cleaner_shader_fence_mc_addr = + mes->resource_1_gpu_addr + hw_rsrc_size; +return mes_v11_0_submit_pkt_and_poll_completion (mes, &mes_set_hw_res_pkt,sizeof (mes_set_hw_res_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1 , api_status));
@@ -1632,7 +1637,8 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block)if (r) goto failure; -if (amdgpu_sriov_is_mes_info_enable (adev)) { +if (amdgpu_sriov_is_mes_info_enable (adev) || + adev->gfx.enable_cleaner_shader) { r =mes_v11_0_set_hw_resources_1 (&adev->mes);if (r) {DRM_ERROR ("failed mes_v11_0_set_hw_resources_1, r=%d\n" , r);
@@ -1665,10 +1671,13 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block)static int mes_v11_0_hw_fini (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; -if (amdgpu_sriov_is_mes_info_enable (adev)) { + +if (amdgpu_sriov_is_mes_info_enable (adev) || + adev->gfx.enable_cleaner_shader) {amdgpu_bo_free_kernel (&adev->mes.resource_1, &adev->mes.resource_1_gpu_addr, - &adev->mes.resource_1_addr); + &adev->mes.resource_1_addr); } +return 0 ; }
Signature · 1 line
2.48.1
Alex Deucher
maintainerPATCH 2/2 drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in the mes_set_hw_res_pkt structure, allowing for proper synchronization of the cleaner shader execution.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +22 -0
@@ -678,6 +678,9 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,static int mes_v12_0_set_hw_resources_1 (struct amdgpu_mes *mes,int pipe) { +unsigned int alloc_size =AMDGPU_GPU_PAGE_SIZE ; +int ret =0 ; +struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_1_pkt;memset (&mes_set_hw_res_1_pkt,0 ,sizeof (mes_set_hw_res_1_pkt));
@@ -687,6 +690,19 @@ static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes, int pipe) mes_set_hw_res_1_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; mes_set_hw_res_1_pkt.mes_kiq_unmap_timeout =0xa ; + ret =amdgpu_bo_create_kernel (adev, alloc_size,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &mes->resource_1, + &mes->resource_1_gpu_addr, + &mes->resource_1_addr); +if (ret) { +dev_err (adev->dev,"(%d) failed to create mes resource_1 bo\n" , ret); +return ret; + } + + mes_set_hw_res_1_pkt.cleaner_shader_fence_mc_addr = + mes->resource_1_gpu_addr; +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &mes_set_hw_res_1_pkt,sizeof (mes_set_hw_res_1_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1 , api_status));
@@ -1770,6 +1786,12 @@ static int mes_v12_0_hw_init(struct amdgpu_ip_block *ip_block)static int mes_v12_0_hw_fini (struct amdgpu_ip_block *ip_block) { +struct amdgpu_device *adev = ip_block->adev; + +if (adev->enable_uni_mes) +amdgpu_bo_free_kernel (&adev->mes.resource_1, + &adev->mes.resource_1_gpu_addr, + &adev->mes.resource_1_addr);return 0 ; }
Signature · 1 line
2.48.1
RE: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
[AMD Official Use Only - AMD Internal Distribution Only]
Why only free the mem when unified mes is enabled , I remembered that set_hw_resource_1 will also be called in none-unified mes mode .
Another thing is eventually we probably should allocate total 129 pages the same as GFX11 (128 for hw_resource_1 and one extra page for MES internal usage) . But seems SRIOV still not use that 128 pages, It can be updated later when I update the API for gfx12 to enable that .
Regards
Shaoyun.liu
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Monday, February 10, 2025 4:19 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; SHANMUGAM, SRINIVASAN <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in the mes_set_hw_res_pkt structure, allowing for proper synchronization of the cleaner shader execution.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +3 -0
@@ -678,6 +678,9 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,static int mes_v12_0_set_hw_resources_1 (struct amdgpu_mes *mes,int pipe) { +unsigned int alloc_size =AMDGPU_GPU_PAGE_SIZE ; +int ret =0 ; +struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_1_pkt; memset(&mes_set_hw_res_1_pkt, 0, sizeof(mes_set_hw_res_1_pkt)); @@ -687,6 +690,19 @@ static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes, int pipe) mes_set_hw_res_1_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS;
mes_set_hw_res_1_pkt.mes_kiq_unmap_timeout = 0xa;
+ ret = amdgpu_bo_create_kernel(adev, alloc_size, PAGE_SIZE,
+ AMDGPU_GEM_DOMAIN_VRAM, + &mes->resource_1, + &mes->resource_1_gpu_addr, + &mes->resource_1_addr);
+ if (ret) {
+ dev_err(adev->dev, "(%d) failed to create mes resource_1 bo\n", ret);
+ return ret;
+ }
+
+ mes_set_hw_res_1_pkt.cleaner_shader_fence_mc_addr =
+ mes->resource_1_gpu_addr;
+
return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe,
&mes_set_hw_res_1_pkt, sizeof(mes_set_hw_res_1_pkt),
offsetof(union MESAPI_SET_HW_RESOURCES_1, api_status)); @@ -1770,6 +1786,12 @@ static int mes_v12_0_hw_init(struct amdgpu_ip_block *ip_block) static int mes_v12_0_hw_fini(struct amdgpu_ip_block *ip_block) {
+ struct amdgpu_device *adev = ip_block->adev;
+
+ if (adev->enable_uni_mes)
+ amdgpu_bo_free_kernel(&adev->mes.resource_1,
+ &adev->mes.resource_1_gpu_addr,
+ &adev->mes.resource_1_addr);
return 0;}
--
2.48.1
Re: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Why only free the mem when unified mes is enabled , I remembered that
set_hw_resource_1will also be called in none-unified mes mode .
mes_v12_0_set_hw_resources_1() is currently only called when unified mes mode is enabled so it makes sense to align the free side as well.
Quoted 3 lines
Another thing is eventually we probably should allocate total 129 pages the same as GFX11 (128 for
hw_resource_1and one extra page for MES internal usage) . But seems SRIOV still not use that 128 pages, It can be updated later when I update the API for gfx12 to enable that .
yeah, we can add that later if we need it. The current mes 12 packet doesn't seem to support that feature yet.
Alex
Quoted 78 lines
Regards
Shaoyun.liu-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Monday, February 10, 2025 4:19 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; SHANMUGAM, SRINIVASAN <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in themes_set_hw_res_pktstructure, allowing for proper synchronization of the cleaner shader execution.Cc Christian König <[email protected]>Cc Srinivasan Shanmugam <[email protected]>Suggested-by Shaoyun Liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +3
-0@@ -678,6 +678,9 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,static int mes_v12_0_set_hw_resources_1 (struct amdgpu_mes *mes,int pipe) { +unsigned int alloc_size =AMDGPU_GPU_PAGE_SIZE ; +int ret =0 ; +struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_1_pkt; memset(&mes_set_hw_res_1_pkt, 0, sizeof(mes_set_hw_res_1_pkt)); @@ -687,6 +690,19 @@ static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes, int pipe) mes_set_hw_res_1_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS;mes_set_hw_res_1_pkt.mes_kiq_unmap_timeout = 0xa;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +19
-1+ ret =amdgpu_bo_create_kernel (adev, alloc_size,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &mes->resource_1, + &mes->resource_1_gpu_addr, + &mes->resource_1_addr); +if (ret) { +dev_err (adev->dev,"(%d) failed to create mes resource_1 bo\n" , ret); +return ret; + } + + mes_set_hw_res_1_pkt.cleaner_shader_fence_mc_addr = + mes->resource_1_gpu_addr; +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &mes_set_hw_res_1_pkt,sizeof (mes_set_hw_res_1_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1, api_status)); @@ -1770,6 +1786,12 @@ static int mes_v12_0_hw_init(struct amdgpu_ip_block *ip_block) static int mes_v12_0_hw_fini(struct amdgpu_ip_block *ip_block) { +struct amdgpu_device *adev = ip_block->adev; + +if (adev->enable_uni_mes) +amdgpu_bo_free_kernel (&adev->mes.resource_1, + &adev->mes.resource_1_gpu_addr, + &adev->mes.resource_1_addr);return 0 ; } --2.48.1
RE: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
[AMD Official Use Only - AMD Internal Distribution Only]
I believe this could be a mistake , from MES side , the set_hw_resource_1 should always be called no matter it's unified or none-unified . I think we should remove it for the unified check at first place .
Regards
Shaoyun.liu
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, February 11, 2025 10:24 AM
To: Liu, Shaoyun <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Koenig, Christian <[email protected]>; SHANMUGAM, SRINIVASAN <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Why only free the mem when unified mes is enabled , I remembered that
set_hw_resource_1will also be called in none-unified mes mode .
mes_v12_0_set_hw_resources_1() is currently only called when unified mes mode is enabled so it makes sense to align the free side as well.
Quoted 3 lines
Another thing is eventually we probably should allocate total 129 pages the same as GFX11 (128 for
hw_resource_1and one extra page for MES internal usage) . But seems SRIOV still not use that 128 pages, It can be updated later when I update the API for gfx12 to enable that .
yeah, we can add that later if we need it. The current mes 12 packet doesn't seem to support that feature yet.
Alex
Quoted 86 lines
Regards
Shaoyun.liu-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Monday, February 10, 2025 4:19 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; SHANMUGAM, SRINIVASAN <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX12This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in themes_set_hw_res_pktstructure, allowing for proper synchronization of the cleaner shader execution.Cc Christian König <[email protected]>Cc Srinivasan Shanmugam <[email protected]>Suggested-by Shaoyun Liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +3
-0@@ -678,6 +678,9 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes, static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes, int pipe) { +unsigned int alloc_size =AMDGPU_GPU_PAGE_SIZE ; +int ret =0 ; +struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_1_pkt;memset(&mes_set_hw_res_1_pkt, 0, sizeof(mes_set_hw_res_1_pkt)); @@ -687,6 +690,19 @@ static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes, int pipe) mes_set_hw_res_1_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS; mes_set_hw_res_1_pkt.mes_kiq_unmap_timeout = 0xa;drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +13
-0+ ret =amdgpu_bo_create_kernel (adev, alloc_size,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &mes->resource_1, + &mes->resource_1_gpu_addr, + &mes->resource_1_addr); +if (ret) { +dev_err (adev->dev,"(%d) failed to create mes resource_1 bo\n" , ret); +return ret; + } + + mes_set_hw_res_1_pkt.cleaner_shader_fence_mc_addr = + mes->resource_1_gpu_addr; + return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_set_hw_res_1_pkt, sizeof(mes_set_hw_res_1_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1,
api_status)); @@ -1770,6 +1786,12 @@ static intmes_v12_0_hw_init(struct amdgpu_ip_block *ip_block)static int
mes_v12_0_hw_fini(struct amdgpu_ip_block *ip_block){drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +6
-1+struct amdgpu_device *adev = ip_block->adev; + +if (adev->enable_uni_mes) +amdgpu_bo_free_kernel (&adev->mes.resource_1, + &adev->mes.resource_1_gpu_addr, + &adev->mes.resource_1_addr);return 0 ; } --2.48.1
[AMD Official Use Only - AMD Internal Distribution Only]
Looks good to me. You can can add
Reviewed by: Shaoyun.liu <[email protected]>
-----Original Message-----
From: Deucher, Alexander <[email protected]>
Sent: Monday, February 10, 2025 4:19 PM
To: [email protected]
Cc: SHANMUGAM, SRINIVASAN <[email protected]>; cao, lin <[email protected]>; Chen, JingWen (Wayne) <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [PATCH V5 1/2] drm/amdgpu/mes: Add cleaner shader fence address handling in MES for GFX11
From: Srinivasan Shanmugam <[email protected]>
This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in the mes_set_hw_res_pkt structure, allowing for proper synchronization of the cleaner shader execution.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +3 -1
@@ -743,7 +743,9 @@ static int mes_v11_0_set_hw_resources(struct amdgpu_mes *mes)static int mes_v11_0_set_hw_resources_1 (struct amdgpu_mes *mes) { -int size =128 *AMDGPU_GPU_PAGE_SIZE ; +unsigned int hw_rsrc_size =128 *AMDGPU_GPU_PAGE_SIZE ; +/* add a page for the cleaner shader fence */ +unsigned int alloc_size = hw_rsrc_size +AMDGPU_GPU_PAGE_SIZE ;int ret =0 ;struct amdgpu_device *adev = mes->adev; union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_pkt; @@ -754,7 +756,7 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes) mes_set_hw_res_pkt.header.dwsize = API_FRAME_SIZE_IN_DWORDS;
mes_set_hw_res_pkt.enable_mes_info_ctx = 1;
- ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
+ ret = amdgpu_bo_create_kernel(adev, alloc_size, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_VRAM,
&mes->resource_1,
&mes->resource_1_gpu_addr,
@@ -765,7 +767,10 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes)
}
mes_set_hw_res_pkt.mes_info_ctx_mc_addr = mes->resource_1_gpu_addr;
- mes_set_hw_res_pkt.mes_info_ctx_size = mes->resource_1->tbo.base.size;
+ mes_set_hw_res_pkt.mes_info_ctx_size = hw_rsrc_size;
+ mes_set_hw_res_pkt.cleaner_shader_fence_mc_addr =
+ mes->resource_1_gpu_addr + hw_rsrc_size;
+
return mes_v11_0_submit_pkt_and_poll_completion(mes,
&mes_set_hw_res_pkt, sizeof(mes_set_hw_res_pkt),
offsetof(union MESAPI_SET_HW_RESOURCES_1, api_status)); @@ -1632,7 +1637,8 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block)
if (r)
goto failure;- if (amdgpu_sriov_is_mes_info_enable(adev)) {
+ if (amdgpu_sriov_is_mes_info_enable(adev) ||
+ adev->gfx.enable_cleaner_shader) {
r = mes_v11_0_set_hw_resources_1(&adev->mes);
if (r) {
DRM_ERROR("failed mes_v11_0_set_hw_resources_1, r=%d\n", r); @@ -1665,10 +1671,13 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block) static int mes_v11_0_hw_fini(struct amdgpu_ip_block *ip_block) {
struct amdgpu_device *adev = ip_block->adev;
- if (amdgpu_sriov_is_mes_info_enable(adev)) {
+
+ if (amdgpu_sriov_is_mes_info_enable(adev) ||
+ adev->gfx.enable_cleaner_shader) {
amdgpu_bo_free_kernel(&adev->mes.resource_1, &adev->mes.resource_1_gpu_addr,
- &adev->mes.resource_1_addr);
+ &adev->mes.resource_1_addr);
}
+
return 0;}
--
2.48.1
Am 10.02.25 um 22:19 schrieb Alex Deucher:
Quoted 16 lines
From: Srinivasan Shanmugam <[email protected]>
This commit introduces enhancements to the handling of the cleaner shader fence in the AMDGPU MES driver:
- The MES (Microcode Execution Scheduler) now sends a PM4 packet to the KIQ (Kernel Interface Queue) to request the cleaner shader, ensuring that requests are handled in a controlled manner and avoiding the race conditions.
- The CP (Compute Processor) firmware has been updated to use a private bus for accessing specific registers, avoiding unnecessary operations that could lead to issues in VF (Virtual Function) mode.
- The cleaner shader fence memory address is now set correctly in themes_set_hw_res_pktstructure, allowing for proper synchronization of the cleaner shader execution.
Quoted 7 lines
Cc lin cao <[email protected]>Cc Jingwen Chen <[email protected]>Cc Christian König <[email protected]>Cc Alex Deucher <[email protected]>Suggested-by Shaoyun Liu <[email protected]>Signed-off-by Srinivasan Shanmugam <[email protected]>Signed-off-by Alex Deucher <[email protected]>
Quoted 66 lines
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +15
-6@@ -743,7 +743,9 @@ static int mes_v11_0_set_hw_resources(struct amdgpu_mes *mes)static int mes_v11_0_set_hw_resources_1 (struct amdgpu_mes *mes) { -int size =128 *AMDGPU_GPU_PAGE_SIZE ; +unsigned int hw_rsrc_size =128 *AMDGPU_GPU_PAGE_SIZE ; +/* add a page for the cleaner shader fence */ +unsigned int alloc_size = hw_rsrc_size +AMDGPU_GPU_PAGE_SIZE ;int ret =0 ;struct amdgpu_device *adev = mes->adev;union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_pkt;@@ -754,7 +756,7 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes) mes_set_hw_res_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; mes_set_hw_res_pkt.enable_mes_info_ctx =1 ; - ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE, + ret = amdgpu_bo_create_kernel(adev, alloc_size, PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, &mes->resource_1, &mes->resource_1_gpu_addr,@@ -765,7 +767,10 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes) } mes_set_hw_res_pkt.mes_info_ctx_mc_addr = mes->resource_1_gpu_addr; - mes_set_hw_res_pkt.mes_info_ctx_size = mes->resource_1->tbo.base.size; + mes_set_hw_res_pkt.mes_info_ctx_size = hw_rsrc_size; + mes_set_hw_res_pkt.cleaner_shader_fence_mc_addr = + mes->resource_1_gpu_addr + hw_rsrc_size; +return mes_v11_0_submit_pkt_and_poll_completion (mes, &mes_set_hw_res_pkt,sizeof (mes_set_hw_res_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1 , api_status));@@ -1632,7 +1637,8 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block)if (r) goto failure; -if (amdgpu_sriov_is_mes_info_enable (adev)) { +if (amdgpu_sriov_is_mes_info_enable (adev) || + adev->gfx.enable_cleaner_shader) { r =mes_v11_0_set_hw_resources_1 (&adev->mes);if (r) {DRM_ERROR ("failed mes_v11_0_set_hw_resources_1, r=%d\n" , r);@@ -1665,10 +1671,13 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block *ip_block)static int mes_v11_0_hw_fini (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; -if (amdgpu_sriov_is_mes_info_enable (adev)) { + +if (amdgpu_sriov_is_mes_info_enable (adev) || + adev->gfx.enable_cleaner_shader) {amdgpu_bo_free_kernel (&adev->mes.resource_1, &adev->mes.resource_1_gpu_addr, - &adev->mes.resource_1_addr); + &adev->mes.resource_1_addr); } +return 0 ; }