linux中斷的unbalanced問題

來源:互聯網
上載者:User

首先摘一段網上的見解:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.