]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/sch_generic.c
Merge branch 'for-2.6.24' of master.kernel.org:/pub/scm/linux/kernel/git/olof/pasemi...
[linux-2.6-omap-h63xx.git] / net / sched / sch_generic.c
index e01d57692c9a76f530b89cbc0b9e9443ae3c8ced..e595e6570ce054245c6f8e355b7612a01521526b 100644 (file)
@@ -134,7 +134,7 @@ static inline int qdisc_restart(struct net_device *dev)
 {
        struct Qdisc *q = dev->qdisc;
        struct sk_buff *skb;
-       int ret;
+       int ret = NETDEV_TX_BUSY;
 
        /* Dequeue packet */
        if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL))
@@ -145,7 +145,8 @@ static inline int qdisc_restart(struct net_device *dev)
        spin_unlock(&dev->queue_lock);
 
        HARD_TX_LOCK(dev, smp_processor_id());
-       ret = dev_hard_start_xmit(skb, dev);
+       if (!netif_subqueue_stopped(dev, skb))
+               ret = dev_hard_start_xmit(skb, dev);
        HARD_TX_UNLOCK(dev);
 
        spin_lock(&dev->queue_lock);
@@ -556,6 +557,7 @@ void dev_deactivate(struct net_device *dev)
 {
        struct Qdisc *qdisc;
        struct sk_buff *skb;
+       int running;
 
        spin_lock_bh(&dev->queue_lock);
        qdisc = dev->qdisc;
@@ -571,12 +573,31 @@ void dev_deactivate(struct net_device *dev)
 
        dev_watchdog_down(dev);
 
-       /* Wait for outstanding dev_queue_xmit calls. */
+       /* Wait for outstanding qdisc-less dev_queue_xmit calls. */
        synchronize_rcu();
 
        /* Wait for outstanding qdisc_run calls. */
-       while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
-               yield();
+       do {
+               while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
+                       yield();
+
+               /*
+                * Double-check inside queue lock to ensure that all effects
+                * of the queue run are visible when we return.
+                */
+               spin_lock_bh(&dev->queue_lock);
+               running = test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
+               spin_unlock_bh(&dev->queue_lock);
+
+               /*
+                * The running flag should never be set at this point because
+                * we've already set dev->qdisc to noop_qdisc *inside* the same
+                * pair of spin locks.  That is, if any qdisc_run starts after
+                * our initial test it should see the noop_qdisc and then
+                * clear the RUNNING bit before dropping the queue lock.  So
+                * if it is set here then we've found a bug.
+                */
+       } while (WARN_ON_ONCE(running));
 }
 
 void dev_init_scheduler(struct net_device *dev)