Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599961 > unrolled thread

[PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED

Started byTony Lindgren <tony@atomide.com>
First post2017-03-14 02:00 +0100
Last post2017-03-14 16:00 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED Tony Lindgren <tony@atomide.com> - 2017-03-14 02:00 +0100
    Re: [PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED Thomas Gleixner <tglx@linutronix.de> - 2017-03-14 09:40 +0100
      Re: [PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED Tony Lindgren <tony@atomide.com> - 2017-03-14 16:00 +0100

#1599961 — [PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED

FromTony Lindgren <tony@atomide.com>
Date2017-03-14 02:00 +0100
Subject[PATCH] genirq: Fix handle_nested_irq() for IRQF_SHARED
Message-ID<tkIYF-EG-15@gated-at.bofh.it>
Shared interrupts can be registered with handle_nested_irq(), but
currently only one of the registered handlers gets called.

The use of shared interrupts with handle_nested_irq() is probably rare,
but at least a case of a shared VBUS interrupt between USB PHY and
battery charger drivers for a PMIC makes sense.

Typically for_each_action_of_desc() gets called via handle_irq_event()
at _handle_irq_event_percpu(), but handle_nested_irq() is different
because of it's dummy irq_nested_primary_handler().

Let's fix the issue by calling the handler for all the entries in
the action list.

Fixes: 399b5da29b9f ("genirq: Support nested threaded irq handling")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 kernel/irq/chip.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -348,9 +348,11 @@ void handle_nested_irq(unsigned int irq)
 	irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
 	raw_spin_unlock_irq(&desc->lock);
 
-	action_ret = action->thread_fn(action->irq, action->dev_id);
-	if (!noirqdebug)
-		note_interrupt(desc, action_ret);
+	for_each_action_of_desc(desc, action) {
+		action_ret = action->thread_fn(action->irq, action->dev_id);
+		if (!noirqdebug)
+			note_interrupt(desc, action_ret);
+	}
 
 	raw_spin_lock_irq(&desc->lock);
 	irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);
-- 
2.11.1

[toc] | [next] | [standalone]


#1600121

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-14 09:40 +0100
Message-ID<tkQ9Q-5Sw-11@gated-at.bofh.it>
In reply to#1599961
On Mon, 13 Mar 2017, Tony Lindgren wrote:

> Shared interrupts can be registered with handle_nested_irq(), but
> currently only one of the registered handlers gets called.
> 
> The use of shared interrupts with handle_nested_irq() is probably rare,
> but at least a case of a shared VBUS interrupt between USB PHY and
> battery charger drivers for a PMIC makes sense.
> 
> Typically for_each_action_of_desc() gets called via handle_irq_event()
> at _handle_irq_event_percpu(), but handle_nested_irq() is different
> because of it's dummy irq_nested_primary_handler().
> 
> Let's fix the issue by calling the handler for all the entries in
> the action list.
>
> Fixes: 399b5da29b9f ("genirq: Support nested threaded irq handling")

It's not a fix, it's an extension. The nested facility was not meant to
handle shared interrupts in the first place. I really hope that hardware
folks finally understand that irq sharing is crap and broken...

> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  kernel/irq/chip.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
> --- a/kernel/irq/chip.c
> +++ b/kernel/irq/chip.c
> @@ -348,9 +348,11 @@ void handle_nested_irq(unsigned int irq)
>  	irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS);
>  	raw_spin_unlock_irq(&desc->lock);
>  
> -	action_ret = action->thread_fn(action->irq, action->dev_id);
> -	if (!noirqdebug)
> -		note_interrupt(desc, action_ret);
> +	for_each_action_of_desc(desc, action) {
> +		action_ret = action->thread_fn(action->irq, action->dev_id);
> +		if (!noirqdebug)
> +			note_interrupt(desc, action_ret);

This is wrong. See how __handle_irq_event_percpu() does this. But no need
to resend. See:

http://lkml.kernel.org/r/1488904098-5350-1-git-send-email-ckeepax@opensource.wolfsonmicro.com

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1600530

FromTony Lindgren <tony@atomide.com>
Date2017-03-14 16:00 +0100
Message-ID<tkW5A-1Ad-25@gated-at.bofh.it>
In reply to#1600121
* Thomas Gleixner <tglx@linutronix.de> [170314 01:40]:
> On Mon, 13 Mar 2017, Tony Lindgren wrote:
> 
> > Shared interrupts can be registered with handle_nested_irq(), but
> > currently only one of the registered handlers gets called.
> > 
> > The use of shared interrupts with handle_nested_irq() is probably rare,
> > but at least a case of a shared VBUS interrupt between USB PHY and
> > battery charger drivers for a PMIC makes sense.
> > 
> > Typically for_each_action_of_desc() gets called via handle_irq_event()
> > at _handle_irq_event_percpu(), but handle_nested_irq() is different
> > because of it's dummy irq_nested_primary_handler().
> > 
> > Let's fix the issue by calling the handler for all the entries in
> > the action list.
> >
> > Fixes: 399b5da29b9f ("genirq: Support nested threaded irq handling")
> 
> It's not a fix, it's an extension. The nested facility was not meant to
> handle shared interrupts in the first place. I really hope that hardware
> folks finally understand that irq sharing is crap and broken...

Yes totally.

> > +	for_each_action_of_desc(desc, action) {
> > +		action_ret = action->thread_fn(action->irq, action->dev_id);
> > +		if (!noirqdebug)
> > +			note_interrupt(desc, action_ret);
> 
> This is wrong. See how __handle_irq_event_percpu() does this. But no need
> to resend. See:
> 
> http://lkml.kernel.org/r/1488904098-5350-1-git-send-email-ckeepax@opensource.wolfsonmicro.com

Oh OK yeah makes sense, my patch is overwriting action_ret..

Thanks,

Tony

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web