Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: synaptics - retry SMBus intertouch setup when companion is not ready
@ 2026-06-03  0:20 Raphaël Larocque
  2026-06-03  1:00 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Raphaël Larocque @ 2026-06-03  0:20 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, kees, linux-kernel, Raphaël Larocque

On some machines (here: Lenovo ThinkPad T440p 20AWS0H800),
the SMBus companion device is not ready
by the time psmouse probes the Synaptics touchpad
during early boot.  synaptics_setup_intertouch() returns -EAGAIN in
this situation, but synaptics_init() previously treated this the same
as any other error and fell through immediately to PS/2 mode.  As a
result, the touchpad and TrackPoint were unresponsive for several
minutes after a cold boot, until an internal reconnect cycle (which
already carries retry logic in synaptics_reconnect()) eventually
succeeded.

Fix this by adding an exponential back-off retry loop in synaptics_init()
when synaptics_setup_intertouch() returns -EAGAIN: clean up the failed
state, sleep for 500 ms on the first attempt doubling each time up to
4000 ms, then retry.  The worst-case added latency at boot is ~7.5 s
(500 + 1000 + 2000 + 4000 ms), and only for hardware that actually
reports SYN_CAP_INTERTOUCH.  The pattern mirrors what
synaptics_reconnect() already does after resume.

Tested-by: Raphaël Larocque <rlarocque@disroot.org>
Signed-off-by: Raphaël Larocque <rlarocque@disroot.org>
---
 drivers/input/mouse/synaptics.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index c70502e24031..5c1bfff2b16c 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -1918,6 +1918,23 @@ int synaptics_init(struct psmouse *psmouse)
 		}
 
 		error = synaptics_setup_intertouch(psmouse, &info, true);
+		if (error == -EAGAIN) {
+			/*
+			 * On some systems (e.g. ThinkPad T440p) the SMBus
+			 * companion device is not yet ready at boot time.
+			 * Clean up and retry with exponential back-off,
+			 * mirroring synaptics_reconnect().
+			 */
+			unsigned int delay = 500;
+
+			do {
+				psmouse_smbus_cleanup(psmouse);
+				msleep(delay);
+				error = synaptics_setup_intertouch(psmouse, &info, true);
+				delay *= 2;
+			} while (error == -EAGAIN && delay <= 4000);
+		}
+
 		if (!error)
 			return PSMOUSE_SYNAPTICS_SMBUS;
 	}
-- 
2.53.0


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

* Re: [PATCH] Input: synaptics - retry SMBus intertouch setup when companion is not ready
  2026-06-03  0:20 [PATCH] Input: synaptics - retry SMBus intertouch setup when companion is not ready Raphaël Larocque
@ 2026-06-03  1:00 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-06-03  1:00 UTC (permalink / raw)
  To: Raphaël Larocque; +Cc: linux-input, kees, linux-kernel

Hi Raphaël,

On Tue, Jun 02, 2026 at 08:20:46PM -0400, Raphaël Larocque wrote:
> On some machines (here: Lenovo ThinkPad T440p 20AWS0H800),
> the SMBus companion device is not ready
> by the time psmouse probes the Synaptics touchpad
> during early boot.  synaptics_setup_intertouch() returns -EAGAIN in
> this situation, but synaptics_init() previously treated this the same
> as any other error and fell through immediately to PS/2 mode.  As a
> result, the touchpad and TrackPoint were unresponsive for several
> minutes after a cold boot, until an internal reconnect cycle (which
> already carries retry logic in synaptics_reconnect()) eventually
> succeeded.
> 
> Fix this by adding an exponential back-off retry loop in synaptics_init()
> when synaptics_setup_intertouch() returns -EAGAIN: clean up the failed
> state, sleep for 500 ms on the first attempt doubling each time up to
> 4000 ms, then retry.  The worst-case added latency at boot is ~7.5 s
> (500 + 1000 + 2000 + 4000 ms), and only for hardware that actually
> reports SYN_CAP_INTERTOUCH.  The pattern mirrors what
> synaptics_reconnect() already does after resume.
> 
> Tested-by: Raphaël Larocque <rlarocque@disroot.org>
> Signed-off-by: Raphaël Larocque <rlarocque@disroot.org>
> ---
>  drivers/input/mouse/synaptics.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> index c70502e24031..5c1bfff2b16c 100644
> --- a/drivers/input/mouse/synaptics.c
> +++ b/drivers/input/mouse/synaptics.c
> @@ -1918,6 +1918,23 @@ int synaptics_init(struct psmouse *psmouse)
>  		}
>  
>  		error = synaptics_setup_intertouch(psmouse, &info, true);
> +		if (error == -EAGAIN) {
> +			/*
> +			 * On some systems (e.g. ThinkPad T440p) the SMBus
> +			 * companion device is not yet ready at boot time.
> +			 * Clean up and retry with exponential back-off,
> +			 * mirroring synaptics_reconnect().
> +			 */
> +			unsigned int delay = 500;
> +
> +			do {
> +				psmouse_smbus_cleanup(psmouse);
> +				msleep(delay);
> +				error = synaptics_setup_intertouch(psmouse, &info, true);
> +				delay *= 2;
> +			} while (error == -EAGAIN && delay <= 4000);
> +		}
> +

The idea here is that if adapter/device is not ready we leave enuough
"breadcumbs" for it to recognize when SMBus companion appears and
complete the initialization without repeatedly cleaning up and retrying
initialization anew.

Could you enable logging and see where the logic fails for you? I am not
too keen on simply adding up to 8 seconds delay to the boot time.

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2026-06-03  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03  0:20 [PATCH] Input: synaptics - retry SMBus intertouch setup when companion is not ready Raphaël Larocque
2026-06-03  1:00 ` Dmitry Torokhov

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