]> git.hungrycats.org Git - linux/commitdiff
r8169: fix early queue wake-up.
authorFrancois Romieu <romieu@fr.zoreil.com>
Mon, 30 Jan 2012 23:00:19 +0000 (00:00 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 10 Jun 2012 13:42:04 +0000 (14:42 +0100)
[ Upstream commit ae1f23fb433ac0aaff8aeaa5a7b14348e9aa8277 ]

With infinite gratitude to Eric Dumazet for allowing me to identify
the error.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ethernet/realtek/r8169.c

index 5104d769e8f51dbedc12e8f184f1e9307e275e7a..5f3fa3242c577a7264280d213bae4c7c4522903a 100644 (file)
@@ -5561,7 +5561,18 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
        RTL_W8(TxPoll, NPQ);
 
        if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) {
+               /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
+                * not miss a ring update when it notices a stopped queue.
+                */
+               smp_wmb();
                netif_stop_queue(dev);
+               /* Sync with rtl_tx:
+                * - publish queue status and cur_tx ring index (write barrier)
+                * - refresh dirty_tx ring index (read barrier).
+                * May the current thread have a pessimistic view of the ring
+                * status and forget to wake up queue, a racing rtl_tx thread
+                * can't.
+                */
                smp_mb();
                if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)
                        netif_wake_queue(dev);
@@ -5663,6 +5674,13 @@ static void rtl8169_tx_interrupt(struct net_device *dev,
 
        if (tp->dirty_tx != dirty_tx) {
                tp->dirty_tx = dirty_tx;
+               /* Sync with rtl8169_start_xmit:
+                * - publish dirty_tx ring index (write barrier)
+                * - refresh cur_tx ring index and queue status (read barrier)
+                * May the current thread miss the stopped queue condition,
+                * a racing xmit thread can only have a right view of the
+                * ring status.
+                */
                smp_mb();
                if (netif_queue_stopped(dev) &&
                    (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) {