Linux中斷的unblance問題

http://blog.csdn.net/myleeming/archive/2009/06/02/4235224.aspx

 

首先摘一段網上的見解:

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了,所以可見這本身就是一個無害的信息。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章