ipipe: Fix handling of level triggered IRQs
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
@@ -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
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
Signed-off-by Florian Bezdeka <[email protected]>---
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...
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.Signed-off-by Florian Bezdeka <[email protected]>--- kernel/irq/chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)kernel/irq/chip.c +0
-0
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
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.Signed-off-by Florian Bezdeka <[email protected]>--- kernel/irq/chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)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); }
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
-0void __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_irqwith 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
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.Signed-off-by Florian Bezdeka <[email protected]>--- kernel/irq/chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)kernel/irq/chip.c +0
-0kernel/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_irqwith hard-irqs on?To answer myself: E.g. Linux IRQ handling uses
ipipe_endcallbacks 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
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.Signed-off-by Florian Bezdeka <[email protected]>--- kernel/irq/chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)kernel/irq/chip.c +0
-0kernel/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_irqwith hard-irqs on?
Quoted 8 lines
Quoted 3 lines
To answer myself: E.g. Linux IRQ handling uses
ipipe_endcallbacks 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