* rt-mutex usage in i2c
@ 2015-03-09 13:43 Sebastian Andrzej Siewior
2015-03-14 11:27 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-03-09 13:43 UTC (permalink / raw)
To: linux-i2c
Cc: Mauro Carvalho Chehab, linux-media@vger.kernel.org, Wolfram Sang,
Mike Galbraith, Mike Rapoport, Jean Delvare
I have two questions:
- em28xx_i2c_xfer() in drivers/media/usb/em28xx/em28xx-i2c.c takes a
rt_mutex lock. This struct i2c_algorithm's ->master_xfer callback.
Why does it take an extra lock since it looks to me that it is
protected by struct i2c_adapter's bus_lock already.
- i2c_transfer() has this piece:
2091 if (in_atomic() || irqs_disabled()) {
2092 ret = i2c_trylock_adapter(adap);
is this irqs_disabled() is what bothers me and should not be there.
pxa does a spin_lock_irq() which would enable interrupts on return /
too early.
mxs has a wait_for_completion() which needs irqs enabled _and_ makes
in_atomic() problematic, too. I have't checked other drivers but the
commit, that introduced it, does not explain why it is required.
So _should_ this be invoked from an interrupt handler (for instance),
then it would record the wrong process as the lock owner. This isn't
problematic unless on SMP the owner gets boosted because a process
with a higher priority needs the lock.
Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: rt-mutex usage in i2c
2015-03-09 13:43 rt-mutex usage in i2c Sebastian Andrzej Siewior
@ 2015-03-14 11:27 ` Wolfram Sang
2015-03-14 11:32 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2015-03-14 11:27 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-i2c, Mauro Carvalho Chehab, linux-media@vger.kernel.org,
Mike Galbraith, Mike Rapoport, Jean Delvare
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Hi Sebastian,
> - i2c_transfer() has this piece:
> 2091 if (in_atomic() || irqs_disabled()) {
> 2092 ret = i2c_trylock_adapter(adap);
>
> is this irqs_disabled() is what bothers me and should not be there.
> pxa does a spin_lock_irq() which would enable interrupts on return /
> too early.
> mxs has a wait_for_completion() which needs irqs enabled _and_ makes
> in_atomic() problematic, too. I have't checked other drivers but the
> commit, that introduced it, does not explain why it is required.
I haven't really looked into it, but a quick search gave me this thread
explaining the intention of the code in question:
http://lists.lm-sensors.org/pipermail/i2c/2007-November/002268.html
Regards,
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: rt-mutex usage in i2c
2015-03-14 11:27 ` Wolfram Sang
@ 2015-03-14 11:32 ` Wolfram Sang
2015-03-15 7:07 ` Mike Rapoport
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2015-03-14 11:32 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-i2c, Mauro Carvalho Chehab, linux-media@vger.kernel.org,
Mike Galbraith, Mike Rapoport, Jean Delvare
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
On Sat, Mar 14, 2015 at 12:27:03PM +0100, Wolfram Sang wrote:
> Hi Sebastian,
>
> > - i2c_transfer() has this piece:
> > 2091 if (in_atomic() || irqs_disabled()) {
> > 2092 ret = i2c_trylock_adapter(adap);
> >
> > is this irqs_disabled() is what bothers me and should not be there.
> > pxa does a spin_lock_irq() which would enable interrupts on return /
> > too early.
> > mxs has a wait_for_completion() which needs irqs enabled _and_ makes
> > in_atomic() problematic, too. I have't checked other drivers but the
> > commit, that introduced it, does not explain why it is required.
>
> I haven't really looked into it, but a quick search gave me this thread
> explaining the intention of the code in question:
>
> http://lists.lm-sensors.org/pipermail/i2c/2007-November/002268.html
>
> Regards,
>
> Wolfram
>
And adding a recent mail address from Mike to cc.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: rt-mutex usage in i2c
2015-03-14 11:32 ` Wolfram Sang
@ 2015-03-15 7:07 ` Mike Rapoport
[not found] ` <CABpLfoiQg1smiebL0=nWX4Sp1H+XD9VViUqGk13gRcfdAwkFoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2015-03-15 7:07 UTC (permalink / raw)
To: Wolfram Sang
Cc: Sebastian Andrzej Siewior, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
Mauro Carvalho Chehab,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Mike Galbraith, Jean Delvare
On Sat, Mar 14, 2015 at 1:32 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> On Sat, Mar 14, 2015 at 12:27:03PM +0100, Wolfram Sang wrote:
>> Hi Sebastian,
>>
>> > - i2c_transfer() has this piece:
>> > 2091 if (in_atomic() || irqs_disabled()) {
>> > 2092 ret = i2c_trylock_adapter(adap);
>> >
>> > is this irqs_disabled() is what bothers me and should not be there.
>> > pxa does a spin_lock_irq() which would enable interrupts on return /
>> > too early.
>> > mxs has a wait_for_completion() which needs irqs enabled _and_ makes
>> > in_atomic() problematic, too. I have't checked other drivers but the
>> > commit, that introduced it, does not explain why it is required.
That was some time ago, but as far as I remember, PIO in i2c_pxa was
required to enable communication with PMIC in interrupt context.
>> I haven't really looked into it, but a quick search gave me this thread
>> explaining the intention of the code in question:
>>
>> http://lists.lm-sensors.org/pipermail/i2c/2007-November/002268.html
>>
>> Regards,
>>
>> Wolfram
>>
>
> And adding a recent mail address from Mike to cc.
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-16 20:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-09 13:43 rt-mutex usage in i2c Sebastian Andrzej Siewior
2015-03-14 11:27 ` Wolfram Sang
2015-03-14 11:32 ` Wolfram Sang
2015-03-15 7:07 ` Mike Rapoport
[not found] ` <CABpLfoiQg1smiebL0=nWX4Sp1H+XD9VViUqGk13gRcfdAwkFoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-16 20:50 ` Sebastian Andrzej Siewior
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).