I have a scenario where my driver needs to listen to two different interrupts from two different IRQ lines. Is it possible to register two different IRQs and install two different handlers for the single driver? What's the best way to achieve this?

P.S: This is Linux device driver and the both IRQs are not shared.

  • Could those who vote for off-topic please describe why they think it's off-topic? It's a perfectly valid Linux kernel question.
    – dirkt
    May 17 '17 at 11:07
  • I haven't voted, but kernel programming questions might be better moved to the programming site StackOverflow (which is what both closers so far have voted to do). U.S.E. leans more towards admins/users, even if this sometimes involves debugging the kernel code or trying to guess at the intention of its authors.
    – sourcejedi
    May 17 '17 at 11:50
  • "If your question is a programming question, requiring knowledge of programming languages other than unix shell scripting languages, ask on Stack Overflow." unix.stackexchange.com/help/on-topic
    – sourcejedi
    May 17 '17 at 11:53
  • @sourcejedi: But it's not a programming question. It doesn't involve a particular programming language, it's not a question about how to write something in a particular programming language, it's a question about how the Linux kernel works. That the Linux kernel happens to be written in C is not important for this question.
    – dirkt
    May 17 '17 at 14:45
  • @dirkt "What's the best way to achieve this?" = code.
    – sourcejedi
    May 17 '17 at 14:54

register two different IRQs and install two different handlers for the single driver

"It's just that easy". The answer to "is it possible" is "Yes".

Device interrupt rountines will not interrupt each other on the same CPU.

According to LDD3 (this is quite old now), a single interrupt routine could be assured that it did not run on multiple CPUs simultaneously. I'm not sure what was meant by this - I can't imagine it applies to timer interrupts.

In your driver, I would expect it to be possible for the different interrupt routines to run at the same time, on different CPUs.

However the typical "spin lock irqsave" to achieve mutual exclusion where necessary, should still work fine in this case.

You might want to double-check you have the NMI watchdog, and lockdep enabled on your test system :). The NMI watchdog will trigger if a cpu gets stuck spinning inside an interrupt routine.



This is totally possible. When registering an interrupt handler, the driver gives the kernel the address of a function to call when the interrupt triggers. A driver can set up as many interrupts as it wants, and all can point to the same service routine or they can all point to their own (or some other combination of things).

See this answer for a bit more detail on how interrupts are actually handled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.