Skip to contentSkip to conversation

drm/amd: Apply the suspend state guard to dGPUs

PATCH In review Mario Limonciello 2 participants 2 messages Dec 2 – Dec 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Apply the suspend state guard to dGPUs

Commit 1657793def101 ("drm/amd: Forbid suspending into non-default suspend states") refuses to suspend into a different state than the previous one, so that a failed 'deep' suspend isn't followed by an 's2idle' fallback. The check lives in the branch taken when neither in_s0ix nor in_s3 is set.

amdgpu_acpi_is_s3_active() is always true for a dGPU, so in_s3 is always set and the guard is never evaluated. A dGPU whose S3 attempt is aborted (e.g. "Wakeup pending. Abort CPU freeze" after the noirq ASIC reset) is then allowed to suspend to s2idle, and fails to resume with an unresponsive SMU and a failed GPU reset.

Evaluate the guard before in_s0ix/in_s3 are decided so it applies to all devices, and so that a rejected suspend doesn't leave a stale flag behind.

Fixes 1657793def101 ("drm/amd: Forbid suspending into non-default suspend states")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 26 ++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +15 -11
index 2a86142699842..5223cc4d38492 100644
@@ -2655,22 +2655,26 @@ 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);
 
+#if IS_ENABLED(CONFIG_SUSPEND)
+	/*
+	 * Don't allow going deep first time followed by s2idle the next time.
+	 * This needs to be checked before in_s0ix/in_s3 are decided, as
+	 * amdgpu_acpi_is_s3_active() is always true for a dGPU.
+	 */
+	if (adev->last_suspend_state != PM_SUSPEND_ON &&
+	    adev->last_suspend_state != pm_suspend_target_state) {
+		drm_err_once(drm_dev, "Unsupported suspend state %d\n",
+			     pm_suspend_target_state);
+		return -EINVAL;
+	}
+#endif
+
 	if (amdgpu_acpi_is_s0ix_active(adev))
 		adev->in_s0ix = true;
 	else if (amdgpu_acpi_is_s3_active(adev))
 		adev->in_s3 = true;
-	if (!adev->in_s0ix && !adev->in_s3) {
-#if IS_ENABLED(CONFIG_SUSPEND)
-		/* don't allow going deep first time followed by s2idle the next time */
-		if (adev->last_suspend_state != PM_SUSPEND_ON &&
-		    adev->last_suspend_state != pm_suspend_target_state) {
-			drm_err_once(drm_dev, "Unsupported suspend state %d\n",
-				     pm_suspend_target_state);
-			return -EINVAL;
-		}
-#endif
+	if (!adev->in_s0ix && !adev->in_s3)
 		return 0;
-	}
 
 #if IS_ENABLED(CONFIG_SUSPEND)
 	/* cache the state last used for suspend */
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Mario Limonciello

Commit 1657793def101 ("drm/amd: Forbid suspending into non-default suspend states") refuses to suspend into a different state than the previous one, so that a failed 'deep' suspend isn't followed by an 's2idle' fallback. The check lives in the branch taken when neither in_s0ix nor in_s3 is set.

amdgpu_acpi_is_s3_active() is always true for a dGPU, so in_s3 is always set and the guard is never evaluated. A dGPU whose S3 attempt is aborted (e.g. "Wakeup pending. Abort CPU freeze" after the noirq ASIC reset) is then allowed to suspend to s2idle, and fails to resume with an unresponsive SMU and a failed GPU reset.

Quoted 7 lines

Evaluate the guard before in_s0ix/in_s3 are decided so it applies to all devices, and so that a rejected suspend doesn't leave a stale flag behind.

Fixes 1657793def101 ("drm/amd: Forbid suspending into non-default suspend states")
Quoted 49 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 26 ++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +15 -12
index 2a86142699842..5223cc4d38492 100644
@@ -2655,22 +2655,26 @@ 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);
 
+#if IS_ENABLED(CONFIG_SUSPEND)
+       /*
+        * Don't allow going deep first time followed by s2idle the next time.
+        * This needs to be checked before in_s0ix/in_s3 are decided, as
+        * amdgpu_acpi_is_s3_active() is always true for a dGPU.
+        */
+       if (adev->last_suspend_state != PM_SUSPEND_ON &&
+           adev->last_suspend_state != pm_suspend_target_state) {
+               drm_err_once(drm_dev, "Unsupported suspend state %d\n",
+                            pm_suspend_target_state);
+               return -EINVAL;
+       }
+#endif
+
        if (amdgpu_acpi_is_s0ix_active(adev))
                adev->in_s0ix = true;
        else if (amdgpu_acpi_is_s3_active(adev))
                adev->in_s3 = true;
-       if (!adev->in_s0ix && !adev->in_s3) {
-#if IS_ENABLED(CONFIG_SUSPEND)
-               /* don't allow going deep first time followed by s2idle the next time */
-               if (adev->last_suspend_state != PM_SUSPEND_ON &&
-                   adev->last_suspend_state != pm_suspend_target_state) {
-                       drm_err_once(drm_dev, "Unsupported suspend state %d\n",
-                                    pm_suspend_target_state);
-                       return -EINVAL;
-               }
-#endif
+       if (!adev->in_s0ix && !adev->in_s3)
                return 0;
-       }
 
 #if IS_ENABLED(CONFIG_SUSPEND)
        /* cache the state last used for suspend */
--

2.43.0