drm/amdgpu: add UAPI to create user queue gangs
Subsystems (3)
Alex Deucher
maintainerPATCH 1/8 drm/amdgpu: add UAPI to create user queue gangs
Queues in a gang will schedule together.
--- include/uapi/drm/amdgpu_drm.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/uapi/drm/amdgpu_drm.h +11 -0
@@ -329,6 +329,7 @@ union drm_amdgpu_ctx {#define AMDGPU_USERQ_OP_CREATE 1#define AMDGPU_USERQ_OP_FREE 2#define AMDGPU_USERQ_OP_QUERY_STATUS 3 +#define AMDGPU_USERQ_OP_CREATE_GANG 4/* queue priority levels */ /* low < normal low < normal high < high */
@@ -417,6 +418,15 @@ struct drm_amdgpu_userq_in {__u64 mqd_size; }; +struct drm_amdgpu_userq_in_create_gang { +/** AMDGPU_USERQ_OP_* */ +__u32 op; +__u32 pad; +/** Queue ids passed for operation USERQ_OP_CREATE_GANG */ +__u32 primary_queue_id; +__u32 secondary_queue_id; +}; +/* The structure to carry output of userqueue ops */ struct drm_amdgpu_userq_out {/**
@@ -436,6 +446,7 @@ struct drm_amdgpu_userq_out_query_state {union drm_amdgpu_userq {struct drm_amdgpu_userq_in in; +struct drm_amdgpu_userq_in_create_gang in_cg;struct drm_amdgpu_userq_out out;struct drm_amdgpu_userq_out_query_state out_qs; };
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 2/8 drm/amdgpu/mes11: add API for gang submit
Add API for setting up a gang. Gangs schedule together.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 2 +- drivers/gpu/drm/amd/include/mes_v11_api_def.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
@@ -125,7 +125,7 @@ static const char *mes_v11_0_opcodes[] = {"UPDATE_ROOT_PAGE_TABLE" ,"AMD_LOG" ,"unused" , -"unused" , +"SET_GANG_SUBMIT" , "SET_HW_RSRC_1", };
drivers/gpu/drm/amd/include/mes_v11_api_def.h +18 -0
@@ -64,6 +64,7 @@ enum MES_SCH_API_OPCODE {MES_SCH_API_MISC =14 ,MES_SCH_API_UPDATE_ROOT_PAGE_TABLE =15 ,MES_SCH_API_AMD_LOG =16 , +MES_SCH_API_SET_GANG_SUBMIT =18 ,MES_SCH_API_SET_HW_RSRC_1 =19 , MES_SCH_API_MAX = 0xFF };
@@ -633,6 +634,13 @@ struct SET_SHADER_DEBUGGER {uint32_t trap_en; }; +struct SET_GANG_SUBMIT { +uint64_t gang_context_addr; +uint64_t slave_gang_context_addr; +uint32_t gang_context_array_index; +uint32_t slave_gang_context_array_index; +}; +enum MESAPI_MISC__CHANGE_CONFIG_OPTION {MESAPI_MISC__CHANGE_CONFIG_OPTION_LIMIT_SINGLE_PROCESS =0 ,MESAPI_MISC__CHANGE_CONFIG_OPTION_ENABLE_HWS_LOGGING_BUFFER =1 ,
@@ -703,5 +711,15 @@ union MESAPI_AMD_LOG { uint32_t max_dwords_in_api[API_FRAME_SIZE_IN_DWORDS]; }; +union MESAPI__SET_GANG_SUBMIT { +struct { +union MES_API_HEADER header; +struct MES_API_STATUS api_status; +struct SET_GANG_SUBMIT set_gang_submit; + }; + +uint32_t max_dwords_in_api[API_FRAME_SIZE_IN_DWORDS ]; +}; +#pragma pack(pop)#endif
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 3/8 drm/amdgpu/mes: add callback for gang submit
In reply to Alex DeucherAdd function pointer for gang submit setup.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +8 -0
@@ -279,6 +279,11 @@ struct mes_reset_queue_input {bool legacy_gfx; }; +struct mes_set_gang_submit_input { +uint64_t primary_gang_context_addr; +uint64_t secondary_gang_context_addr; +}; +enum mes_misc_opcode {MES_MISC_OP_WRITE_REG ,MES_MISC_OP_READ_REG ,
@@ -366,6 +371,9 @@ struct amdgpu_mes_funcs {int (*reset_hw_queue)(struct amdgpu_mes *mes,struct mes_reset_queue_input *input); + +int (*set_gang_submit)(struct amdgpu_mes *mes, +struct mes_set_gang_submit_input *input); };#define amdgpu_mes_kiq_hw_init (adev) (adev)->mes.kiq_hw_init((adev))
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 4/8 drm/amdgpu/mes11: add support for setting gang submit
In reply to Alex DeucherEnable a primary and secondary queue that schedule together.
v2: fix offset of api_status (Prike)
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +22 -0
@@ -783,6 +783,27 @@ static int mes_v11_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v11_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input *input) +{ +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +return mes_v11_0_submit_pkt_and_poll_completion (mes, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , api_status)); +} +static const struct amdgpu_mes_funcs mes_v11_0_funcs = { .add_hw_queue = mes_v11_0_add_hw_queue, .remove_hw_queue = mes_v11_0_remove_hw_queue,
@@ -792,6 +813,7 @@ static const struct amdgpu_mes_funcs mes_v11_0_funcs = { .resume_gang = mes_v11_0_resume_gang, .misc_op = mes_v11_0_misc_op, .reset_hw_queue = mes_v11_0_reset_hw_queue, + .set_gang_submit = mes_v11_0_set_gang_submit, }; static int mes_v11_0_allocate_ucode_buffer(struct amdgpu_device *adev,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 5/8 drm/amdgpu/mes12: add support for setting gang submit
In reply to Alex DeucherEnable a primary and secondary queue that schedule together.
v2: fix offset of api_status (Prike)
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +28 -0
@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input *input) +{ +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , api_status)); +} +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue,
@@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device *adev,
Signature · 1 line
2.49.0
Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Enable a primary and secondary queue that schedule together.
v2: fix offset of api_status (Prike)
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21 -0
@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input *input) +{ +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;
I think this packet should be always submitted to AMDGPU_MES_SCHED_PIPE, same pipe as in mes_v12_0_add_hw_queue where the queue is created.
This is because HWS on AMDGPU_MES_KIQ_PIPE does not have the queue information.
+
+ return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe,
+ &mes_gang_submit_pkt, sizeof(mes_gang_submit_pkt),
+ offsetof(union MESAPI__SET_GANG_SUBMIT, api_status));
+}
+
static const struct amdgpu_mes_funcs mes_v12_0_funcs = {
.add_hw_queue = mes_v12_0_add_hw_queue,
.remove_hw_queue = mes_v12_0_remove_hw_queue,
@@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = {
.resume_gang = mes_v12_0_resume_gang,
.misc_op = mes_v12_0_misc_op,
.reset_hw_queue = mes_v12_0_reset_hw_queue,+ .set_gang_submit = mes_v12_0_set_gang_submit,
};
static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device *adev,
--
2.49.0
Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 54 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input *input) +{ +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;
Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created.
This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.
Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +7
-1+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , api_status)); +} +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue,@@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device *adev, --2.49.0
RE: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
Regards
Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 59 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;
Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.
Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
What about kernel queues mapped through MES? Do those need to go through KIQ or is SCHED ok? They seem to go through KIQ today. Is going through SCHED ok?
Alex
Quoted 101 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 59 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
RE: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
[AMD Official Use Only - AMD Internal Distribution Only]
kiq still be used for kernel queues map/unmap including the scheduler queue itself . I think we can keep this design. The gang related will go through SCHED.
Regards
Shaoyun.liu
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, April 29, 2025 3:05 PM
To: Liu, Shaoyun <[email protected]>
Cc: Chen, Michael <[email protected]>; Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
What about kernel queues mapped through MES? Do those need to go through KIQ or is SCHED ok? They seem to go through KIQ today. Is going through SCHED ok?
Alex
Quoted 108 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 62 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +24
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct +mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 , +sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize = +API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
kiq still be used for kernel queues map/unmap including the scheduler queue itself . I think we can keep this design. The gang related will go through SCHED.
What about queue resets?
Alex
Quoted 130 lines
Regards
Shaoyun.liu-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Tuesday, April 29, 2025 3:05 PM
To: Liu, Shaoyun <[email protected]>
Cc: Chen, Michael <[email protected]>; Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
What about kernel queues mapped through MES? Do those need to go through KIQ or is SCHED ok? They seem to go through KIQ today. Is going through SCHED ok?
Alex
Quoted 108 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 62 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +24
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct +mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 , +sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize = +API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
In reply to Alex Deucher[AMD Official Use Only - AMD Internal Distribution Only]
All legacy / kernel queues related ops (add / remove / reset) can go through KIQ pipe. Non queue related ops (read_reg / write_reg etc.) can go through KIQ pipe too.
All user queues related ops should go through SCHED pipe
________________________________
From: Alex Deucher <[email protected]>
Sent: Tuesday, April 29, 2025 3:05 PM
To: Liu, Shaoyun <[email protected]>
Cc: Chen, Michael <[email protected]>; Deucher, Alexander <[email protected]>; [email protected] <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 4 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
What about kernel queues mapped through MES? Do those need to go through KIQ or is SCHED ok? They seem to go through KIQ today. Is going through SCHED ok?
Alex
Quoted 101 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 59 lines · Michael
[Public]
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)Acked-by Sunil Khatri <[email protected]>Reviewed-by Prike Liang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
RE: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
[AMD Official Use Only - AMD Internal Distribution Only]
Ye , that’s guide line , I believe that’s align with our legacy kiq usage .
Shaoyun.liu
From: Chen, Michael <[email protected]>
Sent: Tuesday, April 29, 2025 3:20 PM
To: Alex Deucher <[email protected]>; Liu, Shaoyun <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; Khatri, Sunil <[email protected]>; Liang, Prike <[email protected]>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
[AMD Official Use Only - AMD Internal Distribution Only]
All legacy / kernel queues related ops (add / remove / reset) can go through KIQ pipe. Non queue related ops (read_reg / write_reg etc.) can go through KIQ pipe too.
All user queues related ops should go through SCHED pipe
________________________________
From: Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Tuesday, April 29, 2025 3:05 PM
To: Liu, Shaoyun <[email protected]<mailto:[email protected]>>
Cc: Chen, Michael <[email protected]<mailto:[email protected]>>; Deucher, Alexander <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submit
Quoted 4 lines · On Tue, Apr 29, 2025 at 2:56 PM Liu, Shaoyun…
[AMD Official Use Only - AMD Internal Distribution Only]
Correctly , the gang submission related stuff only used for scheduler pipe , kiq is for used for kernel driver only and should not expose to the user queue.
What about kernel queues mapped through MES? Do those need to go through KIQ or is SCHED ok? They seem to go through KIQ today. Is going through SCHED ok?
Alex
Quoted 101 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Alex Deucher
Sent: Tuesday, April 29, 2025 2:39 PM
To: Chen, Michael <[email protected]<mailto:[email protected]>>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang submitQuoted 59 lines · On Tue, Apr 29, 2025 at 2:23 PM Chen, Michael…
[Public]
________________________________
From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of
Alex Deucher <[email protected]<mailto:[email protected]>>
Sent: Monday, April 28, 2025 5:20 PM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>; Khatri, Sunil <[email protected]<mailto:[email protected]>>; Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: [PATCH 5/8] drm/amdgpu/mes12: add support for setting gang
submitEnable a primary and secondary queue that schedule together.
v2: fix offset of
api_status(Prike)--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +21
-0@@ -879,6 +879,33 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__RESET, api_status)); } +static int mes_v12_0_set_gang_submit (struct amdgpu_mes *mes, +struct mes_set_gang_submit_input +*input) { +union MESAPI__SET_GANG_SUBMIT mes_gang_submit_pkt; +int pipe; + +memset (&mes_gang_submit_pkt,0 ,sizeof (mes_gang_submit_pkt)); + + mes_gang_submit_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_gang_submit_pkt.header.opcode =MES_SCH_API_SET_GANG_SUBMIT ; + mes_gang_submit_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_gang_submit_pkt.set_gang_submit.gang_context_addr = + input->primary_gang_context_addr; + mes_gang_submit_pkt.set_gang_submit.slave_gang_context_addr = + input->secondary_gang_context_addr; + +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ;Quoted 3 lines
I think this packet should be always submitted to
AMDGPU_MES_SCHED_PIPE, same pipe as inmes_v12_0_add_hw_queuewhere the queue is created. This is because HWS onAMDGPU_MES_KIQ_PIPEdoes not have the queue information.Sounds like the reset queue function and the map and unmap legacy queues should also be changed?
Alex
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8
-0+ +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, + &mes_gang_submit_pkt,sizeof (mes_gang_submit_pkt), + offsetof(union MESAPI__SET_GANG_SUBMIT , +api_status)); } +static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .add_hw_queue = mes_v12_0_add_hw_queue, .remove_hw_queue = mes_v12_0_remove_hw_queue, @@ -888,6 +915,7 @@ static const struct amdgpu_mes_funcs mes_v12_0_funcs = { .resume_gang = mes_v12_0_resume_gang, .misc_op = mes_v12_0_misc_op, .reset_hw_queue = mes_v12_0_reset_hw_queue, + .set_gang_submit = mes_v12_0_set_gang_submit, }; static int mes_v12_0_allocate_ucode_buffer(struct amdgpu_device*adev,
--
2.49.0
Alex Deucher
maintainerPATCH 6/8 drm/amdgpu/userq: add callback for gang setup
In reply to Alex DeucherTwo queues can be ganged and will schedule together.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +3 -0
@@ -80,6 +80,9 @@ struct amdgpu_userq_funcs { struct amdgpu_usermode_queue *queue);int (*reset)(struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_usermode_queue *queue); +int (*set_gang)(struct amdgpu_userq_mgr *uq_mgr, +struct amdgpu_usermode_queue *primary_queue, +struct amdgpu_usermode_queue *secondary_queue); };/* Usermode queues for gfx */
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 7/8 drm/amdgpu/userq/mes: implement set gang submit
In reply to Alex DeucherEnable the userq callback for setting up gang submission.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +26 -0
@@ -367,10 +367,36 @@ static int mes_userq_reset(struct amdgpu_userq_mgr *uq_mgr,return r; } +static int mes_set_gang (struct amdgpu_userq_mgr *uq_mgr, +struct amdgpu_usermode_queue *primary_queue, +struct amdgpu_usermode_queue *secondary_queue) +{ +struct amdgpu_userq_obj *primary_ctx = &primary_queue->fw_obj; +struct amdgpu_userq_obj *secondary_ctx = &secondary_queue->fw_obj; +struct amdgpu_device *adev = uq_mgr->adev; +struct mes_set_gang_submit_input input; +int r; + +memset (&input,0x0 ,sizeof (struct mes_set_gang_submit_input )); + + input.primary_gang_context_addr = + primary_ctx->gpu_addr +AMDGPU_USERQ_PROC_CTX_SZ ; + input.secondary_gang_context_addr = + secondary_ctx->gpu_addr +AMDGPU_USERQ_PROC_CTX_SZ ; + +amdgpu_mes_lock (&adev->mes); + r = adev->mes.funcs->set_gang_submit (&adev->mes, &input); +amdgpu_mes_unlock (&adev->mes); +if (r) +dev_err (adev->dev,"Failed to set gang submit, err (%d)\n" , r); +return r; +} +const struct amdgpu_userq_funcs userq_mes_funcs = { .mqd_create = mes_userq_mqd_create, .mqd_destroy = mes_userq_mqd_destroy, .unmap = mes_userq_unmap, .map = mes_userq_map, .reset = mes_userq_reset, + .set_gang = mes_set_gang, };
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 8/8 drm/amdgpu/userq: enable support for creating gangs
In reply to Alex DeucherGangs are sets of userqs that schedule together. You specify the primary and secondary queues and the scheduler will make sure they always run at the same time.
v2: handle setting up the gang again after unmaps
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 95 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 2 + 2 files changed, 97 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +95 -0
@@ -92,19 +92,39 @@ amdgpu_userq_unmap_helper(struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_device *adev = uq_mgr->adev;const struct amdgpu_userq_funcs *userq_funcs = adev->userq_funcs[queue->queue_type]; +struct amdgpu_usermode_queue *secondary_queue =NULL ;bool gpu_reset = false;int r =0 ; +if (queue->gang_primary) + secondary_queue = queue->gang_secondary; +if (queue->state ==AMDGPU_USERQ_STATE_MAPPED ) { r = userq_funcs->unmap (uq_mgr, queue);if (r) { queue->state =AMDGPU_USERQ_STATE_HUNG ; gpu_reset =amdgpu_userq_queue_reset_helper (uq_mgr, queue); +if (gpu_reset) + goto reset; }else { queue->state =AMDGPU_USERQ_STATE_UNMAPPED ; } } +if (secondary_queue) { +if (secondary_queue->state ==AMDGPU_USERQ_STATE_MAPPED ) { + r = userq_funcs->unmap (uq_mgr, secondary_queue); +if (r) { + secondary_queue->state =AMDGPU_USERQ_STATE_HUNG ; + gpu_reset =amdgpu_userq_queue_reset_helper (uq_mgr, secondary_queue); +if (gpu_reset) + goto reset; + }else { + secondary_queue->state =AMDGPU_USERQ_STATE_MAPPED ; + } + } + } +reset:if (gpu_reset)amdgpu_userq_gpu_reset (adev);
@@ -118,19 +138,40 @@ amdgpu_userq_map_helper(struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_device *adev = uq_mgr->adev;const struct amdgpu_userq_funcs *userq_funcs = adev->userq_funcs[queue->queue_type]; +struct amdgpu_usermode_queue *secondary_queue =NULL ;bool gpu_reset = false;int r =0 ; +if (queue->gang_primary) + secondary_queue = queue->gang_secondary; +if (queue->state ==AMDGPU_USERQ_STATE_UNMAPPED ) { r = userq_funcs->map (uq_mgr, queue);if (r) { queue->state =AMDGPU_USERQ_STATE_HUNG ; gpu_reset =amdgpu_userq_queue_reset_helper (uq_mgr, queue); +if (gpu_reset) + goto reset; }else { queue->state =AMDGPU_USERQ_STATE_MAPPED ; } } +if (secondary_queue) { +if (secondary_queue->state ==AMDGPU_USERQ_STATE_UNMAPPED ) { + r = userq_funcs->map (uq_mgr, secondary_queue); +if (r) { + secondary_queue->state =AMDGPU_USERQ_STATE_HUNG ; + gpu_reset =amdgpu_userq_queue_reset_helper (uq_mgr, secondary_queue); +if (gpu_reset) + goto reset; + }else { + secondary_queue->state =AMDGPU_USERQ_STATE_MAPPED ; + } + } + r = userq_funcs->set_gang (uq_mgr, queue, secondary_queue); + } +reset:if (gpu_reset)amdgpu_userq_gpu_reset (adev);
@@ -561,6 +602,53 @@ amdgpu_userq_query_status(struct drm_file *filp, union drm_amdgpu_userq *args)return 0 ; } +static int +amdgpu_userq_create_gang (struct drm_file *filp,union drm_amdgpu_userq *args) +{ +struct amdgpu_usermode_queue *primary_queue, *secondary_queue; +struct amdgpu_fpriv *fpriv = filp->driver_priv; +struct amdgpu_userq_mgr *uq_mgr = &fpriv->userq_mgr; +const struct amdgpu_userq_funcs *userq_funcs; +struct amdgpu_device *adev = uq_mgr->adev; +int primary_queue_id = args->in_cg.primary_queue_id; +int secondary_queue_id = args->in_cg.secondary_queue_id; +int r; + +mutex_lock (&uq_mgr->userq_mutex); + primary_queue =amdgpu_userq_find (uq_mgr, primary_queue_id); +if (!primary_queue) { +dev_err (adev->dev,"Invalid gang primary queue id\n" ); +mutex_unlock (&uq_mgr->userq_mutex); +return -EINVAL ; + } +if ((primary_queue->queue_type !=AMDGPU_HW_IP_GFX ) && + (primary_queue->queue_type !=AMDGPU_HW_IP_COMPUTE )) { +dev_err (adev->dev,"Invalid gang primary queue type\n" ); +mutex_unlock (&uq_mgr->userq_mutex); +return -EINVAL ; + } + secondary_queue =amdgpu_userq_find (uq_mgr, secondary_queue_id); +if (!secondary_queue) { +dev_err (adev->dev,"Invalid gang secondary queue id\n" ); +mutex_unlock (&uq_mgr->userq_mutex); +return -EINVAL ; + } +if ((secondary_queue->queue_type !=AMDGPU_HW_IP_GFX ) && + (secondary_queue->queue_type !=AMDGPU_HW_IP_COMPUTE )) { +dev_err (adev->dev,"Invalid gang secondary queue type\n" ); +mutex_unlock (&uq_mgr->userq_mutex); +return -EINVAL ; + } + + primary_queue->gang_primary = true; + primary_queue->gang_secondary = secondary_queue; + userq_funcs = adev->userq_funcs[primary_queue->queue_type]; + r = userq_funcs->set_gang (uq_mgr, primary_queue, secondary_queue); +mutex_unlock (&uq_mgr->userq_mutex); + +return r; +} +int amdgpu_userq_ioctl (struct drm_device *dev,void *data,struct drm_file *filp) {
@@ -611,6 +699,13 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,if (r)DRM_ERROR ("Failed to query usermode queue status\n" );break ; +case AMDGPU_USERQ_OP_CREATE_GANG : +if (args->in_cg.pad) +return -EINVAL ; + r =amdgpu_userq_create_gang (filp, args); +if (r) +DRM_ERROR ("Failed to create usermode queue gang\n" ); +break ;default :DRM_DEBUG_DRIVER ("Invalid user queue op specified: %d\n" , args->in.op);return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +2 -0
@@ -66,6 +66,8 @@ struct amdgpu_usermode_queue {u32 xcp_id;int priority;uint64_t generation; +bool gang_primary; +struct amdgpu_usermode_queue *gang_secondary; };struct amdgpu_userq_funcs {
Signature · 1 line
2.49.0