Re: lockdep and threaded IRQs (was: ...)

From: David Brownell
Date: Fri Feb 27 2009 - 18:19:18 EST


On Friday 27 February 2009, Andrew Morton wrote:
>
> > There are actually two issues.  The lockdep issue is
> > one ... the above #ifdef suffices to work around it
> > for all the TWL4030 (family) IRQs.

(And other similar cases, of course, including those
MMC cases that crap out in the ARM memory management
code when lockdep wrongly disables IRQs.)


> > The other is that Linux needs real support for threaded
> > interrupts.  Almost every I2C (or SPI) device that raises
> > an IRQ needs its IRQ handler to run in a thread, and most
> > of them have the same type of workqueue-based hack to
> > get such a thread.  (Some others have bugs instead...)
> >
> > Obviously, if any threaded IRQ handler grabs a mutex,
> > but lockdep has disabled IRQs, trouble ensues...
>
> What's going on here?  hardirq handlers cannot take mutexes and cannot
> sleep, period.  

But these handlers are *NOT* running in hardirq context;
so such thought doesn't apply. The hardirq bit of the
IRQ-handling activity completed quite a bit earlier.

Being able to sleep and grab mutexes is one of the main
reasons for wanting threaded IRQ handlers. For common
(embedded) I2C hardware, if threaded IRQ handlers can't
sleep they're completely useless.

And something that may eventually matter for mainline:
in RT contexts, thread priority applies to mutex grabbing,
and helps manage priority inversion. That's equivalent
to sleeping.

This stuff just pokes at some annoying current gaps in the
IRQ framework. I'll be glad when eventually there's no
need to work around those weaknesses ... that is, when
real threaded IRQ support is available.


> Enabling local interrupts might shut up some warning,
> but won't fix the deadlocks which that warning is there to warn us
> about.

Wrong; all such warnings are false, in these cases.

- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/