Skip to contentSkip to conversation

drm/amdgpu: correct the S3 abort check condition

PATCH Superseded Prike Liang 2 participants 5 messages Oct 24, 2024 – Oct 25, 2024

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 drm/amdgpu: correct the S3 abort check condition

In the normal S3 entry, the TOS cycle counter is not reset during BIOS execution the _S3 method, so it doesn't determine whether the _S3 method is executed exactly. Howerver, the PM core performs the S3 suspend will set the PM_SUSPEND_FLAG_FW_RESUME bit if all the devices suspend successfully. Therefore, drivers can check the pm_suspend_global_flags bit(1) to detect the S3 suspend abort event.

Fixes 4d58c599df75 ("drm/amdgpu: update suspend status

for aborting from deeper suspend")

---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +13 -10
index dd1c1aacdd8e..12ff6cf568dc 100644
@@ -578,16 +578,13 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
 
 static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
 {
-	u32 sol_reg;
-
-	sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
-
 	/* Will reset for the following suspend abort cases.
-	 * 1) Only reset limit on APU side, dGPU hasn't checked yet.
-	 * 2) S3 suspend abort and TOS already launched.
+	 * 1) Only reset on APU side, dGPU hasn't checked yet.
+	 * 2) S3 suspend aborted in the normal S3 suspend or
+	 *    performing pm core test.
 	 */
 	if (adev->flags & AMD_IS_APU && adev->in_s3 &&
-			sol_reg) {
+			!pm_resume_via_firmware()) {
 		adev->suspend_complete = false;
 		return true;
 	} else {
@@ -603,11 +600,17 @@ static int soc15_asic_reset(struct amdgpu_device *adev)
 	 * successfully. So now, temporarily enable it for the
 	 * S3 suspend abort case.
 	 */
-	if (((adev->apu_flags & AMD_APU_IS_RAVEN) ||
-	    (adev->apu_flags & AMD_APU_IS_RAVEN2)) &&
-		!soc15_need_reset_on_resume(adev))
+
+	if ((adev->apu_flags & AMD_APU_IS_PICASSO ||
+			!(adev->apu_flags & AMD_APU_IS_RAVEN)) &&
+			soc15_need_reset_on_resume(adev))
+		goto asic_reset;
+
+	if ((adev->apu_flags & AMD_APU_IS_RAVEN) ||
+			(adev->apu_flags & AMD_APU_IS_RAVEN2))
 		return 0;
 
+asic_reset:
 	switch (soc15_asic_reset_method(adev)) {
 	case AMD_RESET_METHOD_PCI:
 		dev_info(adev->dev, "PCI reset\n");
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 2/2 drm/amdgpu: clean up the suspend_complete

To check the status of S3 suspend completion, use the PM core pm_suspend_global_flags bit(1) to detect S3 abort events. Therefore, clean up the AMDGPU driver's private flag suspend_complete.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/soc15.c      |  7 ++-----
 drivers/gpu/drm/amd/amdgpu/soc21.c      | 16 ++++++----------
 5 files changed, 10 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
index 48c9b9b06905..9b35763ae0a7 100644
@@ -1111,8 +1111,6 @@ struct amdgpu_device {
 	bool				in_s3;
 	bool				in_s4;
 	bool				in_s0ix;
-	/* indicate amdgpu suspension status */
-	bool				suspend_complete;
 
 	enum pp_mp1_state               mp1_state;
 	struct amdgpu_doorbell_index doorbell_index;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
index 680e44fdee6e..78972151b970 100644
@@ -2501,7 +2501,6 @@ static int amdgpu_pmops_suspend(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-	adev->suspend_complete = false;
 	if (amdgpu_acpi_is_s0ix_active(adev))
 		adev->in_s0ix = true;
 	else if (amdgpu_acpi_is_s3_active(adev))
@@ -2516,7 +2515,6 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-	adev->suspend_complete = true;
 	if (amdgpu_acpi_should_gpu_reset(adev))
 		return amdgpu_asic_reset(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
index b4c4b9916289..6ffcee3008ba 100644
@@ -3276,8 +3276,8 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev)
 	 * confirmed that the APU gfx10/gfx11 needn't such update.
 	 */
 	if (adev->flags & AMD_IS_APU &&
-			adev->in_s3 && !adev->suspend_complete) {
-		DRM_INFO(" Will skip the CSB packet resubmit\n");
+			adev->in_s3 && !pm_resume_via_firmware()) {
+		DRM_INFO("Will skip the CSB packet resubmit\n");
 		return 0;
 	}
 	r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -5
index 12ff6cf568dc..d9d11131a744 100644
@@ -584,13 +584,10 @@ static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
 	 *    performing pm core test.
 	 */
 	if (adev->flags & AMD_IS_APU && adev->in_s3 &&
-			!pm_resume_via_firmware()) {
-		adev->suspend_complete = false;
+			!pm_resume_via_firmware())
 		return true;
-	} else {
-		adev->suspend_complete = true;
+	else
 		return false;
-	}
 }
 
 static int soc15_asic_reset(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/soc21.c +6 -10
index c4b950e75133..8d5844d7a10f 100644
@@ -897,22 +897,18 @@ static int soc21_common_suspend(struct amdgpu_ip_block *ip_block)
 
 static bool soc21_need_reset_on_resume(struct amdgpu_device *adev)
 {
-	u32 sol_reg1, sol_reg2;
+	u32 sol_reg;
 
 	/* 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;
+	sol_reg = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);
+	if (!(adev->flags & AMD_IS_APU) && sol_reg)
+		return true;
+	else
+		return false;
 }
 
 static int soc21_common_resume(struct amdgpu_ip_block *ip_block)
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v3 2/2] drm/amdgpu: clean up the suspend_complete

Quoted 98 lines · Prike Liang

To check the status of S3 suspend completion, use the PM core pm_suspend_global_flags bit(1) to detect S3 abort events. Therefore, clean up the AMDGPU driver's private flag suspend_complete.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/soc15.c      |  7 ++-----
 drivers/gpu/drm/amd/amdgpu/soc21.c      | 16 ++++++----------
 5 files changed, 10 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
index 48c9b9b06905..9b35763ae0a7 100644
@@ -1111,8 +1111,6 @@ struct amdgpu_device {
 	bool				in_s3;
 	bool				in_s4;
 	bool				in_s0ix;
-	/* indicate amdgpu suspension status */
-	bool				suspend_complete;
 
 	enum pp_mp1_state               mp1_state;
 	struct amdgpu_doorbell_index doorbell_index;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
index 680e44fdee6e..78972151b970 100644
@@ -2501,7 +2501,6 @@ static int amdgpu_pmops_suspend(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-	adev->suspend_complete = false;
 	if (amdgpu_acpi_is_s0ix_active(adev))
 		adev->in_s0ix = true;
 	else if (amdgpu_acpi_is_s3_active(adev))
@@ -2516,7 +2515,6 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev)
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-	adev->suspend_complete = true;
 	if (amdgpu_acpi_should_gpu_reset(adev))
 		return amdgpu_asic_reset(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
index b4c4b9916289..6ffcee3008ba 100644
@@ -3276,8 +3276,8 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device *adev)
 	 * confirmed that the APU gfx10/gfx11 needn't such update.
 	 */
 	if (adev->flags & AMD_IS_APU &&
-			adev->in_s3 && !adev->suspend_complete) {
-		DRM_INFO(" Will skip the CSB packet resubmit\n");
+			adev->in_s3 && !pm_resume_via_firmware()) {
+		DRM_INFO("Will skip the CSB packet resubmit\n");
 		return 0;
 	}
 	r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -5
index 12ff6cf568dc..d9d11131a744 100644
@@ -584,13 +584,10 @@ static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
 	 *    performing pm core test.
 	 */
 	if (adev->flags & AMD_IS_APU && adev->in_s3 &&
-			!pm_resume_via_firmware()) {
-		adev->suspend_complete = false;
+			!pm_resume_via_firmware())
 		return true;
-	} else {
-		adev->suspend_complete = true;
+	else
 		return false;
-	}
 }
 
 static int soc15_asic_reset(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/soc21.c +1 -2
index c4b950e75133..8d5844d7a10f 100644
@@ -897,22 +897,18 @@ static int soc21_common_suspend(struct amdgpu_ip_block *ip_block)
 
 static bool soc21_need_reset_on_resume(struct amdgpu_device *adev)
 {
-	u32 sol_reg1, sol_reg2;
+	u32 sol_reg;
 
 	/* 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 &&

drivers/gpu/drm/amd/amdgpu/soc21.c static int soc21_common_suspend(struct amdgpu_ip_block *ip_block) · line 907

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +1 -8
-	    !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;
+	sol_reg = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);

Actually, two samples are taken intentionally to make sure that FW is not hung before deciding on reset.

Thanks,
Lijo

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +4 -0
+	if (!(adev->flags & AMD_IS_APU) && sol_reg)
+		return true;
+	else
+		return false;
 }
 
 static int soc21_common_resume(struct amdgpu_ip_block *ip_block)
#3 lore raw

RE: [PATCH v3 2/2] drm/amdgpu: clean up the suspend_complete

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 121 lines

From: Lazar, Lijo <[email protected]>
Sent: Thursday, October 24, 2024 4:40 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH v3 2/2] drm/amdgpu: clean up the suspend_complete

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_cp_gfx_start(struct amdgpu_device

Quoted 54 lines · Prike Liang

To check the status of S3 suspend completion, use the PM core pm_suspend_global_flags bit(1) to detect S3 abort events. Therefore, clean up the AMDGPU driver's private flag suspend_complete.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/soc15.c      |  7 ++-----
 drivers/gpu/drm/amd/amdgpu/soc21.c      | 16 ++++++----------
 5 files changed, 10 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
index 48c9b9b06905..9b35763ae0a7 100644
@@ -1111,8 +1111,6 @@ struct amdgpu_device {
    bool                            in_s3;
    bool                            in_s4;
    bool                            in_s0ix;
-   /* indicate amdgpu suspension status */
-   bool                            suspend_complete;
 
    enum pp_mp1_state               mp1_state;
    struct amdgpu_doorbell_index doorbell_index; diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 680e44fdee6e..78972151b970 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
@@ -2501,7 +2501,6 @@ static int amdgpu_pmops_suspend(struct device *dev)
    struct drm_device *drm_dev = dev_get_drvdata(dev);
    struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-   adev->suspend_complete = false;
    if (amdgpu_acpi_is_s0ix_active(adev))
            adev->in_s0ix = true;
    else if (amdgpu_acpi_is_s3_active(adev)) @@ -2516,7 +2515,6 @@

static int amdgpu_pmops_suspend_noirq(struct device *dev)

    struct drm_device *drm_dev = dev_get_drvdata(dev);
    struct amdgpu_device *adev = drm_to_adev(drm_dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
-   adev->suspend_complete = true;
    if (amdgpu_acpi_should_gpu_reset(adev))
            return amdgpu_asic_reset(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index b4c4b9916289..6ffcee3008ba 100644
@@ -3276,8 +3276,8 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device

*adev)

drivers/gpu/drm/amd/amdgpu/soc15.c static bool soc15_need_reset_on_resume(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
     * confirmed that the APU gfx10/gfx11 needn't such update.
     */
    if (adev->flags & AMD_IS_APU &&
-                   adev->in_s3 && !adev->suspend_complete) {
-           DRM_INFO(" Will skip the CSB packet resubmit\n");
+                   adev->in_s3 && !pm_resume_via_firmware()) {
+           DRM_INFO("Will skip the CSB packet resubmit\n");
            return 0;
    }
    r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
drivers/gpu/drm/amd/amdgpu/soc15.c +0 -0
index 12ff6cf568dc..d9d11131a744 100644
@@ -584,13 +584,10 @@ static bool soc15_need_reset_on_resume(struct

amdgpu_device *adev)

Quoted 40 lines
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -5
     *    performing pm core test.
     */
    if (adev->flags & AMD_IS_APU && adev->in_s3 &&
-                   !pm_resume_via_firmware()) {
-           adev->suspend_complete = false;
+                   !pm_resume_via_firmware())
            return true;
-   } else {
-           adev->suspend_complete = true;
+   else
            return false;
-   }
 }
 
 static int soc15_asic_reset(struct amdgpu_device *adev) diff --git

a/drivers/gpu/drm/amd/amdgpu/soc21.c
b/drivers/gpu/drm/amd/amdgpu/soc21.c
index c4b950e75133..8d5844d7a10f 100644

drivers/gpu/drm/amd/amdgpu/soc21.c +1 -9
@@ -897,22 +897,18 @@ static int soc21_common_suspend(struct
 amdgpu_ip_block *ip_block)
 
 static bool soc21_need_reset_on_resume(struct amdgpu_device *adev)  {
-   u32 sol_reg1, sol_reg2;
+   u32 sol_reg;
 
    /* 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);
-   }
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/soc21.c static int soc21_common_suspend(struct amdgpu_ip_block *ip_block) · line 907

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +1 -1
-   return false;
+   sol_reg = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);

Actually, two samples are taken intentionally to make sure that FW is not hung before deciding on reset.

However, the original two samples cannot filter out the case where the dGPU is completely suspended. When the dGPU is in competition to suspend, the SOL remains at zero until the PSP resumes. Therefore, the original two SOL samples checking will wrongly reset the case of the dGPU being completely suspended. Personally, one SOL check is sufficient to determine if the dGPU device has been completely suspended.

Thanks,
Prike

Quoted 10 lines

Thanks,
Lijo

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +4 -0
+   if (!(adev->flags & AMD_IS_APU) && sol_reg)
+           return true;
+   else
+           return false;
 }
 
 static int soc21_common_resume(struct amdgpu_ip_block *ip_block)
#4 lore raw

Re: [PATCH v3 2/2] drm/amdgpu: clean up the suspend_complete

Quoted 123 lines · Prike

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 121 lines

From: Lazar, Lijo <[email protected]>
Sent: Thursday, October 24, 2024 4:40 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH v3 2/2] drm/amdgpu: clean up the suspend_complete

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_cp_gfx_start(struct amdgpu_device

Quoted 54 lines · Prike Liang

To check the status of S3 suspend completion, use the PM core pm_suspend_global_flags bit(1) to detect S3 abort events. Therefore, clean up the AMDGPU driver's private flag suspend_complete.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 --
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   |  4 ++--
 drivers/gpu/drm/amd/amdgpu/soc15.c      |  7 ++-----
 drivers/gpu/drm/amd/amdgpu/soc21.c      | 16 ++++++----------
 5 files changed, 10 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
index 48c9b9b06905..9b35763ae0a7 100644
@@ -1111,8 +1111,6 @@ struct amdgpu_device {
    bool                            in_s3;
    bool                            in_s4;
    bool                            in_s0ix;
-   /* indicate amdgpu suspension status */
-   bool                            suspend_complete;
 
    enum pp_mp1_state               mp1_state;
    struct amdgpu_doorbell_index doorbell_index; diff --git

a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 680e44fdee6e..78972151b970 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
@@ -2501,7 +2501,6 @@ static int amdgpu_pmops_suspend(struct device *dev)
    struct drm_device *drm_dev = dev_get_drvdata(dev);
    struct amdgpu_device *adev = drm_to_adev(drm_dev);
 
-   adev->suspend_complete = false;
    if (amdgpu_acpi_is_s0ix_active(adev))
            adev->in_s0ix = true;
    else if (amdgpu_acpi_is_s3_active(adev)) @@ -2516,7 +2515,6 @@

static int amdgpu_pmops_suspend_noirq(struct device *dev)

    struct drm_device *drm_dev = dev_get_drvdata(dev);
    struct amdgpu_device *adev = drm_to_adev(drm_dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
-   adev->suspend_complete = true;
    if (amdgpu_acpi_should_gpu_reset(adev))
            return amdgpu_asic_reset(adev);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index b4c4b9916289..6ffcee3008ba 100644
@@ -3276,8 +3276,8 @@ static int gfx_v9_0_cp_gfx_start(struct amdgpu_device

*adev)

drivers/gpu/drm/amd/amdgpu/soc15.c static bool soc15_need_reset_on_resume(struct

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
     * confirmed that the APU gfx10/gfx11 needn't such update.
     */
    if (adev->flags & AMD_IS_APU &&
-                   adev->in_s3 && !adev->suspend_complete) {
-           DRM_INFO(" Will skip the CSB packet resubmit\n");
+                   adev->in_s3 && !pm_resume_via_firmware()) {
+           DRM_INFO("Will skip the CSB packet resubmit\n");
            return 0;
    }
    r = amdgpu_ring_alloc(ring, gfx_v9_0_get_csb_size(adev) + 4 + 3);
drivers/gpu/drm/amd/amdgpu/soc15.c +0 -0
index 12ff6cf568dc..d9d11131a744 100644
@@ -584,13 +584,10 @@ static bool soc15_need_reset_on_resume(struct

amdgpu_device *adev)

Quoted 40 lines
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -5
     *    performing pm core test.
     */
    if (adev->flags & AMD_IS_APU && adev->in_s3 &&
-                   !pm_resume_via_firmware()) {
-           adev->suspend_complete = false;
+                   !pm_resume_via_firmware())
            return true;
-   } else {
-           adev->suspend_complete = true;
+   else
            return false;
-   }
 }
 
 static int soc15_asic_reset(struct amdgpu_device *adev) diff --git

a/drivers/gpu/drm/amd/amdgpu/soc21.c
b/drivers/gpu/drm/amd/amdgpu/soc21.c
index c4b950e75133..8d5844d7a10f 100644

drivers/gpu/drm/amd/amdgpu/soc21.c +1 -9
@@ -897,22 +897,18 @@ static int soc21_common_suspend(struct
 amdgpu_ip_block *ip_block)
 
 static bool soc21_need_reset_on_resume(struct amdgpu_device *adev)  {
-   u32 sol_reg1, sol_reg2;
+   u32 sol_reg;
 
    /* 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);
-   }
 
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/soc21.c static int soc21_common_suspend(struct amdgpu_ip_block *ip_block) · line 907

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +1 -1
-   return false;
+   sol_reg = RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_81);

Actually, two samples are taken intentionally to make sure that FW is not hung before deciding on reset.

However, the original two samples cannot filter out the case where the dGPU is completely suspended. When the dGPU is in competition to suspend, the SOL remains at zero until the PSP resumes. Therefore, the original two SOL samples checking will wrongly reset the case of the dGPU being completely suspended. Personally, one SOL check is sufficient to determine if the dGPU device has been completely suspended.

If the dGPU is completely suspended (D3), then those two samples will be
0. In that case, there won't be any reset (sol_reg1 != sol_reg2).

If it's ticking, then SOS is active - then a reset is possible. If it's non-zero, but not ticking, FW is hung. There is no point in trying a reset as FW needs to be active to do so. That case will eventually end up in a different failure.

Thanks,
Lijo

Quoted 13 lines

Thanks,
Prike

Quoted 10 lines

Thanks,
Lijo

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/soc21.c +4 -0
+   if (!(adev->flags & AMD_IS_APU) && sol_reg)
+           return true;
+   else
+           return false;
 }
 
 static int soc21_common_resume(struct amdgpu_ip_block *ip_block)