Understanding of interrupt handle_level_irq [original]

 The following is my original creation, a little experience in the process of solving the problem, if there is any inaccurate description, please point out, thank you very much

Linux kernel version: linux-4.9.18

I once encountered the following problems when debugging the touch screen

/startup/modules #
 [  233.370296] irq 44: nobody cared (try booting with the "irqpoll" option)
[  233.376983] CPU: 0 PID: 0 Comm: swapper Tainted: G           O    4.9.18 #8
[  233.383912] Hardware name: Broadcom Cygnus SoC
[  233.388378] [<c010cbfc>] (unwind_backtrace) from [<c010a5fc>] (show_stack+0x10/0x14)
[  233.396103] [<c010a5fc>] (show_stack) from [<c0145d38>] (__report_bad_irq+0x24/0xa4)
[  233.403821] 
[<c0145d38>] (__report_bad_irq) from [<c0145fdc>] (note_interrupt+0x1c8/0x274)
[  233.412052] 
[<c0145fdc>] (note_interrupt) from [<c014400c>] (handle_irq_event_percpu+0x44/0x50)
[  233.420715] 
[<c014400c>] (handle_irq_event_percpu) from [<c0144040>] (handle_irq_event+0x28/0x3c)
[  233.429550] 
[<c0144040>] (handle_irq_event) from [<c0146574>] (handle_simple_irq+0x70/0x78)
[  233.437868] 
[<c0146574>] (handle_simple_irq) from [<c01438d8>] (generic_handle_irq+0x18/0x28)
[  233.446366] 
[<c01438d8>] (generic_handle_irq) from [<c02adb3c>] (iproc_gpio_irq_handler+0xd0/0x11c)
[  233.455376] 
[<c02adb3c>] (iproc_gpio_irq_handler) from [<c01438d8>] (generic_handle_irq+0x18/0x28)
[  233.464297] 
[<c01438d8>] (generic_handle_irq) from [<c0143980>] (__handle_domain_irq+0x80/0xa4)
[  233.472959] 
[<c0143980>] (__handle_domain_irq) from [<c01013d0>] (gic_handle_irq+0x50/0x84)
[  233.481275] [<c01013d0>] (gic_handle_irq) from [<c010b02c>] (__irq_svc+0x6c/0x90)
[  233.488723] Exception stack(0xc0901f60 to 0xc0901fa8)
[  233.493754] 1f60: c0112900 c0717028 c0901fb8 00000000 c093af4c 00000000 00000335 c0826220
[  233.501896] 1f80: 00000001 414fc091 df9eab80 00000000 c0900038 c0901fb0 c010843c c0108440
[  233.510034] 1fa0: 60000013 ffffffff
[  233.513514] [<c010b02c>] (__irq_svc) from [<c0108440>] (arch_cpu_idle+0x2c/0x38)
[  233.520887] [<c0108440>] (arch_cpu_idle) from [<c013a6ec>] (cpu_startup_entry+0x50/0xc0)
[  233.528956] [<c013a6ec>] (cpu_startup_entry) from [<c0800d70>] (start_kernel+0x414/0x4b0)
[  233.537097] handlers:
[  233.539363] 
[<c014408c>] irq_default_primary_handler threaded [<bf03ff68>] synaptics_rmi4_irq [synaptics_dsx]
[  233.549300] Disabling IRQ #44

First, let's take a look at the error tracking linux kernel

kernel/irq/spurious.c

Therefore, it can be seen from the log information with prompts that it is the branch of the else going, and bad_action_ret (action_ret) returns to 0

Through the information of the dump_stack of this function, it can be traced back to the caller

 

drivers/pinctrl/bcm/pinctrl-iproc-gpio.c

 

 

kernel/irq/chip.c

handle_level_irq

===> handle_irq_event  (kernel/irq/handle.c)

===> handle_irq_event_percpu   (kernel/irq/handle.c)

===>__handle_irq_event_percpu  (kernel/irq/handle.c)

 

According to the log, we can see note_interrupt in the figure below , which means noirqdebug=0

Kernel/irq/handle.c

 

Because we have analyzed above that bad_action_ret(action_ret) returns to 0

Therefore, in the note_interrupt function, it will only branch from the following

Kernel/irq/spurious.c

As can be seen from the above figure, if you want to have such an error, you must meet the conditions

desc->irqs_unhandled > 99900 is true

If you want to meet the above conditions, then only the following places will make irqs_unhandled++

Kernel/irq/spurious.c

From the above figure, we can see that the conditions must be met:

action_ret == IRQ_NONE is true

Continue to look back at the following figure, action_ret is retval

 

res is action_ret

And the callback function of action->handler is :

The second parameter of request_threaded_irq threaded registration interrupt

 

kernel/irq/manage.c

Because handler is NULL, handler = irq_default_primary_handler

 

action_ret = IRQ_WAKE_THREAD

Kernel/irq/spurious.c

 

After the above picture, we can find that action_ret = IRQ_NONE

 

So let's take a look at how it is called here, and what is the generation of an interrupt?

First , the handle_level_irq function is registered in the kernel here

drivers/pinctrl/bcm/pinctrl-iproc-gpio.c

static int iproc_gpio_probe(struct platform_device *pdev)

===> gpiochip_irqchip_add

Include/linux/gpio/driver.h

typedef    void (*irq_flow_handler_t)(struct irq_desc *desc);

Here is gpiochip->irq_handler = handle_level_irq

struct irqaction *action

 

when an interrupt starts

arch/arm/kernel/entry-armv.S

There is a global handle_arch_irq

 

This global handle_arch_irq will be assigned in the following places

arch/arm/kernel/setup.c

void __init setup_arch(char **cmdline_p)

===> handle_arch_irq is assigned

Then we need to find out where mdesc->handle_irq is assigned?

 

drivers/irqchip/irq-gic.c

Here is the function set_handle_irq like this

 

Next, let's take a look at the implementation of this function.

arch/arm/kernel/irq.c

 

So where is this set_handle_irq called?

For kernel version Linux-4.9.18

drivers/irqchip/irq-gic.c

gic_of_init

===>__gic_init_bases

===>set_handle_irq

Include / linux / irqchip.h

Include/linux/of.h

 

Include/linux/of.h

So we come to a conclusion:

handle_arch_irq = gic_handle_irq

After an interrupt starts, enter from entry-armv.S

 

handle_domain_irq

===> __handle_domain_irq

===>generic_handle_irq

===>generic_handle_irq_desc

 

The desc->handle_irq here is actually handle_level_irq

Here is how to convert the past?

drivers/pinctrl/bcm/pinctrl-iproc-gpio.c

gpiochip_set_chained_irqchip

===> irq_set_chained_handler_and_data

===> __irq_do_set_handler

Kernel/irq/chip.c

 

Kernel/irq/manage.c

Irq_thread

 

The purpose of this function is to check if there is any interrupt nesting

 

 

 

 

refer to:

http://www.wowotech.net/irq_subsystem/request_threaded_irq.html

http://www.wowotech.net/linux_kenrel/interrupt_descriptor.html

https://blog.csdn.net/tiantao2012/article/details/78062621

https://blog.csdn.net/tiantao2012/article/details/78094691

https://blog.csdn.net/zhao2272062978/article/details/70599978

https://blog.csdn.net/droidphone/article/details/7467436

https://blog.csdn.net/droidphone/article/details/7445825

https://blog.csdn.net/droidphone/article/category/1118447

https://blog.csdn.net/phenix_lord/article/details/45116259

https://blog.csdn.net/phenix_lord/article/details/45116595

https://blog.csdn.net/phenix_lord/article/details/45116689

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324666360&siteId=291194637