summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffery Miller <jefferymiller@google.com>2023-07-26 02:52:48 +0000
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2023-07-25 22:07:42 -0700
commit92e24e0e57f72e06c2df87116557331fd2d4dda2 (patch)
tree0d1b38b73e1a3a654e3a3d4434ab30259c52a99a
parent8362bf82fb5441613aac7c6c9dbb6b83def6ad3b (diff)
Input: psmouse - add delay when deactivating for SMBus mode
There is a period of time between the psmouse deactivate and the ability to communicate with the SMBus companion. Insert a sleep after the deactivate to account for the delay and ensure the SMBus companion is responsive. Attempting to read from the SMBus companion too quickly was causing the touchpad on machines with an i801_smbus companion to stop working after a sleep/resume cycle. On resume the rmi4_smbus would fail with errors reading the SMBus version number: ``` [5454] i2c_i801:i801_check_post:414: i801_smbus 0000:00:1f.3: No response smbus_result: i2c-0 a=02c f=0000 c=fd BYTE_DATA rd res=-6 rmi4_smbus 0-002c: failed to get SMBus version number! ... rmi4_f01 rmi4-00.fn01: Failed to restore normal operation: -6. rmi4_f01 rmi4-00.fn01: Resume failed with code -6. rmi4_physical rmi4-00: Failed to suspend functions: -6 rmi4_smbus 0-002c: Failed to resume device: -6 ``` In this case the rmi_smb_get_version fails with -ENXIO if it happens too soon after the preceding serio_resume -> psmouse_deactivate call. On boot this issue could cause the touchpad to stay in the limited PS/2 mode. This only reproduced in 1 in 10 boots on the Lenovo T440p. Failures in the log on boot would show up as: ``` psmouse serio1: synaptics: Trying to set up SMBus access [122] i2c_i801:i801_check_post:437: i801_smbus 0000:00:1f.3: No response psmouse serio1: synaptics: SMbus companion is not ready yet ``` Experimentation on the Lenovo T440p showed that a delay of 7-12ms on resume allowed the companion to respond. The 30ms delay in this patch was chosen based on the linux-input message: Link: https://lore.kernel.org/all/BYAPR03MB47572F2C65E52ED673238D41B2439@BYAPR03MB4757.namprd03.prod.outlook.com/ Signed-off-by: Jeffery Miller <jefferymiller@google.com> Link: https://lore.kernel.org/r/20230726025256.81174-1-jefferymiller@google.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/mouse/psmouse-smbus.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/input/mouse/psmouse-smbus.c b/drivers/input/mouse/psmouse-smbus.c
index 2a2459b1b4f2..7b13de979908 100644
--- a/drivers/input/mouse/psmouse-smbus.c
+++ b/drivers/input/mouse/psmouse-smbus.c
@@ -5,6 +5,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/libps2.h>
@@ -118,13 +119,18 @@ static psmouse_ret_t psmouse_smbus_process_byte(struct psmouse *psmouse)
return PSMOUSE_FULL_PACKET;
}
-static int psmouse_smbus_reconnect(struct psmouse *psmouse)
+static void psmouse_activate_smbus_mode(struct psmouse_smbus_dev *smbdev)
{
- struct psmouse_smbus_dev *smbdev = psmouse->private;
-
- if (smbdev->need_deactivate)
- psmouse_deactivate(psmouse);
+ if (smbdev->need_deactivate) {
+ psmouse_deactivate(smbdev->psmouse);
+ /* Give the device time to switch into SMBus mode */
+ msleep(30);
+ }
+}
+static int psmouse_smbus_reconnect(struct psmouse *psmouse)
+{
+ psmouse_activate_smbus_mode(psmouse->private);
return 0;
}
@@ -257,8 +263,7 @@ int psmouse_smbus_init(struct psmouse *psmouse,
}
}
- if (need_deactivate)
- psmouse_deactivate(psmouse);
+ psmouse_activate_smbus_mode(smbdev);
psmouse->private = smbdev;
psmouse->protocol_handler = psmouse_smbus_process_byte;