Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For a shared interrupt line how do I find which interrupt handler to use?

For a shared interrupt line,I can have several interrupt handlers. The kernel will sequentially invoke all the handlers for that particular shared line. As far as I know, each handler, when invoked informs the kernel whether it was the correct handler to be invoked or not.

My questions is how is this determined,is there a way it checks a memory mapped register that tells status of a particular device or is there some other hardware mechanism ? How does the handler know that the corresponding device is indeed the one that issued the interrupt or not ?

Is this information relayed through the interrupt controller that is between the devices and the processor interrupt line ??

like image 477
hit.at.ro Avatar asked Jan 17 '13 02:01

hit.at.ro


People also ask

How do you register an interrupt handler on a shared IRQ line?

Installing a Shared HandlerShared interrupts are installed through request_irq just like nonshared ones, but there are two differences: The SA_SHIRQ bit must be specified in the flags argument when requesting the interrupt. The dev_id argument must be unique.

How kernel comes to know which device raised an interrupt when interrupt is shared?

The kernel will sequentially invoke all the handlers for that particular shared line. Exactly. Say Dev1 and Dev2 shares the IRQ10. When an interrupt is generated for IRQ10, all ISRs registered with this line will be invoked one by one.

What is interrupt specific handler?

Interrupt Handler Overview The job of the interrupt handler is to service the device and stop it from interrupting. Once the handler returns, the CPU resumes what it was doing before the interrupt occurred. The DDI/DKI provides interfaces for registering and servicing interrupts.

Can two devices share the same interrupt input line?

A device may nearly ground its interrupt line when it's not sending its interrupt, thus preventing any other device from using that interrupt wire. That's OK if only that device uses that interrupt. But if a second device tries to use the same interrupt line it can't do so.


1 Answers

The kernel will sequentially invoke all the handlers for that particular shared line.

Exactly. Say Dev1 and Dev2 shares the IRQ10. When an interrupt is generated for IRQ10, all ISRs registered with this line will be invoked one by one.

In our scenario, say Dev2 was the one that generated the interrupt. If Dev1's ISR is registered first, than its ISR (i.e Dev1's ISR) only called first. In that ISR, the interrupt status register will be verified for interrupt. If no interrupt bit is set (which is the case, cause Dev2 raised the interrupt) then we can confirm that interrupt was not generated by Dev1 - so Dev1's ISR should return to the kernel IRQ_NONE - which means:"I did not handled that interrupt", so on the kernel continues to the next ISR (i.e Dev2's ISR), which in turn, will indeed verify that its corresponding device generated the interrupt, thus, this handler should handle it and eventually return IRQ_HANDLED - which means:"I handled this one".

See the return values IRQ_NONE/IRQ_HANDLED for more information.

How does the handler know that the corresponding device issued the interrupt or not ?

By reading the Interrupt status register only.

Is this information relayed through the interrupt controller that is between the devices and the processor interrupt line ??

I'm not sure about this. But the OS will take care of calling ISRs based on the return values from ISR.

like image 184
Jeyaram Avatar answered Sep 29 '22 20:09

Jeyaram