drm/amdgpu: Reset dGPU if suspend got aborted
Subsystems (2)
PATCH 1/1 drm/amdgpu: Reset dGPU if suspend got aborted
For SOC21 ASICs, there is an issue in re-enabling PM features if a suspend got aborted. In such cases, reset the device during resume phase. This is a workaround till a proper solution is finalized.
--- drivers/gpu/drm/amd/amdgpu/soc21.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc21.c +27 -0
@@ -867,10 +867,37 @@ static int soc21_common_suspend(void *handle)return soc21_common_hw_fini (adev); } +static bool soc21_need_reset_on_resume (struct amdgpu_device *adev) +{ +u32 sol_reg1, sol_reg2; +bool sos_alive; + + sol_reg1 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); +msleep (100 ); + sol_reg2 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); + sos_alive = (sol_reg1 != sol_reg2); + +/* Will reset for the following suspend abort cases. +* 1) Only reset dGPU side. +* 2) S3 suspend abort and TOS already launched. +*/ +if (!(adev->flags &AMD_IS_APU ) && adev->in_s3 && + !adev->suspend_complete && sos_alive) +return true; + +return false; +} +static int soc21_common_resume (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (soc21_need_reset_on_resume (adev)) { +dev_info (adev->dev, +"S3 suspend abort case, let's reset ASIC.\n" ); +soc21_asic_reset (adev); + } +return soc21_common_hw_init (adev); }
Signature · 1 line
2.25.1
[AMD Official Use Only - General]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Thursday, March 28, 2024 11:06 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: Reset dGPU if suspend got aborted
For SOC21 ASICs, there is an issue in re-enabling PM features if a suspend got aborted. In such cases, reset the device during resume phase. This is a workaround till a proper solution is finalized.
--- drivers/gpu/drm/amd/amdgpu/soc21.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc21.c +16 -0
@@ -867,10 +867,37 @@ static int soc21_common_suspend(void *handle)return soc21_common_hw_fini (adev); } +static bool soc21_need_reset_on_resume (struct amdgpu_device *adev) { +u32 sol_reg1, sol_reg2; +bool sos_alive; + + sol_reg1 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); +msleep (100 ); + sol_reg2 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); + sos_alive = (sol_reg1 != sol_reg2); + +/* Will reset for the following suspend abort cases. +* 1) Only reset dGPU side. +* 2) S3 suspend abort and TOS already launched. +*/ +if (!(adev->flags &AMD_IS_APU ) && adev->in_s3 && + !adev->suspend_complete && sos_alive) +return true;
[kevin]:
I think we can adjust the code order and only read registers when needed, thus saving function process time.
Best Regards,
Kevin
+
+ return false;
+}
+
static int soc21_common_resume(void *handle) {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;+ if (soc21_need_reset_on_resume(adev)) {
+ dev_info(adev->dev,
+ "S3 suspend abort case, let's reset ASIC.\n");
+ soc21_asic_reset(adev);
+ }
+
return soc21_common_hw_init(adev);
}
--
2.25.1
Quoted 41 lines · Yang(Kevin)
[AMD Official Use Only - General]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Thursday, March 28, 2024 11:06 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: Reset dGPU if suspend got abortedFor SOC21 ASICs, there is an issue in re-enabling PM features if a suspend got aborted. In such cases, reset the device during resume phase. This is a workaround till a proper solution is finalized.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/soc21.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/amd/amdgpu/soc21.c +16
-0@@ -867,10 +867,37 @@ static int soc21_common_suspend(void *handle)return soc21_common_hw_fini (adev); } +static bool soc21_need_reset_on_resume (struct amdgpu_device *adev) { +u32 sol_reg1, sol_reg2; +bool sos_alive; + + sol_reg1 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); +msleep (100 ); + sol_reg2 =RREG32_SOC15 (MP0 ,0 , regMP0_SMN_C2PMSG_81); + sos_alive = (sol_reg1 != sol_reg2); + +/* Will reset for the following suspend abort cases. +* 1) Only reset dGPU side. +* 2) S3 suspend abort and TOS already launched. +*/ +if (!(adev->flags &AMD_IS_APU ) && adev->in_s3 && + !adev->suspend_complete && sos_alive) +return true;
Quoted 3 lines
[kevin]:
I think we can adjust the code order and only read registers when needed, thus saving function process time.
Agree, will send a v2.
Thanks,
Lijo
Quoted 21 lines
Best Regards,
Kevindrivers/gpu/drm/amd/amdgpu/soc21.c +10
-1+ +return false; +} +static int soc21_common_resume (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (soc21_need_reset_on_resume (adev)) { +dev_info (adev->dev, +"S3 suspend abort case, let's reset ASIC.\n" ); +soc21_asic_reset (adev); + } +return soc21_common_hw_init (adev); } --2.25.1