* [PATCH v3] i2c: npcm7xx: Fix timeout calculation
@ 2020-08-30 21:31 Tali Perry
2020-08-31 3:35 ` Joel Stanley
2020-09-08 6:26 ` Wolfram Sang
0 siblings, 2 replies; 4+ messages in thread
From: Tali Perry @ 2020-08-30 21:31 UTC (permalink / raw)
To: kunyi, xqiu, benjaminfair, avifishman70, joel, tmaimon77, wsa
Cc: linux-i2c, openbmc, linux-kernel, Tali Perry
timeout_usec value calculation was wrong, the calculated value
was in msec instead of usec.
Signed-off-by: Tali Perry <tali.perry1@gmail.com>
Reviewed-by: Avi Fishman <avifishman70@gmail.com>
---
drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
index 75f07138a6fa..dfcf04e1967f 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -2093,8 +2093,12 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
}
}
- /* Adaptive TimeOut: astimated time in usec + 100% margin */
- timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);
+ /*
+ * Adaptive TimeOut: estimated time in usec + 100% margin:
+ * 2: double the timeout for clock stretching case
+ * 9: bits per transaction (including the ack/nack)
+ */
+ timeout_usec = (2 * 9 * USEC_PER_SEC / bus->bus_freq) * (2 + nread + nwrite);
timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] i2c: npcm7xx: Fix timeout calculation
2020-08-30 21:31 [PATCH v3] i2c: npcm7xx: Fix timeout calculation Tali Perry
@ 2020-08-31 3:35 ` Joel Stanley
2020-08-31 18:10 ` Alex Qiu
2020-09-08 6:26 ` Wolfram Sang
1 sibling, 1 reply; 4+ messages in thread
From: Joel Stanley @ 2020-08-31 3:35 UTC (permalink / raw)
To: Tali Perry
Cc: Kun Yi, xqiu, Benjamin Fair, Avi Fishman, Tomer Maimon,
Wolfram Sang, linux-i2c, OpenBMC Maillist,
Linux Kernel Mailing List
On Sun, 30 Aug 2020 at 21:31, Tali Perry <tali.perry1@gmail.com> wrote:
>
> timeout_usec value calculation was wrong, the calculated value
> was in msec instead of usec.
>
> Signed-off-by: Tali Perry <tali.perry1@gmail.com>
> Reviewed-by: Avi Fishman <avifishman70@gmail.com>
Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Reviewed-by: Joel Stanley <joel@jms.id.au>
Cheers,
Joel
> ---
> drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> index 75f07138a6fa..dfcf04e1967f 100644
> --- a/drivers/i2c/busses/i2c-npcm7xx.c
> +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> @@ -2093,8 +2093,12 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
> }
> }
>
> - /* Adaptive TimeOut: astimated time in usec + 100% margin */
> - timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);
> + /*
> + * Adaptive TimeOut: estimated time in usec + 100% margin:
> + * 2: double the timeout for clock stretching case
> + * 9: bits per transaction (including the ack/nack)
> + */
> + timeout_usec = (2 * 9 * USEC_PER_SEC / bus->bus_freq) * (2 + nread + nwrite);
> timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
> if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
> dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
>
> base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd
> --
> 2.22.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] i2c: npcm7xx: Fix timeout calculation
2020-08-31 3:35 ` Joel Stanley
@ 2020-08-31 18:10 ` Alex Qiu
0 siblings, 0 replies; 4+ messages in thread
From: Alex Qiu @ 2020-08-31 18:10 UTC (permalink / raw)
To: Joel Stanley
Cc: Tali Perry, Kun Yi, Benjamin Fair, Avi Fishman, Tomer Maimon,
Wolfram Sang, linux-i2c, OpenBMC Maillist,
Linux Kernel Mailing List
On Sun, Aug 30, 2020 at 8:35 PM Joel Stanley <joel@jms.id.au> wrote:
>
> On Sun, 30 Aug 2020 at 21:31, Tali Perry <tali.perry1@gmail.com> wrote:
> >
> > timeout_usec value calculation was wrong, the calculated value
> > was in msec instead of usec.
> >
> > Signed-off-by: Tali Perry <tali.perry1@gmail.com>
> > Reviewed-by: Avi Fishman <avifishman70@gmail.com>
>
> Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
> Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Alex Qiu <xqiu@google.com>
>
> Cheers,
>
> Joel
>
> > ---
> > drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> > index 75f07138a6fa..dfcf04e1967f 100644
> > --- a/drivers/i2c/busses/i2c-npcm7xx.c
> > +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> > @@ -2093,8 +2093,12 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
> > }
> > }
> >
> > - /* Adaptive TimeOut: astimated time in usec + 100% margin */
> > - timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);
> > + /*
> > + * Adaptive TimeOut: estimated time in usec + 100% margin:
> > + * 2: double the timeout for clock stretching case
> > + * 9: bits per transaction (including the ack/nack)
> > + */
> > + timeout_usec = (2 * 9 * USEC_PER_SEC / bus->bus_freq) * (2 + nread + nwrite);
> > timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
> > if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
> > dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
> >
> > base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd
> > --
> > 2.22.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] i2c: npcm7xx: Fix timeout calculation
2020-08-30 21:31 [PATCH v3] i2c: npcm7xx: Fix timeout calculation Tali Perry
2020-08-31 3:35 ` Joel Stanley
@ 2020-09-08 6:26 ` Wolfram Sang
1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2020-09-08 6:26 UTC (permalink / raw)
To: Tali Perry
Cc: kunyi, xqiu, benjaminfair, avifishman70, joel, tmaimon77,
linux-i2c, openbmc, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 342 bytes --]
On Mon, Aug 31, 2020 at 12:31:21AM +0300, Tali Perry wrote:
> timeout_usec value calculation was wrong, the calculated value
> was in msec instead of usec.
>
> Signed-off-by: Tali Perry <tali.perry1@gmail.com>
> Reviewed-by: Avi Fishman <avifishman70@gmail.com>
Applied to for-current, thanks! And thanks for the Fixes-tag, Joel.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-08 6:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 21:31 [PATCH v3] i2c: npcm7xx: Fix timeout calculation Tali Perry
2020-08-31 3:35 ` Joel Stanley
2020-08-31 18:10 ` Alex Qiu
2020-09-08 6:26 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).