drm/amdgpu/mes: optimize compute loop handling
Subsystems (2)
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu/mes: optimize compute loop handling
Break when we get to the end of the supported pipes rather than continuing the loop.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -1
@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Signature · 1 line
2.48.1
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu/mes: enable compute pipes across all MEC
Enable pipes on both MECs for MES.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -2
@@ -130,8 +130,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) { -/* use only 1st MEC pipes */ -if (i >= adev->gfx.mec.num_pipe_per_mec) +if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Signature · 1 line
2.48.1
RE: [PATCH 2/4] drm/amdgpu/mes: enable compute pipes across all MEC
[AMD Official Use Only - AMD Internal Distribution Only]
Regards,
Prike
Quoted 34 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 3:09 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 2/4] drm/amdgpu/mes: enable compute pipes across all MECEnable pipes on both MECs for MES.
Fixes 745f46b6a99f ("drm/amdgpu: enable mes v12 self test")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-2@@ -130,8 +130,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) { -/* use only 1st MEC pipes */ -if (i >= adev->gfx.mec.num_pipe_per_mec) +if (i >= (adev->gfx.mec.num_pipe_per_mec * adev- >gfx.mec.num_mec))break ; adev->mes.compute_hqd_mask[i] =0xc ;}--
2.48.1
Re: [PATCH 2/4] drm/amdgpu/mes: enable compute pipes across all MEC
In reply to Alex DeucherQuoted 13 lines · Alex Deucher
Enable pipes on both MECs for MES.
Fixes 745f46b6a99f ("drm/amdgpu: enable mes v12 self test")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 133
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-2@@ -130,8 +130,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) { -/* use only 1st MEC pipes */ -if (i >= adev->gfx.mec.num_pipe_per_mec) +if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))
Same comment as in patch 1.
Thanks,
Lijo
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Re: [PATCH 2/4] drm/amdgpu/mes: enable compute pipes across all MEC
Quoted 19 lines · Lijo
Quoted 15 lines · Alex Deucher
Enable pipes on both MECs for MES.
Fixes 745f46b6a99f ("drm/amdgpu: enable mes v12 self test")Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -130,8 +130,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 133
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-2for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) { -/* use only 1st MEC pipes */ -if (i >= adev->gfx.mec.num_pipe_per_mec) +if (i >= (adev->gfx.mec.num_pipe_per_mec * adev->gfx.mec.num_mec))Same comment as in patch 1.
This keeps the array access bounded.
Alex
Quoted 8 lines
Thanks,
LijoQuoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu/mes: drop MES 10.x leftovers
In reply to Alex DeucherLeftover from MES bring up. There is no production MES support for MES 10.x. The rest of the MES 10.x code has already been removed so drop this.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -4
@@ -136,11 +136,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) { -if (amdgpu_ip_version (adev,SDMA0_HWIP ,0 ) < -IP_VERSION (6 ,0 ,0 )) - adev->mes.sdma_hqd_mask[i] = i ?0 :0x3fc ;/* zero sdma_hqd_mask for non-existent engine */ -else if (adev->sdma.num_instances ==1 ) +if (adev->sdma.num_instances ==1 ) adev->mes.sdma_hqd_mask[i] = i ?0 :0xfc ;else adev->mes.sdma_hqd_mask[i] =0xfc ;
Signature · 1 line
2.48.1
RE: [PATCH 3/4] drm/amdgpu/mes: drop MES 10.x leftovers
[Public]
Regards,
Prike
Quoted 36 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 3:09 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/4] drm/amdgpu/mes: drop MES 10.x leftoversLeftover from MES bring up. There is no production MES support for MES 10.x. The rest of the MES 10.x code has already been removed so drop this.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-5@@ -136,11 +136,8 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) { -if (amdgpu_ip_version (adev,SDMA0_HWIP ,0 ) < -IP_VERSION (6 ,0 ,0 )) - adev->mes.sdma_hqd_mask[i] = i ?0 :0x3fc ;/* zero sdma_hqd_mask for non-existent engine */ -else if (adev->sdma.num_instances ==1 ) +if (adev->sdma.num_instances ==1 ) adev->mes.sdma_hqd_mask[i] = i ?0 :0xfc ;else adev->mes.sdma_hqd_mask[i] =0xfc ; --2.48.1
Alex Deucher
maintainerPATCH 4/4 drm/amdgpu/mes: clean up SDMA HQD loop
In reply to Alex DeucherFollow the same logic as the other IP types.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -5
@@ -136,11 +136,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) { -/* zero sdma_hqd_mask for non-existent engine */ -if (adev->sdma.num_instances ==1 ) - adev->mes.sdma_hqd_mask[i] = i ?0 :0xfc ; -else - adev->mes.sdma_hqd_mask[i] =0xfc ; +if (i >= adev->sdma.num_instances) +break ; + adev->mes.sdma_hqd_mask[i] =0xfc ; }for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) {
Signature · 1 line
2.48.1
RE: [PATCH 4/4] drm/amdgpu/mes: clean up SDMA HQD loop
[Public]
Regards,
Prike
Quoted 37 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 3:09 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu/mes: clean up SDMA HQD loopFollow the same logic as the other IP types.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3
-6@@ -136,11 +136,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev) }for (i =0 ; i <AMDGPU_MES_MAX_SDMA_PIPES ; i++) { -/* zero sdma_hqd_mask for non-existent engine */ -if (adev->sdma.num_instances ==1 ) - adev->mes.sdma_hqd_mask[i] = i ?0 :0xfc ; -else - adev->mes.sdma_hqd_mask[i] =0xfc ; +if (i >= adev->sdma.num_instances) +break ; + adev->mes.sdma_hqd_mask[i] =0xfc ; }for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) { --2.48.1
[Public]
Regards,
Prike
Quoted 34 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 20, 2025 3:09 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu/mes: optimize compute loop handlingBreak when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-2@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; } --2.48.1
Quoted 14 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {
Unless I'm not seeing something, why not just keep it i < adev->gfx.mec.num_pipe_per_mec?
Thanks,
Lijo
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
[Public]
Quoted 31 lines
From: amd-gfx <[email protected]> On Behalf Of Lazar, Lijo
Sent: Thursday, March 20, 2025 7:14 PM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Cc: Liu, Shaoyun <[email protected]>
Subject: Re: [PATCH 1/4] drm/amdgpu/mes: optimize compute loop handlingQuoted 15 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {Unless I'm not seeing something, why not just keep it i <
adev->gfx.mec.num_pipe_per_mec?
Quoted 3 lines
Thanks,
Lijo
This check way may benefit when the check case is adev->gfx.mec.num_pipe_per_mec < AMDGPU_MES_MAX_COMPUTE_PIPES; in this way it will reduce the later unused loop check.
Thanks,
Prike
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Quoted 13 lines · Lijo
Quoted 9 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {Unless I'm not seeing something, why not just keep it i <
adev->gfx.mec.num_pipe_per_mec?
AMDGPU_MES_MAX_COMPUTE_PIPES Is the size of the array and I think it is aligned to the max supported by the firmware, so if we had num_pipe_per_mec larger than that for some reason this would prevent an overflow.
Alex
Quoted 12 lines
Thanks,
LijoQuoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Quoted 24 lines · Alex Deucher
Quoted 13 lines · Lijo
Quoted 9 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {Unless I'm not seeing something, why not just keep it i <
adev->gfx.mec.num_pipe_per_mec?
Quoted 5 lines
AMDGPU_MES_MAX_COMPUTE_PIPESIs the size of the array and I think it is aligned to the max supported by the firmware, so if we hadnum_pipe_per_meclarger than that for some reason this would prevent an overflow.
I think it should be kept the other way and array size should be fixed, otherwise it hides a real problem.
Thanks,
Lijo
Quoted 14 lines
Alex
Quoted 12 lines
Thanks,
LijoQuoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Quoted 28 lines · Lijo
Quoted 24 lines · Alex Deucher
Quoted 22 lines · Lijo
Quoted 14 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {Unless I'm not seeing something, why not just keep it i <
adev->gfx.mec.num_pipe_per_mec?
Quoted 8 lines
Quoted 5 lines
AMDGPU_MES_MAX_COMPUTE_PIPESIs the size of the array and I think it is aligned to the max supported by the firmware, so if we hadnum_pipe_per_meclarger than that for some reason this would prevent an overflow.I think it should be kept the other way and array size should be fixed, otherwise it hides a real problem.
How about a dev_warn when we break out of the loop? If we see that, we can fix the array size or figure out why it's too large.
Alex
Quoted 19 lines
Thanks,
LijoQuoted 14 lines
Alex
Quoted 12 lines
Thanks,
LijoQuoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }
Quoted 35 lines · Alex Deucher
Quoted 34 lines · Lijo
Quoted 29 lines · Alex Deucher
Quoted 13 lines · Lijo
Quoted 9 lines · Alex Deucher
Break when we get to the end of the supported pipes rather than continuing the loop.
Reviewed-by Shaoyun.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 132
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0
-0@@ -132,7 +132,7 @@ int amdgpu_mes_init(struct amdgpu_device *adev)for (i =0 ; i <AMDGPU_MES_MAX_COMPUTE_PIPES ; i++) {Unless I'm not seeing something, why not just keep it i <
adev->gfx.mec.num_pipe_per_mec?
AMDGPU_MES_MAX_COMPUTE_PIPESIs the size of the array and I think it is aligned to the max supported by the firmware, so if we hadnum_pipe_per_meclarger than that for some reason this would prevent an overflow.
Quoted 6 lines
Quoted 2 lines
I think it should be kept the other way and array size should be fixed, otherwise it hides a real problem.
How about a
dev_warnwhen we break out of the loop? If we see that, we can fix the array size or figure out why it's too large.
Yes, that will do.
Thanks,
Lijo
Quoted 21 lines
Alex
Quoted 19 lines
Thanks,
LijoQuoted 14 lines
Alex
Quoted 12 lines
Thanks,
LijoQuoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1
-1/* use only 1st MEC pipes */ if (i >= adev->gfx.mec.num_pipe_per_mec) -continue ; +break ; adev->mes.compute_hqd_mask[i] =0xc ; }