Re: Interrupt handling - Linux

From: Lee Jones
Date: Thu Nov 29 2012 - 06:18:46 EST


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@xxxxxxxxxxxxxxxxx
> > 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/