in linux kernel development,i read about interrupt that when the kernel receives interrupt,it invokes sequentially each registered handler on the line.
My question is why kernel invokes other handler?
2 Answers
This is because several devices are sharing the same interrupt line. The only way the kernel can detect which handler to invoke is by passing the dev_id
of the device to all the handlers which requires invoking the handler. The handler that was registered with the passed dev_id
gets a match and it continues to run.
Remember, the handler was registered as:
static irqreturn_t intr_handler(int irq, void *dev_id, struct pt_regs *regs)
the handler was registered by passing the dev_id
. So, that's the only thing that distinguishes devices on the same IRQ line.
In a well define interrupt handler, specifically share the irq line, which will check whether the interrupt is raised by the specific device by reading some registers, and if it is, then handles the interrupt and return IRQ_HANDLED
, or return IRQ_NONE
to indicate that is not the device the handler servicing.
So, it invokes sequentially each registered handler on the line until that the handler return IRQ_HANDLED
meaning processing properly