Skip to contentSkip to conversation

drm/amdgpu: Reset dGPU if suspend got aborted

PATCH Superseded Lijo Lazar 3 participants 3 messages Mar 28, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH v2 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.

---
v2: Read TOS status only if required (Kevin).
Refine log message.

 drivers/gpu/drm/amd/amdgpu/soc21.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc21.c +25 -0
index 8526282f4da1..abe319b0f063 100644
@@ -867,10 +867,35 @@ 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;
+
+	/* Will reset for the following suspend abort cases.
+	 * 1) Only reset dGPU side.
+	 * 2) S3 suspend got aborted and TOS is active.
+	 */
+	if (!(adev->flags & AMD_IS_APU) && adev->in_s3 &&
+	    !adev->suspend_complete) {
+		sol_reg1 = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);
+		msleep(100);
+		sol_reg2 = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);
+
+		return (sol_reg1 != sol_reg2);
+	}
+
+	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 aborted, resetting...");
+		soc21_asic_reset(adev);
+	}
+
 	return soc21_common_hw_init(adev);
 }
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

[Public]

Quoted 10 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Thursday, March 28, 2024 12:20 AM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Reset dGPU if suspend got aborted

Quoted 5 lines

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.

Quoted 51 lines

---
v2: Read TOS status only if required (Kevin).
Refine log message.

 drivers/gpu/drm/amd/amdgpu/soc21.c | 25
+++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc21.c +24 -1
index 8526282f4da1..abe319b0f063 100644
@@ -867,10 +867,35 @@ 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;
+
+     /* Will reset for the following suspend abort cases.
+      * 1) Only reset dGPU side.
+      * 2) S3 suspend got aborted and TOS is active.
+      */
+     if (!(adev->flags & AMD_IS_APU) && adev->in_s3 &&
+         !adev->suspend_complete) {
+             sol_reg1 = RREG32_SOC15(MP0, 0,
 regMP0_SMN_C2PMSG_81);
+             msleep(100);
+             sol_reg2 = RREG32_SOC15(MP0, 0,
 regMP0_SMN_C2PMSG_81);
+
+             return (sol_reg1 != sol_reg2);
+     }
+
+     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 aborted, resetting...");
+             soc21_asic_reset(adev);
+     }
+
      return soc21_common_hw_init(adev);
 }
 
--

2.25.1

Reviewed-by on v2 1/1
#2 lore raw
In reply to Lijo Lazar

[AMD Official Use Only - General]

Best Regards,
Kevin

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Lijo Lazar
Sent: Thursday, March 28, 2024 12:20 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: [PATCH v2] 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.

---
v2: Read TOS status only if required (Kevin).
Refine log message.

 drivers/gpu/drm/amd/amdgpu/soc21.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc21.c +24 -1
index 8526282f4da1..abe319b0f063 100644
@@ -867,10 +867,35 @@ 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;
+
+       /* Will reset for the following suspend abort cases.
+        * 1) Only reset dGPU side.
+        * 2) S3 suspend got aborted and TOS is active.
+        */
+       if (!(adev->flags & AMD_IS_APU) && adev->in_s3 &&
+           !adev->suspend_complete) {
+               sol_reg1 = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);
+               msleep(100);
+               sol_reg2 = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);
+
+               return (sol_reg1 != sol_reg2);
+       }
+
+       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 aborted, resetting...");
+               soc21_asic_reset(adev);
+       }
+
        return soc21_common_hw_init(adev);
 }
 
--

2.25.1