Re: [patch/rfc 1/2] GENIRQ: add handle_threaded_irq() flow handler

David Brownell
2009-03-18T18:31:35Z

On Wednesday 18 March 2009, Felipe Balbi wrote:
> > +     action = desc->action;
> > +     if (unlikely(!action || (desc->status & IRQ_DISABLED)))
> > +             goto out_unlock;
>
> you say below irqs are always enabled

Right here they're always disabled by spin_lock_irq().
The "below" follows spin_unlock_irq(), which re-enables
them to traverse that (locked) action list.

> so this branch is something we
> never want to happen. How about adding a WARN() then ?

When some one says "irqs are enabled" they mean that,
local_irq_disable() or friends have not been called,
so for example a timer or other IRQ could arrive.

The IRQ_DISABLED flag in an IRQ descriptor means
something different: "don't try *handling* this".

That particular check is used in *ALL* flow handlers.
It guards against things like races in disable_irq()
paths, which could allow an IRQ that was in flight
to arrive "after" the IRQ was disabled.

In the case of an IRQ enable/disable mask sitting
across an I2C bus boundary, it's particularly easy
to see how such a race might happen ... since both
the thread masking the IRQ, and the one handling it,
are subject to preemption and scheduling.