* [PATCH] drm/amd: Forbid suspending into non-default suspend states
@ 2025-04-08 18:09 Mario Limonciello
2025-04-08 20:13 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Mario Limonciello @ 2025-04-08 18:09 UTC (permalink / raw)
To: amd-gfx; +Cc: Mario Limonciello
From: Mario Limonciello <mario.limonciello@amd.com>
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
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 6d83ccfa42eeb..d79fd557b2d6c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1124,6 +1124,7 @@ struct amdgpu_device {
bool in_s3;
bool in_s4;
bool in_s0ix;
+ suspend_state_t last_suspend_state;
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 26bf896f1444e..24ee4710f807f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2548,8 +2548,20 @@ static int amdgpu_pmops_suspend(struct device *dev)
adev->in_s0ix = true;
else if (amdgpu_acpi_is_s3_active(adev))
adev->in_s3 = true;
- if (!adev->in_s0ix && !adev->in_s3)
+ if (!adev->in_s0ix && !adev->in_s3) {
+ /* 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;
+ }
return 0;
+ }
+
+ /* cache the state last used for suspend */
+ adev->last_suspend_state = pm_suspend_target_state;
+
return amdgpu_device_suspend(drm_dev, true);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amd: Forbid suspending into non-default suspend states
2025-04-08 18:09 [PATCH] drm/amd: Forbid suspending into non-default suspend states Mario Limonciello
@ 2025-04-08 20:13 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2025-04-08 20:13 UTC (permalink / raw)
To: Mario Limonciello; +Cc: amd-gfx, Mario Limonciello
On Tue, Apr 8, 2025 at 2:10 PM Mario Limonciello <superm1@kernel.org> wrote:
>
> From: Mario Limonciello <mario.limonciello@amd.com>
>
> 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
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +
> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6d83ccfa42eeb..d79fd557b2d6c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1124,6 +1124,7 @@ struct amdgpu_device {
> bool in_s3;
> bool in_s4;
> bool in_s0ix;
> + suspend_state_t last_suspend_state;
>
> 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 26bf896f1444e..24ee4710f807f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -2548,8 +2548,20 @@ static int amdgpu_pmops_suspend(struct device *dev)
> adev->in_s0ix = true;
> else if (amdgpu_acpi_is_s3_active(adev))
> adev->in_s3 = true;
> - if (!adev->in_s0ix && !adev->in_s3)
> + if (!adev->in_s0ix && !adev->in_s3) {
> + /* 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;
> + }
> return 0;
> + }
> +
> + /* cache the state last used for suspend */
> + adev->last_suspend_state = pm_suspend_target_state;
> +
> return amdgpu_device_suspend(drm_dev, true);
> }
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-08 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 18:09 [PATCH] drm/amd: Forbid suspending into non-default suspend states Mario Limonciello
2025-04-08 20:13 ` Alex Deucher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.