Search code examples
clinux-kernellinux-device-driverinterrupt-handling

linux disable_irq() and local_irq_save()


I have a piece of code where there is:

disable_irq(irq_clk);
local_irq_save(flags);

I found that the disable_irq() disables a specific interrupt, on the other hand local_irq_save() disables all the interrupt.

So I wonder the meaning of the above code.


Solution

  • This makes sense, because interrupts are disabled at different levels.

    disable_irq(irq_clk);
    

    This code disables (masks) interrupt in interrupt controller. If you have disabled interrupt at this level, the interrupt wouldn't be passed to internal interrupt controller pipeline. It would not be prioritized, it would not be routed to the destination CPU.

    local_irq_save(flags);
    

    This code disables all interrupts at the level of CPU IRQ interface. Interrupts are passed to CPU IRQ interface after they have passed priority & routing pipeline of the interrupt controller and have been asserted to the CPU.