Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1383763 > unrolled thread
| Started by | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| First post | 2016-04-20 23:50 +0200 |
| Last post | 2016-04-21 16:20 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v6 08/19] i2c: octeon: Enable High-Level Controller Wolfram Sang <wsa@the-dreams.de> - 2016-04-20 23:50 +0200
Re: [PATCH v6 08/19] i2c: octeon: Enable High-Level Controller David Daney <ddaney@caviumnetworks.com> - 2016-04-21 00:00 +0200
Re: [PATCH v6 08/19] i2c: octeon: Enable High-Level Controller Wolfram Sang <wsa@the-dreams.de> - 2016-04-21 16:00 +0200
Re: [PATCH v6 08/19] i2c: octeon: Enable High-Level Controller Jan Glauber <jan.glauber@caviumnetworks.com> - 2016-04-21 16:20 +0200
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-04-20 23:50 +0200 |
| Subject | Re: [PATCH v6 08/19] i2c: octeon: Enable High-Level Controller |
| Message-ID | <rq8au-6mN-3@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Apr 11, 2016 at 05:28:39PM +0200, Jan Glauber wrote:
> From: David Daney <ddaney@caviumnetworks.com>
>
> Use High-Level Controller (HLC) when possible. The HLC can read/write
> up to 8 bytes and is completely optional. The most important difference
> of the HLC is that it only requires one interrupt for a transfer
> (up to 8 bytes) where the low-level read/write requires 2 interrupts
> plus one interrupt per transferred byte. Since the interrupts are costly
> using the HLC improves the performance. Also, the HLC provides improved error
> handling.
Much better description, thanks!
> + while (1) {
> + val = octeon_i2c_ctl_read(i2c);
> + if (!(val & (TWSI_CTL_STA | TWSI_CTL_STP)));
> + break;
> +
> + /* clear IFLG event */
> + if (val & TWSI_CTL_IFLG)
> + octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
> +
> + if (try++ > 100) {
> + pr_err("%s: giving up\n", __func__);
> + break;
> + }
> +
> + /* spin until any start/stop has finished */
> + udelay(10);
> + }
Maybe you can use one of the readx_poll_timeout() functions?
> +/**
> + * octeon_i2c_hlc_wait - wait for an HLC operation to complete
> + * @i2c: The struct octeon_i2c
> + *
> + * Returns 0 on success, otherwise a negative errno.
> + */
> +static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
> +{
> + int time_left;
> +
> + octeon_i2c_hlc_int_enable(i2c);
> + time_left = wait_event_interruptible_timeout(i2c->queue,
> + octeon_i2c_hlc_test_ready(i2c),
> + i2c->adap.timeout);
Have you tested signal handling thoroughly? Most driver dropped the
_interruptible after a while. Mostly they found out that the state
machine of the interrupt handler couldn't gracefully deal with it and
nobody really needed the interruptible. Just saying.
> + octeon_i2c_int_disable(i2c);
> + if (!time_left) {
> + octeon_i2c_hlc_int_clear(i2c);
> + dev_dbg(i2c->dev, "%s: timeout\n", __func__);
> + return -ETIMEDOUT;
> + }
> +
> + if (time_left < 0) {
> + dev_dbg(i2c->dev, "%s: wait interrupted\n", __func__);
> + return time_left;
> + }
> + return 0;
> +}
Drop the debug messages?
I can't say much about the HW details, of course. Didn't spot anything
suspicious there.
[toc] | [next] | [standalone]
| From | David Daney <ddaney@caviumnetworks.com> |
|---|---|
| Date | 2016-04-21 00:00 +0200 |
| Message-ID | <rq8ka-6rk-1@gated-at.bofh.it> |
| In reply to | #1383763 |
On 04/20/2016 02:43 PM, Wolfram Sang wrote:
> On Mon, Apr 11, 2016 at 05:28:39PM +0200, Jan Glauber wrote:
[...]
>> + */
>> +static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
>> +{
>> + int time_left;
>> +
>> + octeon_i2c_hlc_int_enable(i2c);
>> + time_left = wait_event_interruptible_timeout(i2c->queue,
>> + octeon_i2c_hlc_test_ready(i2c),
>> + i2c->adap.timeout);
>
> Have you tested signal handling thoroughly? Most driver dropped the
> _interruptible after a while. Mostly they found out that the state
> machine of the interrupt handler couldn't gracefully deal with it and
> nobody really needed the interruptible. Just saying.
Good point. We know that exiting with a signal leaves us in an
undefined state.
We will have to think on this point.
>
>> + octeon_i2c_int_disable(i2c);
>> + if (!time_left) {
>> + octeon_i2c_hlc_int_clear(i2c);
>> + dev_dbg(i2c->dev, "%s: timeout\n", __func__);
>> + return -ETIMEDOUT;
>> + }
>> +
>> + if (time_left < 0) {
>> + dev_dbg(i2c->dev, "%s: wait interrupted\n", __func__);
>> + return time_left;
>> + }
>> + return 0;
>> +}
>
> Drop the debug messages?
>
> I can't say much about the HW details, of course. Didn't spot anything
> suspicious there.
>
[toc] | [prev] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-04-21 16:00 +0200 |
| Message-ID | <rqnjd-1xU-39@gated-at.bofh.it> |
| In reply to | #1383766 |
[Multipart message — attachments visible in raw view] — view raw
> I think we should just drop the _interruptible_ and use > wait_event_timeout. The same is already used in the octeon_i2c_wait(). > The 2ms timeout should not hurt anyone. This is what most people have good experience with :)
[toc] | [prev] | [next] | [standalone]
| From | Jan Glauber <jan.glauber@caviumnetworks.com> |
|---|---|
| Date | 2016-04-21 16:20 +0200 |
| Message-ID | <rqnCx-1Zd-1@gated-at.bofh.it> |
| In reply to | #1383763 |
On Wed, Apr 20, 2016 at 11:43:54PM +0200, Wolfram Sang wrote:
> On Mon, Apr 11, 2016 at 05:28:39PM +0200, Jan Glauber wrote:
> > From: David Daney <ddaney@caviumnetworks.com>
> >
> > Use High-Level Controller (HLC) when possible. The HLC can read/write
> > up to 8 bytes and is completely optional. The most important difference
> > of the HLC is that it only requires one interrupt for a transfer
> > (up to 8 bytes) where the low-level read/write requires 2 interrupts
> > plus one interrupt per transferred byte. Since the interrupts are costly
> > using the HLC improves the performance. Also, the HLC provides improved error
> > handling.
>
> Much better description, thanks!
>
> > + while (1) {
> > + val = octeon_i2c_ctl_read(i2c);
> > + if (!(val & (TWSI_CTL_STA | TWSI_CTL_STP)));
> > + break;
> > +
> > + /* clear IFLG event */
> > + if (val & TWSI_CTL_IFLG)
> > + octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
> > +
> > + if (try++ > 100) {
> > + pr_err("%s: giving up\n", __func__);
> > + break;
> > + }
> > +
> > + /* spin until any start/stop has finished */
> > + udelay(10);
> > + }
>
> Maybe you can use one of the readx_poll_timeout() functions?
Nice, but I don't think we can use readx_poll_timeout() here because
of the octeon_i2c_ctl_write inside the loop...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web