amd_pmc: Delay s2idle suspend for some devices
Subsystems (3)
v6 cover amd_pmc: Delay s2idle suspend for some devices
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/[email protected]/
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/[email protected]/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/[email protected]/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/[email protected]/T/#u
and https://lore.kernel.org/platform-driver-x86/[email protected]/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/[email protected]/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/[email protected]/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(-)
Signature · 1 line
2.48.1
PATCH v6 1/4 platform/x86/amd/pmc: Check for intermediate wakeup in function
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.
--- drivers/platform/x86/amd/pmc/pmc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +14 -3
@@ -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/[email protected]/ +*/ +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 */
Signature · 1 line
2.48.1
PATCH v6 2/4 platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops
In reply to Daniel GibsonSome 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).
--- 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(-)
drivers/platform/x86/amd/pmc/pmc-quirks.c +39 -0
@@ -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;
drivers/platform/x86/amd/pmc/pmc.c +23 -1
@@ -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 */
drivers/platform/x86/amd/pmc/pmc.h +1 -0
@@ -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);
Signature · 1 line
2.48.1
PATCH v6 3/4 platform/x86/amd/pmc: Add delay_suspend module parameter
In reply to Daniel GibsonEnabling 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[])
--- drivers/platform/x86/amd/pmc/pmc.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +23 -2
@@ -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: [email protected]" ); +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: [email protected] 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;
Signature · 1 line
2.48.1
PATCH v6 4/4 platform/x86/amd/pmc: Don't log during intermediate wakeups
In reply to Daniel GibsonThe 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.
--- drivers/platform/x86/amd/pmc/pmc.c | 39 ++++++++++++++++++++++++------ drivers/platform/x86/amd/pmc/pmc.h | 1 + 2 files changed, 32 insertions(+), 8 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +31 -8
@@ -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: [email protected] 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: [email protected] 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)
drivers/platform/x86/amd/pmc/pmc.h +1 -0
@@ -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;
Signature · 1 line
2.48.1
Ilpo Järvinen
maintainerQuoted 32 lines · 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_pmcmodule) does that immediately, so it may be worth trying if callingmsleep()inamd_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.
Quoted 7 lines
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/[email protected]/
Changes in v6:
- Rebased to review-ilpo-next branch (commit2565a28cdcdc"platform/x86: ISST: Restore SST-PP control to all domains")
Thanks, this one applied cleanly to the review-ilpo-next branch.
--
i.
Quoted 55 lines
Changes in v5 (https://lore.kernel.org/platform-driver-x86/[email protected]/T/#u):
- Re-add missing first commit ("Check for intermediate wakeup in function")
(sorry!)
- Add Reviewed-By tags for Hans de Goede's reviewChanges in v4 (https://lore.kernel.org/platform-driver-x86/[email protected]/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/[email protected]/T/#u
and https://lore.kernel.org/platform-driver-x86/[email protected]/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 messageChanges in v2 (https://lore.kernel.org/platform-driver-x86/[email protected]/t/#u):
- Documented this inDocumentation/arch/x86/amd-debugging.rst
- Added example for reset register kernel message in same file
- Inamd_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 functionamd_pmc_intermediate_wakeup_need_delay()inpmc.c, so the checks of
the different quirks are separated more clearly.
- Added functionamd_pmc_want_suspend_delay()inpmc.chandlingamd_pmc_quirk_need_suspend_delay()together withdisable_workarounds
anddelay_suspendand 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 matchingv1: https://lore.kernel.org/platform-driver-x86/[email protected]/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: Adddelay_suspendmodule parameter platform/x86/amd/pmc: Don't log during intermediate wakeupsdrivers/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(-)
Signature · 1 line
i.
Quoted 37 lines · Ilpo Järvinen
Quoted 35 lines · 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_pmcmodule) does that immediately, so it may be worth trying if callingmsleep()inamd_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!
Quoted 7 lines
Quoted 4 lines
[1] https://lore.kernel.org/platform-driver-x86/[email protected]/
Changes in v6:
- Rebased to review-ilpo-next branch (commit2565a28cdcdc"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! :)
Quoted 59 lines
--
i.Quoted 55 lines
Changes in v5 (https://lore.kernel.org/platform-driver-x86/[email protected]/T/#u):
- Re-add missing first commit ("Check for intermediate wakeup in function")
(sorry!)
- Add Reviewed-By tags for Hans de Goede's reviewChanges in v4 (https://lore.kernel.org/platform-driver-x86/[email protected]/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/[email protected]/T/#u
and https://lore.kernel.org/platform-driver-x86/[email protected]/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 messageChanges in v2 (https://lore.kernel.org/platform-driver-x86/[email protected]/t/#u):
- Documented this inDocumentation/arch/x86/amd-debugging.rst
- Added example for reset register kernel message in same file
- Inamd_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 functionamd_pmc_intermediate_wakeup_need_delay()inpmc.c, so the checks of
the different quirks are separated more clearly.
- Added functionamd_pmc_want_suspend_delay()inpmc.chandlingamd_pmc_quirk_need_suspend_delay()together withdisable_workarounds
anddelay_suspendand 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 matchingv1: https://lore.kernel.org/platform-driver-x86/[email protected]/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: Adddelay_suspendmodule parameter platform/x86/amd/pmc: Don't log during intermediate wakeupsdrivers/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(-)