Skip to content

Commit b4706d8

Browse files
Eliav FarberKAGA-KOKO
authored andcommitted
genirq/kexec: Prevent redundant IRQ masking by checking state before shutdown
During machine kexec, machine_kexec_mask_interrupts() is responsible for disabling or masking all interrupts. While the irq_disable() is only invoked when the interrupt is not yet disabled, it unconditionally invokes the irq_mask() callback for every interrupt descriptor, even when the interrupt is already masked or not even started up yet. A specific issue was observed in the crash kernel flow after unbinding a device (prior to kexec) that used a GPIO as an IRQ source. The warning was triggered by the gpiochip_disable_irq() function, which attempts to clear the FLAG_IRQ_IS_ENABLED flag when FLAG_USED_AS_IRQ was not set. This issue surfaced after commit a817382 ("gpio: gpiolib: Allow GPIO IRQs to lazy disable") introduced lazy disablement for GPIO IRQs. It replaced disable/enable hooks with mask/unmask hooks. Unlike the disable hook, the mask hook doesn't handle already-masked IRQs. When a GPIO-IRQ driver is unbound, the IRQ is released, triggering __irq_disable() and irq_state_set_masked(). A subsequent call to machine_kexec_mask_interrupts() re-invokes chip->irq_mask(). This results in a call chain, including gpiochip_irq_mask() and gpiochip_disable_irq(). Since FLAG_USED_AS_IRQ was cleared earlier, the warning is triggered. Replace the direct invocation of the irq_mask() and irq_disable() callbacks invoking to irq_shutdown(), which handles the cases correct and avoid it all together when the interrupt has never been started up. Signed-off-by: Eliav Farber <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent bad6722 commit b4706d8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

kernel/irq/kexec.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void machine_kexec_mask_interrupts(void)
1717
int check_eoi = 1;
1818

1919
chip = irq_desc_get_chip(desc);
20-
if (!chip)
20+
if (!chip || !irqd_is_started(&desc->irq_data))
2121
continue;
2222

2323
if (IS_ENABLED(CONFIG_GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD)) {
@@ -31,10 +31,6 @@ void machine_kexec_mask_interrupts(void)
3131
if (check_eoi && chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
3232
chip->irq_eoi(&desc->irq_data);
3333

34-
if (chip->irq_mask)
35-
chip->irq_mask(&desc->irq_data);
36-
37-
if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
38-
chip->irq_disable(&desc->irq_data);
34+
irq_shutdown(desc);
3935
}
4036
}

0 commit comments

Comments
 (0)