From nobody Fri Jun 12 20:18:53 2026 Received: from smtp-bc0f.mail.infomaniak.ch (smtp-bc0f.mail.infomaniak.ch [45.157.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95DE6318EE7 for ; Thu, 11 Jun 2026 15:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190279; cv=none; b=sd2zUSefeFqnPxJ0Di++hdNcG4itDUxVzfGD3ZQGo+uNUCMA5ST29xQM92kE9JNq81+SfZ87zi0yXO4yZGxi10NAvjfq9IGxJqyneBQtvH4wJ1qfvz6tBeTMp31ZUxun8KNyLhYDMRdi1nrLM4zEjDHu4S2CJgWL6C2lvOsLgFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190279; c=relaxed/simple; bh=ldEjmRTtGXtvqQM36rVtzfGUKHm6h3b8k6Yyh6EYEKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZaPcR9jPLX6BJXMme9bvjQbSbWKhy1DUucMrpq8b4zK9TjXWcr4Sm5AL7w48taeQwZ1mcwqvRIExAmcJKBeL0mzInGaFxwDSHeeGgRf1HRVxu/oSPB2JCFhj/J7qjmSLm2SVZ2r7mEzVqB0oIDisC1diU5o6zpWZR3e7MmsPo6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh; spf=pass smtp.mailfrom=gibson.sh; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b=gnfYbWkr; arc=none smtp.client-ip=45.157.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gibson.sh Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b="gnfYbWkr" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4gbmC10XLmzslR for ; Thu, 11 Jun 2026 17:04:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.sh; s=20260228; t=1781190268; bh=ddd/C3MV0f6jniH/HHXw2Qim2MIZ2eDJT+LOTz2LunY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gnfYbWkrJJFYYW63jBZL0UpANyNmXmDC8rsv1jBoFIFTLmw8da0RGB3U6Lk9hGm5O qPIKJHygEqus1PBvCwFzhPw+DXTvGvMkjSiG6POxUJ/L/aij5N5vKpVitCbIZf3SEw JOhF2i5y4Z8RDmoaeuNVD+xyLDjctP91ZOPMj5jRi/nhiDJWNbIr0KNUvEhYm47yWi ZdGqIbLI5L0S4jUh2r5q5N19uDdedPcsiIDwXTX5hyZV3/5DUx5Y+HkmzZ4UAp0bBM RtmJTIrUbu9Kuu9qAreKANFPmdotPh3lXJZspK8L1g5lctnFJ3ibT5ivSnkE1yjXUU lTOMfrHIdQaGw== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4gbmC04CDWzMLk for ; Thu, 11 Jun 2026 17:04:28 +0200 (CEST) Received: from unknown by spiderdemon.horst.lan (DragonFly Mail Agent v0.13); Thu, 11 Jun 2026 17:04:28 +0200 From: Daniel Gibson To: Shyam Sundar S K , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Mario Limonciello Cc: Daniel Gibson , stable@vger.kernel.org Subject: [PATCH v6 1/4] platform/x86/amd/pmc: Check for intermediate wakeup in function Date: Thu, 11 Jun 2026 17:04:23 +0200 Message-ID: <20260611150426.3683372-2-daniel@gibson.sh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260611150426.3683372-1-daniel@gibson.sh> References: <20260611150426.3683372-1-daniel@gibson.sh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Content-Type: text/plain; charset="utf-8" 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 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; } =20 +static bool amd_pmc_intermediate_wakeup_need_delay(struct amd_pmc_dev *pde= v) +{ + /* + * 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.or= g/ + */ + struct smu_metrics table; + + return get_metrics_table(pdev, &table) =3D=3D 0 && table.s0i3_last_entry_= status; +} + static void amd_pmc_s2idle_prepare(void) { struct amd_pmc_dev *pdev =3D &pmc; @@ -702,11 +715,9 @@ static void amd_pmc_s2idle_prepare(void) static void amd_pmc_s2idle_check(void) { struct amd_pmc_dev *pdev =3D &pmc; - struct smu_metrics table; int rc; =20 - /* Avoid triggering OVP */ - if (!get_metrics_table(pdev, &table) && table.s0i3_last_entry_status) + if (amd_pmc_intermediate_wakeup_need_delay(pdev)) msleep(2500); =20 /* Dump the IdleMask before we add to the STB */ --=20 2.48.1 From nobody Fri Jun 12 20:18:53 2026 Received: from smtp-8faf.mail.infomaniak.ch (smtp-8faf.mail.infomaniak.ch [83.166.143.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BEE1301465 for ; Thu, 11 Jun 2026 15:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190278; cv=none; b=Yr3DLdJ4R0HbCKoZQxVBggHPgxcO+VlXaOppz9rt9qhdw5je99vKDcMurUjsE/k7E7VCxCxvQyq3NlCiZL/w98vehyPAfVJVRvOGbkcDsRIwZSEfGCXFeoPoWjrGU5NipjBkXDbOOAt9xf0XlXP3NWLN4cEI6pkhLnY+9z/5nFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190278; c=relaxed/simple; bh=kqBEwstCtBwFImlyEu42KOAC3fl1UgnaiFoU414rSJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jAV+SMQYUYT7qIjWVaJoSs21wEAXOI/w9+R2XnrkWR1GuX6LKt7ewAThc0FK+sKGs1pGW1wf3KCCHlOQ5B6yLEGtDleacyY8C27bAgMmpnObYJXbVrlBUAbixbY2v6TJL4BOFFuSx30zKFVcfTZhdE3VDmBIEv8yInuz/d1oo/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh; spf=pass smtp.mailfrom=gibson.sh; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b=a0dSYnis; arc=none smtp.client-ip=83.166.143.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gibson.sh Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b="a0dSYnis" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4gbmC111ZFzrr8 for ; Thu, 11 Jun 2026 17:04:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.sh; s=20260228; t=1781190269; bh=9RkVTX/rtlW0evSNvSlz7nW6dAA8SbYv3dsvnGS/rkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a0dSYnisorH2SwxuKYz0FOycjdhbzOmAB91xViETX76ms4/wJ5TYcM+GOMYU6eN7b el/cVJ2PILMjWG7ZXuWTorqiWECJGz2FbfjhKAvvClivlhX/qmgmFbkSnbNVzfmCtd apjto8TZ9SleEIGwBCGjxRCNc++ReLL8ivajfrr/u7Fq2oPDh5tmM/N/pzXaHwlpY3 11AfwPXMwjbv1NYYBq6vx8bp/Qh3QBeOCAKh5O7rkwOsCD+Yu4ZffwZmTqYaN8lKpc /MW/ophgvL+oOw07gSCrrQF8e7lbU/vP+ePe6iB0U1jpx8AkyAkMoXapjgjArWPFRS CPIrz9bvZJs7w== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4gbmC04XBxzBFc for ; Thu, 11 Jun 2026 17:04:28 +0200 (CEST) Received: from unknown by spiderdemon.horst.lan (DragonFly Mail Agent v0.13); Thu, 11 Jun 2026 17:04:28 +0200 From: Daniel Gibson To: Shyam Sundar S K , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Mario Limonciello Cc: Daniel Gibson , Sindre Henriksen , Hans de Goede , stable@vger.kernel.org Subject: [PATCH v6 2/4] platform/x86/amd/pmc: Delay suspend for some Lenovo Laptops Date: Thu, 11 Jun 2026 17:04:24 +0200 Message-ID: <20260611150426.3683372-3-daniel@gibson.sh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260611150426.3683372-1-daniel@gibson.sh> References: <20260611150426.3683372-1-daniel@gibson.sh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha 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 Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D221383 Tested-by: Sindre Henriksen Suggested-by: Mario Limonciello (AMD) Reviewed-by: Mario Limonciello (AMD) Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Hans de Goede Signed-off-by: Daniel Gibson 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/x= 86/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; }; =20 static struct quirk_entry quirk_s2idle_bug =3D { @@ -33,6 +34,10 @@ static struct quirk_entry quirk_s2idle_spurious_8042 =3D= { .spurious_8042 =3D true, }; =20 +static struct quirk_entry quirk_s2idle_need_suspend_delay =3D { + .need_suspend_delay =3D true, +}; + static const struct dmi_system_id fwbug_list[] =3D { { .ident =3D "L14 Gen2 AMD", @@ -203,6 +208,35 @@ static const struct dmi_system_id fwbug_list[] =3D { DMI_MATCH(DMI_PRODUCT_NAME, "82XQ"), } }, + /* https://bugzilla.kernel.org/show_bug.cgi?id=3D221383 */ + { + .ident =3D "Zen3-based IdeaPad Slim and similar", + .driver_data =3D &quirk_s2idle_need_suspend_delay, + .matches =3D { + 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 =3D "Zen3+-based IdeaPad Slim and similar", + .driver_data =3D &quirk_s2idle_need_suspend_delay, + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83K"), + } + }, + { + .ident =3D "IdeaPad Slim 3 15ARP10 (83MM)", + .driver_data =3D &quirk_s2idle_need_suspend_delay, + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "83MM"), + } + }, /* https://bugzilla.kernel.org/show_bug.cgi?id=3D221273 */ { .ident =3D "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); } =20 +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(str= uct amd_pmc_dev *pdev) return get_metrics_table(pdev, &table) =3D=3D 0 && table.s0i3_last_entry_= status; } =20 +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=3D221383 + */ + 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 =3D &pmc; @@ -717,7 +738,8 @@ static void amd_pmc_s2idle_check(void) struct amd_pmc_dev *pdev =3D &pmc; int rc; =20 - if (amd_pmc_intermediate_wakeup_need_delay(pdev)) + if (amd_pmc_intermediate_wakeup_need_delay(pdev) || + amd_pmc_want_suspend_delay(pdev)) msleep(2500); =20 /* 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 { }; =20 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); --=20 2.48.1 From nobody Fri Jun 12 20:18:53 2026 Received: from smtp-8faa.mail.infomaniak.ch (smtp-8faa.mail.infomaniak.ch [83.166.143.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2CC1318EE7 for ; Thu, 11 Jun 2026 15:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190273; cv=none; b=CI33TCHOzsIh6PEeOLq7y+0RvmUy0Ydp1bymL7/mpzH/TdWz+p5/h55yEWCCaaH/jLkAKw9QNSUJ81MzQdlCUw5Q03LRwn3BuWwzCLgdoHMrQhjsFJZgZ7g7TPJthv9AvyXS5Dxtwl2DK1u7subOeH5I9rZg/rcZfZJJTd2Hs/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190273; c=relaxed/simple; bh=7zHfeCmQWeGbP3dVpYHYW8/FWi66YWkTVtTzQPhoats=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KfMXByfIYuPPJT+3EKhH6ePX/BHA410E0f3mjxFABvi+T5Loi05LT4f3cdm3DtNy6SRHPHYjH/YsOLoOdXZ1W4fHBtYvldhwUfdeFF5t6xBc5yfX9xaHzHLcZXQOkSNL1omDpGF5dq24GPrum729F+F5NmHIWgP3iQ6C6MmmB8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh; spf=pass smtp.mailfrom=gibson.sh; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b=VSYkNvHt; arc=none smtp.client-ip=83.166.143.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gibson.sh Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b="VSYkNvHt" Received: from smtp-4-0000.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10::a6b]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4gbmC10gjJz375 for ; Thu, 11 Jun 2026 17:04:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.sh; s=20260228; t=1781190268; bh=bqW0RhbkxKWfgbrkVMtQ9jSHJs8wTyA2a5n8PJR4O7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSYkNvHt8ik7jyTuMcHNXEuF4V96u7qjiWckZVkpu+93VID4/4TYkJ6rEqgPUrfi9 o8qNJxPOB4S9j8yQsnaVLtRderOm6WZ0HHQYkdmvws7g6yN9yN8ArgkZqfFQ8ZWbM4 i+mq9kMje4dqlYHs8/5KZ4KRNs6UgKTdhfkpek49h9DEfX6R/d4jjwFt4Glc1tIReM xEgzznF4jqcUNxAuLjgXipfTLD01trCq42qGBNgSS4CLqmBBPVRl5//1CQMHGxr71y jMgTQSaAHr2P7aYVwU9JJizgCyTSDFBbwMqMcx6/rUSXEnIEd3VxhiT4eynb0eCFEI h2SLxrMIGzhPQ== Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4gbmC04XX7zwHd for ; Thu, 11 Jun 2026 17:04:28 +0200 (CEST) Received: from unknown by spiderdemon.horst.lan (DragonFly Mail Agent v0.13); Thu, 11 Jun 2026 17:04:28 +0200 From: Daniel Gibson To: Shyam Sundar S K , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Mario Limonciello Cc: Daniel Gibson , Hans de Goede , stable@vger.kernel.org Subject: [PATCH v6 3/4] platform/x86/amd/pmc: Add delay_suspend module parameter Date: Thu, 11 Jun 2026 17:04:25 +0200 Message-ID: <20260611150426.3683372-4-daniel@gibson.sh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260611150426.3683372-1-daniel@gibson.sh> References: <20260611150426.3683372-1-daniel@gibson.sh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Content-Type: text/plain; charset="utf-8" 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=3D221383 Reviewed-by: Hans de Goede Signed-off-by: Daniel Gibson 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 #include #include +#include #include #include #include @@ -183,6 +184,11 @@ static bool disable_workarounds; module_param(disable_workarounds, bool, 0644); MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bu= gs"); =20 +static int delay_suspend =3D -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 k= eyboard issues after suspend. 0: don't delay, 1: do delay, -1 (default): le= t amd_pmc decide. If you need this please report this to: platform-driver-x= 86@vger.kernel.org"); + static struct amd_pmc_dev pmc; =20 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=3D221383 */ - 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=3D1 force-enables this, otherwise it can be + * disabled with disable_workarounds or delay_suspend=3D0 + */ + if (delay_suspend =3D=3D 1 || (delay_suspend =3D=3D -1 && !disable_worka= rounds)) { + 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, e= ven though your device is assumed to need it!\n"); + } else if (delay_suspend =3D=3D 1) { + dev_info(pdev->dev, "Delaying suspend by 2.5s because delay_suspend=3D1.= 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; --=20 2.48.1 From nobody Fri Jun 12 20:18:53 2026 Received: from smtp-8fab.mail.infomaniak.ch (smtp-8fab.mail.infomaniak.ch [83.166.143.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C0B4313546 for ; Thu, 11 Jun 2026 15:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190279; cv=none; b=a1nh+V4LfxhFp6fQAuzien7kkPFNtkakhseq0R6bjSlKyycT+F58JQxtDOgVnLXCbPcUjO09+norkgOJlNTQy1ZrLEDP0UXX8N3FwK94j58PGZCk7x1LPMe0YQ4GoTI6Kti5gdHT5n/mKJS5/Z4+LM4n3BC1z8u+xvzAeb4PSrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781190279; c=relaxed/simple; bh=Jq8ysKyX9XjKDYarXwCW/jpo7H3q6jR29jqXAKG+VP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fWzP+1N1P3lP1hMl1rtUPkJRy95cEPmn4NVYDYH+MyYuLQZBBThArAlnpmMzhjFgTxUiyGcFWT0lrxD4W6LuoN5nGLT8BoVre9X5hVbtMjeYNKKLcspI12NAzj1HrJb1GkZPjweO43fpR1kqaqoZUJslGVsJ95i9pKGdSiG70tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh; spf=pass smtp.mailfrom=gibson.sh; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b=Qtb5htk3; arc=none smtp.client-ip=83.166.143.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.sh Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gibson.sh Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gibson.sh header.i=@gibson.sh header.b="Qtb5htk3" Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4gbmC11Kqkzs5P for ; Thu, 11 Jun 2026 17:04:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.sh; s=20260228; t=1781190269; bh=/TzDI8kdlhnZuKW1ZWymH3Q+HdpRLbQx52o+ic/JCXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qtb5htk3Vn+e2Rpkg86SP2/Y2QT5V3gS7vQwBgyIAPTN2rDW3tnR6yHU7JjeTFsfv MsETIF0DfRHnzr9K9J3xjo5H6s6wrGSKnKbIfmFMkWLbBtCTdhgyjtnzZJIiC7ms+p +p/qVDBTjnaB/vdRDTOGuSIacIzJ4Nf08sNGghwP8LDXuAdUjMBWV93qTkyftjfEeL 9zVjbh2o79D/peyBqSgxroVtttnj7mLFzaC8wCeBUkpcUwhxYNyQTxfCHXkFvR6oeM 2mB9ktm9e083LjWNAEjoVVDH5k2A+vhXNbrp7ZySBVIJNTm9+Gr7WCSwxtQJ3GQJDb u2pJAY/oWQj5w== Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4gbmC04q8Gz8Tx for ; Thu, 11 Jun 2026 17:04:28 +0200 (CEST) Received: from unknown by spiderdemon.horst.lan (DragonFly Mail Agent v0.13); Thu, 11 Jun 2026 17:04:28 +0200 From: Daniel Gibson To: Shyam Sundar S K , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Mario Limonciello Cc: Daniel Gibson , Hans de Goede , stable@vger.kernel.org Subject: [PATCH v6 4/4] platform/x86/amd/pmc: Don't log during intermediate wakeups Date: Thu, 11 Jun 2026 17:04:26 +0200 Message-ID: <20260611150426.3683372-5-daniel@gibson.sh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260611150426.3683372-1-daniel@gibson.sh> References: <20260611150426.3683372-1-daniel@gibson.sh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha Content-Type: text/plain; charset="utf-8" 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=3D221383 Reviewed-by: Hans de Goede Signed-off-by: Daniel Gibson 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(str= uct amd_pmc_dev *pdev) =20 static bool amd_pmc_want_suspend_delay(struct amd_pmc_dev *pdev) { + /* + * intermediate_wakeup implies that the machine didn't get to deepest sle= ep + * 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 =3D !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=3D0 */ if (delay_suspend =3D=3D 1 || (delay_suspend =3D=3D -1 && !disable_worka= rounds)) { - 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, e= ven 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 =3D=3D 1) { - dev_info(pdev->dev, "Delaying suspend by 2.5s because delay_suspend=3D1.= 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=3D1= . 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 a= s affected in the future. System Vendor: \"%s\" Product Name: \"%s\" Produc= t 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 =3D 1; =20 + /* Reset this variable because this is a fresh suspend */ + pdev->is_first_check_after_suspend =3D true; + /* Reset and Start SMU logging - to monitor the s0i3 stats */ amd_pmc_setup_smu_logging(pdev); =20 @@ -769,6 +789,9 @@ static void amd_pmc_s2idle_check(void) rc =3D 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 =3D false; } =20 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; --=20 2.48.1