首先摘一段网上的见解:
The enable_irq unbalanced messages are harmless. It just means that when the driver called disable_irq there were no devices already using the irq, and as such it was already disabled, so the call to disable_irq was forgotten by the kernel, so when we call enable_irq the core kernel code thinks it's unbalanced when it isn't.
我们再来跟一下这个unbalanced的代码:
void enable_irq(unsigned int irq)
{
struct irqdesc *desc = irq_desc + irq;
unsigned long flags;
spin_lock_irqsave(&irq_controller_lock, flags);
if (unlikely(!desc->disable_depth)) {
printk("enable_irq(%u) unbalanced from %p/n", irq,
__builtin_return_address(0));
} else if (!--desc->disable_depth) {
desc->probing = 0;
desc->chip->unmask(irq);
/*
* If the interrupt is waiting to be processed,
* try to re-run it. We can't directly run it
* from here since the caller might be in an
* interrupt-protected region.
*/
if (desc->pending && list_empty(&desc->pend)) {
desc->pending = 0;
if (!desc->chip->retrigger ||
desc->chip->retrigger(irq))
list_add(&desc->pend, &irq_pending);
}
}
spin_unlock_irqrestore(&irq_controller_lock, flags);
}
可见unbalanced这个问题只会发生在enalbe_irq函数中,这里要提到一个变量disable_depth,这是一个标志中断禁止否的变量,如果调用disabled,这个变量会++,是正数,表示禁止中断,如果是enable,这个变量会--,是0,表示允许,一般都会一一对应。
而如果这个变量本身就是0,enable的时候,我们再去enable它的时候系统会去检查你这个是不是0,如果是0的话表示你这个中断本来就是打开的,你现在再去打开没有必要,这就是unbalanced了,所以可见这本身就是一个无害的信息。