* Questions about i2c_transfer() usage in timer context...
@ 2012-02-20 13:01 Stephane Grosjean
[not found] ` <4F424440.300-g4cQ8AsIbFbL9ATBNaCtXw@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Stephane Grosjean @ 2012-02-20 13:01 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Hi,
I'm facing a deadlock regarding a timer callback which is only calling
i2c_transfer(), and I wonder if this comes from that call: I first
googled and found that i2c_transfer() may sleep (which is forbidden in
my timer callback) but when I have a look the beginning of the function,
it starts to check if it is in any atomic context, before trying to
acquire a lock...
So I'm afraid I'm lost and I hope someone will be able to understand to
that question: might i2c_transfer() be used in a timer callback or
should I handle my periodic call to i2c_tranfer() by means of a delayed
work?
Thanks for your reply,
Regards,
Stéphane
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Questions about i2c_transfer() usage in timer context...
[not found] ` <4F424440.300-g4cQ8AsIbFbL9ATBNaCtXw@public.gmane.org>
@ 2012-02-20 13:11 ` Jean Delvare
[not found] ` <20120220141112.1e633beb-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
[not found] ` <CADkCAusvXZC5Ju2oNbBgi6aZO2E9upoDPbtFqTbrbBhd8eCu8A@mail.gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Jean Delvare @ 2012-02-20 13:11 UTC (permalink / raw)
To: Stephane Grosjean; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Bonjour Stéphane,
On Mon, 20 Feb 2012 14:01:52 +0100, Stephane Grosjean wrote:
> I'm facing a deadlock regarding a timer callback which is only calling
> i2c_transfer(), and I wonder if this comes from that call: I first
> googled and found that i2c_transfer() may sleep (which is forbidden in
> my timer callback) but when I have a look the beginning of the function,
> it starts to check if it is in any atomic context, before trying to
> acquire a lock...
>
> So I'm afraid I'm lost and I hope someone will be able to understand to
> that question: might i2c_transfer() be used in a timer callback or
> should I handle my periodic call to i2c_tranfer() by means of a delayed
> work?
Depends on the underlying I2C adapter driver. One of the sleep causes
is indeed the acquisition of the mutex in i2c_transfer(). However the
function then calls a driver specific callback function
(adap->algo->master_xfer) which may or may not sleep too depending on
the implementation. So if you want your code to be portable, you have to
assume that it may sleep, which means you indeed have to use a delayed
work.
HTH,
--
Jean Delvare
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Questions about i2c_transfer() usage in timer context...
[not found] ` <20120220141112.1e633beb-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2012-02-20 13:19 ` Stephane Grosjean
0 siblings, 0 replies; 4+ messages in thread
From: Stephane Grosjean @ 2012-02-20 13:19 UTC (permalink / raw)
To: Jean Delvare; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Merci Jean,
Thx for the quick answer. I think this will help.
Stéphane
Le 20/02/2012 14:11, Jean Delvare a écrit :
> Bonjour Stéphane,
>
> On Mon, 20 Feb 2012 14:01:52 +0100, Stephane Grosjean wrote:
>> I'm facing a deadlock regarding a timer callback which is only calling
>> i2c_transfer(), and I wonder if this comes from that call: I first
>> googled and found that i2c_transfer() may sleep (which is forbidden in
>> my timer callback) but when I have a look the beginning of the function,
>> it starts to check if it is in any atomic context, before trying to
>> acquire a lock...
>>
>> So I'm afraid I'm lost and I hope someone will be able to understand to
>> that question: might i2c_transfer() be used in a timer callback or
>> should I handle my periodic call to i2c_tranfer() by means of a delayed
>> work?
> Depends on the underlying I2C adapter driver. One of the sleep causes
> is indeed the acquisition of the mutex in i2c_transfer(). However the
> function then calls a driver specific callback function
> (adap->algo->master_xfer) which may or may not sleep too depending on
> the implementation. So if you want your code to be portable, you have to
> assume that it may sleep, which means you indeed have to use a delayed
> work.
>
> HTH,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Questions about i2c_transfer() usage in timer context...
[not found] ` <CADkCAusvXZC5Ju2oNbBgi6aZO2E9upoDPbtFqTbrbBhd8eCu8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-02-20 14:13 ` Jean Delvare
0 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2012-02-20 14:13 UTC (permalink / raw)
To: Bill Gatliff; +Cc: Stephane Grosjean, linux-i2c-u79uwXL29TY76Z2rM5mHXA
Hi Bill,
On Mon, 20 Feb 2012 07:46:07 -0600, Bill Gatliff wrote:
> On Feb 20, 2012 7:11 AM, "Jean Delvare" <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> > On Mon, 20 Feb 2012 14:01:52 +0100, Stephane Grosjean wrote:
> > > I'm facing a deadlock regarding a timer callback...
> >
> > Depends on the underlying I2C adapter driver. One of the sleep causes
> > is indeed the acquisition of the mutex in i2c_transfer(). However the
> > function then calls a driver specific callback function
> > (adap->algo->master_xfer) which may or may not sleep too depending on
> > the implementation.
>
> Indeed. A fair number of the i2c transfer functions I have encountered call
> schedule_work() or equivalent, and/or wait_for_completion().
Or even plain msleep().
> The low-level transfer function implementations are entirely
> platform-dependent, and often lean heavily on the assumption that they
> aren't called in atomic contexts. So in addition to driving architecture
> decisions in your code which calls them, they can also have implications
> for real-time performance.
>
> None of the above is a complaint, mind you. Just observations. :)
I certainly hope you wouldn't dare to complain without also submitting
a proposal and a patch set addressing any issue you have ;)
--
Jean Delvare
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-20 14:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20 13:01 Questions about i2c_transfer() usage in timer context Stephane Grosjean
[not found] ` <4F424440.300-g4cQ8AsIbFbL9ATBNaCtXw@public.gmane.org>
2012-02-20 13:11 ` Jean Delvare
[not found] ` <20120220141112.1e633beb-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-02-20 13:19 ` Stephane Grosjean
[not found] ` <CADkCAusvXZC5Ju2oNbBgi6aZO2E9upoDPbtFqTbrbBhd8eCu8A@mail.gmail.com>
[not found] ` <CADkCAusvXZC5Ju2oNbBgi6aZO2E9upoDPbtFqTbrbBhd8eCu8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-20 14:13 ` Jean Delvare
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).