netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gregory CLEMENT <novexz@gmail.com>
To: hskinnemoen@atmel.com, linux-arm-kernel@lists.arm.linux.org.uk,
	netdev@vger.kernel.org
Subject: [PATCH] MACB: clear transmit buffers properly on TX Underrun
Date: Thu, 13 Dec 2007 08:51:57 +0100	[thread overview]
Message-ID: <4760E49D.5040406@gmail.com> (raw)

Hi,
I generated this patch for linux 2.6.24-rc5 and test it on AT91SAM9263 
with iperf.

From: Gregory CLEMENT <gclement00@gmail.com>
Date: Wed, 12 Dec 2007 18:10:14 +0100
Subject: [PATCH] MACB: clear transmit buffers properly on TX Underrun

Initially transmit buffer pointers were only reset. But buffer descriptors
were possibly still set as ready, and buffer in upper layer was not
freed. This caused driver hang under big load.
Now reset clean properly the buffer descriptor and freed upper layer.

Signed-off-by: Gregory CLEMENT <gclement00@gmail.com>
---
 drivers/net/macb.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 047ea7b..2ee1dab 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -307,9 +307,33 @@ static void macb_tx(struct macb *bp)
         (unsigned long)status);
 
     if (status & MACB_BIT(UND)) {
+        int i;
         printk(KERN_ERR "%s: TX underrun, resetting buffers\n",
-               bp->dev->name);
+               bp->dev->name);
+
+        head = bp->tx_head;
+
+        /* free transmit buffer in upper layer*/
+        for (tail = bp->tx_tail; tail != head; tail = NEXT_TX(tail)) {
+            struct ring_info *rp = &bp->tx_skb[tail];
+            struct sk_buff *skb = rp->skb;
+
+            BUG_ON(skb == NULL);
+
+            rmb();
+
+            dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len,
+                             DMA_TO_DEVICE);
+            rp->skb = NULL;
+            dev_kfree_skb_irq(skb);
+        }
+
+        /*Mark all the buffer as used to avoid sending a lost buffer*/
+        for (i = 0; i < RX_RING_SIZE; i++)
+            bp->tx_ring[i].ctrl = MACB_BIT(TX_USED);
+
         bp->tx_head = bp->tx_tail = 0;
+
     }
 
     if (!(status & MACB_BIT(COMP)))
-- 
1.5.3.7


-- 
Gregory CLEMENT
Adeneo
Adetel Group
2, chemin du Ruisseau
69134 ECULLY - FRANCE
Tél. : +33 (0)4 72 18 08 40 - Fax : +33 (0)4 72 18 08 41

www.adetelgroup.com


             reply	other threads:[~2007-12-13  7:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-13  7:51 Gregory CLEMENT [this message]
2007-12-13 11:33 ` [PATCH] MACB: clear transmit buffers properly on TX Underrun Haavard Skinnemoen
2007-12-16 11:37   ` Gregory CLEMENT
2007-12-18 14:52     ` Haavard Skinnemoen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4760E49D.5040406@gmail.com \
    --to=novexz@gmail.com \
    --cc=hskinnemoen@atmel.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).