* [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume
@ 2023-06-08 21:04 Jeffery Miller
2023-07-21 23:53 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Jeffery Miller @ 2023-06-08 21:04 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jonathan Denose, jdenose, Lyude Paul, benjamin.tissoires,
Andrew Duggan, loic.poulain, Andrew Duggan, Jeffery Miller,
Javier Martinez Canillas, Jeremy Kerr, Jonathan Cameron,
Uwe Kleine-König, linux-input, linux-kernel
On resume there can be a period of time after the
preceding serio_resume -> psmouse_deactivate call
where calls to rmi_smb_get_version fail with
-ENXIO.
The call path in rmi_smb_resume is rmi_smb_resume -> rmi_smb_reset ->
rmi_smb_enable_smbus_mode -> rmi_smb_get_version where
this failure would occur.
Add a 30ms delay and retry in the ENXIO case to ensure the following
rmi_driver_resume calls in rmi_smbus_resume can succeed.
This behavior was seen on a Lenovo T440p machine that required
a delay of approximately 7-12ms.
The 30ms delay was chosen based on the linux-input message:
Link: https://lore.kernel.org/all/BYAPR03MB47572F2C65E52ED673238D41B2439@BYAPR03MB4757.namprd03.prod.outlook.com/
With this patch the trimmed resume logs look similar to:
```
psmouse serio1: PM: calling serio_resume+0x0/0x8c @ 5399, parent: i8042
[5399] libps2:__ps2_command:316: psmouse serio1: f5 [] - 0/00000000 []
psmouse serio1: PM: serio_resume+0x0/0x8c returned 0 after 3259 usecs
...
rmi4_smbus 0-002c: PM: calling rmi_smb_resume ... @ 5454, parent: i2c-0
...
[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_smbus 0-002c: sleeping to retry getting the SMBus version number
...
rmi4_smbus 0-002c: PM: rmi_smb_resume ... returned 0 after 41351 usecs
```
Signed-off-by: Jeffery Miller <jefferymiller@google.com>
---
Early boot dmesg include:
```
rmi4_smbus 0-002c: registering SMbus-connected sensor
rmi4_f01 rmi4-00.fn01: found RMI device, manufacturer: Synaptics, product: TM2722-001, fw id: 0
```
The resume order looks correct. The `psmouse serio1` resume returns
before the rmi_smb_resume is called showing the patch from
https://lore.kernel.org/all/89456fcd-a113-4c82-4b10-a9bcaefac68f@google.com/
is applied and working for that ordering.
I attempted to try to rule out some interaction between the concurrent
input resume calls for other i8042 devices.
Adding a 7ms delay after psmouse_deactivate which is called in the
preceding psmouse serio1 serio_resume function also allows
this version call to succeed.
If the rmi_smb_probe device_disable_async_suspend patch is applied
it will also avoid this issue. However the time between
the psmouse_deactivate call for serio_resume and rmi_smb_resume
was over 60ms on my test machine. This would naturally be long
enough to avoid this particular delay.
Changes in v3:
- Tagged mail message Link to resolve checkpatch warning.
Changes in v2:
- Changed to a single retry of 30ms based on previous feedback.
drivers/input/rmi4/rmi_smbus.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
index 4bf0e1df6a4a..b6d90c92e8a2 100644
--- a/drivers/input/rmi4/rmi_smbus.c
+++ b/drivers/input/rmi4/rmi_smbus.c
@@ -45,13 +45,25 @@ static int rmi_smb_get_version(struct rmi_smb_xport *rmi_smb)
int retval;
/* Check if for SMBus new version device by reading version byte. */
- retval = i2c_smbus_read_byte_data(client, SMB_PROTOCOL_VERSION_ADDRESS);
- if (retval < 0) {
+ for (int i = 0; i < 2; i++) {
+ if (i > 0) {
+ dev_warn(&client->dev, "sleeping to retry getting the SMBus version number\n");
+ fsleep(30000);
+ }
+ retval = i2c_smbus_read_byte_data(client,
+ SMB_PROTOCOL_VERSION_ADDRESS);
+ if (retval >= 0)
+ return retval + 1;
+
dev_err(&client->dev, "failed to get SMBus version number!\n");
- return retval;
+ /* There can be a delay on resume where the read returns
+ * -ENXIO. Retry to allow additional time for the read
+ * to become responsive.
+ */
+ if (retval != -ENXIO)
+ break;
}
-
- return retval + 1;
+ return retval;
}
/* SMB block write - wrapper over ic2_smb_write_block */
--
2.41.0.162.gfafddb0af9-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume
@ 2023-06-09 19:47 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-06-09 19:47 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20230608210404.722123-1-jefferymiller@google.com>
References: <20230608210404.722123-1-jefferymiller@google.com>
TO: Jeffery Miller <jefferymiller@google.com>
TO: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: Jonathan Denose <jdenose@chromium.org>
CC: jdenose@google.com
CC: Lyude Paul <lyude@redhat.com>
CC: benjamin.tissoires@redhat.com
CC: Andrew Duggan <andrew@duggan.us>
CC: loic.poulain@linaro.org
CC: Jeffery Miller <jefferymiller@google.com>
CC: Javier Martinez Canillas <javierm@redhat.com>
CC: Jeremy Kerr <jk@codeconstruct.com.au>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
CC: linux-input@vger.kernel.org
CC: linux-kernel@vger.kernel.org
Hi Jeffery,
kernel test robot noticed the following build warnings:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on dtor-input/for-linus linus/master v6.4-rc5 next-20230609]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jeffery-Miller/Input-synaptics-rmi4-retry-reading-SMBus-version-on-resume/20230609-050652
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20230608210404.722123-1-jefferymiller%40google.com
patch subject: [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume
:::::: branch date: 23 hours ago
:::::: commit date: 23 hours ago
config: arm64-randconfig-m031-20230608 (https://download.01.org/0day-ci/archive/20230610/202306100350.ck6PwGko-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.3.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202306100350.ck6PwGko-lkp@intel.com/
smatch warnings:
drivers/input/rmi4/rmi_smbus.c:66 rmi_smb_get_version() error: uninitialized symbol 'retval'.
vim +/retval +66 drivers/input/rmi4/rmi_smbus.c
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 41
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 42 static int rmi_smb_get_version(struct rmi_smb_xport *rmi_smb)
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 43 {
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 44 struct i2c_client *client = rmi_smb->client;
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 45 int retval;
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 46
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 47 /* Check if for SMBus new version device by reading version byte. */
0fe13a588e68ca Jeffery Miller 2023-06-08 48 for (int i = 0; i < 2; i++) {
0fe13a588e68ca Jeffery Miller 2023-06-08 49 if (i > 0) {
0fe13a588e68ca Jeffery Miller 2023-06-08 50 dev_warn(&client->dev, "sleeping to retry getting the SMBus version number\n");
0fe13a588e68ca Jeffery Miller 2023-06-08 51 fsleep(30000);
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 52 }
0fe13a588e68ca Jeffery Miller 2023-06-08 53 retval = i2c_smbus_read_byte_data(client,
0fe13a588e68ca Jeffery Miller 2023-06-08 54 SMB_PROTOCOL_VERSION_ADDRESS);
0fe13a588e68ca Jeffery Miller 2023-06-08 55 if (retval >= 0)
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 56 return retval + 1;
0fe13a588e68ca Jeffery Miller 2023-06-08 57
0fe13a588e68ca Jeffery Miller 2023-06-08 58 dev_err(&client->dev, "failed to get SMBus version number!\n");
0fe13a588e68ca Jeffery Miller 2023-06-08 59 /* There can be a delay on resume where the read returns
0fe13a588e68ca Jeffery Miller 2023-06-08 60 * -ENXIO. Retry to allow additional time for the read
0fe13a588e68ca Jeffery Miller 2023-06-08 61 * to become responsive.
0fe13a588e68ca Jeffery Miller 2023-06-08 62 */
0fe13a588e68ca Jeffery Miller 2023-06-08 63 if (retval != -ENXIO)
0fe13a588e68ca Jeffery Miller 2023-06-08 64 break;
0fe13a588e68ca Jeffery Miller 2023-06-08 65 }
0fe13a588e68ca Jeffery Miller 2023-06-08 @66 return retval;
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 67 }
82264d0cf7aef2 Benjamin Tissoires 2016-11-08 68
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume
2023-06-08 21:04 [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume Jeffery Miller
@ 2023-07-21 23:53 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2023-07-21 23:53 UTC (permalink / raw)
To: Jeffery Miller
Cc: Jonathan Denose, jdenose, Lyude Paul, benjamin.tissoires,
Andrew Duggan, loic.poulain, Andrew Duggan,
Javier Martinez Canillas, Jeremy Kerr, Jonathan Cameron,
Uwe Kleine-König, linux-input, linux-kernel
Hi Jeffery,
On Thu, Jun 08, 2023 at 09:04:00PM +0000, Jeffery Miller wrote:
> On resume there can be a period of time after the
> preceding serio_resume -> psmouse_deactivate call
> where calls to rmi_smb_get_version fail with
> -ENXIO.
>
> The call path in rmi_smb_resume is rmi_smb_resume -> rmi_smb_reset ->
> rmi_smb_enable_smbus_mode -> rmi_smb_get_version where
> this failure would occur.
>
> Add a 30ms delay and retry in the ENXIO case to ensure the following
> rmi_driver_resume calls in rmi_smbus_resume can succeed.
>
> This behavior was seen on a Lenovo T440p machine that required
> a delay of approximately 7-12ms.
>
> The 30ms delay was chosen based on the linux-input message:
> Link: https://lore.kernel.org/all/BYAPR03MB47572F2C65E52ED673238D41B2439@BYAPR03MB4757.namprd03.prod.outlook.com/
I do not quite like putting these retries in RMI code. I wonder if we
should not move the delay into psmouse_smbus_reconnect():
if (smbdev->need_deactivate) {
psmouse_deactivate(psmouse);
/* Give the device time to switch to SMBus mode */
msleep(30);
}
or even factor it out into psmouse_activate_smbus_mode() and call it
from psmouse_smbus_reconnect() as well as psmouse_smbus_init().
Thanks.
or even factor it out into psmouse_activate_smbus_mode() and call it
from psmouse_smbus_reconnect() as well as psmouse_smbus_init().
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-21 23:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08 21:04 [PATCH v3] Input: synaptics-rmi4 - retry reading SMBus version on resume Jeffery Miller
2023-07-21 23:53 ` Dmitry Torokhov
-- strict thread matches above, loose matches on Subject: below --
2023-06-09 19:47 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.