Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing
@ 2026-09-26 20:26 David Heidelberg via B4 Relay
  2026-09-26 20:37 ` sashiko-bot
  2026-09-28  4:38 ` Dmitry Torokhov
  0 siblings, 2 replies; 4+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-09-26 20:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Andi Shyti, Rob Herring, Marco Mattiolo
  Cc: linux-input, linux-kernel, phone-devel, stable, David Heidelberg

From: David Heidelberg <david@ixit.cz>

System suspend powers the controller off and resume powers it back on,
but the resume path enables the interrupt before s6sy761_power_on()
checks the boot. The firmware raises its boot-complete event on the
interrupt line, the threaded handler consumes it, s6sy761_power_on()
then reads an empty event and resume fails with -ENODEV, skipping the
touch function setup:

s6sy761 2-0048: PM: dpm_run_callback(): s6sy761_resume [s6sy761] returns -19

Power the chip on first and only then unmask the interrupt. Once resume
completes the boot handshake the chip comes back with sensing off, as
at probe where input_open() turns it on, so the touchscreen stays dead
after resume. Send SENSE_ON again when the input device is open.

Tested on a Pixel 3 XL over several s2idle cycles: resume succeeds and
the touch function and sense status match the pre-suspend state.

Assisted-by: LLM
Cc: stable@vger.kernel.org
Fixes: 0145a7141e59 ("Input: add support for the Samsung S6SY761 touchscreen")
Signed-off-by: David Heidelberg <david@ixit.cz>
---
Changes in v2:
- Explicit return err in _resume. (Dmitry)
- Do not enable interrupt when power on fails. (Dmitry)
- Link to v1: https://patch.msgid.link/20260923-s6sy761-suspend-v1-1-6fff96e71cb0@ixit.cz
---
 drivers/input/touchscreen/s6sy761.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
index 0f24a9b730635..899c179fb2d31 100644
--- a/drivers/input/touchscreen/s6sy761.c
+++ b/drivers/input/touchscreen/s6sy761.c
@@ -495,20 +495,32 @@ static int s6sy761_suspend(struct device *dev)
 	s6sy761_power_off(sdata);
 
 	return 0;
 }
 
 static int s6sy761_resume(struct device *dev)
 {
 	struct s6sy761_data *sdata = dev_get_drvdata(dev);
+	int err;
+
+	err = s6sy761_power_on(sdata);
+	if (err)
+		return err;
 
 	enable_irq(sdata->client->irq);
 
-	return s6sy761_power_on(sdata);
+	guard(mutex)(&sdata->input->mutex);
+
+	if (!input_device_enabled(sdata->input))
+		return 0;
+
+	err = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON);
+
+	return err;
 }
 
 static const struct dev_pm_ops s6sy761_pm_ops = {
 	SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume)
 	RUNTIME_PM_OPS(s6sy761_runtime_suspend, s6sy761_runtime_resume, NULL)
 };
 
 #ifdef CONFIG_OF

---
base-commit: 7079a12d7506b07fb53b54a664bfad5fa9b16d70
change-id: 20260923-s6sy761-suspend-24674b0857ba

Best regards,
--  
David Heidelberg <david@ixit.cz>



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

* Re: [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing
  2026-09-26 20:26 [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing David Heidelberg via B4 Relay
@ 2026-09-26 20:37 ` sashiko-bot
  2026-09-30  5:14   ` Dmitry Torokhov
  2026-09-28  4:38 ` Dmitry Torokhov
  1 sibling, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-09-26 20:37 UTC (permalink / raw)
  To: David Heidelberg; +Cc: dmitry.torokhov, linux-input

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] input: permanent IRQ disable on s6sy761_power_on() failure
--

commit e5e3e44a0960351c54b4dc02894567b7b504952c
Author: David Heidelberg <david@ixit.cz>

Input: s6sy761 - fix resume ordering and restore sensing

This commit alters the resume ordering to power on the controller before
unmasking the interrupt, addressing an issue where the boot-complete
event was consumed prematurely. It also ensures SENSE_ON is re-sent upon
resume if the input device is already open.

> diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
> index 0f24a9b730635..899c179fb2d31 100644
> --- a/drivers/input/touchscreen/s6sy761.c
> +++ b/drivers/input/touchscreen/s6sy761.c
> @@ -500,10 +500,22 @@ static int s6sy761_suspend(struct device *dev)
>  static int s6sy761_resume(struct device *dev)
>  {
>  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
> +	int err;
> +
> +	err = s6sy761_power_on(sdata);
> +	if (err)
> +		return err;

[Severity: Medium]
Will this early return permanently disable the interrupt if power on fails?

If s6sy761_power_on() fails (for example, due to a transient I2C error
during resume), this early return skips enable_irq(). However, the PM core
will still clear the suspended state despite the error.

On the next system suspend cycle, s6sy761_suspend() will run again and call
disable_irq(), which unconditionally increments the IRQ disable depth to 2.
A subsequent successful resume would then call enable_irq() only once,
reducing the depth back to 1, which leaves the IRQ permanently disabled.

Should the error path balance the IRQ state to avoid losing touchscreen
functionality after a transient failure?

>  
>  	enable_irq(sdata->client->irq);
>  

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260926-s6sy761-suspend-v2-1-8f00a96ee6e8@ixit.cz?part=1

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

* Re: [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing
  2026-09-26 20:26 [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing David Heidelberg via B4 Relay
  2026-09-26 20:37 ` sashiko-bot
@ 2026-09-28  4:38 ` Dmitry Torokhov
  1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2026-09-28  4:38 UTC (permalink / raw)
  To: david
  Cc: Andi Shyti, Rob Herring, Marco Mattiolo, linux-input,
	linux-kernel, phone-devel, stable

On Sat, Sep 26, 2026 at 10:26:47PM +0200, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> System suspend powers the controller off and resume powers it back on,
> but the resume path enables the interrupt before s6sy761_power_on()
> checks the boot. The firmware raises its boot-complete event on the
> interrupt line, the threaded handler consumes it, s6sy761_power_on()
> then reads an empty event and resume fails with -ENODEV, skipping the
> touch function setup:
> 
> s6sy761 2-0048: PM: dpm_run_callback(): s6sy761_resume [s6sy761] returns -19
> 
> Power the chip on first and only then unmask the interrupt. Once resume
> completes the boot handshake the chip comes back with sensing off, as
> at probe where input_open() turns it on, so the touchscreen stays dead
> after resume. Send SENSE_ON again when the input device is open.
> 
> Tested on a Pixel 3 XL over several s2idle cycles: resume succeeds and
> the touch function and sense status match the pre-suspend state.
> 
> Assisted-by: LLM
> Cc: stable@vger.kernel.org
> Fixes: 0145a7141e59 ("Input: add support for the Samsung S6SY761 touchscreen")
> Signed-off-by: David Heidelberg <david@ixit.cz>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing
  2026-09-26 20:37 ` sashiko-bot
@ 2026-09-30  5:14   ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2026-09-30  5:14 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: David Heidelberg, linux-input

On Sat, Sep 26, 2026 at 08:37:44PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] input: permanent IRQ disable on s6sy761_power_on() failure
> --
> 
> commit e5e3e44a0960351c54b4dc02894567b7b504952c
> Author: David Heidelberg <david@ixit.cz>
> 
> Input: s6sy761 - fix resume ordering and restore sensing
> 
> This commit alters the resume ordering to power on the controller before
> unmasking the interrupt, addressing an issue where the boot-complete
> event was consumed prematurely. It also ensures SENSE_ON is re-sent upon
> resume if the input device is already open.
> 
> > diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
> > index 0f24a9b730635..899c179fb2d31 100644
> > --- a/drivers/input/touchscreen/s6sy761.c
> > +++ b/drivers/input/touchscreen/s6sy761.c
> > @@ -500,10 +500,22 @@ static int s6sy761_suspend(struct device *dev)
> >  static int s6sy761_resume(struct device *dev)
> >  {
> >  	struct s6sy761_data *sdata = dev_get_drvdata(dev);
> > +	int err;
> > +
> > +	err = s6sy761_power_on(sdata);
> > +	if (err)
> > +		return err;
> 
> [Severity: Medium]
> Will this early return permanently disable the interrupt if power on fails?
> 
> If s6sy761_power_on() fails (for example, due to a transient I2C error
> during resume), this early return skips enable_irq(). However, the PM core
> will still clear the suspended state despite the error.

It looks like the PM core never implemented properly trackign device
state and not calling suspend on devices that has not resumed. That
means that we need to do it ourselves. We definitely do not want to keep
interrupts enabled if powering up the device failed.

I'll send out a patch fixing this.

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2026-09-30  5:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-26 20:26 [PATCH v2] Input: s6sy761 - fix resume ordering and restore sensing David Heidelberg via B4 Relay
2026-09-26 20:37 ` sashiko-bot
2026-09-30  5:14   ` Dmitry Torokhov
2026-09-28  4:38 ` Dmitry Torokhov

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