Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH v2] Input: pm8941-pwrkey - report wakeup events
@ 2026-11-23 13:03 Michael Auer
  2026-11-23 15:19 ` Konrad Dybcio
  2026-11-23 18:12 ` Dmitry Torokhov
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Auer @ 2026-11-23 13:03 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-arm-msm, linux-kernel, Michael Auer

The power key (and resin, with "wakeup-source") is a wakeup source, but
the driver never reports a wakeup event. Its wakeup_count in
/sys/class/wakeup stays 0 even after it woke the system, so user space
cannot tell a key press from other wakeups. PowerDevil, for example,
uses the wakeup counts to decide whether to turn the display on after
resume.

Report a wakeup event from the interrupt handler, as other power key
drivers do.

Signed-off-by: Michael Auer <mick@yoxcu.de>
---
Changes in v2:
- Report the wakeup event only after the status register was read
  successfully (Dmitry)
- v1: https://lore.kernel.org/linux-input/20261121204112.847960-1-mick@yoxcu.de/

Tested (v1 and v2) on a OnePlus 6 (sdm845, PM8998) with an
sdm845-mainline 7.1-rc1 based kernel: after a power key wakeup from
suspend the key's wakeup_count is no longer 0, and PowerDevil reports
the wakeup as coming from the power key. On input/next it was only
build tested (W=1, arm64 and x86_64 allmodconfig).

The event is reported for every interrupt, press and release. After
resume the press can be read as a release (the handler then simulates
the press), so reporting only presses could miss the wakeup.

Tool use: the analysis, the code and the commit messages were
written with an LLM coding assistant (Claude Code). I reviewed all
of it and tested it on my phone as described above.

 drivers/input/misc/pm8941-pwrkey.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c
index 34b4afbb1984..034db0ccc9b3 100644
--- a/drivers/input/misc/pm8941-pwrkey.c
+++ b/drivers/input/misc/pm8941-pwrkey.c
@@ -165,6 +165,9 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data)
 	if (err)
 		return IRQ_HANDLED;
 
+	/* Let user space see that the key woke the system */
+	pm_wakeup_event(pwrkey->dev, 0);
+
 	sts &= pwrkey->data->status_bit;
 
 	if (pwrkey->sw_debounce_time_us && !sts)

base-commit: fed36ea16e3e9929a07c7dc285916216dffac7fa
-- 
2.43.0


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

* Re: [PATCH v2] Input: pm8941-pwrkey - report wakeup events
  2026-11-23 13:03 [PATCH v2] Input: pm8941-pwrkey - report wakeup events Michael Auer
@ 2026-11-23 15:19 ` Konrad Dybcio
  2026-11-23 18:12 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2026-11-23 15:19 UTC (permalink / raw)
  To: Michael Auer, Dmitry Torokhov; +Cc: linux-input, linux-arm-msm, linux-kernel

On 11/23/26 2:03 PM, Michael Auer wrote:
> The power key (and resin, with "wakeup-source") is a wakeup source, but
> the driver never reports a wakeup event. Its wakeup_count in
> /sys/class/wakeup stays 0 even after it woke the system, so user space
> cannot tell a key press from other wakeups. PowerDevil, for example,
> uses the wakeup counts to decide whether to turn the display on after
> resume.
> 
> Report a wakeup event from the interrupt handler, as other power key
> drivers do.
> 
> Signed-off-by: Michael Auer <mick@yoxcu.de>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

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

* Re: [PATCH v2] Input: pm8941-pwrkey - report wakeup events
  2026-11-23 13:03 [PATCH v2] Input: pm8941-pwrkey - report wakeup events Michael Auer
  2026-11-23 15:19 ` Konrad Dybcio
@ 2026-11-23 18:12 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2026-11-23 18:12 UTC (permalink / raw)
  To: Michael Auer; +Cc: linux-input, linux-arm-msm, linux-kernel

On Mon, Nov 23, 2026 at 02:03:36PM +0100, Michael Auer wrote:
> The power key (and resin, with "wakeup-source") is a wakeup source, but
> the driver never reports a wakeup event. Its wakeup_count in
> /sys/class/wakeup stays 0 even after it woke the system, so user space
> cannot tell a key press from other wakeups. PowerDevil, for example,
> uses the wakeup counts to decide whether to turn the display on after
> resume.
> 
> Report a wakeup event from the interrupt handler, as other power key
> drivers do.
> 
> Signed-off-by: Michael Auer <mick@yoxcu.de>

Applied, thank you.

-- 
Dmitry

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

end of thread, other threads:[~2026-11-23 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 13:03 [PATCH v2] Input: pm8941-pwrkey - report wakeup events Michael Auer
2026-11-23 15:19 ` Konrad Dybcio
2026-11-23 18:12 ` Dmitry Torokhov

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