diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -2514,7 +2514,7 @@ static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev) static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); - unsigned int frags, entry = tp->cur_tx % NUM_TX_DESC; + unsigned int frags, cur_tx, entry = tp->cur_tx % NUM_TX_DESC; struct TxDesc *txd = tp->TxDescArray + entry; void __iomem *ioaddr = tp->mmio_addr; dma_addr_t mapping; @@ -2567,13 +2567,17 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev) dev->trans_start = jiffies; + cur_tx = tp->cur_tx; + tp->cur_tx += frags + 1; - smp_wmb(); + mmiowb(); - RTL_W8(TxPoll, NPQ); /* set polling bit */ + smp_mb(); - if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { + if (cur_tx == tp->dirty_tx) + RTL_W8(TxPoll, NPQ); + else if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { netif_stop_queue(dev); smp_rmb(); if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS) @@ -2677,10 +2681,18 @@ static void rtl8169_tx_interrupt(struct net_device *dev, if (tp->dirty_tx != dirty_tx) { tp->dirty_tx = dirty_tx; - smp_wmb(); - if (netif_queue_stopped(dev) && - (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) { - netif_wake_queue(dev); + smp_mb(); + if (unlikely(netif_queue_stopped(dev))) { + netif_tx_lock(dev); + if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS) + netif_wake_queue(dev); + if (dirty_tx != tp->cur_tx) + RTL_W8(TxPoll, NPQ); + netif_tx_unlock(dev); + } else if (dirty_tx != tp->cur_tx) { + netif_tx_lock(dev); + RTL_W8(TxPoll, NPQ); + netif_tx_unlock(dev); } } }