linux kernel 工程师
全部博文(99)
分类: LINUX
2014-02-08 16:14:33
handle_edge_irq,handle_level_irq等函数会调用handle_irq_event,我们来看一下它的流程
handle_irq_event->handle_irq_event_percpu->action->handler
irqreturn_t handle_irq_event(struct irq_desc *desc)
{
struct irqaction *action = desc->action;
irqreturn_t ret;
desc->istate &= ~IRQS_PENDING;
irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS); /* 设置IRQD_IRQ_INPROGRESS标志,防止同一中断isr嵌套执行*/
raw_spin_unlock(&desc->lock);
ret = handle_irq_event_percpu(desc, action);
raw_spin_lock(&desc->lock);
irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS);/* 清除IRQD_IRQ_INPROGRESS标志 */
return ret;
}
irqreturn_t
handle_irq_event_percpu(struct irq_desc *desc, struct irqaction *action)
{
irqreturn_t retval = IRQ_NONE;
unsigned int flags = 0, irq = desc->irq_data.irq;
trace_irq_entry(irq, NULL, action);
do {
irqreturn_t res;
trace_irq_handler_entry(irq, action);
res = action->handler(irq, action->dev_id); /* 调用action->handler,即request_irq 时注册的handler 函数 */
trace_irq_handler_exit(irq, action, res);
if (WARN_ONCE(!irqs_disabled(),"irq %u handler %pF enabled interrupts\n",
irq, action->handler))
local_irq_disable();
switch (res) {
case IRQ_WAKE_THREAD: /* 线程化的中断通常返回这个值 IRQ_WAKE_THREAD */
/*
* Catch drivers which return WAKE_THREAD but
* did not set up a thread function
*/
if (unlikely(!action->thread_fn)) {
warn_no_thread(irq, action);
break;
}
irq_wake_thread(desc, action); /* 唤醒线程化的中断线程 */
/* Fall through to add to randomness */
case IRQ_HANDLED:
flags |= action->flags;
break;
default:
break;
}
retval |= res;
action = action->next; /* 如果共享中断,则需要循环执行action链表上的action */
} while (action);
add_interrupt_randomness(irq, flags);
if (!noirqdebug)
note_interrupt(irq, desc, retval);
trace_irq_exit(retval);
return retval;
}