LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Doubt in IRQ handling of kernel (https://www.linuxquestions.org/questions/linux-kernel-70/doubt-in-irq-handling-of-kernel-4175661097/)

ayyasprings 09-18-2019 11:22 AM

Doubt in IRQ handling of kernel
 
Hi,

In IRQ flow of ARM architecture for example, when interrupt was triggered, in the architecture specific assembly file the Program Counter register was assigned the address of handle_arch_irq function, which in turn was assigned the function pointer "mdesc->handle_irq".


The handle_irq function pointer is declared in struct machine_desc. In that structure declaration, handle_irq function pointer has argument as struct pt_regs, whose definition is

Code:

struct pt_regs {
        unsigned long uregs[18];
};


But in the generic IRQ handling source code we don't have any handle_irq function having the struct pt_regs as argument.


Also in

https://www.kernel.org/doc/html/late...enericirq.html

it was mentioned as Whenever an interrupt triggers, the low-level architecture code calls into the generic interrupt code by calling desc->handle_irq().


But that generic interrupt code has two arguments irq number and struct irq_desc.

My doubt is will the struct pt_regs argument in architecture specific function pointer handle_irq smoothly type casted to the arguments of generic interrupt code handle_irq function pointer's 2 argument?

I got this doubt because I could not find exact match of function prototype between architecture specific function pointer and generic interrupt handling function pointer and as internally the arguments of generic code will be passed into the stack space which can be accommodated with struct pt_regs as it has just array of unsigned long.


Please reply whether my mapping is correct, if not what is the real logic?


Thanks,
Ayyappan M.

ayyasprings 09-19-2019 06:28 AM

I got it after code walkthrough.

the architecture specific mdesc->handle_irq function calls board specific function assigned to that.
which in turn calls handle_IRQ() which receives irq number as one of the argument, and that argument is passed to generic_handle_irq function if it was a valid interrupt which in turn extracts the irq_desc structure value based on the irq number which was populated either in bootup or driver initialization. And corresponding desc->handle_irq() of generic interrupt handling code, will be called with arguments irq number and struct irq_desc extracted.

syg00 09-19-2019 06:47 AM

Beyond me, but appreciate the update.


All times are GMT -5. The time now is 12:44 AM.