ACPI: button: lid events lost since 6.18.57, please backport a004b8f0d3bc
Subsystems (4)
Hey there,
Claude did most of the work on this one, but it looks valid from the point of view of my (very little) kernel dev experience.
Please backport the following upstream commit to 6.18.y:
a004b8f0d3bc ("ACPI: button: Enable wakeup GPEs for ACPI buttons at probe time")
It fixes a regression that 6.18.y picked up in 6.18.57 and that is still present in 6.18.62.
Background: 6.18.57 received 52d864019636 ("ACPI: button: Convert the driver to a platform one") as a dependency of fe80251152fe ("ACPI:
button: Fix ACPI GPE handler leak during removal"), together with 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons"), which fixes the former. Since 57c31e6d620f, button wakeup GPEs that have handler methods are no longer enabled at runtime. Upstream fixed this in v7.1 with a004b8f0d3bc, but that commit is tagged "Cc: stable # 7.0+", so it was never picked up for 6.18.y, even though 6.18.y now carries the commit it fixes.
Symptoms on my laptop (FUJITSU LIFEBOOK U9311, BIOS 2.54) with the Void Linux kernel packages:
- 6.18.52: lid works, acpid receives "button/lid LID close/open".
- 6.18.62: the "Lid Switch" input device (PNP0C0D:00) emits no SW_LID events at all (evtest shows nothing), so closing the lid does not suspend the machine. /proc/acpi/button/lid/LID/state still toggles correctly, and closing the lid wakes the machine from a manually triggered suspend, which suggests the GPE is only armed for wakeup.
- On 6.18.62, GPE 0x24 shows "disabled" in /sys/firmware/acpi/interrupts/ while it is "enabled" on 6.18.52. Writing "enable" to it restores lid events.
Backport note: a004b8f0d3bc applies to 6.18.60 and 6.18.62 with offsets, but does not build as is, because struct acpi_button has no "dev" member in 6.18.y. Using &button->pdev->dev in the two dev_dbg() calls is sufficient. With that change, drivers/acpi/button.o and drivers/acpi/acpica/evxfgpe.o build cleanly with W=1 on 6.18.62. The adjusted patch is attached for reference.
I sadly haven't had the time to build a patched kernel to actually test this.
Thanks,
Florian Wagner
#regzbot introduced: v6.18.52..v6.18.60
Sasha Levin
maintainerQuoted 4 lines
Backport note:
a004b8f0d3bcapplies to 6.18.60 and 6.18.62 with offsets, but does not build as is, because structacpi_buttonhas no "dev" member in 6.18.y. Using&button->pdev->devin the twodev_dbg()calls is sufficient.
A backport that works would be much appreciated :)
Signature · 2 lines
Thanks, Sasha
Florian Wagner
Tested-by NickQuoted 6 lines · On Sun, 8 Nov 2026 19:34:30 -0500 Sasha Levin <[email protected]> wrote:
Quoted 4 lines
Backport note:
a004b8f0d3bcapplies to 6.18.60 and 6.18.62 with offsets, but does not build as is, because structacpi_buttonhas no "dev" member in 6.18.y. Using&button->pdev->devin the twodev_dbg()calls is sufficient.A backport that works would be much appreciated :)
Oh; shame on me. Here's the missing attachment. But then: I've since had the time to test it on a release 6.18.62 kernel and can confirm it fixed my issue (GPE24 enabled again; laptop suspends and wakes up from lid close/open).
Regards
Florian
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Rafael J. Wysocki" <[email protected]>
Date: Fri, 22 May 2026 16:52:10 +0200
Subject: [PATCH] ACPI: button: Enable wakeup GPEs for ACPI buttons at probe
time
[ Upstream commit a004b8f0d3bc5d82d3f2c91ff93f4b4b7ccb8f76 ]
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.
[ Adjusted for 6.18.y: struct acpi_button has no dev member in this
tree, so use &button->pdev->dev in the two dev_dbg() calls. ]
--- drivers/acpi/acpica/evxfgpe.c | 50 ++++++++++++++++++++++++++++------- drivers/acpi/button.c | 22 +++++++++++++++ include/acpi/acpixf.h | 5 ++++ 3 files changed, 68 insertions(+), 9 deletions(-)
drivers/acpi/acpica/evxfgpe.c +41 -9
@@ -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 gpe_device, u32 gpe_number) 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 gpe_device, u32 gpe_number)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)/*******************************************************************************
drivers/acpi/button.c +22 -0
@@ -190,6 +190,7 @@ struct acpi_button {ktime_t last_time;bool suspended;bool lid_state_initialized; +bool gpe_enabled; };static struct acpi_device *lid_device;
@@ -651,6 +652,21 @@ static int acpi_button_probe(struct platform_device *pdev) 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->pdev->dev,"Enabled ACPI GPE%02llx\n" , + device->wakeup.gpe_number); + }break ; }if (ACPI_FAILURE (status)) {
@@ -694,6 +710,12 @@ static void acpi_button_remove(struct platform_device *pdev) acpi_button_event);break ;default : +if (button->gpe_enabled) { +dev_dbg (&button->pdev->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 :
include/acpi/acpixf.h +5 -0
@@ -725,6 +725,11 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status*/ 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))
Signature · 1 line
2.43.0
Sasha Levin
maintainerQuoted 1 line
Oh; shame on me. Here's the missing attachment.
Thanks for testing. The patch came as a MIME attachment, which our tooling can't pick up, and it has no Signed-off-by from you. Could you resend it as a regular [PATCH 6.18.y] mail with the upstream commit tag, the adjustment note and your Signed-off-by?
Signature · 2 lines
Thanks, Sasha
PATCH 1/1 ACPI: button: Enable wakeup GPEs for ACPI buttons at probe time
From: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit a004b8f0d3bc5d82d3f2c91ff93f4b4b7ccb8f76 ]
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.
[ Adjusted for 6.18.y: struct acpi_button has no dev member in this
tree, so use &button->pdev->dev in the two dev_dbg() calls. ]
---
Notes:
Resent inline with my Signed-off-by, as requested. Applies to v6.18.60 through v6.18.63 (the touched files are unchanged in between).
drivers/acpi/acpica/evxfgpe.c | 50 ++++++++++++++++++++++++++++------- drivers/acpi/button.c | 22 +++++++++++++++ include/acpi/acpixf.h | 5 ++++ 3 files changed, 68 insertions(+), 9 deletions(-)
drivers/acpi/acpica/evxfgpe.c +41 -9
@@ -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 gpe_device, u32 gpe_number) 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 gpe_device, u32 gpe_number)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)/*******************************************************************************
drivers/acpi/button.c +22 -0
@@ -190,6 +190,7 @@ struct acpi_button {ktime_t last_time;bool suspended;bool lid_state_initialized; +bool gpe_enabled; };static struct acpi_device *lid_device;
@@ -651,6 +652,21 @@ static int acpi_button_probe(struct platform_device *pdev) 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->pdev->dev,"Enabled ACPI GPE%02llx\n" , + device->wakeup.gpe_number); + }break ; }if (ACPI_FAILURE (status)) {
@@ -694,6 +710,12 @@ static void acpi_button_remove(struct platform_device *pdev) acpi_button_event);break ;default : +if (button->gpe_enabled) { +dev_dbg (&button->pdev->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 :
include/acpi/acpixf.h +5 -0
@@ -725,6 +725,11 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status*/ 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))
Signature · 1 line
2.43.0
Re: [PATCH 6.18.y] ACPI: button: Enable wakeup GPEs for ACPI buttons at probe time
Quoted 2 lines
That causes function keys to stop working on some systems [1] and there may be other related issues elsewhere.
Queued for 6.18, thanks.
Signature · 2 lines
Thanks, Sasha