drivers/acpi/acpica/evxfgpe.c | 50 ++++++++++++++++++++++++++++++++++-------- drivers/acpi/button.c | 22 ++++++++++++++++++ include/acpi/acpixf.h | 5 ++++ 3 files changed, 68 insertions(+), 9 deletions(-)
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Prior to commit 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake()
for buttons"), ACPI button wakeup GPEs having handler methods remained
enabled after acpi_wakeup_gpe_init(), but currently they are not enabled
because acpi_setup_gpe_for_wake() disables them.
That causes function keys to stop working on some systems [1] and there
may be other related issues elsewhere.
To address that, make the ACPI button driver enable wakeup GPEs for ACPI
buttons so long as they have handler methods. While this does not
restore the old behavior exactly (the ACPI button driver needs to be
bound to the button devices for the GPEs to be enabled), it should be
sufficient to restore the missing functionality.
For this purpose, introduce acpi_enable_gpe_cond() that enables
a GPE if its dispatch type matches the supplied one and modify
acpi_button_probe() to use that function for enabling the GPEs in
question.
Fixes: 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons")
Reported-by: Nick <nick@kousu.ca>
Closes: https://lore.kernel.org/linux-acpi/E2OXET.4X5GTP37VTNC3@kousu.ca/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 7.0+ <stable@vger.kernel.org> # 7.0+
---
v1 -> v2:
* Change the acpi_enable_gpe_cond() third parameter to a dispatch type (or
"any type" value) and modify checks in it accordingly to address a
problem pointed out by sashiko.dev
* Adjust comments in acpi_enable_gpe_cond() and acpi_enable_gpe()
* Update the changelog
@Nick, It would be good to test this version of the patch on your system
because it is a bit different from the previous one (which was not entirely
correct). I'm not expecting it to behave differently, but additional
testing would be welcome.
Thanks!
---
drivers/acpi/acpica/evxfgpe.c | 50 ++++++++++++++++++++++++++++++++++--------
drivers/acpi/button.c | 22 ++++++++++++++++++
include/acpi/acpixf.h | 5 ++++
3 files changed, 68 insertions(+), 9 deletions(-)
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -78,18 +78,22 @@ ACPI_EXPORT_SYMBOL(acpi_update_all_gpes)
/*******************************************************************************
*
- * FUNCTION: acpi_enable_gpe
+ * FUNCTION: acpi_enable_gpe_cond
*
* PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
* gpe_number - GPE level within the GPE block
+ * dispatch_type - GPE dispatch type to match
*
* RETURN: Status
*
- * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
- * hardware-enabled.
+ * DESCRIPTION: Add a reference to a GPE so long as its dispatch type matches
+ * the supplied one, or it is different from ACPI_GPE_DISPATCH_NONE
+ * if the supplied one is ACPI_GPE_DISPATCH_MASK. On the first
+ * reference, the GPE is hardware-enabled.
*
******************************************************************************/
-acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
+acpi_status acpi_enable_gpe_cond(acpi_handle gpe_device, u32 gpe_number,
+ u8 dispatch_type)
{
acpi_status status = AE_BAD_PARAMETER;
struct acpi_gpe_event_info *gpe_event_info;
@@ -100,14 +104,18 @@ acpi_status acpi_enable_gpe(acpi_handle
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
/*
- * Ensure that we have a valid GPE number and that there is some way
- * of handling the GPE (handler or a GPE method). In other words, we
- * won't allow a valid GPE to be enabled if there is no way to handle it.
+ * Ensure that we have a valid GPE number and that the dispatch type of
+ * the GPE matches the supplied one (or it is not ACPI_GPE_DISPATCH_NONE
+ * if the supplied one is ACPI_GPE_DISPATCH_MASK).
*/
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (gpe_event_info) {
- if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) !=
- ACPI_GPE_DISPATCH_NONE) {
+ if (dispatch_type == ACPI_GPE_DISPATCH_MASK)
+ dispatch_type = ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags);
+ else if (dispatch_type != ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags))
+ dispatch_type = ACPI_GPE_DISPATCH_NONE;
+
+ if (dispatch_type != ACPI_GPE_DISPATCH_NONE) {
status = acpi_ev_add_gpe_reference(gpe_event_info, TRUE);
if (ACPI_SUCCESS(status) &&
ACPI_GPE_IS_POLLING_NEEDED(gpe_event_info)) {
@@ -128,6 +136,30 @@ acpi_status acpi_enable_gpe(acpi_handle
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
return_ACPI_STATUS(status);
}
+ACPI_EXPORT_SYMBOL(acpi_enable_gpe_cond)
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_enable_gpe
+ *
+ * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
+ * gpe_number - GPE level within the GPE block
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
+ * hardware-enabled.
+ *
+ ******************************************************************************/
+acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
+{
+ /*
+ * Ensure that there is some way of handling the GPE (handler or a GPE
+ * method). In other words, we won't allow a valid GPE to be enabled if
+ * there is no way to handle it.
+ */
+ return acpi_enable_gpe_cond(gpe_device, gpe_number, ACPI_GPE_DISPATCH_MASK);
+}
ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
/*******************************************************************************
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -179,6 +179,7 @@ struct acpi_button {
ktime_t last_time;
bool suspended;
bool lid_state_initialized;
+ bool gpe_enabled;
};
static struct acpi_device *lid_device;
@@ -646,6 +647,21 @@ static int acpi_button_probe(struct plat
status = acpi_install_notify_handler(device->handle,
ACPI_ALL_NOTIFY, handler,
button);
+ if (ACPI_SUCCESS(status) && device->wakeup.flags.valid) {
+ acpi_status st;
+
+ /*
+ * If the wakeup GPE has a handler method, enable it in
+ * case it is also used for signaling runtime events.
+ */
+ st = acpi_enable_gpe_cond(device->wakeup.gpe_device,
+ device->wakeup.gpe_number,
+ ACPI_GPE_DISPATCH_METHOD);
+ button->gpe_enabled = ACPI_SUCCESS(st);
+ if (button->gpe_enabled)
+ dev_dbg(button->dev, "Enabled ACPI GPE%02llx\n",
+ device->wakeup.gpe_number);
+ }
break;
}
if (ACPI_FAILURE(status)) {
@@ -689,6 +705,12 @@ static void acpi_button_remove(struct pl
acpi_button_event);
break;
default:
+ if (button->gpe_enabled) {
+ dev_dbg(button->dev, "Disabling ACPI GPE%02llx\n",
+ adev->wakeup.gpe_number);
+ acpi_disable_gpe(adev->wakeup.gpe_device,
+ adev->wakeup.gpe_number);
+ }
acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY,
button->type == ACPI_BUTTON_TYPE_LID ?
acpi_lid_notify :
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -726,6 +726,11 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_sta
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_update_all_gpes(void))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
+ acpi_enable_gpe_cond(acpi_handle gpe_device,
+ u32 gpe_number,
+ u8 dispatch_type))
+
+ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_enable_gpe(acpi_handle gpe_device,
u32 gpe_number))
On May 22, 2026 2:52:10 p.m. UTC, "Rafael J. Wysocki" <rafael@kernel.org> wrote:
>From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
>Prior to commit 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake()
>for buttons"), ACPI button wakeup GPEs having handler methods remained
>enabled after acpi_wakeup_gpe_init(), but currently they are not enabled
>because acpi_setup_gpe_for_wake() disables them.
>
>That causes function keys to stop working on some systems [1] and there
>may be other related issues elsewhere.
>
>To address that, make the ACPI button driver enable wakeup GPEs for ACPI
>buttons so long as they have handler methods. While this does not
>restore the old behavior exactly (the ACPI button driver needs to be
>bound to the button devices for the GPEs to be enabled), it should be
>sufficient to restore the missing functionality.
>
>For this purpose, introduce acpi_enable_gpe_cond() that enables
>a GPE if its dispatch type matches the supplied one and modify
>acpi_button_probe() to use that function for enabling the GPEs in
>question.
>
>Fixes: 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons")
>Reported-by: Nick <nick@kousu.ca>
>Closes: https://lore.kernel.org/linux-acpi/E2OXET.4X5GTP37VTNC3@kousu.ca/ [1]
>Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>Cc: 7.0+ <stable@vger.kernel.org> # 7.0+
>---
>
>v1 -> v2:
> * Change the acpi_enable_gpe_cond() third parameter to a dispatch type (or
> "any type" value) and modify checks in it accordingly to address a
> problem pointed out by sashiko.dev
> * Adjust comments in acpi_enable_gpe_cond() and acpi_enable_gpe()
> * Update the changelog
>
>@Nick, It would be good to test this version of the patch on your system
>because it is a bit different from the previous one (which was not entirely
>correct). I'm not expecting it to behave differently, but additional
>testing would be welcome.
>
I tested this on top of 45255ea1ca096. The keys are still working as expected! I compared it against 6.19.14 too and all the keys seem to behave as before.
I noticed one difference, but it might not be directly related: KEY_SLEEP takes significantly longer to trigger suspend on 7.1-rc4 than on 6.19.14. On the older version it suspends in about a second; on 7.1-rc4 it takes about a minute before it fully suspends. The lid switch on the other hand suspends in about a second, and so does the suspend button in my DE, on both versions. I guess they're doing different kinds of suspend. That's probably related to the other ACPI changes that landed in 7.0.
Here's a log of me pressing the keys again: (we don't see KEY_SUSPEND here because it triggers hiberation which I don't have set up so it just shuts down and I lose the log)
(Apologies if you got this twice, I managed to reset.my mail client to HTML defaults while testing somehow)
$ uname -r
6.19.14-arch1-1
$ sudo libinput debug-events --show-keycodes
-event2 DEVICE_ADDED Power Button seat0 default group1 cap:k
-event4 DEVICE_ADDED Video Bus seat0 default group2 cap:k
-event1 DEVICE_ADDED Power Button seat0 default group3 cap:k
-event0 DEVICE_ADDED Lid Switch seat0 default group4 cap:S
-event5 DEVICE_ADDED Toshiba input device seat0 default group5 cap:k
-event12 DEVICE_ADDED Synaptics TM3322-002 seat0 default group6 cap:pg size 95x53mm tap (dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on dwtp-on
-event3 DEVICE_ADDED AT Translated Set 2 keyboard seat0 default group7 cap:k
-event5 KEYBOARD_KEY +0.000s KEY_MUTE (113) pressed
event5 KEYBOARD_KEY +0.000s KEY_MUTE (113) released
event5 KEYBOARD_KEY +1.054s KEY_MUTE (113) pressed
event5 KEYBOARD_KEY +1.054s KEY_MUTE (113) released
event5 KEYBOARD_KEY +2.979s KEY_COFFEE (152) pressed
event5 KEYBOARD_KEY +2.979s KEY_COFFEE (152) released
event5 KEYBOARD_KEY +3.810s KEY_COFFEE (152) pressed
event5 KEYBOARD_KEY +3.810s KEY_COFFEE (152) released
event5 KEYBOARD_KEY +5.552s KEY_BATTERY (236) pressed
event5 KEYBOARD_KEY +5.552s KEY_BATTERY (236) released
event5 KEYBOARD_KEY +6.180s KEY_BATTERY (236) pressed
event5 KEYBOARD_KEY +6.180s KEY_BATTERY (236) released
event5 KEYBOARD_KEY +7.964s KEY_SLEEP (142) pressed
event5 KEYBOARD_KEY +7.964s KEY_SLEEP (142) released
event5 KEYBOARD_KEY +10.545s KEY_UNKNOWN (240) pressed
event5 KEYBOARD_KEY +10.545s KEY_UNKNOWN (240) released
-event1 KEYBOARD_KEY +10.598s KEY_WAKEUP (143) pressed
event1 KEYBOARD_KEY +10.598s KEY_WAKEUP (143) released
-event2 KEYBOARD_KEY +10.600s KEY_WAKEUP (143) pressed
event2 KEYBOARD_KEY +10.600s KEY_WAKEUP (143) released
-event5 KEYBOARD_KEY +20.312s KEY_SWITCHVIDEOMODE (227) pressed
event5 KEYBOARD_KEY +20.312s KEY_SWITCHVIDEOMODE (227) released
event5 KEYBOARD_KEY +20.981s KEY_SWITCHVIDEOMODE (227) pressed
event5 KEYBOARD_KEY +20.981s KEY_SWITCHVIDEOMODE (227) released
event5 KEYBOARD_KEY +21.467s KEY_BRIGHTNESSDOWN (224) pressed
event5 KEYBOARD_KEY +21.467s KEY_BRIGHTNESSDOWN (224) released
event5 KEYBOARD_KEY +22.034s KEY_BRIGHTNESSDOWN (224) pressed
event5 KEYBOARD_KEY +22.034s KEY_BRIGHTNESSDOWN (224) released
event5 KEYBOARD_KEY +22.420s KEY_BRIGHTNESSUP (225) pressed
event5 KEYBOARD_KEY +22.420s KEY_BRIGHTNESSUP (225) released
event5 KEYBOARD_KEY +22.845s KEY_BRIGHTNESSUP (225) pressed
event5 KEYBOARD_KEY +22.845s KEY_BRIGHTNESSUP (225) released
event5 KEYBOARD_KEY +23.757s KEY_WLAN (238) pressed
event5 KEYBOARD_KEY +23.757s KEY_WLAN (238) released
event5 KEYBOARD_KEY +24.953s KEY_WLAN (238) pressed
event5 KEYBOARD_KEY +24.953s KEY_WLAN (238) released
$ uname -r
7.1.0-rc4-1-git-00393-g39551c4ef087
$ sudo libinput debug-events --show-keycodes
-event5 DEVICE_ADDED Toshiba input device seat0 default group1 cap:k
-event12 DEVICE_ADDED Synaptics TM3322-002 seat0 default group2 cap:pg size 95x53mm tap (dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on dwtp-on
-event4 DEVICE_ADDED Video Bus seat0 default group3 cap:k
-event2 DEVICE_ADDED Power Button seat0 default group4 cap:k
-event1 DEVICE_ADDED Power Button seat0 default group5 cap:k
-event0 DEVICE_ADDED Lid Switch seat0 default group6 cap:S
-event3 DEVICE_ADDED AT Translated Set 2 keyboard seat0 default group7 cap:k
event3 KEYBOARD_KEY +1.467s KEY_LEFTCTRL (29) pressed
event3 KEYBOARD_KEY +1.469s KEY_LEFTMETA (125) pressed
event3 KEYBOARD_KEY +1.470s KEY_F24 (194) pressed
event3 KEYBOARD_KEY +1.608s KEY_F24 (194) released
event3 KEYBOARD_KEY +1.611s KEY_LEFTMETA (125) released
event3 KEYBOARD_KEY +1.612s KEY_LEFTCTRL (29) released
-event5 KEYBOARD_KEY +4.041s KEY_WLAN (238) pressed
event5 KEYBOARD_KEY +4.041s KEY_WLAN (238) released
event5 KEYBOARD_KEY +7.001s KEY_BRIGHTNESSUP (225) pressed
event5 KEYBOARD_KEY +7.001s KEY_BRIGHTNESSUP (225) released
event5 KEYBOARD_KEY +7.568s KEY_BRIGHTNESSDOWN (224) pressed
event5 KEYBOARD_KEY +7.568s KEY_BRIGHTNESSDOWN (224) released
event5 KEYBOARD_KEY +12.350s KEY_SWITCHVIDEOMODE (227) pressed
event5 KEYBOARD_KEY +12.350s KEY_SWITCHVIDEOMODE (227) released
event5 KEYBOARD_KEY +13.726s KEY_SWITCHVIDEOMODE (227) pressed
event5 KEYBOARD_KEY +13.726s KEY_SWITCHVIDEOMODE (227) released
event5 KEYBOARD_KEY +19.846s KEY_SLEEP (142) pressed
event5 KEYBOARD_KEY +19.846s KEY_SLEEP (142) released
-event3 KEYBOARD_KEY +50.998s KEY_LEFTCTRL (29) pressed
event3 KEYBOARD_KEY +51.140s KEY_LEFTCTRL (29) released
-event5 KEYBOARD_KEY +96.713s KEY_UNKNOWN (240) pressed
event5 KEYBOARD_KEY +96.716s KEY_UNKNOWN (240) released
-event1 KEYBOARD_KEY +96.740s KEY_WAKEUP (143) pressed
event1 KEYBOARD_KEY +96.740s KEY_WAKEUP (143) released
-event2 KEYBOARD_KEY +96.743s KEY_WAKEUP (143) pressed
event2 KEYBOARD_KEY +96.743s KEY_WAKEUP (143) released
-event5 KEYBOARD_KEY +111.647s KEY_BATTERY (236) pressed
event5 KEYBOARD_KEY +111.647s KEY_BATTERY (236) released
event5 KEYBOARD_KEY +113.308s KEY_BATTERY (236) pressed
event5 KEYBOARD_KEY +113.308s KEY_BATTERY (236) released
event5 KEYBOARD_KEY +119.950s KEY_COFFEE (152) pressed
event5 KEYBOARD_KEY +119.950s KEY_COFFEE (152) released
event5 KEYBOARD_KEY +121.349s KEY_COFFEE (152) pressed
event5 KEYBOARD_KEY +121.349s KEY_COFFEE (152) released
event5 KEYBOARD_KEY +124.933s KEY_MUTE (113) pressed
event5 KEYBOARD_KEY +124.933s KEY_MUTE (113) released
event5 KEYBOARD_KEY +125.420s KEY_MUTE (113) pressed
event5 KEYBOARD_KEY +125.420s KEY_MUTE (113) released
-event0 SWITCH_TOGGLE +133.939s switch lid state 1
-event5 KEYBOARD_KEY +136.839s KEY_UNKNOWN (240) pressed
event5 KEYBOARD_KEY +136.850s KEY_UNKNOWN (240) released
-event0 SWITCH_TOGGLE +136.873s switch lid state 0
-event1 KEYBOARD_KEY +136.873s KEY_WAKEUP (143) pressed
event1 KEYBOARD_KEY +136.873s KEY_WAKEUP (143) released
-event2 KEYBOARD_KEY +136.874s KEY_WAKEUP (143) pressed
event2 KEYBOARD_KEY +136.874s KEY_WAKEUP (143) released
On Sat, May 23, 2026 at 4:15 AM Nick <nick@kousu.ca> wrote:
>
>
>
> On May 22, 2026 2:52:10 p.m. UTC, "Rafael J. Wysocki" <rafael@kernel.org> wrote:
> >From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> >Prior to commit 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake()
> >for buttons"), ACPI button wakeup GPEs having handler methods remained
> >enabled after acpi_wakeup_gpe_init(), but currently they are not enabled
> >because acpi_setup_gpe_for_wake() disables them.
> >
> >That causes function keys to stop working on some systems [1] and there
> >may be other related issues elsewhere.
> >
> >To address that, make the ACPI button driver enable wakeup GPEs for ACPI
> >buttons so long as they have handler methods. While this does not
> >restore the old behavior exactly (the ACPI button driver needs to be
> >bound to the button devices for the GPEs to be enabled), it should be
> >sufficient to restore the missing functionality.
> >
> >For this purpose, introduce acpi_enable_gpe_cond() that enables
> >a GPE if its dispatch type matches the supplied one and modify
> >acpi_button_probe() to use that function for enabling the GPEs in
> >question.
> >
> >Fixes: 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons")
> >Reported-by: Nick <nick@kousu.ca>
> >Closes: https://lore.kernel.org/linux-acpi/E2OXET.4X5GTP37VTNC3@kousu.ca/ [1]
> >Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >Cc: 7.0+ <stable@vger.kernel.org> # 7.0+
> >---
> >
> >v1 -> v2:
> > * Change the acpi_enable_gpe_cond() third parameter to a dispatch type (or
> > "any type" value) and modify checks in it accordingly to address a
> > problem pointed out by sashiko.dev
> > * Adjust comments in acpi_enable_gpe_cond() and acpi_enable_gpe()
> > * Update the changelog
> >
> >@Nick, It would be good to test this version of the patch on your system
> >because it is a bit different from the previous one (which was not entirely
> >correct). I'm not expecting it to behave differently, but additional
> >testing would be welcome.
> >
>
>
> I tested this on top of 45255ea1ca096. The keys are still working as expected! I compared it against 6.19.14 too and all the keys seem to behave as before.
Thanks for the confirmation!
I'll add a Tested-by tag for you to the patch when applying it unless
you don't want me to do that.
> I noticed one difference, but it might not be directly related: KEY_SLEEP takes significantly longer
> to trigger suspend on 7.1-rc4 than on 6.19.14. On the older version it suspends in about a second;
> on 7.1-rc4 it takes about a minute before it fully suspends. The lid switch on the other hand suspends
> in about a second, and so does the suspend button in my DE, on both versions.
This is unlikely to be related to the issue addressed by the $subject patch.
> I guess they're doing different kinds of suspend. That's probably related to the other ACPI changes
> that landed in 7.0.
One thing to take into consideration here is that the kernel doesn't
trigger suspend by itself. The
key press event first goes to user space which then decides what to do
with it and may (or may
not) trigger a system suspend in response. It may be doing different
things for KEY_SLEEP and
the lid switch.
© 2016 - 2026 Red Hat, Inc.