lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251226102656.6296-6-lkml@antheas.dev>
Date: Fri, 26 Dec 2025 12:26:43 +0200
From: Antheas Kapenekakis <lkml@...heas.dev>
To: dmitry.osipenko@...labora.com
Cc: bob.beckett@...labora.com,
	bookeldor@...il.com,
	hadess@...ess.net,
	jaap@...tsma.org,
	kernel@...labora.com,
	lennart@...ttering.net,
	linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	lkml@...heas.dev,
	mccann@....edu,
	rafael@...nel.org,
	richard@...hsie.com,
	sebastian.reichel@...labora.com,
	superm1@...nel.org,
	systemd-devel@...ts.freedesktop.org,
	xaver.hugl@...il.com
Subject: [RFC v1 5/8] acpi/x86: s2idle: move DSM notifications to
 do_notification callback

Currently, the DSM Sleep Entry/Exit/Display On/Off notifications fire
during the suspend sequence. Move them to the new do_notification
callback so they can be called during runtime as well. The kernel will
still ensure that they are called during s2idle without userspace
involvement.

Signed-off-by: Antheas Kapenekakis <lkml@...heas.dev>
---
 drivers/acpi/x86/s2idle.c | 87 +++++++++++++++++++++++----------------
 1 file changed, 52 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
index 08fa7841a484..7693162c68fd 100644
--- a/drivers/acpi/x86/s2idle.c
+++ b/drivers/acpi/x86/s2idle.c
@@ -547,6 +547,53 @@ static u8 acpi_s2idle_get_standby_states(void)
 	return states;
 }
 
+static int acpi_s2idle_do_notification(standby_notification_t state)
+{
+	switch ((__force unsigned int)state) {
+	case PM_SN_INACTIVE_ENTRY:
+		if (lps0_dsm_func_mask > 0)
+			acpi_sleep_run_lps0_dsm(
+				acpi_s2idle_vendor_amd() ?
+					ACPI_LPS0_DISPLAY_OFF_AMD :
+					ACPI_LPS0_DISPLAY_OFF,
+				lps0_dsm_func_mask, lps0_dsm_guid);
+
+		if (lps0_dsm_func_mask_microsoft > 0)
+			acpi_sleep_run_lps0_dsm(ACPI_LPS0_DISPLAY_OFF,
+						lps0_dsm_func_mask_microsoft,
+						lps0_dsm_guid_microsoft);
+		break;
+	case PM_SN_INACTIVE_EXIT:
+		if (lps0_dsm_func_mask > 0)
+			acpi_sleep_run_lps0_dsm(
+				acpi_s2idle_vendor_amd() ?
+					ACPI_LPS0_DISPLAY_ON_AMD :
+					ACPI_LPS0_DISPLAY_ON,
+				lps0_dsm_func_mask, lps0_dsm_guid);
+		if (lps0_dsm_func_mask_microsoft > 0)
+			acpi_sleep_run_lps0_dsm(ACPI_LPS0_DISPLAY_ON,
+						lps0_dsm_func_mask_microsoft,
+						lps0_dsm_guid_microsoft);
+		break;
+	case PM_SN_SLEEP_ENTRY:
+		if (lps0_dsm_func_mask_microsoft > 0)
+			acpi_sleep_run_lps0_dsm(ACPI_LPS0_SLEEP_ENTRY,
+						lps0_dsm_func_mask_microsoft,
+						lps0_dsm_guid_microsoft);
+		break;
+	case PM_SN_SLEEP_EXIT:
+		if (lps0_dsm_func_mask_microsoft > 0)
+			acpi_sleep_run_lps0_dsm(ACPI_LPS0_SLEEP_EXIT,
+						lps0_dsm_func_mask_microsoft,
+						lps0_dsm_guid_microsoft);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int acpi_s2idle_begin_lps0(void)
 {
 	if (pm_debug_messages_on && !lpi_constraints_table) {
@@ -576,33 +623,16 @@ static int acpi_s2idle_prepare_late_lps0(void)
 	if (pm_debug_messages_on)
 		lpi_check_constraints();
 
-	/* Screen off */
+	/* LPS0 entry */
 	if (lps0_dsm_func_mask > 0)
 		acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
-					ACPI_LPS0_DISPLAY_OFF_AMD :
-					ACPI_LPS0_DISPLAY_OFF,
+					ACPI_LPS0_ENTRY_AMD :
+					ACPI_LPS0_ENTRY,
 					lps0_dsm_func_mask, lps0_dsm_guid);
 
 	if (lps0_dsm_func_mask_microsoft > 0)
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_DISPLAY_OFF,
-				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
-
-	/* LPS0 entry */
-	if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd())
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD,
-					lps0_dsm_func_mask, lps0_dsm_guid);
-
-	if (lps0_dsm_func_mask_microsoft > 0) {
-		/* Modern Standby entry */
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_SLEEP_ENTRY,
-				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
 		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
 				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
-	}
-
-	if (lps0_dsm_func_mask > 0 && !acpi_s2idle_vendor_amd())
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
-					lps0_dsm_func_mask, lps0_dsm_guid);
 
 	list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) {
 		if (handler->prepare)
@@ -643,27 +673,14 @@ static void acpi_s2idle_restore_early_lps0(void)
 					ACPI_LPS0_EXIT,
 					lps0_dsm_func_mask, lps0_dsm_guid);
 
-	if (lps0_dsm_func_mask_microsoft > 0) {
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
-				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
-		/* Modern Standby exit */
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_SLEEP_EXIT,
-				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
-	}
-
-	/* Screen on */
 	if (lps0_dsm_func_mask_microsoft > 0)
-		acpi_sleep_run_lps0_dsm(ACPI_LPS0_DISPLAY_ON,
+		acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
 				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
-	if (lps0_dsm_func_mask > 0)
-		acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
-					ACPI_LPS0_DISPLAY_ON_AMD :
-					ACPI_LPS0_DISPLAY_ON,
-					lps0_dsm_func_mask, lps0_dsm_guid);
 }
 
 static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
 	.get_standby_states = acpi_s2idle_get_standby_states,
+	.do_notification = acpi_s2idle_do_notification,
 	.begin = acpi_s2idle_begin_lps0,
 	.prepare = acpi_s2idle_prepare,
 	.prepare_late = acpi_s2idle_prepare_late_lps0,
-- 
2.52.0



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ