Message ID | 20200310023827.30024-2-acelan.kao@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1,SRU,OEM-OSP1-B,F,Unstable] UBUNTU: SAUCE: Input: i8042 - Fix the selftest retry logic | expand |
We're to propose a V2 that preserves fault tolerance as the original code does. You-Sheng Yang On 2020-03-10 10:38, AceLan Kao wrote: > BugLink: https://bugs.launchpad.net/bugs/1866734 > > It returns -NODEV at the first selftest timeout, so the retry logic > doesn't work. Move the return outside of the while loop to make it real > retry 5 times before returns -ENODEV. > > BTW, the origin loop will retry 6 times, also fix this. > > Signed-off-by: AceLan Kao <acelan.kao@canonical.com> > --- > drivers/input/serio/i8042.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c > index 1e29408491eb..c64f43ebe56a 100644 > --- a/drivers/input/serio/i8042.c > +++ b/drivers/input/serio/i8042.c > @@ -937,10 +937,9 @@ static int i8042_controller_selftest(void) > */ > do { > > - if (i8042_command(¶m, I8042_CMD_CTL_TEST)) { > - pr_info("i8042 controller selftest timeout\n"); > - return -ENODEV; > - } > + if (i8042_command(¶m, I8042_CMD_CTL_TEST)) > + pr_info("i8042 controller selftest timeout (%d/5)\n", > + i+1); > > if (param == I8042_RET_CTL_TEST) > return 0; > @@ -948,7 +947,9 @@ static int i8042_controller_selftest(void) > dbg("i8042 controller selftest: %#x != %#x\n", > param, I8042_RET_CTL_TEST); > msleep(50); > - } while (i++ < 5); > + } while (++i < 5); > + if (i == 5) > + return -ENODEV; > > #ifdef CONFIG_X86 > /* >
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 1e29408491eb..c64f43ebe56a 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -937,10 +937,9 @@ static int i8042_controller_selftest(void) */ do { - if (i8042_command(¶m, I8042_CMD_CTL_TEST)) { - pr_info("i8042 controller selftest timeout\n"); - return -ENODEV; - } + if (i8042_command(¶m, I8042_CMD_CTL_TEST)) + pr_info("i8042 controller selftest timeout (%d/5)\n", + i+1); if (param == I8042_RET_CTL_TEST) return 0; @@ -948,7 +947,9 @@ static int i8042_controller_selftest(void) dbg("i8042 controller selftest: %#x != %#x\n", param, I8042_RET_CTL_TEST); msleep(50); - } while (i++ < 5); + } while (++i < 5); + if (i == 5) + return -ENODEV; #ifdef CONFIG_X86 /*
BugLink: https://bugs.launchpad.net/bugs/1866734 It returns -NODEV at the first selftest timeout, so the retry logic doesn't work. Move the return outside of the while loop to make it real retry 5 times before returns -ENODEV. BTW, the origin loop will retry 6 times, also fix this. Signed-off-by: AceLan Kao <acelan.kao@canonical.com> --- drivers/input/serio/i8042.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)