linux中断的unbalanced问题

首先摘一段网上的见解:

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了,所以可见这本身就是一个无害的信息。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值