drm/amdgpu: add AMDGPU_IDS_FLAGS_GANG_SUBMIT
Subsystems (3)
PATCH 1/2 drm/amdgpu: add AMDGPU_IDS_FLAGS_GANG_SUBMIT
Add a UAPI flag indicating if gang submit is supported or not.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ include/uapi/drm/amdgpu_drm.h | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
@@ -939,6 +939,10 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (adev->gfx.config.ta_cntl2_truncate_coord_mode) dev_info->ids_flags |=AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD ; +/* Gang submit is not supported under SRIOV currently */ +if (!amdgpu_sriov_vf (adev)) + dev_info->ids_flags |=AMDGPU_IDS_FLAGS_GANG_SUBMIT ; +if (amdgpu_passthrough (adev)) dev_info->ids_flags |= (AMDGPU_IDS_FLAGS_MODE_PT << AMDGPU_IDS_FLAGS_MODE_SHIFT) &
include/uapi/drm/amdgpu_drm.h +5 -4
@@ -1084,10 +1084,11 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow {* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU * */ -#define AMDGPU_IDS_FLAGS_FUSION 0x1 -#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2 -#define AMDGPU_IDS_FLAGS_TMZ 0x4 -#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8 +#define AMDGPU_IDS_FLAGS_FUSION 0x01 +#define AMDGPU_IDS_FLAGS_PREEMPTION 0x02 +#define AMDGPU_IDS_FLAGS_TMZ 0x04 +#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x08 +#define AMDGPU_IDS_FLAGS_GANG_SUBMIT 0x10/* * Query h/w info: Flag identifying VF/PF/PT mode
Signature · 1 line
2.43.0
PATCH 2/2 drm/amdgpu: reject gang submissions under SRIOV
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size >1 )) { ret = -EINVAL ; goto free_all_kdata; }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
Quoted 10 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
Quoted 6 lines
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 22 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-2@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size >1 )) { ret = -EINVAL ; goto free_all_kdata; } --2.43.0
RE: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
[AMD Official Use Only - AMD Internal Distribution Only]
I can confirm that during world switch the entire gfx block (including gfx, compute and sdma for gfx10+) been switched together .
Regards
Shaoyun.liu
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 5, 2025 9:32 AM
To: Christian König <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
Quoted 10 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
Quoted 6 lines
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 24 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size + >1 )) { ret = -EINVAL ; goto free_all_kdata; } --2.43.0
Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
Quoted 7 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
I can confirm that during world switch the entire gfx block (including gfx, compute and sdma for gfx10+) been switched together .
Regards
Shaoyun.liu
Hi Everyone,
At the moment there are only two uses of gang submit:
1. Mesh + task shaders where GFX and ACE are used together
2. Transfer queues where SDMA and ACE are used together (not yet fully implemented in RADV)
Based on the conversation above, it sounds like both of these would work just fine under SRIOV.
Thanks,
Timur
Quoted 71 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 5, 2025 9:32 AM
To: Christian König <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOVQuoted 13 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple
submissions are executed on the HW at the same time on different engines.Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to
allow sharing the HW resources between multiple VFs.Quoted 8 lines
The problem is now that the SRIOV world switch can't know about such
inter dependencies and will cause a timeout if it waits for a partially running gang submission.To conclude SRIOV and gang submissions are fundamentally incompatible
at the moment. For now just disable them.Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 26 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } - if (!p->gang_size) { + if (!p->gang_size || (amdgpu_sriov_vf(p->adev) && p-Quoted 1 line
gang_size+ > 1)) {
ret =-EINVAL;
gotofree_all_kdata;
}
--
2.43.0
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
In reply to Liu, ShaoyunQuoted 3 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
I can confirm that during world switch the entire gfx block (including gfx, compute and sdma for gfx10+) been switched together .
Yeah, but that simply doesn't work as expected.
The problem is that the world switch can't preempt running gfx shaders and compute shaders only when CWSR is available.
Now what world switch currently does is to wait for the gfx draw to finish, then pause the gfx queue and then other the compute queues.
When gfx starts first that approach works, but when the compute queue runs first we then try to preempt a compute queue which is waiting for the gfx draw to start.
Since we don't have CWSR for this compute queue this results in a lockup at the moment.
Regards,
Christian.
Quoted 57 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 5, 2025 9:32 AM
To: Christian König <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOVQuoted 10 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
Quoted 6 lines
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 24 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size + >1 )) { ret = -EINVAL ; goto free_all_kdata; } --2.43.0
Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
Quoted 8 lines · Christian König
Quoted 3 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
I can confirm that during world switch the entire gfx block (including gfx, compute and sdma for gfx10+) been switched together .
Yeah, but that simply doesn't work as expected.
Quoted 7 lines
The problem is that the world switch can't preempt running gfx shaders and compute shaders only when CWSR is available.
Now what world switch currently does is to wait for the gfx draw to finish, then pause the gfx queue and then other the compute queues.
When gfx starts first that approach works, but when the compute queue runs first we then try to preempt a compute queue which is waiting for the gfx draw to start.
Since we don't have CWSR for this compute queue this results in a lockup at the moment.
Compute queues can still preempt without CWSR, it's just dispatch level (like gfx) rather than instruction level preemption.
Alex
Quoted 62 lines
Regards,
Christian.Quoted 57 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 5, 2025 9:32 AM
To: Christian König <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOVQuoted 10 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
Quoted 6 lines
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 24 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size + >1 )) { ret = -EINVAL ; goto free_all_kdata; } --2.43.0
Christian König
maintainerRe: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOV
Quoted 11 lines · Alex Deucher
Quoted 10 lines · Christian König
Quoted 3 lines · Shaoyun
[AMD Official Use Only - AMD Internal Distribution Only]
I can confirm that during world switch the entire gfx block (including gfx, compute and sdma for gfx10+) been switched together .
Yeah, but that simply doesn't work as expected.
The problem is that the world switch can't preempt running gfx shaders and compute shaders only when CWSR is available.
Quoted 8 lines
Quoted 5 lines
Now what world switch currently does is to wait for the gfx draw to finish, then pause the gfx queue and then other the compute queues.
When gfx starts first that approach works, but when the compute queue runs first we then try to preempt a compute queue which is waiting for the gfx draw to start.
Since we don't have CWSR for this compute queue this results in a lockup at the moment.
Compute queues can still preempt without CWSR, it's just dispatch level (like gfx) rather than instruction level preemption.
Yeah, exactly that's the problem.
It can happen that the compute dispatch is already running and waiting for the gfx dispatch to start.
But the gfx dispatch will never start because we are world switching and gfx has already been preempted.
If you preempt gfx first it can happen that compute dispatch waits for gfx.
If you preempt compute first it can happen that gfx dispatch waits for compute.
As far as I can see that is unsolvable with the current approach. We would either need CWSR for mesh shader compute dispatches or a global barrier for each submission.
Otherwise the hypervisor simply lacks the information and handling for executing a world switch when gang submit is used.
Regards,
Christian.
Quoted 65 lines
Alex
Quoted 62 lines
Regards,
Christian.Quoted 57 lines
Regards
Shaoyun.liu-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 5, 2025 9:32 AM
To: Christian König <[email protected]>
Cc: Deucher, Alexander <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: reject gang submissions under SRIOVQuoted 10 lines · Christian König
Gang submission means that the kernel driver guarantees that multiple submissions are executed on the HW at the same time on different engines.
Background is that those submissions then depend on each other and each can't finish stand alone.
SRIOV now uses world switch to preempt submissions on the engines to allow sharing the HW resources between multiple VFs.
Quoted 6 lines
The problem is now that the SRIOV world switch can't know about such inter dependencies and will cause a timeout if it waits for a partially running gang submission.
To conclude SRIOV and gang submissions are fundamentally incompatible at the moment. For now just disable them.
Are you sure about this? Thinking about this more, most gang submissions are between gfx and compute. The entire GC block (gfx, compute, and sdma on gfx10+) gets preempted on world switch so all of the active queues would be preempted. Everything gets resumed when the VF gets switched back. VCN/JPEG gets switched independently so that could be a problem if you have a gang with VCN and GC, but I think all gangs within GC should in theory be ok.
Alex
Quoted 24 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-2@@ -286,7 +286,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, } } -if (!p->gang_size) { +if (!p->gang_size || (amdgpu_sriov_vf (p->adev) && p->gang_size + >1 )) { ret = -EINVAL ; goto free_all_kdata; } --2.43.0
Christian König
maintainerPing?
Alex can we commit this until we have found a solution for SRIOV?
Regards,
Christian.
Quoted 43 lines · Christian König
Add a UAPI flag indicating if gang submit is supported or not.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ include/uapi/drm/amdgpu_drm.h | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4
-0@@ -939,6 +939,10 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (adev->gfx.config.ta_cntl2_truncate_coord_mode) dev_info->ids_flags |=AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD ; +/* Gang submit is not supported under SRIOV currently */ +if (!amdgpu_sriov_vf (adev)) + dev_info->ids_flags |=AMDGPU_IDS_FLAGS_GANG_SUBMIT ; +if (amdgpu_passthrough (adev)) dev_info->ids_flags |= (AMDGPU_IDS_FLAGS_MODE_PT << AMDGPU_IDS_FLAGS_MODE_SHIFT) &include/uapi/drm/amdgpu_drm.h +5
-4@@ -1084,10 +1084,11 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow {* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU * */ -#define AMDGPU_IDS_FLAGS_FUSION 0x1 -#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2 -#define AMDGPU_IDS_FLAGS_TMZ 0x4 -#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8 +#define AMDGPU_IDS_FLAGS_FUSION 0x01 +#define AMDGPU_IDS_FLAGS_PREEMPTION 0x02 +#define AMDGPU_IDS_FLAGS_TMZ 0x04 +#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x08 +#define AMDGPU_IDS_FLAGS_GANG_SUBMIT 0x10/* * Query h/w info: Flag identifying VF/PF/PT mode
Alex Deucher
Reviewed-byQuoted 4 lines · Christian König
Ping?
Alex can we commit this until we have found a solution for SRIOV?
Series is:
Quoted 49 lines
Regards,
Christian.Quoted 43 lines · Christian König
Add a UAPI flag indicating if gang submit is supported or not.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ include/uapi/drm/amdgpu_drm.h | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4
-0@@ -939,6 +939,10 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)if (adev->gfx.config.ta_cntl2_truncate_coord_mode) dev_info->ids_flags |=AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD ; +/* Gang submit is not supported under SRIOV currently */ +if (!amdgpu_sriov_vf (adev)) + dev_info->ids_flags |=AMDGPU_IDS_FLAGS_GANG_SUBMIT ; +if (amdgpu_passthrough (adev)) dev_info->ids_flags |= (AMDGPU_IDS_FLAGS_MODE_PT << AMDGPU_IDS_FLAGS_MODE_SHIFT) &include/uapi/drm/amdgpu_drm.h +5
-4@@ -1084,10 +1084,11 @@ struct drm_amdgpu_cs_chunk_cp_gfx_shadow {* Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU * */ -#define AMDGPU_IDS_FLAGS_FUSION 0x1 -#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2 -#define AMDGPU_IDS_FLAGS_TMZ 0x4 -#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8 +#define AMDGPU_IDS_FLAGS_FUSION 0x01 +#define AMDGPU_IDS_FLAGS_PREEMPTION 0x02 +#define AMDGPU_IDS_FLAGS_TMZ 0x04 +#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x08 +#define AMDGPU_IDS_FLAGS_GANG_SUBMIT 0x10/* * Query h/w info: Flag identifying VF/PF/PT mode