mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
@ 2026-10-30  3:05 Saranya Gopal
  2026-10-30 22:00 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Saranya Gopal @ 2026-10-30  3:05 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-pm, linux-kernel, rafael.j.wysocki

When first_ec is NULL, acpi_ec_dispatch_gpe() previously treated any
active GPE as a wake source. On platforms where an _Ixx GPE is shared
by user-wakeup and background events, that can cause unnecessary
wakeups.

Return -ENODEV when no EC instance is available so the s2idle wake
path can handle that case. On x86, check active GPEs against those
registered from _Ixx methods. Preserve immediate wakeup for active
non-_Ixx GPEs; otherwise cancel the SCI wake request and dispatch
active _Ixx GPEs. The common s2idle path then synchronizes event
processing and checks whether a driver requested wakeup. Lookup or
dispatch failures conservatively request wakeup.

The non-x86 fallback retains the previous any-GPE status check.

Fixes: 46767b17fda3 ("ACPI: PM: s2idle: Add _Ixx GPE wake indicator support")
Signed-off-by: Saranya Gopal <saranya.gopal@intel.com>
---
 drivers/acpi/ec.c         | 10 ++++-----
 drivers/acpi/internal.h   |  6 +++---
 drivers/acpi/sleep.c      | 18 +++++++++-------
 drivers/acpi/sleep.h      |  8 ++++++++
 drivers/acpi/x86/s2idle.c | 43 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 70 insertions(+), 15 deletions(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 64ad4cfa6208..8be572af4115 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -2155,19 +2155,19 @@ static bool acpi_ec_work_in_progress(struct acpi_ec *ec)
 	return ec->events_in_progress + ec->queries_in_progress > 0;
 }
 
-bool acpi_ec_dispatch_gpe(void)
+int acpi_ec_dispatch_gpe(void)
 {
 	bool work_in_progress = false;
 
 	if (!first_ec)
-		return acpi_any_gpe_status_set(U32_MAX);
+		return -ENODEV;
 
 	/*
 	 * Report wakeup if the status bit is set for any enabled GPE other
 	 * than the EC one.
 	 */
 	if (acpi_any_gpe_status_set(first_ec->gpe))
-		return true;
+		return 1;
 
 	/*
 	 * Cancel the SCI wakeup and process all pending events in case there
@@ -2195,7 +2195,7 @@ bool acpi_ec_dispatch_gpe(void)
 	spin_unlock_irq(&first_ec->lock);
 
 	if (!work_in_progress)
-		return false;
+		return 0;
 
 	pm_pr_dbg("ACPI EC GPE dispatched\n");
 
@@ -2212,7 +2212,7 @@ bool acpi_ec_dispatch_gpe(void)
 		spin_unlock_irq(&first_ec->lock);
 	} while (work_in_progress && !pm_wakeup_pending());
 
-	return false;
+	return 0;
 }
 #endif /* CONFIG_PM_SLEEP */
 
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 40f875b265a9..8a602dea402e 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -236,7 +236,7 @@ void acpi_ec_register_opregions(struct acpi_device *adev);
 
 #ifdef CONFIG_PM_SLEEP
 void acpi_ec_flush_work(void);
-bool acpi_ec_dispatch_gpe(void);
+int acpi_ec_dispatch_gpe(void);
 #endif
 
 #else
@@ -256,9 +256,9 @@ static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit
 static inline void acpi_ec_register_opregions(struct acpi_device *adev) {}
 
 static inline void acpi_ec_flush_work(void) {}
-static inline bool acpi_ec_dispatch_gpe(void)
+static inline int acpi_ec_dispatch_gpe(void)
 {
-	return false;
+	return -ENOTSUP;
 }
 
 #endif
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 132a9df98471..9366c3d927c2 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -787,13 +787,17 @@ bool acpi_s2idle_wake(void)
 			return true;
 		}
 
-		/*
-		 * Check non-EC GPE wakeups and if there are none, cancel the
-		 * SCI-related wakeup and dispatch the EC GPE.
-		 */
-		if (acpi_ec_dispatch_gpe()) {
-			pm_pr_dbg("ACPI non-EC GPE wakeup\n");
-			return true;
+		/* Check EC handling and other GPE wake sources. */
+		{
+			int ret = acpi_ec_dispatch_gpe();
+
+			if (ret == -ENODEV) {
+				if (acpi_x86_s2idle_check_ixx_gpes())
+					return true;
+			} else if (ret > 0) {
+				pm_pr_dbg("ACPI non-EC GPE wakeup\n");
+				return true;
+			}
 		}
 
 		acpi_os_wait_events_complete();
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 9c3cb109c5d2..955e9c22bf0d 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -20,6 +20,14 @@ extern int acpi_s2idle_prepare(void);
 extern bool acpi_s2idle_wake(void);
 extern void acpi_s2idle_restore(void);
 extern void acpi_s2idle_end(void);
+#if defined(CONFIG_X86) && defined(CONFIG_SUSPEND)
+extern bool acpi_x86_s2idle_check_ixx_gpes(void);
+#else
+static inline bool acpi_x86_s2idle_check_ixx_gpes(void)
+{
+	return acpi_any_gpe_status_set(U32_MAX);
+}
+#endif
 
 extern void acpi_s2idle_setup(void);
 
diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
index c278ea14c0b3..979684950f24 100644
--- a/drivers/acpi/x86/s2idle.c
+++ b/drivers/acpi/x86/s2idle.c
@@ -16,6 +16,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/bitmap.h>
 #include <linux/device.h>
 #include <linux/dmi.h>
 #include <linux/suspend.h>
@@ -24,6 +25,8 @@
 
 #ifdef CONFIG_SUSPEND
 
+static DECLARE_BITMAP(acpi_s2idle_ixx_gpes, 256);
+
 static void acpi_setup_ixx_gpes(void)
 {
 	acpi_handle gpe_root;
@@ -47,11 +50,51 @@ static void acpi_setup_ixx_gpes(void)
 
 		acpi_mark_gpe_for_wake(NULL, i);
 		acpi_set_gpe_wake_mask(NULL, i, ACPI_GPE_ENABLE);
+		set_bit(i, acpi_s2idle_ixx_gpes);
 
 		pm_pr_dbg("ACPI: GPE0x%02x armed for wake via %s\n", i, gpe_nr_str);
 	}
 }
 
+bool acpi_x86_s2idle_check_ixx_gpes(void)
+{
+	acpi_handle gpe_device;
+	acpi_event_status status;
+	u32 gpe;
+
+	for (gpe = 0; gpe < acpi_current_gpe_count; gpe++) {
+		if (ACPI_FAILURE(acpi_get_gpe_device(gpe, &gpe_device)))
+			return true;
+
+		if (!gpe_device && gpe < 256 &&
+		    test_bit(gpe, acpi_s2idle_ixx_gpes))
+			continue;
+
+		if (ACPI_FAILURE(acpi_get_gpe_status(gpe_device, gpe, &status)))
+			return true;
+
+		if ((status & ACPI_EVENT_FLAG_STATUS_SET) &&
+		    (status & ACPI_EVENT_FLAG_ENABLE_SET))
+			return true;
+	}
+
+	pm_system_cancel_wakeup();
+
+	for_each_set_bit(gpe, acpi_s2idle_ixx_gpes, 256) {
+		if (ACPI_FAILURE(acpi_get_gpe_status(NULL, gpe, &status)))
+			return true;
+		if (!(status & ACPI_EVENT_FLAG_STATUS_SET) ||
+		    !(status & ACPI_EVENT_FLAG_ENABLE_SET))
+			continue;
+
+		pm_pr_dbg("ACPI _Ixx GPE 0x%02x status set\n", gpe);
+		if (acpi_dispatch_gpe(NULL, gpe) != ACPI_INTERRUPT_HANDLED)
+			return true;
+	}
+
+	return false;
+}
+
 static bool sleep_no_lps0 __read_mostly;
 module_param(sleep_no_lps0, bool, 0644);
 MODULE_PARM_DESC(sleep_no_lps0, "Do not use the special LPS0 device interface");
-- 
2.34.1


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

* Re: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
  2026-10-30  3:05 [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC Saranya Gopal
@ 2026-10-30 22:00 ` kernel test robot
  2026-10-31  3:01 ` kernel test robot
  2026-10-31  4:49 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-30 22:00 UTC (permalink / raw)
  To: Saranya Gopal, linux-acpi
  Cc: llvm, oe-kbuild-all, linux-pm, linux-kernel, rafael.j.wysocki

Hi Saranya,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge amd-pstate/linux-next amd-pstate/bleeding-edge linus/master next-20261029]
[cannot apply to v7.3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saranya-Gopal/ACPI-s2idle-Handle-shared-_Ixx-GPEs-without-an-EC/20261030-083515
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20261030030515.3127310-1-saranya.gopal%40intel.com
patch subject: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20261031/202610310520.ZvkDiItr-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/202610310520.ZvkDiItr-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610310520.ZvkDiItr-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/acpi/tables.c:26:
>> drivers/acpi/internal.h:262:10: error: use of undeclared identifier 'ENOTSUP'
     262 |         return -ENOTSUP;
         |                 ^
   1 error generated.


vim +/ENOTSUP +262 drivers/acpi/internal.h

   258	
   259	static inline void acpi_ec_flush_work(void) {}
   260	static inline int acpi_ec_dispatch_gpe(void)
   261	{
 > 262		return -ENOTSUP;
   263	}
   264	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
  2026-10-30  3:05 [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC Saranya Gopal
  2026-10-30 22:00 ` kernel test robot
@ 2026-10-31  3:01 ` kernel test robot
  2026-10-31  4:49 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-31  3:01 UTC (permalink / raw)
  To: Saranya Gopal, linux-acpi
  Cc: oe-kbuild-all, linux-pm, linux-kernel, rafael.j.wysocki

Hi Saranya,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge amd-pstate/linux-next amd-pstate/bleeding-edge linus/master next-20261030]
[cannot apply to v7.3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saranya-Gopal/ACPI-s2idle-Handle-shared-_Ixx-GPEs-without-an-EC/20261030-083515
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20261030030515.3127310-1-saranya.gopal%40intel.com
patch subject: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
config: i386-randconfig-1000-20261031 (https://download.01.org/0day-ci/archive/20261031/202610311004.dFYbEqgo-lkp@intel.com/config)
compiler: gcc-13 (Debian 13.3.0-16) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/202610311004.dFYbEqgo-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610311004.dFYbEqgo-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/acpi/processor_driver.c:25:
   drivers/acpi/internal.h: In function 'acpi_ec_dispatch_gpe':
>> drivers/acpi/internal.h:262:17: error: 'ENOTSUP' undeclared (first use in this function); did you mean 'ENOTSUPP'?
     262 |         return -ENOTSUP;
         |                 ^~~~~~~
         |                 ENOTSUPP
   drivers/acpi/internal.h:262:17: note: each undeclared identifier is reported only once for each function it appears in
--
   In file included from drivers/acpi/x86/utils.c:19:
   drivers/acpi/x86/../internal.h: In function 'acpi_ec_dispatch_gpe':
>> drivers/acpi/x86/../internal.h:262:17: error: 'ENOTSUP' undeclared (first use in this function); did you mean 'ENOTSUPP'?
     262 |         return -ENOTSUP;
         |                 ^~~~~~~
         |                 ENOTSUPP
   drivers/acpi/x86/../internal.h:262:17: note: each undeclared identifier is reported only once for each function it appears in


vim +262 drivers/acpi/internal.h

   258	
   259	static inline void acpi_ec_flush_work(void) {}
   260	static inline int acpi_ec_dispatch_gpe(void)
   261	{
 > 262		return -ENOTSUP;
   263	}
   264	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
  2026-10-30  3:05 [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC Saranya Gopal
  2026-10-30 22:00 ` kernel test robot
  2026-10-31  3:01 ` kernel test robot
@ 2026-10-31  4:49 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-10-31  4:49 UTC (permalink / raw)
  To: Saranya Gopal, linux-acpi
  Cc: oe-kbuild-all, linux-pm, linux-kernel, rafael.j.wysocki

Hi Saranya,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/bleeding-edge amd-pstate/linux-next amd-pstate/bleeding-edge linus/master next-20261030]
[cannot apply to v7.3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saranya-Gopal/ACPI-s2idle-Handle-shared-_Ixx-GPEs-without-an-EC/20261030-083515
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20261030030515.3127310-1-saranya.gopal%40intel.com
patch subject: [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC
config: x86_64-buildonly-randconfig-1000-20261031 (https://download.01.org/0day-ci/archive/20261031/202610311242.kB7pRXhy-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/202610311242.kB7pRXhy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610311242.kB7pRXhy-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/acpi/sleep.c:26:
   drivers/acpi/internal.h: In function 'acpi_ec_dispatch_gpe':
   drivers/acpi/internal.h:262:17: error: 'ENOTSUP' undeclared (first use in this function); did you mean 'ENOTSUPP'?
     262 |         return -ENOTSUP;
         |                 ^~~~~~~
         |                 ENOTSUPP
   drivers/acpi/internal.h:262:17: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/acpi/internal.h:263:1: warning: control reaches end of non-void function [-Wreturn-type]
     263 | }
         | ^

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for PM_GENERIC_DOMAINS_OF
   Depends on [n]: PM_GENERIC_DOMAINS [=y] && OF [=n]
   Selected by [y]:
   - COMMON_CLK_MT8173_MFGTOP [=y] && COMMON_CLK [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y]) && COMMON_CLK_MT8173 [=y] && PM [=y]


vim +263 drivers/acpi/internal.h

a6021aa24f64174 Arnd Bergmann 2024-10-11  258  
a6021aa24f64174 Arnd Bergmann 2024-10-11  259  static inline void acpi_ec_flush_work(void) {}
c644e4b14c9cb08 Saranya Gopal 2026-10-30  260  static inline int acpi_ec_dispatch_gpe(void)
a6021aa24f64174 Arnd Bergmann 2024-10-11  261  {
c644e4b14c9cb08 Saranya Gopal 2026-10-30  262  	return -ENOTSUP;
a6021aa24f64174 Arnd Bergmann 2024-10-11 @263  }
a6021aa24f64174 Arnd Bergmann 2024-10-11  264  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2026-10-31  4:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30  3:05 [PATCH] ACPI: s2idle: Handle shared _Ixx GPEs without an EC Saranya Gopal
2026-10-30 22:00 ` kernel test robot
2026-10-31  3:01 ` kernel test robot
2026-10-31  4:49 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®