Skip to contentSkip to conversation

genirq: bug on inconstent flags and flow handler

PATCH Superseded Florian Fainelli 3 participants 6 messages Jul 23, 2014 – Aug 27, 2014 IRQ

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 genirq: bug on inconstent flags and flow handler

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

 kernel/irq/chip.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/irq/chip.c +6 -1
index a2b28a2fd7b1..17a66b56cd96 100644
@@ -749,8 +749,13 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 		irqd_set(&desc->irq_data, IRQD_PER_CPU);
 	if (irq_settings_can_move_pcntxt(desc))
 		irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
-	if (irq_settings_is_level(desc))
+	if (irq_settings_is_level(desc)) {
+		/* Setting IRQD_LEVEL does not make sense on non-level
+		 * sensitive interrupts
+		 */
+		BUG_ON(desc->handle_irq != handle_level_irq);
 		irqd_set(&desc->irq_data, IRQD_LEVEL);
+	}
 
 	irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Florian Fainelli

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

I disagree here. It's not a reason take the machine down. Its good enough to WARN. That keeps the machine alive and lets us debug that stuff.

Lemme find V1 ....

Quoted 26 lines
 kernel/irq/chip.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/irq/chip.c +6 -1
index a2b28a2fd7b1..17a66b56cd96 100644
@@ -749,8 +749,13 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 		irqd_set(&desc->irq_data, IRQD_PER_CPU);
 	if (irq_settings_can_move_pcntxt(desc))
 		irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
-	if (irq_settings_is_level(desc))
+	if (irq_settings_is_level(desc)) {
+		/* Setting IRQD_LEVEL does not make sense on non-level
+		 * sensitive interrupts
+		 */
+		BUG_ON(desc->handle_irq != handle_level_irq);
 		irqd_set(&desc->irq_data, IRQD_LEVEL);
+	}
 
 	irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
 
Signature · 1 line
1.9.1
#2 lore raw

2014-07-23 11:49 GMT-07:00 Thomas Gleixner <[email protected]>:

Quoted 13 lines · Florian Fainelli
Quoted 11 lines

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

Quoted 3 lines

I disagree here. It's not a reason take the machine down. Its good enough to WARN. That keeps the machine alive and lets us debug that stuff.

Works for me!

Quoted 2 lines

Lemme find V1 ....

Here it is: https://lkml.org/lkml/2014/7/1/468

Quoted 28 lines
Quoted 28 lines

 kernel/irq/chip.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/irq/chip.c +6 -2
index a2b28a2fd7b1..17a66b56cd96 100644
@@ -749,8 +749,13 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
              irqd_set(&desc->irq_data, IRQD_PER_CPU);
      if (irq_settings_can_move_pcntxt(desc))
              irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT);
-     if (irq_settings_is_level(desc))
+     if (irq_settings_is_level(desc)) {
+             /* Setting IRQD_LEVEL does not make sense on non-level
+              * sensitive interrupts
+              */
+             BUG_ON(desc->handle_irq != handle_level_irq);
              irqd_set(&desc->irq_data, IRQD_LEVEL);
+     }
 
      irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
 
--

1.9.1

Signature · 1 line
Florian
#3 lore raw
Quoted 18 lines · Florian Fainelli

2014-07-23 11:49 GMT-07:00 Thomas Gleixner <[email protected]>:

Quoted 13 lines · Florian Fainelli
Quoted 11 lines

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

Quoted 3 lines

I disagree here. It's not a reason take the machine down. Its good enough to WARN. That keeps the machine alive and lets us debug that stuff.

Quoted 6 lines

Works for me!

Quoted 2 lines

Lemme find V1 ....

Here it is: https://lkml.org/lkml/2014/7/1/468

Thomas, do you want me to resubmit that change so you get a clean submission in your inbox? Thanks
--
Florian

#4 lore raw
Quoted 22 lines · Florian Fainelli
Quoted 21 lines · Florian Fainelli

2014-07-23 11:49 GMT-07:00 Thomas Gleixner <[email protected]>:

Quoted 13 lines · Florian Fainelli
Quoted 11 lines

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

Quoted 3 lines

I disagree here. It's not a reason take the machine down. Its good enough to WARN. That keeps the machine alive and lets us debug that stuff.

Works for me!

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Lemme find V1 ....

Here it is: https://lkml.org/lkml/2014/7/1/468

Thomas, do you want me to resubmit that change so you get a clean submission in your inbox? Thanks

Yes please

#5 lore raw
In reply to Thomas Gleixner
Quoted 13 lines · Thomas Gleixner
Quoted 10 lines · Florian Fainelli

It is currently possible for a generic irq chip driver to set IRQ_LEVEL and have its irq flow handler be handle_edge_irq. Setting IRQ_LEVEL in such a case does not make sense, and will actually prevent e.g: the software resend logic from kicking, and potential other problems too.

---
Changes in v2:
- replaced WARN_ON() with BUG_ON() since we really don't want to continue as suggested by Jason Cooper

Quoted 3 lines

I disagree here. It's not a reason take the machine down. Its good enough to WARN. That keeps the machine alive and lets us debug that stuff.

Sure, I have no strong opinion either way. On irc I mentioned that this condition would most likely only arise when porting to a new SoC, so a kernel developer that will know what to do.

I know for me personally, I need to be stopped mid-track and forced to pay attention to something like this. Otherwise, I'll forget and debug for hours... :-)

thx,

Jason.