linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why does handle_simple_irq() require IRQ's to be disabled?
@ 2011-06-06 15:28 David Jander
  2011-06-06 16:18 ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: David Jander @ 2011-06-06 15:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner


Hi,

I am trying to implement/fix interrupt controller functionality in
gpio/pca953x.c, and for some reason which I don't understand, I need to disable
interrupts with local_irq_disable() before calling generic_handle_irq(). This
does not seem right.
If I follow the code of handle_simple_irq(), the handler function setup for
this IRQ, I get to handle_irq_event_percpu(), which has a
WARN_ONCE(!irqs_disabled(),...
This WARN is triggered, since nobody explicitly disables interrupts. Why?

generic_hanlde_irq() is called from a threaded interrupt handler of the parent
of this interrupt controller, and calling local_irq_disable() here seems like
a crime. What am I doing wrong?

Best regards,

-- 
David Jander
Protonic Holland.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why does handle_simple_irq() require IRQ's to be disabled?
  2011-06-06 15:28 Why does handle_simple_irq() require IRQ's to be disabled? David Jander
@ 2011-06-06 16:18 ` Thomas Gleixner
  2011-06-07  7:05   ` David Jander
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2011-06-06 16:18 UTC (permalink / raw)
  To: David Jander; +Cc: linux-kernel

On Mon, 6 Jun 2011, David Jander wrote:
> 
> Hi,
> 
> I am trying to implement/fix interrupt controller functionality in
> gpio/pca953x.c, and for some reason which I don't understand, I need to disable
> interrupts with local_irq_disable() before calling generic_handle_irq(). This
> does not seem right.
> If I follow the code of handle_simple_irq(), the handler function setup for
> this IRQ, I get to handle_irq_event_percpu(), which has a
> WARN_ONCE(!irqs_disabled(),...
> This WARN is triggered, since nobody explicitly disables interrupts. Why?
>  
> generic_hanlde_irq() is called from a threaded interrupt handler of the parent
> of this interrupt controller, and calling local_irq_disable() here seems like
> a crime. What am I doing wrong?

handle_nested_irq() is your friend.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why does handle_simple_irq() require IRQ's to be disabled?
  2011-06-06 16:18 ` Thomas Gleixner
@ 2011-06-07  7:05   ` David Jander
  2011-06-07  8:26     ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: David Jander @ 2011-06-07  7:05 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel


Hi Thomas,

On Mon, 6 Jun 2011 18:18:41 +0200 (CEST)
Thomas Gleixner <tglx@linutronix.de> wrote:

> On Mon, 6 Jun 2011, David Jander wrote:
> > 
> > Hi,
> > 
> > I am trying to implement/fix interrupt controller functionality in
> > gpio/pca953x.c, and for some reason which I don't understand, I need to
> > disable interrupts with local_irq_disable() before calling
> > generic_handle_irq(). This does not seem right.
> > If I follow the code of handle_simple_irq(), the handler function setup for
> > this IRQ, I get to handle_irq_event_percpu(), which has a
> > WARN_ONCE(!irqs_disabled(),...
> > This WARN is triggered, since nobody explicitly disables interrupts. Why?
> >  
> > generic_hanlde_irq() is called from a threaded interrupt handler of the
> > parent of this interrupt controller, and calling local_irq_disable() here
> > seems like a crime. What am I doing wrong?
> 
> handle_nested_irq() is your friend.

Thanks! This worked without disabling IRQ's.
One last question, though:

I set up the handler using irq_set_chip_and_handler(irq, ...,
handle_simple_irq);
>From the interrupt thread, I call handle_nested_irq(). Is it OK, that in this
case, the defined handler function (handle_simple_irq) is not used? Does this
still make sense? Wouldn't calling just irq_set_chip() be enough here (it
seems to work correctly)?

Best regards,

-- 
David Jander
Protonic Holland.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why does handle_simple_irq() require IRQ's to be disabled?
  2011-06-07  7:05   ` David Jander
@ 2011-06-07  8:26     ` Thomas Gleixner
  2011-06-07  8:55       ` David Jander
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2011-06-07  8:26 UTC (permalink / raw)
  To: David Jander; +Cc: linux-kernel

On Tue, 7 Jun 2011, David Jander wrote:
> On Mon, 6 Jun 2011 18:18:41 +0200 (CEST)
> Thomas Gleixner <tglx@linutronix.de> wrote:
> > handle_nested_irq() is your friend.
> 
> Thanks! This worked without disabling IRQ's.
> One last question, though:
> 
> I set up the handler using irq_set_chip_and_handler(irq, ...,
> handle_simple_irq);
> From the interrupt thread, I call handle_nested_irq(). Is it OK, that in this
> case, the defined handler function (handle_simple_irq) is not used? Does this
> still make sense? Wouldn't calling just irq_set_chip() be enough here (it
> seems to work correctly)?

It should be enough. Though you should mark the demuxed interrupts
with irq_set_nested_thread(irqnr, true). That avoids that you create
extra threads for the demuxed interrupts which are never used.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Why does handle_simple_irq() require IRQ's to be disabled?
  2011-06-07  8:26     ` Thomas Gleixner
@ 2011-06-07  8:55       ` David Jander
  0 siblings, 0 replies; 5+ messages in thread
From: David Jander @ 2011-06-07  8:55 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel


Dear Thomas,

On Tue, 7 Jun 2011 10:26:26 +0200 (CEST)
Thomas Gleixner <tglx@linutronix.de> wrote:

> On Tue, 7 Jun 2011, David Jander wrote:
> > On Mon, 6 Jun 2011 18:18:41 +0200 (CEST)
> > Thomas Gleixner <tglx@linutronix.de> wrote:
> > > handle_nested_irq() is your friend.
> > 
> > Thanks! This worked without disabling IRQ's.
> > One last question, though:
> > 
> > I set up the handler using irq_set_chip_and_handler(irq, ...,
> > handle_simple_irq);
> > From the interrupt thread, I call handle_nested_irq(). Is it OK, that in
> > this case, the defined handler function (handle_simple_irq) is not used?
> > Does this still make sense? Wouldn't calling just irq_set_chip() be enough
> > here (it seems to work correctly)?
> 
> It should be enough. Though you should mark the demuxed interrupts
> with irq_set_nested_thread(irqnr, true). That avoids that you create
> extra threads for the demuxed interrupts which are never used.

Cool! Now the disturbingly big list of kernel threads is gone :-)

Thanks a lot!

-- 
David Jander
Protonic Holland.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-07  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-06 15:28 Why does handle_simple_irq() require IRQ's to be disabled? David Jander
2011-06-06 16:18 ` Thomas Gleixner
2011-06-07  7:05   ` David Jander
2011-06-07  8:26     ` Thomas Gleixner
2011-06-07  8:55       ` David Jander

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).