@@ -52338,3 +52338,55 @@ index 1cc063bf6c0b..a3479f12dfa3 100644
5233852338--
52339523392.51.2
5234052340
52341+
52342+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
52343+ From: Antheas Kapenekakis <
[email protected] >
52344+ Date: Sat, 8 Nov 2025 21:14:37 +0100
52345+ Subject: Input: gpio_keys - handle KEY_POWER gracefully during resume
52346+
52347+ Currently, during resume from suspend, if an ISR runs for a gpio-key
52348+ the ISR will rightfully emit a key press event so that userspace does
52349+ not miss the event (e.g., on an embedded device we might sleep until
52350+ a user presses a button; and when we wake up we need to be able to
52351+ identify the specific button).
52352+
52353+ This creates an issue when the gpio-key is KEY_POWER. For ISA/ACPI
52354+ power buttons, when the resume is caused by the power button, the power
52355+ button device increases its wake up count but it does not re-emit
52356+ KEY_POWER during resume. Therefore, both the kernel and userspace
52357+ act unexpectedly if the gpio-key driver emits KEY_POWER during resume,
52358+ by e.g., getting stuck in a suspend loop.
52359+
52360+ This is a problem in newer ASUS devices (ASUS Z13, Xbox Ally, Xbox Ally
52361+ X) as they wire the power button to a gpio pin. Therefore, specifically
52362+ for KEY_POWER gpio-keys, suppress the event during resume to mirror this
52363+ behavior. Do not do it for all keys, as certain embedded devices might
52364+ be relying on this behavior.
52365+
52366+ Signed-off-by: Antheas Kapenekakis <
[email protected] >
52367+ ---
52368+ drivers/input/keyboard/gpio_keys.c | 8 ++++++++
52369+ 1 file changed, 8 insertions(+)
52370+
52371+ diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
52372+ index f9db86da0818..48b927435170 100644
52373+ --- a/drivers/input/keyboard/gpio_keys.c
52374+ +++ b/drivers/input/keyboard/gpio_keys.c
52375+ @@ -420,6 +420,14 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
52376+ pm_stay_awake(bdata->input->dev.parent);
52377+ if (bdata->suspended &&
52378+ (button->type == 0 || button->type == EV_KEY)) {
52379+ + /*
52380+ + * We woke up due to KEY_POWER. If we reprocess the
52381+ + * event userspace/PM logic will get confused and
52382+ + * the device will sleep again. Do not handle
52383+ + * KEY_POWER during the resume phase.
52384+ + */
52385+ + if (button->code == KEY_POWER)
52386+ + return IRQ_HANDLED;
52387+ /*
52388+ * Simulate wakeup key press in case the key has
52389+ * already released by the time we got interrupt
52390+ --
52391+ 2.51.2
52392+
0 commit comments