前言
从分析三可知,中断处理最终调用了irqaction的handler(interrupt context),在必要的情况下唤醒中断处理线程调用thread_fn(process context)。
对应的中断服务例程是在驱动初始化阶段,普通中断通过setup_irq、request_irq或者request_threaded_irq进行申请,percpu中断通过request_percpu_irq、setup_percpu_irq,本篇主要对这上接口进行分析,__setup_irq放在kernel 中断分析之四——中断申请[下]中分析。
request_threaded_irq
关于中断线程化的目的和对系统performance的提升,可以看这篇文章Moving interrupts to threads(翻译)。
1349 /**
1350 * request_threaded_irq - allocate an interrupt line
1351 * @irq: Interrupt line to allocate
1352 * @handler: Function to be called when the IRQ occurs.
1353 * Primary handler for threaded interrupts
1354 * If NULL and thread_fn != NULL the default
1355 * primary handler is installed
1356 * @thread_fn: Function called from the irq handler thread
1357 * If NULL, no irq thread is created
1358 * @irqflags: Interrupt type flags
1359 * @devname: An ascii name for the claiming device
1360 * @dev_id: A cookie passed back to the handler function
1361 *
1362 * This call allocates interrupt resources and enables the
1363 * interrupt line and IRQ handling. From the point this
1364 * call is made your handler function may be invoked. Since
1365 * your handler function must clear any interrupt the board
1366 * raises, you must take care both to initialise your hardware
1367 * and to set up the interrupt handler in the right order.
1368 *
1369 * If you want to set up a threaded irq handler for your device
1370 * then you need to supply @handler and @thread_fn. @handler is
1371 * still called in hard interrupt context and has to check
1372 * whether the interrupt originates from the device. If yes it
1373 * needs to disable the interrupt on the device and