From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Stephane Grosjean <s.grosjean-g4cQ8AsIbFbL9ATBNaCtXw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Questions about i2c_transfer() usage in timer context...
Date: Mon, 20 Feb 2012 14:11:12 +0100 [thread overview]
Message-ID: <20120220141112.1e633beb@endymion.delvare> (raw)
In-Reply-To: <4F424440.300-g4cQ8AsIbFbL9ATBNaCtXw@public.gmane.org>
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
next prev parent reply other threads:[~2012-02-20 13:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[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
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=20120220141112.1e633beb@endymion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=s.grosjean-g4cQ8AsIbFbL9ATBNaCtXw@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 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).