Linux IRQ Subsystem Fundamentals¶
The Linux IRQ subsystem provides a generic interrupt handling framework that separates hardware interrupt controllers from driver interrupt handlers.
This abstraction allows the same driver model to work across different CPU architectures and interrupt controller implementations.
IRQ Architecture Overview¶
A hardware interrupt passes through multiple software layers before reaching a driver ISR.
Linux refers to this architecture as the Generic IRQ Subsystem.
IRQ Controller¶
An IRQ controller is hardware responsible for delivering interrupts to CPUs.
Examples:
- ARM GIC
- RISC-V PLIC
- x86 APIC
- GPIO Interrupt Controllers
Responsibilities:
- Detect interrupt requests
- Route interrupts to CPUs
- Manage interrupt priorities
- Acknowledge interrupt completion
irq_chip¶
Linux abstracts interrupt controller operations through irq_chip.
Simplified model:
Responsibilities:
- IRQ acknowledge
- IRQ masking
- IRQ unmasking
- End-of-interrupt notification
The driver does not directly communicate with interrupt controller hardware.
Instead:
irq_desc¶
Each Linux IRQ is represented by an IRQ descriptor.
Simplified model:
struct irq_desc {
int irq;
enum irq_trigger_type trigger;
struct irq_chip *chip;
struct irq_action *action;
};
Responsibilities:
- Store IRQ metadata
- Associate IRQ controller
- Track registered handlers
- Manage IRQ state
Conceptually:
irq_action¶
An irq_action represents a registered interrupt handler.
Simplified model:
Responsibilities:
- Store ISR callback
- Store driver private data
- Associate handler name
Conceptually:
IRQ Registration Flow¶
Driver registration:
Conceptually:
Result:
IRQ Dispatch Flow¶
When an interrupt occurs:
A simplified dispatch sequence:
irqreturn_t¶
Linux interrupt handlers return irqreturn_t.
IRQ_NONE¶
The interrupt does not belong to the current handler.
Typically used with shared IRQs.
IRQ_HANDLED¶
The interrupt was successfully processed.
Most common return value.
IRQ_WAKE_THREAD¶
Request execution of a threaded interrupt handler.
Used with:
IRQ Context¶
Interrupt handlers execute in IRQ context.
Characteristics:
- Preempt normal execution
- Execute with strict timing requirements
- Must not sleep
Not allowed:
Typical ISR work:
IRQ Context vs Process Context¶
| Property | IRQ Context | Process Context |
|---|---|---|
| Can sleep | No | Yes |
| Can use mutex | No | Yes |
| Can call msleep | No | Yes |
| Interrupt latency sensitive | Yes | No |
| Typical users | ISR | Workqueue, kthread, system calls |
Shared IRQ Concept¶
Multiple devices may share the same Linux IRQ.
Conceptually:
Linux manages this through multiple irq_action objects attached to a single IRQ descriptor.
This topic is typically encountered together with:
- IRQ_NONE
- request_threaded_irq()
- Shared IRQ handling
Relationship to Bottom Half¶
Linux interrupt processing is divided into:
Top Half:
Bottom Half:
The Generic IRQ Subsystem provides the foundation for deferred interrupt processing.
This leads naturally to:
- Workqueue-based interrupt handling
- Threaded IRQs
- request_threaded_irq()
which are common patterns in Linux device drivers.