netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] macb: avoid lockup when TGO during underrun
@ 2009-01-15 18:30 Richard Röjfors
  2009-01-19  5:57 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Röjfors @ 2009-01-15 18:30 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 1742 bytes --]

This patch against linux-2.6.28 solves an issue where macb might run out of TX buffers.

In rare cases when an underrun occur, all macb buffers where consumed and the netif_queue was stopped infinitely. This
happens then the TGO (transfer ongoing) bit in the TSR is set (and UND). It seems like clening up after the underrun
makes the driver and the macb hardware end up in an inconsistent state. The result of this is that in the following
calls to macb_tx no TX buffers are released -> the netif_queue was stopped, and never woken up again.

The solution is to disable the transmitter, if TGO is set, before clening up after the underrun, and re-enable the
transmitter when the cleaning up is done.


A patch to avoid lockup in the macb driver in some rare underrun cases.
Signed-off-by: Richard Röjfors <richard.rojfors@endian.se>

---

diff -urpN linux-2.6.28/drivers/net/macb.c linux-2.6.28-macb/drivers/net/macb.c
--- linux-2.6.28/drivers/net/macb.c	2008-12-25 00:26:37.000000000 +0100
+++ linux-2.6.28-macb/drivers/net/macb.c	2009-01-15 19:06:04.000000000 +0100
@@ -321,6 +321,10 @@ static void macb_tx(struct macb *bp)
 		printk(KERN_ERR "%s: TX underrun, resetting buffers\n",
 			bp->dev->name);

+		/* Transfer ongoing, disable transmitter, to avoid confusion */
+		if (status & MACB_BIT(TGO))
+			macb_writel(bp, NCR, macb_readl(bp, NCR) & ~MACB_BIT(TE));
+
 		head = bp->tx_head;

 		/*Mark all the buffer as used to avoid sending a lost buffer*/
@@ -343,6 +347,10 @@ static void macb_tx(struct macb *bp)
 		}

 		bp->tx_head = bp->tx_tail = 0;
+
+		/* Enable the transmitter again */
+		if (status & MACB_BIT(TGO))
+			macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TE));
 	}

 	if (!(status & MACB_BIT(COMP)))

--Richard

[-- Attachment #2: macb-und-tgo.patch --]
[-- Type: text/plain, Size: 1032 bytes --]

A patch to avoid lockup in the macb driver in some rare underrun cases.
Signed-off-by: Richard Röjfors <richard.rojfors@endian.se>

---

diff -urpN linux-2.6.28/drivers/net/macb.c linux-2.6.28-macb/drivers/net/macb.c
--- linux-2.6.28/drivers/net/macb.c	2008-12-25 00:26:37.000000000 +0100
+++ linux-2.6.28-macb/drivers/net/macb.c	2009-01-15 19:06:04.000000000 +0100
@@ -321,6 +321,10 @@ static void macb_tx(struct macb *bp)
 		printk(KERN_ERR "%s: TX underrun, resetting buffers\n",
 			bp->dev->name);
 
+		/* Transfer ongoing, disable transmitter, to avoid confusion */
+		if (status & MACB_BIT(TGO))
+			macb_writel(bp, NCR, macb_readl(bp, NCR) & ~MACB_BIT(TE));
+
 		head = bp->tx_head;
 
 		/*Mark all the buffer as used to avoid sending a lost buffer*/
@@ -343,6 +347,10 @@ static void macb_tx(struct macb *bp)
 		}
 
 		bp->tx_head = bp->tx_tail = 0;
+
+		/* Enable the transmitter again */
+		if (status & MACB_BIT(TGO))
+			macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TE));
 	}
 
 	if (!(status & MACB_BIT(COMP)))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] macb: avoid lockup when TGO during underrun
  2009-01-15 18:30 [PATCH] macb: avoid lockup when TGO during underrun Richard Röjfors
@ 2009-01-19  5:57 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2009-01-19  5:57 UTC (permalink / raw)
  To: richard.rojfors; +Cc: netdev

From: Richard Röjfors <richard.rojfors@endian.se>
Date: Thu, 15 Jan 2009 19:30:16 +0100

> This patch against linux-2.6.28 solves an issue where macb might run out of TX buffers.
> 
> In rare cases when an underrun occur, all macb buffers where consumed and the netif_queue was stopped infinitely. This
> happens then the TGO (transfer ongoing) bit in the TSR is set (and UND). It seems like clening up after the underrun
> makes the driver and the macb hardware end up in an inconsistent state. The result of this is that in the following
> calls to macb_tx no TX buffers are released -> the netif_queue was stopped, and never woken up again.
> 
> The solution is to disable the transmitter, if TGO is set, before clening up after the underrun, and re-enable the
> transmitter when the cleaning up is done.
> 
> 
> A patch to avoid lockup in the macb driver in some rare underrun cases.
> Signed-off-by: Richard Röjfors <richard.rojfors@endian.se>

Patch applied, thanks Richard.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-19  5:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 18:30 [PATCH] macb: avoid lockup when TGO during underrun Richard Röjfors
2009-01-19  5:57 ` David Miller

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).