* [PATCH] Input: stmfts - restore touch after system resume with the device open
@ 2026-11-23 16:13 David Heidelberg via B4 Relay
2026-11-23 18:17 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: David Heidelberg via B4 Relay @ 2026-11-23 16:13 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Coquelin, Alexandre Torgue, Andi Shyti,
Javier Martinez Canillas, Rob Herring
Cc: linux-input, linux-stm32, linux-arm-kernel, phone-devel,
David Heidelberg
From: David Heidelberg <david@ixit.cz>
stmfts_resume() only calls stmfts_power_on(), which re-initialises the
controller and deliberately leaves it in SLEEP_IN, assuming nobody uses
the touchscreen yet. That assumption does not hold for a system resume:
userspace keeps the evdev node open, runtime PM still considers the
device active and stmfts_input_open() never runs again, so the
controller stays asleep with scanning off. On FTS5 the controller
interrupt enable command is part of the runtime resume sequence, so the
result is a completely dead touchscreen until the input device is
reopened.
Factor the scan enable part of stmfts_input_open() into
stmfts_start_scan() and, when the input device is open, replay the
runtime resume sequence and re-enable scanning from stmfts_resume().
Fixes: 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")
Signed-off-by: David Heidelberg <david@ixit.cz>
---
drivers/input/touchscreen/stmfts.c | 53 +++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
index 36beea6e6eb28..2054c2254947b 100644
--- a/drivers/input/touchscreen/stmfts.c
+++ b/drivers/input/touchscreen/stmfts.c
@@ -563,30 +563,23 @@ static int stmfts5_set_scan(struct stmfts_data *sdata, bool enable)
err = i2c_master_send(sdata->client, scan_mode_cmd,
sizeof(scan_mode_cmd));
if (err != sizeof(scan_mode_cmd))
return err < 0 ? err : -EIO;
return 0;
}
-static int stmfts_input_open(struct input_dev *dev)
+static int stmfts_start_scan(struct stmfts_data *sdata)
{
- struct stmfts_data *sdata = input_get_drvdata(dev);
int err;
- err = pm_runtime_resume_and_get(&sdata->client->dev);
- if (err)
- return err;
-
err = sdata->ops->set_scan(sdata, true);
- if (err) {
- pm_runtime_put_sync(&sdata->client->dev);
+ if (err)
return err;
- }
scoped_guard(mutex, &sdata->mutex) {
sdata->running = true;
if (sdata->hover_enabled && sdata->ops->set_hover) {
err = sdata->ops->set_hover(sdata, true);
if (err)
dev_warn(&sdata->client->dev,
@@ -601,16 +594,32 @@ static int stmfts_input_open(struct input_dev *dev)
/* I can still use only the touch screen */
dev_warn(&sdata->client->dev,
"failed to enable touchkey\n");
}
return 0;
}
+static int stmfts_input_open(struct input_dev *dev)
+{
+ struct stmfts_data *sdata = input_get_drvdata(dev);
+ int err;
+
+ err = pm_runtime_resume_and_get(&sdata->client->dev);
+ if (err)
+ return err;
+
+ err = stmfts_start_scan(sdata);
+ if (err)
+ pm_runtime_put_sync(&sdata->client->dev);
+
+ return err;
+}
+
static void stmfts_input_close(struct input_dev *dev)
{
struct stmfts_data *sdata = input_get_drvdata(dev);
int err;
err = sdata->ops->set_scan(sdata, false);
if (err)
dev_warn(&sdata->client->dev,
@@ -1163,18 +1172,42 @@ static int stmfts_suspend(struct device *dev)
stmfts_power_off(sdata);
return 0;
}
static int stmfts_resume(struct device *dev)
{
struct stmfts_data *sdata = dev_get_drvdata(dev);
+ int err;
+
+ err = stmfts_power_on(sdata);
+ if (err)
+ return err;
+
+ /*
+ * stmfts_power_on() leaves the controller in sleep mode. If the
+ * input device is open, runtime PM still considers the device
+ * active and will not wake it up again, so redo the runtime
+ * resume sequence and re-enable scanning here.
+ */
+ guard(mutex)(&sdata->input->mutex);
+
+ if (!input_device_enabled(sdata->input))
+ return 0;
+
+ err = stmfts_runtime_resume(dev);
+ if (err)
+ return err;
- return stmfts_power_on(sdata);
+ err = stmfts_start_scan(sdata);
+ if (err)
+ return err;
+
+ return 0;
}
static const struct dev_pm_ops stmfts_pm_ops = {
SYSTEM_SLEEP_PM_OPS(stmfts_suspend, stmfts_resume)
RUNTIME_PM_OPS(stmfts_runtime_suspend, stmfts_runtime_resume, NULL)
};
static const struct stmfts_chip_ops stmfts4_ops = {
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20261123-stmfts-suspend-7878d8ee5c74
Best regards,
--
David Heidelberg <david@ixit.cz>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: stmfts - restore touch after system resume with the device open
2026-11-23 16:13 [PATCH] Input: stmfts - restore touch after system resume with the device open David Heidelberg via B4 Relay
@ 2026-11-23 18:17 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-23 18:17 UTC (permalink / raw)
To: david
Cc: Maxime Coquelin, Alexandre Torgue, Andi Shyti,
Javier Martinez Canillas, Rob Herring, linux-input, linux-stm32,
linux-arm-kernel, phone-devel
On Mon, Nov 23, 2026 at 05:13:41PM +0100, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@ixit.cz>
>
> stmfts_resume() only calls stmfts_power_on(), which re-initialises the
> controller and deliberately leaves it in SLEEP_IN, assuming nobody uses
> the touchscreen yet. That assumption does not hold for a system resume:
> userspace keeps the evdev node open, runtime PM still considers the
> device active and stmfts_input_open() never runs again, so the
> controller stays asleep with scanning off. On FTS5 the controller
> interrupt enable command is part of the runtime resume sequence, so the
> result is a completely dead touchscreen until the input device is
> reopened.
>
> Factor the scan enable part of stmfts_input_open() into
> stmfts_start_scan() and, when the input device is open, replay the
> runtime resume sequence and re-enable scanning from stmfts_resume().
>
> Fixes: 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")
> Signed-off-by: David Heidelberg <david@ixit.cz>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 18:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 16:13 [PATCH] Input: stmfts - restore touch after system resume with the device open David Heidelberg via B4 Relay
2026-11-23 18:17 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox