From: Federico Vaga <federico.vaga@cern.ch>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Peter Korsgaard <peter@korsgaard.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/5] i2c:ocores: add polling interface
Date: Mon, 11 Feb 2019 09:20:32 +0100 [thread overview]
Message-ID: <1894984.UOdFTssdus@pcbe13614> (raw)
In-Reply-To: <20190209213353.GA9061@lunn.ch>
On Saturday, February 9, 2019 10:33:53 PM CET Andrew Lunn wrote:
> > +static int ocores_poll_wait(struct ocores_i2c *i2c)
> > +{
> > + u8 mask;
> > + int err;
> > +
> > + if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) {
> > + /* transfer is over */
> > + mask = OCI2C_STAT_BUSY;
> > + } else {
> > + /* on going transfer */
> > + mask = OCI2C_STAT_TIP;
> > + udelay((8 * 1000) / i2c->bus_clock_khz);
> > + }
> > +
> > + /*
> > + * once we are here we expect to get the expected result immediately
> > + * so if after 1ms we timeout then something is broken.
> > + */
> > + err = ocores_wait(i2c, OCI2C_STATUS, mask, 0, msecs_to_jiffies(1));
>
> Hi Federico
>
> I did some timing tests for this. On my box, we request a udelay of
> 80uS. The kernel actually delays for about 79uS. We then spin in
> ocores_wait() for an additional 10-11uS, which is 3 to 4 iterations.
>
> There are actually 9 bits on the wire, not 8, since there is an
> ACK/NACK bit after the actual data transfer. So i changed the delay to
> (9 * 1000) / i2c->bus_clock_khz. That resulted in ocores_wait() mostly
> not looping at all. But for reading an 4K AT24 EEPROM, it increased
> the read time by 10ms, from 424ms to 434ms. So we should probably keep
> with 8.
>
> Tested-by: Andrew Lunn <andrew@lunn.ch>
I had a similar experience. I will add a comment in the code to explain that 8
is not a mistake but a conscious decision. Then I will add what you wrote here
in the patch changelog
>
> Andrew
WARNING: multiple messages have this Message-ID (diff)
From: Federico Vaga <federico.vaga@cern.ch>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Peter Korsgaard <peter@korsgaard.com>,
<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/5] i2c:ocores: add polling interface
Date: Mon, 11 Feb 2019 09:20:32 +0100 [thread overview]
Message-ID: <1894984.UOdFTssdus@pcbe13614> (raw)
In-Reply-To: <20190209213353.GA9061@lunn.ch>
On Saturday, February 9, 2019 10:33:53 PM CET Andrew Lunn wrote:
> > +static int ocores_poll_wait(struct ocores_i2c *i2c)
> > +{
> > + u8 mask;
> > + int err;
> > +
> > + if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) {
> > + /* transfer is over */
> > + mask = OCI2C_STAT_BUSY;
> > + } else {
> > + /* on going transfer */
> > + mask = OCI2C_STAT_TIP;
> > + udelay((8 * 1000) / i2c->bus_clock_khz);
> > + }
> > +
> > + /*
> > + * once we are here we expect to get the expected result immediately
> > + * so if after 1ms we timeout then something is broken.
> > + */
> > + err = ocores_wait(i2c, OCI2C_STATUS, mask, 0, msecs_to_jiffies(1));
>
> Hi Federico
>
> I did some timing tests for this. On my box, we request a udelay of
> 80uS. The kernel actually delays for about 79uS. We then spin in
> ocores_wait() for an additional 10-11uS, which is 3 to 4 iterations.
>
> There are actually 9 bits on the wire, not 8, since there is an
> ACK/NACK bit after the actual data transfer. So i changed the delay to
> (9 * 1000) / i2c->bus_clock_khz. That resulted in ocores_wait() mostly
> not looping at all. But for reading an 4K AT24 EEPROM, it increased
> the read time by 10ms, from 424ms to 434ms. So we should probably keep
> with 8.
>
> Tested-by: Andrew Lunn <andrew@lunn.ch>
I had a similar experience. I will add a comment in the code to explain that 8
is not a mistake but a conscious decision. Then I will add what you wrote here
in the patch changelog
>
> Andrew
next prev parent reply other threads:[~2019-02-11 8:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 16:11 [PATCH v3 0/5] Federico Vaga
2019-02-08 16:11 ` Federico Vaga
2019-02-08 16:11 ` [PATCH v3 1/5] i2c:ocores: stop transfer on timeout Federico Vaga
2019-02-08 16:11 ` Federico Vaga
2019-02-08 16:58 ` Andrew Lunn
2019-02-08 16:11 ` [PATCH v3 2/5] i2c:ocores: do not handle IRQ if IF is not set Federico Vaga
2019-02-08 16:11 ` Federico Vaga
2019-02-08 17:00 ` Andrew Lunn
2019-02-08 16:11 ` [PATCH v3 3/5] i2c:ocores: add polling interface Federico Vaga
2019-02-08 16:11 ` Federico Vaga
2019-02-09 21:33 ` Andrew Lunn
2019-02-11 8:20 ` Federico Vaga [this message]
2019-02-11 8:20 ` Federico Vaga
2019-02-08 16:12 ` [PATCH v3 4/5] i2c:ocores: add SPDX tag Federico Vaga
2019-02-08 16:12 ` Federico Vaga
2019-02-08 17:01 ` Andrew Lunn
2019-02-08 17:16 ` Peter Rosin
2019-02-08 16:12 ` [PATCH v3 5/5] i2c:ocores: checkpatch fixes Federico Vaga
2019-02-08 16:12 ` Federico Vaga
2019-02-08 17:03 ` Andrew Lunn
2019-02-09 21:41 ` [PATCH v3 0/5] Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1894984.UOdFTssdus@pcbe13614 \
--to=federico.vaga@cern.ch \
--cc=andrew@lunn.ch \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter@korsgaard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.