Skip to content

Commit 1657793

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Forbid suspending into non-default suspend states
On systems that default to 'deep' some userspace software likes to try to suspend in 'deep' first. If there is a failure for any reason (such as -ENOMEM) the failure is ignored and then it will try to use 's2idle' as a fallback. This fails, but more importantly it leads to graphical problems. Forbid this behavior and only allow suspending in the last state supported by the system. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4093 Acked-by: Alex Deucher <alexander.deucher@amd.com> Link: https://lore.kernel.org/r/20250408180957.4027643-1-superm1@kernel.org Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 2aabd44)
1 parent 447fab3 commit 1657793

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ struct amdgpu_device {
11231123
bool in_s3;
11241124
bool in_s4;
11251125
bool in_s0ix;
1126+
suspend_state_t last_suspend_state;
11261127

11271128
enum pp_mp1_state mp1_state;
11281129
struct amdgpu_doorbell_index doorbell_index;

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2548,8 +2548,20 @@ static int amdgpu_pmops_suspend(struct device *dev)
25482548
adev->in_s0ix = true;
25492549
else if (amdgpu_acpi_is_s3_active(adev))
25502550
adev->in_s3 = true;
2551-
if (!adev->in_s0ix && !adev->in_s3)
2551+
if (!adev->in_s0ix && !adev->in_s3) {
2552+
/* don't allow going deep first time followed by s2idle the next time */
2553+
if (adev->last_suspend_state != PM_SUSPEND_ON &&
2554+
adev->last_suspend_state != pm_suspend_target_state) {
2555+
drm_err_once(drm_dev, "Unsupported suspend state %d\n",
2556+
pm_suspend_target_state);
2557+
return -EINVAL;
2558+
}
25522559
return 0;
2560+
}
2561+
2562+
/* cache the state last used for suspend */
2563+
adev->last_suspend_state = pm_suspend_target_state;
2564+
25532565
return amdgpu_device_suspend(drm_dev, true);
25542566
}
25552567

0 commit comments

Comments
 (0)