* Re: Interrupt handling - Linux [not found] <CAB6A5-AN7boq57w7z+x6bhO3mYsbHzyD6cAkq1BXN5a+B=2XyQ@mail.gmail.com> @ 2012-11-29 10:15 ` anish kumar 2012-11-29 11:18 ` Lee Jones 0 siblings, 1 reply; 2+ messages in thread From: anish kumar @ 2012-11-29 10:15 UTC (permalink / raw) To: manty kuma Cc: kernelnewbies, Linus Walleij, linux-kernel, Thomas Gleixner, Rob Herring, Paul Mundt, Russell King, Linus Walleij, Lee Jones, Anmar Oueja On Wed, 2012-11-28 at 20:10 +0530, manty kuma wrote: > In linux interrupt programming, we do request_irq(...) in this > function, the first argument is irq number. If i am not wrong, this is > the interrupt line that we are requesting from kernel. For one Right. > particular hardware, is this IRQ line fixed or can it register on any > line based on the availability? The concept is not clear. Kindly In linux there are two concepts related to interrupt which is never clearly mentioned anywhere(at least not that I know of) and that is why let me clarify. 1. Hardware interrupt number.Given by your irq controller or the hardware which is capable of generating the interrupts. 2. Software interrupt number assigned by linux interrupt handling core. So the first question which arises in mind is: why does linux generates the software interrupt number?Won't hardware interrupt number be enough to keep everyone happy? Simple reason is just for book keeping as the software interrupt numbers generated would be linear as we are in control of what numbers to allocate and if we start using the numbers generated by irq controller which can generate random numbers then searching and indexing would require expensive operations as compared to working in linear domain(experts can add more here if I am not to the point). However if your irq controller is capable of choosing the interrupt numbers then linux irq number will be same as hardware interrupt number. So let's come back to the question.So for a particular hardware the hardware interrupt line would be always fixed as well as the software interrupt numbers generated by the linux irq core. > explain. Also, when i do interrupt programming for AVR or ARM, all > the peripherals are having fixed IRQ numbers. and they are having > handlers. There is no concept of interrupt lines as such. So my > second question is how are IRQ lines and IRQ numbers related? IRQ lines are connected to irq controller and you should have a look at the driver of your irq controller as to how does it assign the hardware irq numbers(probably by reading some registers).All the peripherals are connected to the irq controller such as keyboard and mouse and they have fixed irq lines.Once a signal is asserted the irq controller raises an interrupt to arm core and arm core in turn raises a hardware interrupt.This hardware interrupt will call into linux irq handling code.Which interrupt handler to be called is already decided by the individual drivers, remember they have called request_irq with an interrupt number. This interrupt number would be a software interrupt number as explained before and this number to hardware interrupt number association is done by the interrupt controller or the chip driver which is capable of taking(handling) one interrupt and calling individual interrupt handlers after reading the corresponding registers(read handle_nested_irq). This conversion of hardware interrupt number to software interrupt number is done in /kernel/irq/irqdomain.c file. PS:I may be wrong but this description is from what I have read in the code.Please do point out any mistakes. > > > Thanks, > Sandeep > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Interrupt handling - Linux 2012-11-29 10:15 ` Interrupt handling - Linux anish kumar @ 2012-11-29 11:18 ` Lee Jones 0 siblings, 0 replies; 2+ messages in thread From: Lee Jones @ 2012-11-29 11:18 UTC (permalink / raw) To: anish kumar Cc: manty kuma, kernelnewbies, Linus Walleij, linux-kernel, Thomas Gleixner, Rob Herring, Paul Mundt, Russell King, Linus Walleij, Anmar Oueja On Thu, 29 Nov 2012, anish kumar wrote: > On Wed, 2012-11-28 at 20:10 +0530, manty kuma wrote: > > In linux interrupt programming, we do request_irq(...) in this > > function, the first argument is irq number. If i am not wrong, this is > > the interrupt line that we are requesting from kernel. For one > Right. > > particular hardware, is this IRQ line fixed or can it register on any > > line based on the availability? The concept is not clear. Kindly > In linux there are two concepts related to interrupt which is never > clearly mentioned anywhere(at least not that I know of) and that is why > let me clarify. Documentation/IRQ-domain.txt > 1. Hardware interrupt number.Given by your irq controller or the > hardware which is capable of generating the interrupts. > 2. Software interrupt number assigned by linux interrupt handling core. > > So the first question which arises in mind is: why does linux generates > the software interrupt number?Won't hardware interrupt number be enough > to keep everyone happy? > > Simple reason is just for book keeping as the software interrupt numbers > generated would be linear as we are in control of what numbers to > allocate and if we start using the numbers generated by irq controller > which can generate random numbers then searching and indexing would > require expensive operations as compared to working in linear > domain(experts can add more here if I am not to the point). > > However if your irq controller is capable of choosing the interrupt > numbers then linux irq number will be same as hardware interrupt number. > > So let's come back to the question.So for a particular hardware the > hardware interrupt line would be always fixed as well as the software > interrupt numbers generated by the linux irq core. > > > explain. Also, when i do interrupt programming for AVR or ARM, all > > the peripherals are having fixed IRQ numbers. and they are having > > handlers. There is no concept of interrupt lines as such. So my > > second question is how are IRQ lines and IRQ numbers related? > IRQ lines are connected to irq controller and you should have a look at > the driver of your irq controller as to how does it assign the hardware > irq numbers(probably by reading some registers).All the peripherals are > connected to the irq controller such as keyboard and mouse and they have > fixed irq lines.Once a signal is asserted the irq controller raises an > interrupt to arm core and arm core in turn raises a hardware > interrupt.This hardware interrupt will call into linux irq handling > code.Which interrupt handler to be called is already decided by the > individual drivers, remember they have called request_irq with an > interrupt number. > This interrupt number would be a software interrupt number as explained > before and this number to hardware interrupt number association is done > by the interrupt controller or the chip driver which is capable of > taking(handling) one interrupt and calling individual interrupt handlers > after reading the corresponding registers(read handle_nested_irq). > This conversion of hardware interrupt number to software interrupt > number is done in /kernel/irq/irqdomain.c file. > > PS:I may be wrong but this description is from what I have read in the > code.Please do point out any mistakes. > > > > > > Thanks, > > Sandeep > > _______________________________________________ > > Kernelnewbies mailing list > > Kernelnewbies@kernelnewbies.org > > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -- Lee Jones Linaro ST-Ericsson Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-29 11:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAB6A5-AN7boq57w7z+x6bhO3mYsbHzyD6cAkq1BXN5a+B=2XyQ@mail.gmail.com>
2012-11-29 10:15 ` Interrupt handling - Linux anish kumar
2012-11-29 11:18 ` Lee Jones
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox