All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices
@ 2026-06-11 15:04 Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function Daniel Gibson
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 15:04 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel, Mario Limonciello
  Cc: Daniel Gibson

On some AMD Zen3 and Zen3+-based Lenovo IdeaPad laptops the keyboard and
the lid switch stop working after the first suspend, until rebooted.

More specifically, they stop sending events when pressing a key or
closing the lid - it's still possible to toggle the capslock- and
numlock-LEDs with an external keyboard or read the lid state at
/proc/acpi/button/lid/LID/state.

See also https://bugzilla.kernel.org/show_bug.cgi?id=221383

It appears that suspending and/or resuming gets the EC into a broken
state. This problem doesn't happen on Windows and Mario Limonciello
mentioned that the Windows kernel gives hardware and software some time
before actually suspending (before activating HW DRIPS), while Linux
(or the amd_pmc module) does that immediately, so it may be worth trying
if calling msleep() in amd_pmc_s2idle_check() helps.

It turned out that sleeping for 2.5 seconds at that point indeed makes
the problems mostly disappear. Sleeping for 1.5 seconds wasn't enough.

"Mostly" because it turned out that they still occur (on some but not
all devices needing this patch) when using a wakeup timer (wakealarm).

I could build on an existing quirk[1] that also sleeps for 2.5 seconds
under other circumstances; my first commit refactors that a bit so I
can integrate my further changes in a cleaner way.

I found several reports of these or similar issues on the web, for
different devices, so in a second commit I added a parameter to the
kernel module that allows enabling or disabling this, which will make
it easy for people whose devices aren't matched yet to test this quirk.

Thanks to Mario Limonciello for his support and to Sindre Henriksen for
testing my patch and to Ilpo Järvinen and Hans de Goede for reviewing!

[1] https://lore.kernel.org/platform-driver-x86/20250414162446.3853194-1-superm1@kernel.org/

Changes in v6:
- Rebased to review-ilpo-next branch (commit 2565a28cdcdc "platform/x86: ISST: Restore SST-PP control to all domains")

Changes in v5 (https://lore.kernel.org/platform-driver-x86/20260609105756.2813669-1-daniel@gibson.sh/T/#u):
- Re-add missing first commit ("Check for intermediate wakeup in function")
  (sorry!)
- Add Reviewed-By tags for Hans de Goede's review

Changes in v4 (https://lore.kernel.org/platform-driver-x86/20260606044758.2213401-1-daniel@gibson.sh/T/#u):
- Don't log during intermediate wakes, which happen a lot when charging
  those IdeaPads while they're suspended, so dmesg isn't spammed
- Removed the documentation commits to make merging this less painful
  (one of them referred to commits added here, so the IDs would have to
   be fixed up while merging). I'll submit them separately.

Changes in v3 (https://lore.kernel.org/platform-driver-x86/20260512202645.1549111-1-daniel@gibson.sh/T/#u
    and https://lore.kernel.org/platform-driver-x86/20260603031110.345815-1-daniel@gibson.sh/T/#u):
- Rewrote commit messages of patch 1, 4 and 5 as requested in the review
- Adjusted formatting of the other commit messages
- Added another confirmed device (83MM) to the quirks list and mention
  it in the commit message

Changes in v2 (https://lore.kernel.org/platform-driver-x86/20260509013105.816339-1-daniel@gibson.sh/t/#u):
- Documented this in Documentation/arch/x86/amd-debugging.rst
- Added example for reset register kernel message in same file
- In amd_pmc_quirk_need_suspend_delay(), avoid dereferencing a NULL
  pointer of devices not detected for any quirk - oops!
- Mention that timed resumes may still cause those keyboard/lid issues
- Various code changes requested or suggested in reviews of v1:
  - Some formatting changes (commas behind non-terminating entries)
  - Moved check for existing quirk (that OVP thing) into its own function
    amd_pmc_intermediate_wakeup_need_delay() in pmc.c, so the checks of
    the different quirks are separated more clearly.
  - Added function amd_pmc_want_suspend_delay() in pmc.c handling
    amd_pmc_quirk_need_suspend_delay() together with disable_workarounds
    and delay_suspend and also logging about the reason for the delay,
    also for cleaner separation.
  - If delay_suspend=1 is used to force-enable the fix on hardware that
    is not automatically detected as needing this fix, log message
    encouraging the user to report their device, including the most
    relevant DMI values that could be used for matching

v1: https://lore.kernel.org/platform-driver-x86/20260501032655.283789-1-daniel@gibson.sh/t/#u


Daniel Gibson (4):
  platform/x86/amd/pmc: Check for intermediate wakeup in function
  platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops
  platform/x86/amd/pmc: Add delay_suspend module parameter
  platform/x86/amd/pmc: Don't log during intermediate wakeups

 drivers/platform/x86/amd/pmc/pmc-quirks.c | 39 +++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 83 ++++++++++++++++++++++-
 drivers/platform/x86/amd/pmc/pmc.h        |  2 +
 3 files changed, 121 insertions(+), 3 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function
  2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
@ 2026-06-11 15:04 ` Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 2/4] platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops Daniel Gibson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 15:04 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel, Mario Limonciello
  Cc: Daniel Gibson, stable

Refactor code introduced by commit 9f5595d5f03f ("pmc: Require at
least 2.5 seconds between HW sleep cycles") to allow adding different
conditions for that delay in an upcoming change.

Signed-off-by: Daniel Gibson <daniel@gibson.sh>
Cc: stable@vger.kernel.org
---
 drivers/platform/x86/amd/pmc/pmc.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index ccb37383b337..25509099a958 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -670,6 +670,19 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
 	return rc;
 }
 
+static bool amd_pmc_intermediate_wakeup_need_delay(struct amd_pmc_dev *pdev)
+{
+	/*
+	 * Starting a new HW sleep cycle right after waking from one
+	 * can cause electrical problems triggering the over voltage protection.
+	 * That is avoided by delaying the next suspend a bit, see also
+	 * https://lore.kernel.org/all/20250414162446.3853194-1-superm1@kernel.org/
+	 */
+	struct smu_metrics table;
+
+	return get_metrics_table(pdev, &table) == 0 && table.s0i3_last_entry_status;
+}
+
 static void amd_pmc_s2idle_prepare(void)
 {
 	struct amd_pmc_dev *pdev = &pmc;
@@ -702,11 +715,9 @@ static void amd_pmc_s2idle_prepare(void)
 static void amd_pmc_s2idle_check(void)
 {
 	struct amd_pmc_dev *pdev = &pmc;
-	struct smu_metrics table;
 	int rc;
 
-	/* Avoid triggering OVP */
-	if (!get_metrics_table(pdev, &table) && table.s0i3_last_entry_status)
+	if (amd_pmc_intermediate_wakeup_need_delay(pdev))
 		msleep(2500);
 
 	/* Dump the IdleMask before we add to the STB */
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v6 2/4] platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops
  2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function Daniel Gibson
@ 2026-06-11 15:04 ` Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 3/4] platform/x86/amd/pmc: Add delay_suspend module parameter Daniel Gibson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 15:04 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel, Mario Limonciello
  Cc: Daniel Gibson, Sindre Henriksen, Hans de Goede, stable

Some IdeaPad Slim 3 devices and similar with AMD CPUs have a
nonfunctional keyboard and lid switch after s2idle.

It helps to delay suspend by 2.5 seconds so the EC has some time
to do whatever it needs to get done before suspend - unfortunately
at least on my 16ABR8 waking it with a timer (wakealarm) still
triggers the issue, but at least normal resume via keypress or
lid works fine. On the 14ARP10 wakealarm has been reported to also
work fine with this patch.

This issue has been reported for many different devices, this patch
has been tested with the Zen3-based IdeaPad Slim 3 16ABR8 (82XR)
and the Zen3+-based IdeaPad Slim 3 14ARP10 (83K6) and IdeaPad Slim 3
15ARP10 (83MM).

Reported-by: Sindre Henriksen <sindrehenriksen93@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221383
Tested-by: Sindre Henriksen <sindrehenriksen93@gmail.com>
Suggested-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Daniel Gibson <daniel@gibson.sh>
Cc: stable@vger.kernel.org
---
 drivers/platform/x86/amd/pmc/pmc-quirks.c | 39 +++++++++++++++++++++++
 drivers/platform/x86/amd/pmc/pmc.c        | 24 +++++++++++++-
 drivers/platform/x86/amd/pmc/pmc.h        |  1 +
 3 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/amd/pmc/pmc-quirks.c b/drivers/platform/x86/amd/pmc/pmc-quirks.c
index 24506e342943..74ddf1d8289a 100644
--- a/drivers/platform/x86/amd/pmc/pmc-quirks.c
+++ b/drivers/platform/x86/amd/pmc/pmc-quirks.c
@@ -18,6 +18,7 @@
 struct quirk_entry {
 	u32 s2idle_bug_mmio;
 	bool spurious_8042;
+	bool need_suspend_delay;
 };
 
 static struct quirk_entry quirk_s2idle_bug = {
@@ -33,6 +34,10 @@ static struct quirk_entry quirk_s2idle_spurious_8042 = {
 	.spurious_8042 = true,
 };
 
+static struct quirk_entry quirk_s2idle_need_suspend_delay = {
+	.need_suspend_delay = true,
+};
+
 static const struct dmi_system_id fwbug_list[] = {
 	{
 		.ident = "L14 Gen2 AMD",
@@ -203,6 +208,35 @@ static const struct dmi_system_id fwbug_list[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "82XQ"),
 		}
 	},
+	/* https://bugzilla.kernel.org/show_bug.cgi?id=221383 */
+	{
+		.ident = "Zen3-based IdeaPad Slim and similar",
+		.driver_data = &quirk_s2idle_need_suspend_delay,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+			/*
+			 * Note: there are also some Zen2-based 82X* devices that
+			 * need different quirks, they're already handled above
+			 */
+			DMI_MATCH(DMI_PRODUCT_NAME, "82X"),
+		}
+	},
+	{
+		.ident = "Zen3+-based IdeaPad Slim and similar",
+		.driver_data = &quirk_s2idle_need_suspend_delay,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "83K"),
+		}
+	},
+	{
+		.ident = "IdeaPad Slim 3 15ARP10 (83MM)",
+		.driver_data = &quirk_s2idle_need_suspend_delay,
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "83MM"),
+		}
+	},
 	/* https://bugzilla.kernel.org/show_bug.cgi?id=221273 */
 	{
 		.ident = "Thinkpad L14 Gen3",
@@ -356,6 +390,11 @@ void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev)
 		amd_pmc_skip_nvme_smi_handler(dev->quirks->s2idle_bug_mmio);
 }
 
+bool amd_pmc_quirk_need_suspend_delay(struct amd_pmc_dev *dev)
+{
+	return dev->quirks && dev->quirks->need_suspend_delay;
+}
+
 void amd_pmc_quirks_init(struct amd_pmc_dev *dev)
 {
 	const struct dmi_system_id *dmi_id;
diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index 25509099a958..758abcf9f094 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -683,6 +683,27 @@ static bool amd_pmc_intermediate_wakeup_need_delay(struct amd_pmc_dev *pdev)
 	return get_metrics_table(pdev, &table) == 0 && table.s0i3_last_entry_status;
 }
 
+static bool amd_pmc_want_suspend_delay(struct amd_pmc_dev *pdev)
+{
+	/*
+	 * Some Lenovo Laptops (like different IdeaPad 3 Slims) need some
+	 * me-time before sleeping or they get uncooperative after waking
+	 * up and don't send events for keyboard and lid switch anymore.
+	 *
+	 * Unfortunately this doesn't entirely fix the problem: It can still
+	 * happen when resuming with a timer (wakealarm), but at least the
+	 * more common usecases (wakeup by opening lid or pressing a key)
+	 * work fine with this workaround.
+	 *
+	 * See https://bugzilla.kernel.org/show_bug.cgi?id=221383
+	 */
+	if (!disable_workarounds && amd_pmc_quirk_need_suspend_delay(pdev)) {
+		dev_info(pdev->dev, "Delaying suspend by 2.5s to avoid platform bug\n");
+		return true;
+	}
+	return false;
+}
+
 static void amd_pmc_s2idle_prepare(void)
 {
 	struct amd_pmc_dev *pdev = &pmc;
@@ -717,7 +738,8 @@ static void amd_pmc_s2idle_check(void)
 	struct amd_pmc_dev *pdev = &pmc;
 	int rc;
 
-	if (amd_pmc_intermediate_wakeup_need_delay(pdev))
+	if (amd_pmc_intermediate_wakeup_need_delay(pdev) ||
+	    amd_pmc_want_suspend_delay(pdev))
 		msleep(2500);
 
 	/* Dump the IdleMask before we add to the STB */
diff --git a/drivers/platform/x86/amd/pmc/pmc.h b/drivers/platform/x86/amd/pmc/pmc.h
index 36756e25b4bd..1ef182bb240d 100644
--- a/drivers/platform/x86/amd/pmc/pmc.h
+++ b/drivers/platform/x86/amd/pmc/pmc.h
@@ -165,6 +165,7 @@ enum amd_pmc_def {
 };
 
 void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev);
+bool amd_pmc_quirk_need_suspend_delay(struct amd_pmc_dev *dev);
 void amd_pmc_quirks_init(struct amd_pmc_dev *dev);
 void amd_mp2_stb_init(struct amd_pmc_dev *dev);
 void amd_mp2_stb_deinit(struct amd_pmc_dev *dev);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v6 3/4] platform/x86/amd/pmc: Add delay_suspend module parameter
  2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 2/4] platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops Daniel Gibson
@ 2026-06-11 15:04 ` Daniel Gibson
  2026-06-11 15:04 ` [PATCH v6 4/4] platform/x86/amd/pmc: Don't log during intermediate wakeups Daniel Gibson
  2026-06-11 17:27 ` [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Ilpo Järvinen
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 15:04 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel, Mario Limonciello
  Cc: Daniel Gibson, Hans de Goede, stable

Enabling the new delay_suspend module parameter delays suspend for
2.5 seconds which is known to help for some AMD-based Lenovo Laptops
that otherwise failed to send/receive events for key presses or the
lid switch after s2idle. Apparently the EC needs to do some things
in the background before suspend or it gets into a bad state.

There are many reports of AMD-based laptops (mostly but not exclusively
IdeaPads) about similar issues on the web; this parameter gives
affected users an easy way to try out if their issues have the same
root cause and to work around them until their specific device is added
to the quirks list.

The parameter description has a note encouraging users to report
their device so it can be added to the quirks list, inspired by a
similar request in parameter descriptions of the ideapad-laptop module.

The module parameter can be set to "1" to explicitly enable it,
"0" to disable it even on devices that are assumed to be affected,
or -1 (the default) to enable it if the device is assumed to be affected
(according to fwbug_list[])

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221383
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Daniel Gibson <daniel@gibson.sh>
Cc: stable@vger.kernel.org
---
 drivers/platform/x86/amd/pmc/pmc.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index 758abcf9f094..ce97c27bc362 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -16,6 +16,7 @@
 #include <linux/bits.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/limits.h>
@@ -183,6 +184,11 @@ static bool disable_workarounds;
 module_param(disable_workarounds, bool, 0644);
 MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");
 
+static int delay_suspend = -1;
+module_param(delay_suspend, int, 0644);
+MODULE_PARM_DESC(delay_suspend,
+		 "Delays s2idle by 2.5 seconds to work around buggy ECs, often causing keyboard issues after suspend. 0: don't delay, 1: do delay, -1 (default): let amd_pmc decide. If you need this please report this to: platform-driver-x86@vger.kernel.org");
+
 static struct amd_pmc_dev pmc;
 
 static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
@@ -697,8 +703,23 @@ static bool amd_pmc_want_suspend_delay(struct amd_pmc_dev *pdev)
 	 *
 	 * See https://bugzilla.kernel.org/show_bug.cgi?id=221383
 	 */
-	if (!disable_workarounds && amd_pmc_quirk_need_suspend_delay(pdev)) {
-		dev_info(pdev->dev, "Delaying suspend by 2.5s to avoid platform bug\n");
+	if (amd_pmc_quirk_need_suspend_delay(pdev)) {
+		/*
+		 * delay_suspend=1 force-enables this, otherwise it can be
+		 * disabled with disable_workarounds or delay_suspend=0
+		 */
+		if (delay_suspend == 1 || (delay_suspend == -1 && !disable_workarounds)) {
+			dev_info(pdev->dev, "Delaying suspend by 2.5s to avoid platform bug\n");
+			return true;
+		}
+		dev_info(pdev->dev, "Not delaying suspend because of module parameter, even though your device is assumed to need it!\n");
+	} else if (delay_suspend == 1) {
+		dev_info(pdev->dev, "Delaying suspend by 2.5s because delay_suspend=1. If this solves problems on your machine, please report this whole line to: platform-driver-x86@vger.kernel.org so it can be automatically detected as affected in the future. System Vendor: \"%s\" Product Name: \"%s\" Product Family: \"%s\" Board Vendor: \"%s\" Board Name: \"%s\"\n",
+			 dmi_get_system_info(DMI_SYS_VENDOR),
+			 dmi_get_system_info(DMI_PRODUCT_NAME),
+			 dmi_get_system_info(DMI_PRODUCT_FAMILY),
+			 dmi_get_system_info(DMI_BOARD_VENDOR),
+			 dmi_get_system_info(DMI_BOARD_NAME));
 		return true;
 	}
 	return false;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v6 4/4] platform/x86/amd/pmc: Don't log during intermediate wakeups
  2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
                   ` (2 preceding siblings ...)
  2026-06-11 15:04 ` [PATCH v6 3/4] platform/x86/amd/pmc: Add delay_suspend module parameter Daniel Gibson
@ 2026-06-11 15:04 ` Daniel Gibson
  2026-06-11 17:27 ` [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Ilpo Järvinen
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 15:04 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Ilpo Järvinen,
	platform-driver-x86, linux-kernel, Mario Limonciello
  Cc: Daniel Gibson, Hans de Goede, stable

The ECs in the IdeaPads that need the delay_suspend quirk send lots
of messages when charging, which not only causes intermediate wakeups
when suspended, but also prevents the device from reaching the deepest
suspend state.

Because of this amd_pmc_intermediate_wakeup_need_delay() returns false
during intermediate wakeups and amd_pmc_want_suspend_delay() is called.
So far it always logged its "Delaying suspend by 2.5s ..." messages
then, which spams dmesg. This commit makes sure that those messages are
only logged once per suspend.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221383
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Daniel Gibson <daniel@gibson.sh>
Cc: stable@vger.kernel.org
---
 drivers/platform/x86/amd/pmc/pmc.c | 39 ++++++++++++++++++++++++------
 drivers/platform/x86/amd/pmc/pmc.h |  1 +
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index ce97c27bc362..b2eb9909f6a4 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -691,6 +691,20 @@ static bool amd_pmc_intermediate_wakeup_need_delay(struct amd_pmc_dev *pdev)
 
 static bool amd_pmc_want_suspend_delay(struct amd_pmc_dev *pdev)
 {
+	/*
+	 * intermediate_wakeup implies that the machine didn't get to deepest sleep
+	 * state before - otherwise this function isn't called in amd_pmc_s2idle_check()
+	 * because amd_pmc_intermediate_wakeup_need_delay() returns true first.
+	 * On some IdeaPads that happens when charging, because the EC seems
+	 * to send lots of messages then that wake the machine.
+	 *
+	 * But even in that case, the sleep here is necessary (on those IdeaPads),
+	 * otherwise they wake up completely (resume) after a few seconds.
+	 * So this variable is only used to avoid spamming dmesg on each
+	 * intermediate wakeup.
+	 */
+	bool intermediate_wakeup = !pdev->is_first_check_after_suspend;
+
 	/*
 	 * Some Lenovo Laptops (like different IdeaPad 3 Slims) need some
 	 * me-time before sleeping or they get uncooperative after waking
@@ -709,17 +723,20 @@ static bool amd_pmc_want_suspend_delay(struct amd_pmc_dev *pdev)
 		 * disabled with disable_workarounds or delay_suspend=0
 		 */
 		if (delay_suspend == 1 || (delay_suspend == -1 && !disable_workarounds)) {
-			dev_info(pdev->dev, "Delaying suspend by 2.5s to avoid platform bug\n");
+			if (!intermediate_wakeup)
+				dev_info(pdev->dev, "Delaying suspend by 2.5s to avoid platform bug\n");
 			return true;
 		}
-		dev_info(pdev->dev, "Not delaying suspend because of module parameter, even though your device is assumed to need it!\n");
+		if (!intermediate_wakeup)
+			dev_info(pdev->dev, "Not delaying suspend because of module parameter, even though your device is assumed to need it!\n");
 	} else if (delay_suspend == 1) {
-		dev_info(pdev->dev, "Delaying suspend by 2.5s because delay_suspend=1. If this solves problems on your machine, please report this whole line to: platform-driver-x86@vger.kernel.org so it can be automatically detected as affected in the future. System Vendor: \"%s\" Product Name: \"%s\" Product Family: \"%s\" Board Vendor: \"%s\" Board Name: \"%s\"\n",
-			 dmi_get_system_info(DMI_SYS_VENDOR),
-			 dmi_get_system_info(DMI_PRODUCT_NAME),
-			 dmi_get_system_info(DMI_PRODUCT_FAMILY),
-			 dmi_get_system_info(DMI_BOARD_VENDOR),
-			 dmi_get_system_info(DMI_BOARD_NAME));
+		if (!intermediate_wakeup)
+			dev_info(pdev->dev, "Delaying suspend by 2.5s because delay_suspend=1. If this solves problems on your machine, please report this whole line to: platform-driver-x86@vger.kernel.org so it can be automatically detected as affected in the future. System Vendor: \"%s\" Product Name: \"%s\" Product Family: \"%s\" Board Vendor: \"%s\" Board Name: \"%s\"\n",
+				 dmi_get_system_info(DMI_SYS_VENDOR),
+				 dmi_get_system_info(DMI_PRODUCT_NAME),
+				 dmi_get_system_info(DMI_PRODUCT_FAMILY),
+				 dmi_get_system_info(DMI_BOARD_VENDOR),
+				 dmi_get_system_info(DMI_BOARD_NAME));
 		return true;
 	}
 	return false;
@@ -731,6 +748,9 @@ static void amd_pmc_s2idle_prepare(void)
 	int rc;
 	u32 arg = 1;
 
+	/* Reset this variable because this is a fresh suspend */
+	pdev->is_first_check_after_suspend = true;
+
 	/* Reset and Start SMU logging - to monitor the s0i3 stats */
 	amd_pmc_setup_smu_logging(pdev);
 
@@ -769,6 +789,9 @@ static void amd_pmc_s2idle_check(void)
 	rc = amd_stb_write(pdev, AMD_PMC_STB_S2IDLE_CHECK);
 	if (rc)
 		dev_err(pdev->dev, "error writing to STB: %d\n", rc);
+
+	/* remember that first check after suspend is done (until next prepare) */
+	pdev->is_first_check_after_suspend = false;
 }
 
 static int amd_pmc_dump_data(struct amd_pmc_dev *pdev)
diff --git a/drivers/platform/x86/amd/pmc/pmc.h b/drivers/platform/x86/amd/pmc/pmc.h
index 1ef182bb240d..6973a639d7e3 100644
--- a/drivers/platform/x86/amd/pmc/pmc.h
+++ b/drivers/platform/x86/amd/pmc/pmc.h
@@ -136,6 +136,7 @@ struct amd_pmc_dev {
 	struct dentry *dbgfs_dir;
 	struct quirk_entry *quirks;
 	bool disable_8042_wakeup;
+	bool is_first_check_after_suspend;
 	struct amd_mp2_dev *mp2;
 	struct stb_arg stb_arg;
 	const struct amd_pmc_cpu_info *cpu_info;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices
  2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
                   ` (3 preceding siblings ...)
  2026-06-11 15:04 ` [PATCH v6 4/4] platform/x86/amd/pmc: Don't log during intermediate wakeups Daniel Gibson
@ 2026-06-11 17:27 ` Ilpo Järvinen
  2026-06-11 17:30   ` Daniel Gibson
  4 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2026-06-11 17:27 UTC (permalink / raw)
  To: Daniel Gibson
  Cc: Shyam Sundar S K, Hans de Goede, platform-driver-x86, LKML,
	Mario Limonciello

[-- Attachment #1: Type: text/plain, Size: 5378 bytes --]

On Thu, 11 Jun 2026, Daniel Gibson wrote:

> On some AMD Zen3 and Zen3+-based Lenovo IdeaPad laptops the keyboard and
> the lid switch stop working after the first suspend, until rebooted.
> 
> More specifically, they stop sending events when pressing a key or
> closing the lid - it's still possible to toggle the capslock- and
> numlock-LEDs with an external keyboard or read the lid state at
> /proc/acpi/button/lid/LID/state.
> 
> See also https://bugzilla.kernel.org/show_bug.cgi?id=221383
> 
> It appears that suspending and/or resuming gets the EC into a broken
> state. This problem doesn't happen on Windows and Mario Limonciello
> mentioned that the Windows kernel gives hardware and software some time
> before actually suspending (before activating HW DRIPS), while Linux
> (or the amd_pmc module) does that immediately, so it may be worth trying
> if calling msleep() in amd_pmc_s2idle_check() helps.
> 
> It turned out that sleeping for 2.5 seconds at that point indeed makes
> the problems mostly disappear. Sleeping for 1.5 seconds wasn't enough.
> 
> "Mostly" because it turned out that they still occur (on some but not
> all devices needing this patch) when using a wakeup timer (wakealarm).
> 
> I could build on an existing quirk[1] that also sleeps for 2.5 seconds
> under other circumstances; my first commit refactors that a bit so I
> can integrate my further changes in a cleaner way.
> 
> I found several reports of these or similar issues on the web, for
> different devices, so in a second commit I added a parameter to the
> kernel module that allows enabling or disabling this, which will make
> it easy for people whose devices aren't matched yet to test this quirk.
> 
> Thanks to Mario Limonciello for his support and to Sindre Henriksen for
> testing my patch and to Ilpo Järvinen and Hans de Goede for reviewing!
> 
> [1] https://lore.kernel.org/platform-driver-x86/20250414162446.3853194-1-superm1@kernel.org/
> 
> Changes in v6:
> - Rebased to review-ilpo-next branch (commit 2565a28cdcdc "platform/x86: ISST: Restore SST-PP control to all domains")

Thanks, this one applied cleanly to the review-ilpo-next branch.

--
 i.

> 
> Changes in v5 (https://lore.kernel.org/platform-driver-x86/20260609105756.2813669-1-daniel@gibson.sh/T/#u):
> - Re-add missing first commit ("Check for intermediate wakeup in function")
>   (sorry!)
> - Add Reviewed-By tags for Hans de Goede's review
> 
> Changes in v4 (https://lore.kernel.org/platform-driver-x86/20260606044758.2213401-1-daniel@gibson.sh/T/#u):
> - Don't log during intermediate wakes, which happen a lot when charging
>   those IdeaPads while they're suspended, so dmesg isn't spammed
> - Removed the documentation commits to make merging this less painful
>   (one of them referred to commits added here, so the IDs would have to
>    be fixed up while merging). I'll submit them separately.
> 
> Changes in v3 (https://lore.kernel.org/platform-driver-x86/20260512202645.1549111-1-daniel@gibson.sh/T/#u
>     and https://lore.kernel.org/platform-driver-x86/20260603031110.345815-1-daniel@gibson.sh/T/#u):
> - Rewrote commit messages of patch 1, 4 and 5 as requested in the review
> - Adjusted formatting of the other commit messages
> - Added another confirmed device (83MM) to the quirks list and mention
>   it in the commit message
> 
> Changes in v2 (https://lore.kernel.org/platform-driver-x86/20260509013105.816339-1-daniel@gibson.sh/t/#u):
> - Documented this in Documentation/arch/x86/amd-debugging.rst
> - Added example for reset register kernel message in same file
> - In amd_pmc_quirk_need_suspend_delay(), avoid dereferencing a NULL
>   pointer of devices not detected for any quirk - oops!
> - Mention that timed resumes may still cause those keyboard/lid issues
> - Various code changes requested or suggested in reviews of v1:
>   - Some formatting changes (commas behind non-terminating entries)
>   - Moved check for existing quirk (that OVP thing) into its own function
>     amd_pmc_intermediate_wakeup_need_delay() in pmc.c, so the checks of
>     the different quirks are separated more clearly.
>   - Added function amd_pmc_want_suspend_delay() in pmc.c handling
>     amd_pmc_quirk_need_suspend_delay() together with disable_workarounds
>     and delay_suspend and also logging about the reason for the delay,
>     also for cleaner separation.
>   - If delay_suspend=1 is used to force-enable the fix on hardware that
>     is not automatically detected as needing this fix, log message
>     encouraging the user to report their device, including the most
>     relevant DMI values that could be used for matching
> 
> v1: https://lore.kernel.org/platform-driver-x86/20260501032655.283789-1-daniel@gibson.sh/t/#u
> 
> 
> Daniel Gibson (4):
>   platform/x86/amd/pmc: Check for intermediate wakeup in function
>   platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops
>   platform/x86/amd/pmc: Add delay_suspend module parameter
>   platform/x86/amd/pmc: Don't log during intermediate wakeups
> 
>  drivers/platform/x86/amd/pmc/pmc-quirks.c | 39 +++++++++++
>  drivers/platform/x86/amd/pmc/pmc.c        | 83 ++++++++++++++++++++++-
>  drivers/platform/x86/amd/pmc/pmc.h        |  2 +
>  3 files changed, 121 insertions(+), 3 deletions(-)
> 
> 

-- 
 i.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices
  2026-06-11 17:27 ` [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Ilpo Järvinen
@ 2026-06-11 17:30   ` Daniel Gibson
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Gibson @ 2026-06-11 17:30 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Shyam Sundar S K, Hans de Goede, platform-driver-x86, LKML,
	Mario Limonciello

On 11.06.26 19:27, Ilpo Järvinen wrote:
> On Thu, 11 Jun 2026, Daniel Gibson wrote:
> 
>> On some AMD Zen3 and Zen3+-based Lenovo IdeaPad laptops the keyboard and
>> the lid switch stop working after the first suspend, until rebooted.
>>
>> More specifically, they stop sending events when pressing a key or
>> closing the lid - it's still possible to toggle the capslock- and
>> numlock-LEDs with an external keyboard or read the lid state at
>> /proc/acpi/button/lid/LID/state.
>>
>> See also https://bugzilla.kernel.org/show_bug.cgi?id=221383
>>
>> It appears that suspending and/or resuming gets the EC into a broken
>> state. This problem doesn't happen on Windows and Mario Limonciello
>> mentioned that the Windows kernel gives hardware and software some time
>> before actually suspending (before activating HW DRIPS), while Linux
>> (or the amd_pmc module) does that immediately, so it may be worth trying
>> if calling msleep() in amd_pmc_s2idle_check() helps.
>>
>> It turned out that sleeping for 2.5 seconds at that point indeed makes
>> the problems mostly disappear. Sleeping for 1.5 seconds wasn't enough.
>>
>> "Mostly" because it turned out that they still occur (on some but not
>> all devices needing this patch) when using a wakeup timer (wakealarm).
>>
>> I could build on an existing quirk[1] that also sleeps for 2.5 seconds
>> under other circumstances; my first commit refactors that a bit so I
>> can integrate my further changes in a cleaner way.
>>
>> I found several reports of these or similar issues on the web, for
>> different devices, so in a second commit I added a parameter to the
>> kernel module that allows enabling or disabling this, which will make
>> it easy for people whose devices aren't matched yet to test this quirk.
>>
>> Thanks to Mario Limonciello for his support and to Sindre Henriksen for
>> testing my patch and to Ilpo Järvinen and Hans de Goede for reviewing!
>>
>> [1] https://lore.kernel.org/platform-driver-x86/20250414162446.3853194-1-superm1@kernel.org/
>>
>> Changes in v6:
>> - Rebased to review-ilpo-next branch (commit 2565a28cdcdc "platform/x86: ISST: Restore SST-PP control to all domains")
> 
> Thanks, this one applied cleanly to the review-ilpo-next branch.
> 

Great, thanks a lot for merging! :)

> --
>  i.
> 
>>
>> Changes in v5 (https://lore.kernel.org/platform-driver-x86/20260609105756.2813669-1-daniel@gibson.sh/T/#u):
>> - Re-add missing first commit ("Check for intermediate wakeup in function")
>>   (sorry!)
>> - Add Reviewed-By tags for Hans de Goede's review
>>
>> Changes in v4 (https://lore.kernel.org/platform-driver-x86/20260606044758.2213401-1-daniel@gibson.sh/T/#u):
>> - Don't log during intermediate wakes, which happen a lot when charging
>>   those IdeaPads while they're suspended, so dmesg isn't spammed
>> - Removed the documentation commits to make merging this less painful
>>   (one of them referred to commits added here, so the IDs would have to
>>    be fixed up while merging). I'll submit them separately.
>>
>> Changes in v3 (https://lore.kernel.org/platform-driver-x86/20260512202645.1549111-1-daniel@gibson.sh/T/#u
>>     and https://lore.kernel.org/platform-driver-x86/20260603031110.345815-1-daniel@gibson.sh/T/#u):
>> - Rewrote commit messages of patch 1, 4 and 5 as requested in the review
>> - Adjusted formatting of the other commit messages
>> - Added another confirmed device (83MM) to the quirks list and mention
>>   it in the commit message
>>
>> Changes in v2 (https://lore.kernel.org/platform-driver-x86/20260509013105.816339-1-daniel@gibson.sh/t/#u):
>> - Documented this in Documentation/arch/x86/amd-debugging.rst
>> - Added example for reset register kernel message in same file
>> - In amd_pmc_quirk_need_suspend_delay(), avoid dereferencing a NULL
>>   pointer of devices not detected for any quirk - oops!
>> - Mention that timed resumes may still cause those keyboard/lid issues
>> - Various code changes requested or suggested in reviews of v1:
>>   - Some formatting changes (commas behind non-terminating entries)
>>   - Moved check for existing quirk (that OVP thing) into its own function
>>     amd_pmc_intermediate_wakeup_need_delay() in pmc.c, so the checks of
>>     the different quirks are separated more clearly.
>>   - Added function amd_pmc_want_suspend_delay() in pmc.c handling
>>     amd_pmc_quirk_need_suspend_delay() together with disable_workarounds
>>     and delay_suspend and also logging about the reason for the delay,
>>     also for cleaner separation.
>>   - If delay_suspend=1 is used to force-enable the fix on hardware that
>>     is not automatically detected as needing this fix, log message
>>     encouraging the user to report their device, including the most
>>     relevant DMI values that could be used for matching
>>
>> v1: https://lore.kernel.org/platform-driver-x86/20260501032655.283789-1-daniel@gibson.sh/t/#u
>>
>>
>> Daniel Gibson (4):
>>   platform/x86/amd/pmc: Check for intermediate wakeup in function
>>   platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops
>>   platform/x86/amd/pmc: Add delay_suspend module parameter
>>   platform/x86/amd/pmc: Don't log during intermediate wakeups
>>
>>  drivers/platform/x86/amd/pmc/pmc-quirks.c | 39 +++++++++++
>>  drivers/platform/x86/amd/pmc/pmc.c        | 83 ++++++++++++++++++++++-
>>  drivers/platform/x86/amd/pmc/pmc.h        |  2 +
>>  3 files changed, 121 insertions(+), 3 deletions(-)
>>
>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-11 17:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 15:04 [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Daniel Gibson
2026-06-11 15:04 ` [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function Daniel Gibson
2026-06-11 15:04 ` [PATCH v6 2/4] platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops Daniel Gibson
2026-06-11 15:04 ` [PATCH v6 3/4] platform/x86/amd/pmc: Add delay_suspend module parameter Daniel Gibson
2026-06-11 15:04 ` [PATCH v6 4/4] platform/x86/amd/pmc: Don't log during intermediate wakeups Daniel Gibson
2026-06-11 17:27 ` [PATCH v6 0/4] amd_pmc: Delay s2idle suspend for some devices Ilpo Järvinen
2026-06-11 17:30   ` Daniel Gibson

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.