All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Paul Mundt <lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org>,
	Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Clarification on i2c-pca-platform driver timeout
Date: Mon, 23 Feb 2009 15:50:27 +0100	[thread overview]
Message-ID: <20090223145027.GA3052@pengutronix.de> (raw)
In-Reply-To: <20090223152308.1db394a6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2127 bytes --]

Hello Jean,

On Mon, Feb 23, 2009 at 03:23:08PM +0100, Jean Delvare wrote:
> Hi Wolfram,
> 
> I would like you to clarify the situation when it comes to the value of
> the timeout field of struct i2c_pca9564_pf_platform_data:
> 
> struct i2c_pca9564_pf_platform_data {
> 	(...)
> 	int timeout;		/* timeout = this value * 10us */
> };
> 
> The only user, board-sh7785lcr.c, sets this value to 100, resulting in
> a 1 ms timeout. This seems really short. Is this really intended?

This is a typo. It should say 10ms as a unit, resulting in 1s total.

> Why is the timeout value defined in such a strange unit?

I didn't change this in i2c-algo-pca.c back then, look at the beginning
of pca_xfer:

while ((state = pca_status(adap)) != 0xf8 && timeout--) {
        msleep(10);
}

So, timeout acts as a loop counter in waiting for a free bus, which is
why your change in "Adapter timeout is in jiffies" alone won't do for
pca-based drivers. There seems to be a bigger rework needed for handling
the timeout :( I wanted to look into it this evening, but it seems to
be a bit urgent?

> static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
> {
> 	struct i2c_pca_pf_data *i2c;
> 	(...)
> 	struct i2c_pca9564_pf_platform_data *platform_data =
> 				pdev->dev.platform_data;
> 	(...)
> 	i2c->adap.timeout = platform_data->timeout;
> 
> The problem is that i2c->adap.timeout is supposed to be expressed in
> jiffies, not units of 10 us. So there is a conversion missing.

Yup, see above.

> Lastly, you define a timeout value but never use it. Shouldn't you use
> wait_event_interruptible_timeout() instead of
> wait_event_interruptible() in i2c_pca_pf_waitforcompletion?

This is probably one part of the complete solution.

> An upcoming patch will add code which handles a timeout at i2c-core
> level, so it matters to get all i2c bus drivers right first.

Sounds reasonable...

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  parent reply	other threads:[~2009-02-23 14:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-23 14:23 Clarification on i2c-pca-platform driver timeout Jean Delvare
     [not found] ` <20090223152308.1db394a6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-23 14:50   ` Wolfram Sang [this message]
     [not found]     ` <20090223145027.GA3052-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-02-23 15:52       ` Jean Delvare
     [not found]         ` <20090223165222.6e376e11-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-24 14:09           ` Wolfram Sang

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=20090223145027.GA3052@pengutronix.de \
    --to=w.sang-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=lethal-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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.