[PATCH] Input: synaptics: retry query upon error

From: Takashi Iwai
Date: Tue Jan 18 2022 - 11:28:55 EST


Some recent laptops such as Lenovo ThinkPad T14 AMD Gen 1 show the
errors at querying synaptics attributes. This results in the driver
falling back to the legacy mode without multi-finger support. It
happens only intermittently at some boots, and it seems that the same
query command seems working fine after retrying.

This patch implements a retry of synaptics_query_hardware() call after
some delay when it fails as a workaround.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1194086
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---

It's rather an RFC, as I'm not sure whether it's the best way to fix
the problem. At least, the retry of query seems working reliably, as
well as re-binding via sysfs. And, I have no idea in which condition
this happens; it might be a flaky BIOS issue, of course :)

Above all, the device should have been connected via SMBUS. But the
binding with SMBUS fails, so some other pieces are missing. Maybe the
support with psmouse is suboptimal in anyway, but it's currently the
only way to make it working.

Any suggestions are appreciated.


thanks,

Takashi


drivers/input/mouse/synaptics.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ffad142801b3..0f23fba4c36e 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -416,7 +416,7 @@ static int synaptics_resolution(struct psmouse *psmouse,
return 0;
}

-static int synaptics_query_hardware(struct psmouse *psmouse,
+static int __synaptics_query_hardware(struct psmouse *psmouse,
struct synaptics_device_info *info)
{
int error;
@@ -450,6 +450,21 @@ static int synaptics_query_hardware(struct psmouse *psmouse,
return 0;
}

+static int synaptics_query_hardware(struct psmouse *psmouse,
+ struct synaptics_device_info *info)
+{
+ int err;
+
+ err = __synaptics_query_hardware(psmouse, info);
+ if (err) {
+ psmouse_info(psmouse, "Query error (%d), retrying...\n", err);
+ msleep(100);
+ err = __synaptics_query_hardware(psmouse, info);
+ }
+
+ return err;
+}
+
#endif /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */

#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
--
2.31.1