Skip to contentSkip to conversation

ipipe: Fix handling of level triggered IRQs

PATCH In review Florian Bezdeka 2 participants 6 messages Nov 28, 2022 – Nov 29, 2022 IRQ

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipipe: Fix handling of level triggered IRQs

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

---
 kernel/irq/chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/chip.c +1 -2
index 41415a5ef7d0..6b34403858aa 100644
@@ -990,8 +990,7 @@ void __ipipe_ack_level_irq(struct irq_desc *desc)
 
 void __ipipe_end_level_irq(struct irq_desc *desc)
 {
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	irq_state_clr_masked(desc);
+	unmask_irq(desc);
 }
 
 void __ipipe_ack_fasteoi_irq(struct irq_desc *desc)
Signature · 1 line
2.35.1
#1 lore raw
Quoted 14 lines · Florian Bezdeka

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

Quoted 3 lines

---

Just to be clear: The issue with reporting spurious interrupts with printk() persists. This is step 1 for fixing level triggered IRQs again. I have no good idea for step 2 (spurious interrupts) yet. Maybe the solution is "do not call printk()" in HW irq context.

Step 3 (already on my list): Dealing with UART throttling that has been backported to recent stable trees. So I'm facing different "ipipe does not boot" problems at the same time...

#2 lore raw
In reply to Florian Bezdeka
Quoted 25 lines · Florian Bezdeka

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

---
 kernel/irq/chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/chip.c +0 -0
index 41415a5ef7d0..6b34403858aa 100644

kernel/irq/chip.c void __ipipe_ack_level_irq(struct irq_desc *desc) · line 996

Quoted 9 lines
kernel/irq/chip.c +1 -2
@@ -990,8 +990,7 @@ void __ipipe_ack_level_irq(struct irq_desc *desc)
 
 void __ipipe_end_level_irq(struct irq_desc *desc)
 {
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	irq_state_clr_masked(desc);
+	unmask_irq(desc);
 }
 
 void __ipipe_ack_fasteoi_irq(struct irq_desc *desc)

Ok, this is part of the answer to my other question.

Can you also document a code path that enters __ipipe_end_level_irq with hard-irqs on?

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#3 lore raw
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Florian Bezdeka

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

---
 kernel/irq/chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/chip.c +1 -2
index 41415a5ef7d0..6b34403858aa 100644
@@ -990,8 +990,7 @@ void __ipipe_ack_level_irq(struct irq_desc *desc)
 
 void __ipipe_end_level_irq(struct irq_desc *desc)
 {
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	irq_state_clr_masked(desc);
+	unmask_irq(desc);
 }
 
Quoted 7 lines

kernel/irq/chip.c void __ipipe_ack_level_irq(struct irq_desc *desc) · line 996

Quoted 1 line
kernel/irq/chip.c +0 -0
 void __ipipe_ack_fasteoi_irq(struct irq_desc *desc)

Ok, this is part of the answer to my other question.

Can you also document a code path that enters __ipipe_end_level_irq with hard-irqs on?

To answer myself: E.g. Linux IRQ handling uses ipipe_end callbacks like this, and then obviously without hard IRQs off. I'll augment the patch explanation.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#4 lore raw
Quoted 39 lines · Jan Kiszka
Quoted 38 lines · Jan Kiszka
Quoted 25 lines · Florian Bezdeka

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

---
 kernel/irq/chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/chip.c +0 -0
index 41415a5ef7d0..6b34403858aa 100644

kernel/irq/chip.c void __ipipe_ack_level_irq(struct irq_desc *desc) · line 996

Quoted 9 lines
kernel/irq/chip.c +1 -2
@@ -990,8 +990,7 @@ void __ipipe_ack_level_irq(struct irq_desc *desc)
 
 void __ipipe_end_level_irq(struct irq_desc *desc)
 {
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	irq_state_clr_masked(desc);
+	unmask_irq(desc);
 }
 
 void __ipipe_ack_fasteoi_irq(struct irq_desc *desc)

Ok, this is part of the answer to my other question.

Quoted 7 lines
Quoted 3 lines

Can you also document a code path that enters __ipipe_end_level_irq with hard-irqs on?

To answer myself: E.g. Linux IRQ handling uses ipipe_end callbacks like this, and then obviously without hard IRQs off. I'll augment the patch explanation.

Exactly. Who is responsible for applying the patch to all the different arch trees that we have? If you need a v2 to make the process easier, just post your adjustments. I will happily take them and send v2.

Florian

Quoted 3 lines

Jan

#5 lore raw
Quoted 44 lines · Florian Bezdeka
Quoted 43 lines · Jan Kiszka
Quoted 41 lines · Jan Kiszka
Quoted 25 lines · Florian Bezdeka

Hardware IRQs are enabled here! It might happen that right after enabling the IRQ at hardware level the IRQ comes in again, even before we could fix the software IRQ state flag.

The result was a IRQ storm and system freeze because the same IRQ was not properly masked at hw level during next IRQ arrival. The software IRQ flag is checked before going down to the HW level.

Switching to unmask_irq() has two effects:
- We do not have to care about the software IRQ state flag anymore
- IRQ state is updated in a hwirq off section together with the hw state, so the software state flag and hw state should no longer diverge.

---
 kernel/irq/chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/chip.c +0 -0
index 41415a5ef7d0..6b34403858aa 100644

kernel/irq/chip.c void __ipipe_ack_level_irq(struct irq_desc *desc) · line 996

Quoted 9 lines
kernel/irq/chip.c +1 -2
@@ -990,8 +990,7 @@ void __ipipe_ack_level_irq(struct irq_desc *desc)
 
 void __ipipe_end_level_irq(struct irq_desc *desc)
 {
-	desc->irq_data.chip->irq_unmask(&desc->irq_data);
-	irq_state_clr_masked(desc);
+	unmask_irq(desc);
 }
 
 void __ipipe_ack_fasteoi_irq(struct irq_desc *desc)

Ok, this is part of the answer to my other question.

Can you also document a code path that enters __ipipe_end_level_irq with hard-irqs on?

Quoted 8 lines
Quoted 3 lines

To answer myself: E.g. Linux IRQ handling uses ipipe_end callbacks like this, and then obviously without hard IRQs off. I'll augment the patch explanation.

Exactly. Who is responsible for applying the patch to all the different arch trees that we have? If you need a v2 to make the process easier, just post your adjustments. I will happily take them and send v2.

Already in ipipe-noarch and the x86 branches. Greg can pick from there for ARM/ARM64.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux