David Gundersen <[EMAIL PROTECTED]> :
[...]
> - Why are you checking dirty_tx against cur_rx (shouldn't it be cur_tx?)?

Usual "try something, send something else" bug.

> - Is there a possibility that the driver could be triggering the card to 
> send invalid packets with that code?
[snip]

I do not know but I doubt that it matters.

That being said, the patch below should make things better (though still
not perfect):


diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 8f3e0da..35054e8 100644
--- 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);
                }
        }
 }
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to