Day79 - IRQ Subsystem Fundamentals¶
Objective¶
Understand the architecture of the Linux Generic IRQ Subsystem and how interrupts are dispatched from IRQ controllers to driver interrupt service routines.
This lab extends the GPIO IRQ simulation framework introduced in Day78.
Lab1 - irq_desc and irq_action¶
Goal¶
Separate interrupt handler information from irq_desc.
Before Day79:
After Day79:
irq_action¶
Represents a driver registered interrupt handler.
irq_desc¶
Represents a Linux IRQ descriptor.
request_irq()¶
Registers a new interrupt action.
Responsibilities:
- Allocate irq_action
- Store ISR information
- Attach action to irq_desc
free_irq()¶
Removes the registered action.
Responsibilities:
- Locate matching action
- Release action memory
- Clear irq_desc ownership
Lab2 - IRQ Dispatch Flow¶
Goal¶
Introduce a Generic IRQ dispatch layer.
Instead of calling ISR directly:
use:
irq_dispatch()¶
Responsibilities:
- Validate descriptor
- Locate irq_action
- Invoke ISR
Test¶
Trigger IRQ twice.
Expected output:
[TRIGGER] irq=100
[DISPATCH] irq=100 (button)
[ISR] irq=100 count=1
[TRIGGER] irq=100
[DISPATCH] irq=100 (button)
[ISR] irq=100 count=2
Lab3 - irq_chip Simulation¶
Goal¶
Introduce IRQ controller abstraction.
Linux drivers do not communicate directly with hardware interrupt controllers.
Linux uses:
to abstract controller-specific operations.
irq_chip¶
ACK and EOI¶
Acknowledge interrupt:
End of interrupt:
Simulation:
Updated Dispatch Flow¶
Test¶
Expected output:
[TRIGGER] irq=100
[DISPATCH] irq=100 (button)
[CHIP] ack irq=100
[ISR] irq=100 count=1
[CHIP] eoi irq=100
Lab4 - irqreturn_t¶
Goal¶
Understand Linux interrupt handler return values.
irqreturn_t¶
IRQ_NONE¶
Interrupt does not belong to this handler.
Output:
IRQ_HANDLED¶
Interrupt successfully handled.
Output:
IRQ_WAKE_THREAD¶
Used by threaded IRQs.
Will be used in Day80.
Final Architecture¶
After completing all labs:
Key Learning Points¶
Linux IRQ Layering¶
Linux separates:
- IRQ controller operations
- IRQ descriptor management
- Driver interrupt handlers
This improves portability and scalability.
Generic IRQ Dispatch¶
Interrupt dispatch is managed by the Generic IRQ Subsystem.
Interrupt Result Reporting¶
ISRs communicate handling results through:
rather than traditional error codes.
Preparation for Day80¶
The current framework will be extended with:
in the next lesson.