From: Antheas Kapenekakis <lkml@antheas.dev>
To: linux-pm@vger.kernel.org
Cc: platform-driver-x86@vger.kernel.org,
Mario Limonciello <mario.limonciello@amd.com>,
luke@ljones.dev, me@kylegospodneti.ch,
Denis Benato <benato.denis96@gmail.com>,
Antheas Kapenekakis <lkml@antheas.dev>
Subject: [PATCH v2 3/5] acpi/x86: s2idle: add quirk table for modern standby delays
Date: Sun, 22 Sep 2024 19:22:56 +0200 [thread overview]
Message-ID: <20240922172258.48435-4-lkml@antheas.dev> (raw)
In-Reply-To: <20240922172258.48435-1-lkml@antheas.dev>
Unfortunately, some modern standby systems, including the ROG Ally, rely
on a delay between modern standby transitions. Add a quirk table for
introducing delays between modern standby transitions, and quirk the
ROG Ally on "Display Off", which needs a bit of time to turn off its
controllers prior to suspending (i.e., entering DRIPS).
Reported-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
---
include/linux/suspend.h | 5 +++++
kernel/power/suspend.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 8f33249cc067..d7e2a4d8ab0c 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -144,6 +144,11 @@ struct platform_s2idle_ops {
int (*display_on)(void);
};
+struct platform_s2idle_quirks {
+ int delay_display_off;
+ int delay_display_on;
+};
+
#ifdef CONFIG_SUSPEND
extern suspend_state_t pm_suspend_target_state;
extern suspend_state_t mem_sleep_current;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 610f8ecaeebd..af2abdd2f8c3 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -11,6 +11,7 @@
#include <linux/string.h>
#include <linux/delay.h>
+#include <linux/dmi.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/console.h>
@@ -61,6 +62,30 @@ static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
enum s2idle_states __read_mostly s2idle_state;
static DEFINE_RAW_SPINLOCK(s2idle_lock);
+// The ROG Ally series disconnects its controllers on Display Off, without
+// holding a lock, introducing a race condition. Add a delay to allow the
+// controller to disconnect cleanly prior to suspend.
+static const struct platform_s2idle_quirks rog_ally_quirks = {
+ .delay_display_off = 500,
+};
+
+static const struct dmi_system_id platform_s2idle_quirks[] = {
+ {
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "RC71L"),
+ },
+ .driver_data = (void *)&rog_ally_quirks
+ },
+ {
+ .matches = {
+ DMI_MATCH(DMI_BOARD_NAME, "RC72L"),
+ },
+ .driver_data = (void *)&rog_ally_quirks
+ },
+ {}
+};
+
+
/**
* pm_suspend_default_s2idle - Check if suspend-to-idle is the default suspend.
*
@@ -589,12 +614,26 @@ static int enter_state(suspend_state_t state)
if (state == PM_SUSPEND_TO_IDLE)
s2idle_begin();
+ /*
+ * Windows transitions between Modern Standby states slowly, over multiple
+ * seconds. Certain manufacturers may rely on this, introducing race
+ * conditions. Until Linux can support modern standby, add the relevant
+ * delays between transitions here.
+ */
+ const struct dmi_system_id *s2idle_sysid = dmi_first_match(
+ platform_s2idle_quirks
+ );
+ const struct platform_s2idle_quirks *s2idle_quirks = s2idle_sysid ?
+ s2idle_sysid->driver_data : NULL;
+
/*
* Linux does not have the concept of a "Screen Off" state, so call
* the platform functions for Display On/Off prior to the suspend
* sequence, mirroring Windows which calls them outside of it as well.
*/
platform_suspend_display_off();
+ if (s2idle_quirks && s2idle_quirks->delay_display_off)
+ msleep(s2idle_quirks->delay_display_off);
if (sync_on_suspend_enabled) {
trace_suspend_resume(TPS("sync_filesystems"), 0, true);
@@ -624,6 +663,8 @@ static int enter_state(suspend_state_t state)
Unlock:
mutex_unlock(&system_transition_mutex);
+ if (s2idle_quirks && s2idle_quirks->delay_display_on)
+ msleep(s2idle_quirks->delay_display_on);
platform_suspend_display_on();
return error;
}
--
2.46.1
next prev parent reply other threads:[~2024-09-22 17:24 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-22 17:22 [PATCH v2 0/5] acpi/x86: s2idle: move Display off/on calls outside suspend (fixes ROG Ally suspend) Antheas Kapenekakis
2024-09-22 17:22 ` [PATCH v2 1/5] acpi/x86: s2idle: add support for Display Off and Display On callbacks Antheas Kapenekakis
2024-09-23 15:57 ` Mario Limonciello
2024-09-22 17:22 ` [PATCH v2 2/5] acpi/x86: s2idle: handle Display On/Off calls outside of suspend sequence Antheas Kapenekakis
2024-09-23 16:03 ` Mario Limonciello
2024-09-23 16:15 ` Antheas Kapenekakis
2024-09-23 16:30 ` Mario Limonciello
2024-09-23 16:43 ` Antheas Kapenekakis
2024-09-23 17:01 ` Antheas Kapenekakis
2024-09-23 17:05 ` Mario Limonciello
2024-09-23 17:13 ` Antheas Kapenekakis
2024-09-22 17:22 ` Antheas Kapenekakis [this message]
2024-09-22 17:54 ` [PATCH v2 3/5] acpi/x86: s2idle: add quirk table for modern standby delays Denis Benato
2024-09-22 18:00 ` Antheas Kapenekakis
2024-09-22 17:22 ` [PATCH v2 4/5] acpi/x86: s2idle: call Display On/Off as part of callbacks and rename Antheas Kapenekakis
2024-09-22 17:22 ` [PATCH v2 5/5] platform/x86: asus-wmi: remove Ally (1st gen) and Ally X suspend quirk Antheas Kapenekakis
2024-09-22 18:15 ` [PATCH v2 0/5] acpi/x86: s2idle: move Display off/on calls outside suspend (fixes ROG Ally suspend) Derek J. Clark
2024-09-22 19:40 ` Antheas Kapenekakis
2024-09-23 1:35 ` Derek J. Clark
2024-09-23 5:57 ` Antheas Kapenekakis
2024-09-23 11:09 ` Luke Jones
2024-09-23 13:11 ` Antheas Kapenekakis
2024-09-23 15:56 ` Mario Limonciello
2024-09-23 16:11 ` Antheas Kapenekakis
2024-09-23 16:21 ` Mario Limonciello
2024-09-23 16:54 ` Antheas Kapenekakis
2024-09-23 17:15 ` Mario Limonciello
2024-09-23 17:48 ` Antheas Kapenekakis
2024-10-05 14:21 ` Hans de Goede
2024-10-05 15:10 ` Antheas Kapenekakis
2024-10-05 16:24 ` Hans de Goede
2024-10-05 16:27 ` Hans de Goede
2024-10-05 16:50 ` Antheas Kapenekakis
2024-10-05 16:57 ` Antheas Kapenekakis
2024-10-05 21:47 ` Hans de Goede
2024-10-05 22:15 ` Antheas Kapenekakis
2024-10-06 10:16 ` Hans de Goede
2024-10-06 11:29 ` Antheas Kapenekakis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240922172258.48435-4-lkml@antheas.dev \
--to=lkml@antheas.dev \
--cc=benato.denis96@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=mario.limonciello@amd.com \
--cc=me@kylegospodneti.ch \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox