]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[NET]: Use local_irq_{save,restore}() in napi_complete().
authorDavid S. Miller <davem@davemloft.net>
Fri, 28 Mar 2008 00:42:50 +0000 (17:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Mar 2008 00:42:50 +0000 (17:42 -0700)
Based upon a lockdep report.

Since ->poll() can be invoked from netpoll with interrupts
disabled, we must not unconditionally enable interrupts
in napi_complete().

Instead we must use local_irq_{save,restore}().

Noticed by Peter Zijlstra:

<irqs disabled>

  netpoll_poll()
    poll_napi()
      spin_trylock(&napi->poll_lock)
      poll_one_napi()
        napi->poll() := sky2_poll()
          napi_complete()
            local_irq_disable()
            local_irq_enable() <--- *BUG*

  <irq>
    irq_exit()
      do_softirq()
        net_rx_action()
          spin_lock(&napi->poll_lock) <--- Deadlock!

Because we still hold the lock....

Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h

index a2f003239c8570dd31e869eaa6aa7c0a985f9352..fae6a7ececdbb164ffcf4c5fbdd4c96dffafbc41 100644 (file)
@@ -383,9 +383,11 @@ static inline void __napi_complete(struct napi_struct *n)
 
 static inline void napi_complete(struct napi_struct *n)
 {
-       local_irq_disable();
+       unsigned long flags;
+
+       local_irq_save(flags);
        __napi_complete(n);
-       local_irq_enable();
+       local_irq_restore(flags);
 }
 
 /**