drm/amdgpu: enable userqueue support for GFX12
Subsystems (2)
PATCH 1/1 drm/amdgpu: enable userqueue support for GFX12
From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048
@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break ;default : adev->gfx.me.num_me =1 ;
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +6 -0
@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );
@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block)else DRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs; +#endif + +return r; }
Signature · 1 line
2.46.2
Deucher, Alexander
maintainer[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 10 lines
-----Original Message-----
From: Sharma, Shashank <[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM
To: [email protected]
Cc: Somalapuram, Amaranath <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>; Sharma, Shashank <[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12
Quoted 5 lines
From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
I would like to make this more explicit. In mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers in mes_userqueue.c. E.g.,
mes_v11_0_map_gtt_bo_to_gart() -> mes_userq_map_gtt_bo_to_gart() mes_v11_0_create_wptr_mapping() -> mes_userq_create_wptr_mapping() mes_v11_0_userq_map() -> mes_userq_map() mes_v11_0_userq_unmap() -> mes_userq_unmap() mes_v11_0_userq_mqd_destroy() -> mes_userq_mqd_destroy()
However, mes_v11_userq_create_ctx_space() uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures.
Alex
Quoted 66 lines
Cc Alex Deucher <[email protected]>Cc Christian Koenig <[email protected]>Cc Arvind Yadav <[email protected]>Signed-off-by Somalapuram Amaranath <[email protected]>Signed-off-by Shashank Sharma <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-1@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; } --2.46.2
Hello Alex,
Quoted 17 lines · Alexander
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 10 lines
-----Original Message-----
From: Sharma, Shashank<[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM To:[email protected]
Cc: Somalapuram, Amaranath<[email protected]>; Deucher, Alexander<[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind<[email protected]>; Sharma, Shashank<[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12Quoted 5 lines
From: Somalapuram Amaranath<[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
Quoted 7 lines
I would like to make this more explicit. In
mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers inmes_userqueue.c. E.g.,
mes_v11_0_map_gtt_bo_to_gart()->mes_userq_map_gtt_bo_to_gart()mes_v11_0_create_wptr_mapping()->mes_userq_create_wptr_mapping()mes_v11_0_userq_map()->mes_userq_map()mes_v11_0_userq_unmap()->mes_userq_unmap()mes_v11_0_userq_mqd_destroy()->mes_userq_mqd_destroy()
Initial patch sets had all these functions named similar to 'mes_userq_* ' only, but later you recommended that we should have mention of _v11_0 to indicate the IP specific stuff, as there might be IP specific way of mapping/unmapping/creating and destroying the queues. So with this comment we might be going back to the same version.
As of now, v12 UQ was tested using the the same methods as V11 UQs, and found it functional. We might need more information before taking this step.
- Shashank
Quoted 69 lines
However,
mes_v11_userq_create_ctx_space()uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures. AlexQuoted 65 lines
Cc Alex Deucher<[email protected]>Cc Christian Koenig<[email protected]>Cc Arvind Yadav<[email protected]>Signed-off-by Somalapuram Amaranath<[email protected]>Signed-off-by Shashank Sharma<[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-1@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; } --2.46.2
Quoted 25 lines · Shashank
Hello Alex,
On 14/10/2024 22:29, Deucher, Alexander wrote:
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Sharma, Shashank <[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM
To: [email protected]
Cc: Somalapuram, Amaranath <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>; Sharma, Shashank <[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
I would like to make this more explicit. In
mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers inmes_userqueue.c. E.g.,
Quoted 7 lines
mes_v11_0_map_gtt_bo_to_gart()->mes_userq_map_gtt_bo_to_gart()mes_v11_0_create_wptr_mapping()->mes_userq_create_wptr_mapping()mes_v11_0_userq_map()->mes_userq_map()mes_v11_0_userq_unmap()->mes_userq_unmap()mes_v11_0_userq_mqd_destroy()->mes_userq_mqd_destroy()Initial patch sets had all these functions named similar to 'mes_userq_* ' only, but later you recommended that we should have mention of
_v11_0to indicate the IP specific stuff, as there might be IP specific way of mapping/unmapping/creating and destroying the queues. So with this comment we might be going back to the same version.
Well that was before gfx12 support was on our radar. Generally, you develop for the first generation and if there are things that you can pull out into common code and share across generations, then you should do that when you add support for the next generation.
Quoted 2 lines
As of now, v12 UQ was tested using the the same methods as V11 UQs, and found it functional. We might need more information before taking this step.
You would need to verify that the V11 and V12 MQDs are the same. EIther way, I would recommend making v11 and v12 variants the the functions which populate the MQDs that the firmware uses. There is alays a chance that the firmware may repurpose some of the fields for different things that can lead to subtle bugs. At the end of the day, I think we'll end up with a bunch of helpers in mes_userqueue.c and then a function or two in mes_v11_0_userqueue.c and mes_v12_0_userqueue.c. Alternatively, you could just put the helpers in amdgpu_mes.c and the gfx11 and gfx12 specific functions in mes_v11_0.c and mes_v12_0.c since it will probably only be a function or two. You could even add a callback for the MQD specific changes and add a wrapper like the other functions in amdgpu_mes.c and the generic functions in mes_v11_0_userqueue.c. That would make everything symmetric for mes managed queues.
Alex
Quoted 72 lines
- Shashank
However,
mes_v11_userq_create_ctx_space()uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures.Alex
Cc Alex Deucher <[email protected]>Cc Christian Koenig <[email protected]>Cc Arvind Yadav <[email protected]>Signed-off-by Somalapuram Amaranath <[email protected]>Signed-off-by Shashank Sharma <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-1@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; } --2.46.2
Quoted 32 lines · Alex Deucher
Quoted 30 lines · Shashank
Hello Alex,
On 14/10/2024 22:29, Deucher, Alexander wrote:
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Sharma, Shashank <[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM
To: [email protected]
Cc: Somalapuram, Amaranath <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>; Sharma, Shashank <[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
I would like to make this more explicit. In
mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers inmes_userqueue.c. E.g.,
mes_v11_0_map_gtt_bo_to_gart()->mes_userq_map_gtt_bo_to_gart()mes_v11_0_create_wptr_mapping()->mes_userq_create_wptr_mapping()mes_v11_0_userq_map()->mes_userq_map()mes_v11_0_userq_unmap()->mes_userq_unmap()mes_v11_0_userq_mqd_destroy()->mes_userq_mqd_destroy()
Quoted 5 lines
Quoted 1 line
Initial patch sets had all these functions named similar to 'mes_userq_* ' only, but later you recommended that we should have mention of
_v11_0to indicate the IP specific stuff, as there might be IP specific way of mapping/unmapping/creating and destroying the queues. So with this comment we might be going back to the same version.Well that was before gfx12 support was on our radar. Generally, you develop for the first generation and if there are things that you can pull out into common code and share across generations, then you should do that when you add support for the next generation.
Noted,
Quoted 16 lines
Quoted 1 line
As of now, v12 UQ was tested using the the same methods as V11 UQs, and found it functional. We might need more information before taking this step.
You would need to verify that the V11 and V12 MQDs are the same. EIther way, I would recommend making v11 and v12 variants the the functions which populate the MQDs that the firmware uses. There is alays a chance that the firmware may repurpose some of the fields for different things that can lead to subtle bugs. At the end of the day, I think we'll end up with a bunch of helpers in
mes_userqueue.cand then a function or two inmes_v11_0_userqueue.candmes_v12_0_userqueue.c. Alternatively, you could just put the helpers inamdgpu_mes.cand the gfx11 and gfx12 specific functions inmes_v11_0.candmes_v12_0.csince it will probably only be a function or two. You could even add a callback for the MQD specific changes and add a wrapper like the other functions inamdgpu_mes.cand the generic functions inmes_v11_0_userqueue.c. That would make everything symmetric for mes managed queues.
Quoted 1 line
Alex
Thanks, Noted, I would do the recommended changes.
- Shashank
Quoted 71 lines
Quoted 71 lines
- Shashank
However,
mes_v11_userq_create_ctx_space()uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures.Alex
Cc Alex Deucher <[email protected]>Cc Christian Koenig <[email protected]>Cc Arvind Yadav <[email protected]>Signed-off-by Somalapuram Amaranath <[email protected]>Signed-off-by Shashank Sharma <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-1@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; } --2.46.2
Quoted 57 lines · Shashank
Quoted 32 lines · Alex Deucher
Quoted 30 lines · Shashank
Hello Alex,
On 14/10/2024 22:29, Deucher, Alexander wrote:
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Sharma, Shashank <[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM
To: [email protected]
Cc: Somalapuram, Amaranath <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>; Sharma, Shashank <[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
I would like to make this more explicit. In
mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers inmes_userqueue.c. E.g.,
mes_v11_0_map_gtt_bo_to_gart()->mes_userq_map_gtt_bo_to_gart()mes_v11_0_create_wptr_mapping()->mes_userq_create_wptr_mapping()mes_v11_0_userq_map()->mes_userq_map()mes_v11_0_userq_unmap()->mes_userq_unmap()mes_v11_0_userq_mqd_destroy()->mes_userq_mqd_destroy()Quoted 5 lines
Quoted 1 line
Initial patch sets had all these functions named similar to 'mes_userq_* ' only, but later you recommended that we should have mention of
_v11_0to indicate the IP specific stuff, as there might be IP specific way of mapping/unmapping/creating and destroying the queues. So with this comment we might be going back to the same version.Well that was before gfx12 support was on our radar. Generally, you develop for the first generation and if there are things that you can pull out into common code and share across generations, then you should do that when you add support for the next generation.
Noted,
Quoted 16 lines
Quoted 1 line
As of now, v12 UQ was tested using the the same methods as V11 UQs, and found it functional. We might need more information before taking this step.
You would need to verify that the V11 and V12 MQDs are the same. EIther way, I would recommend making v11 and v12 variants the the functions which populate the MQDs that the firmware uses. There is alays a chance that the firmware may repurpose some of the fields for different things that can lead to subtle bugs. At the end of the day, I think we'll end up with a bunch of helpers in
mes_userqueue.cand then a function or two inmes_v11_0_userqueue.candmes_v12_0_userqueue.c. Alternatively, you could just put the helpers inamdgpu_mes.cand the gfx11 and gfx12 specific functions inmes_v11_0.candmes_v12_0.csince it will probably only be a function or two. You could even add a callback for the MQD specific changes and add a wrapper like the other functions inamdgpu_mes.cand the generic functions inmes_v11_0_userqueue.c. That would make everything symmetric for mes managed queues.
Quoted 3 lines
Quoted 1 line
Alex
Thanks, Noted, I would do the recommended changes.
A took a longer look at the changes and it turns out I could move all of the IP specific stuff into the IP specific code. I hacked together the attached untested patches to clean this up.
Alex
Quoted 72 lines
- Shashank
Quoted 69 lines
Quoted 69 lines
- Shashank
However,
mes_v11_userq_create_ctx_space()uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures.Alex
Cc Alex Deucher <[email protected]>Cc Christian Koenig <[email protected]>Cc Arvind Yadav <[email protected]>Signed-off-by Somalapuram Amaranath <[email protected]>Signed-off-by Shashank Sharma <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-0@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; }
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--
2.46.2
From be97efd971c50e19c951dff075343d3e7ad0ae31 Mon Sep 17 00:00:00 2001
From: Somalapuram Amaranath <[email protected]>
Date: Thu, 10 Oct 2024 20:08:06 +0200
Subject: [PATCH 8/8] drm/amdgpu: enable userqueue support for GFX12
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
v2: rebase on proposed changes (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5 -0
@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048
@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_funcs; +#endif break ;default : adev->gfx.me.num_me =1 ;
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +6 -0
@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );
@@ -1320,6 +1321,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block)else DRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_funcs; +#endif + +return r; }
Signature · 1 line
2.46.2
From 5478434578c7448ac3f4edf7956994982086970d Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 14:14:34 -0400
Subject: [PATCH 2/8] drm/amdgpu/gfx11: update mqd init for UQ
Set the addresses for the UQ metadata.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +8 -0
@@ -4008,6 +4008,14 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,/* active the queue */ mqd->cp_gfx_hqd_active =1 ; +/* set gfx UQ items */ + mqd->shadow_base_lo =lower_32_bits (prop->shadow_addr); + mqd->shadow_base_hi =upper_32_bits (prop->shadow_addr); + mqd->gds_bkup_base_lo =lower_32_bits (prop->gds_bkup_addr); + mqd->gds_bkup_base_hi =upper_32_bits (prop->gds_bkup_addr); + mqd->fw_work_area_base_lo =lower_32_bits (prop->csa_addr); + mqd->fw_work_area_base_hi =upper_32_bits (prop->csa_addr); +return 0 ; }
Signature · 1 line
2.46.2
From fd0173b5d6733bec9e3b27fc37d16f25958bdb88 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 14:15:12 -0400
Subject: [PATCH 3/8] drm/amdgpu/gfx12: update mqd init for UQ
Set the addresses for the UQ metadata.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +6 -0
@@ -2929,6 +2929,12 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m,/* active the queue */ mqd->cp_gfx_hqd_active =1 ; +/* set gfx UQ items */ + mqd->shadow_base_lo =lower_32_bits (prop->shadow_addr); + mqd->shadow_base_hi =upper_32_bits (prop->shadow_addr); + mqd->fw_work_area_base_lo =lower_32_bits (prop->csa_addr); + mqd->fw_work_area_base_hi =upper_32_bits (prop->csa_addr); +return 0 ; }
Signature · 1 line
2.46.2
From debbbded9809e59b6b322b5dc999550bce3f9085 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 14:15:31 -0400
Subject: [PATCH 4/8] drm/amdgpu/sdma6: update mqd init for UQ
Set the addresses for the UQ metadata.
--- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +3 -0
@@ -891,6 +891,9 @@ static int sdma_v6_0_mqd_init(struct amdgpu_device *adev, void *mqd, m->sdmax_rlcx_rb_aql_cntl = regSDMA0_QUEUE0_RB_AQL_CNTL_DEFAULT; m->sdmax_rlcx_dummy_reg = regSDMA0_QUEUE0_DUMMY_REG_DEFAULT; + m->sdmax_rlcx_csa_addr_lo =lower_32_bits (prop->csa_addr); + m->sdmax_rlcx_csa_addr_hi =upper_32_bits (prop->csa_addr); +return 0 ; }
Signature · 1 line
2.46.2
From c70120d8c727b42384ddcd3b414136fb522d2a14 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 13:58:23 -0400
Subject: [PATCH 1/8] drm/amdgpu: add some additional members to
amdgpu_mqd_prop
These are needed for user queues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -813,6 +813,9 @@ struct amdgpu_mqd_prop {uint32_t hqd_queue_priority;bool allow_tunneling;bool hqd_active; +uint64_t shadow_addr; +uint64_t gds_bkup_addr; +uint64_t csa_addr; };struct amdgpu_mqd {
Signature · 1 line
2.46.2
From a7a5efe8f8897869c5fac643f7a10b788a671ab9 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 14:34:18 -0400
Subject: [PATCH 6/8] drm/amdgpu/uq: remove gfx11 specifics from UQ setup
This can all be handled by in the IP specific mpd init code.
--- .../gpu/drm/amd/amdgpu/mes_v11_0_userqueue.c | 84 ++++++++----------- 1 file changed, 36 insertions(+), 48 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0_userqueue.c +36 -48
102 lines not on this page · raw message
Signature · 1 line
2.46.2
From 52021be575c5f06503986e664f69352c47eb55d7 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 15:03:03 -0400
Subject: [PATCH 7/8] drm/amdgpu/uq: make MES UQ setup generic
Now that all of the IP specific code has been moved into the IP specific functions, we can make this code generic.
---
drivers/gpu/drm/amd/amdgpu/Makefile | 2 +-
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 10 ++--
...{mes_v11_0_userqueue.c => mes_userqueue.c} | 49 +++++++++----------
...{mes_v11_0_userqueue.h => mes_userqueue.h} | 6 +--
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 4 +-
5 files changed, 35 insertions(+), 36 deletions(-)
rename drivers/gpu/drm/amd/amdgpu/{mes_v11_0_userqueue.c => mes_userqueue.c} (88%)
rename drivers/gpu/drm/amd/amdgpu/{mes_v11_0_userqueue.h => mes_userqueue.h} (91%)drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -176,7 +176,7 @@ amdgpu-y += \ mes_v12_0.o \ # add GFX userqueue support -amdgpu-$(CONFIG_DRM_AMDGPU_NAVI3X_USERQ) += mes_v11_0_userqueue.o +amdgpu-$(CONFIG_DRM_AMDGPU_NAVI3X_USERQ) += mes_userqueue.o # add UVD block amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -5
@@ -49,7 +49,7 @@#include "gfx_v11_0_3.h" #include "nbio_v4_3.h" #include "mes_v11_0.h" -#include "mes_v11_0_userqueue.h" +#include "mes_userqueue.h" #define GFX11_NUM_GFX_RINGS 1#define GFX11_MEC_HPD_SIZE 2048
@@ -1557,8 +1557,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_pipe_per_mec =4 ; adev->gfx.mec.num_queue_per_pipe =4 ;#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ - adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; - adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_funcs;#endif break ;case IP_VERSION (11 ,0 ,1 ):
@@ -1573,8 +1573,8 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_pipe_per_mec =4 ; adev->gfx.mec.num_queue_per_pipe =4 ;#ifdef CONFIG_DRM_AMD_USERQ_GFX - adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; - adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_funcs;#endif break ;default :
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c renamed from drivers/gpu/drm/amd/amdgpu/mes_v11_0_userqueue.c +24 -25
125 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/mes_userqueue.h renamed from drivers/gpu/drm/amd/amdgpu/mes_v11_0_userqueue.h +3 -3
@@ -22,9 +22,9 @@* */ -#ifndef MES_V11_0_USERQ_H -#define MES_V11_0_USERQ_H +#ifndef MES_USERQ_H +#define MES_USERQ_H #include "amdgpu_userqueue.h" -extern const struct amdgpu_userq_funcs userq_mes_v11_0_funcs; +extern const struct amdgpu_userq_funcs userq_mes_funcs;#endif
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2 -2
@@ -43,7 +43,7 @@#include "sdma_common.h" #include "sdma_v6_0.h" #include "v11_structs.h" -#include "mes_v11_0_userqueue.h" +#include "mes_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_6_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_6_0_1.bin" );
@@ -1367,7 +1367,7 @@ static int sdma_v6_0_sw_init(struct amdgpu_ip_block *ip_block)DRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" );#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ - adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_funcs;#endif return r;
Signature · 1 line
2.46.2
From 8bd1b33f9887f57dea046c9cd0c8136750670894 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Fri, 18 Oct 2024 14:15:51 -0400
Subject: [PATCH 5/8] drm/amdgpu/sdma7: update mqd init for UQ
Set the addresses for the UQ metadata.
--- drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +3 -0
@@ -881,6 +881,9 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd, m->sdmax_rlcx_rb_aql_cntl =0x4000 ;//regSDMA0_QUEUE0_RB_AQL_CNTL_DEFAULT; m->sdmax_rlcx_dummy_reg =0xf ;//regSDMA0_QUEUE0_DUMMY_REG_DEFAULT; + m->sdmax_rlcx_csa_addr_lo =lower_32_bits (prop->csa_addr); + m->sdmax_rlcx_csa_addr_hi =upper_32_bits (prop->csa_addr); +return 0 ; }
Signature · 1 line
2.46.2
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Alex,
I have created an integration branch for GFX12, and cleaned up and ported these patches. We will finish testing and start the code review of these patches soon.
Regards
Shashank
________________________________
From: Alex Deucher <[email protected]>
Sent: Friday, October 18, 2024 9:18 PM
To: Sharma, Shashank <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected] <[email protected]>; Somalapuram, Amaranath <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: enable userqueue support for GFX12
Quoted 57 lines · Shashank
Quoted 32 lines · Alex Deucher
Quoted 30 lines · Shashank
Hello Alex,
On 14/10/2024 22:29, Deucher, Alexander wrote:
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Sharma, Shashank <[email protected]>
Sent: Thursday, October 10, 2024 2:08 PM
To: [email protected]
Cc: Somalapuram, Amaranath <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Yadav, Arvind <[email protected]>; Sharma, Shashank <[email protected]>
Subject: [PATCH] drm/amdgpu: enable userqueue support for GFX12From: Somalapuram Amaranath <[email protected]>
This patch enables Usermode queue support across GFX, Compute and SDMA IPs on GFX12/SDMA7. It typically reuses Navi3X userqueue IP functions to create and destroy MQDs.
I would like to make this more explicit. In
mes_v11_0_userqueue.c, I would suggest splitting out any non-gfx11 specific code into some new helpers inmes_userqueue.c. E.g.,
mes_v11_0_map_gtt_bo_to_gart()->mes_userq_map_gtt_bo_to_gart()mes_v11_0_create_wptr_mapping()->mes_userq_create_wptr_mapping()mes_v11_0_userq_map()->mes_userq_map()mes_v11_0_userq_unmap()->mes_userq_unmap()mes_v11_0_userq_mqd_destroy()->mes_userq_mqd_destroy()Quoted 5 lines
Quoted 1 line
Initial patch sets had all these functions named similar to 'mes_userq_* ' only, but later you recommended that we should have mention of
_v11_0to indicate the IP specific stuff, as there might be IP specific way of mapping/unmapping/creating and destroying the queues. So with this comment we might be going back to the same version.Well that was before gfx12 support was on our radar. Generally, you develop for the first generation and if there are things that you can pull out into common code and share across generations, then you should do that when you add support for the next generation.
Noted,
Quoted 16 lines
Quoted 1 line
As of now, v12 UQ was tested using the the same methods as V11 UQs, and found it functional. We might need more information before taking this step.
You would need to verify that the V11 and V12 MQDs are the same. EIther way, I would recommend making v11 and v12 variants the the functions which populate the MQDs that the firmware uses. There is alays a chance that the firmware may repurpose some of the fields for different things that can lead to subtle bugs. At the end of the day, I think we'll end up with a bunch of helpers in
mes_userqueue.cand then a function or two inmes_v11_0_userqueue.candmes_v12_0_userqueue.c. Alternatively, you could just put the helpers inamdgpu_mes.cand the gfx11 and gfx12 specific functions inmes_v11_0.candmes_v12_0.csince it will probably only be a function or two. You could even add a callback for the MQD specific changes and add a wrapper like the other functions inamdgpu_mes.cand the generic functions inmes_v11_0_userqueue.c. That would make everything symmetric for mes managed queues.
Quoted 3 lines
Quoted 1 line
Alex
Thanks, Noted, I would do the recommended changes.
A took a longer look at the changes and it turns out I could move all of the IP specific stuff into the IP specific code. I hacked together the attached untested patches to clean this up.
Alex
Quoted 74 lines
- Shashank
Quoted 71 lines
Quoted 71 lines
- Shashank
However,
mes_v11_userq_create_ctx_space()uses the v11 mqd structures which may not match the v12 structures. We should add a v12 implementation for any functions that use the v12 structures.Alex
Cc Alex Deucher <[email protected]>Cc Christian Koenig <[email protected]>Cc Arvind Yadav <[email protected]>Signed-off-by Somalapuram Amaranath <[email protected]>Signed-off-by Shashank Sharma <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 6 ++++++ 2 files changed, 11 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +5
-0@@ -46,6 +46,7 @@#include "gfx_v12_0.h" #include "nbif_v6_3_1.h" #include "mes_v12_0.h" +#include "mes_v11_0_userqueue.h" #define GFX12_NUM_GFX_RINGS 1#define GFX12_MEC_HPD_SIZE 2048@@ -1335,6 +1336,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block) adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =2 ; adev->gfx.mec.num_queue_per_pipe =4 ; +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_GFX ] = &userq_mes_v11_0_funcs; + adev->userq_funcs[AMDGPU_HW_IP_COMPUTE ] = &userq_mes_v11_0_funcs; +#endif break; default: adev->gfx.me.num_me = 1;drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +5
-1@@ -42,6 +42,7 @@#include "sdma_common.h" #include "sdma_v7_0.h" #include "v12_structs.h" +#include "mes_v11_0_userqueue.h" MODULE_FIRMWARE ("amdgpu/sdma_7_0_0.bin" );MODULE_FIRMWARE ("amdgpu/sdma_7_0_1.bin" );@@ -1317,6 +1318,11 @@ static int sdma_v7_0_sw_init(struct amdgpu_ip_block *ip_block) elseDRM_ERROR ("Failed to allocated memory for SDMA IP Dump\n" ); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ + adev->userq_funcs[AMDGPU_HW_IP_DMA ] = &userq_mes_v11_0_funcs;#endif + +return r; } --2.46.2