Re: Gianfar driver failing on MPC8641D based board

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Anton Vorontsov
Date: Friday, February 26, 2010 - 2:38 pm

On Fri, Feb 26, 2010 at 11:27:42AM -0500, Paul Gortmaker wrote:


Yeah, I don't think this is gianfar-related. It must be something
else triggered by the fact that gianfar no longer sends stuff.

OK, I think I found what's happening in gianfar.

Some background...

start_xmit() prepares new skb for transmitting, generally it does
three things:

1. sets up all BDs (marks them ready to send), except the first one.
2. stores skb into tx_queue->tx_skbuff so that clean_tx_ring()
   would cleanup it later.
3. sets up the first BD, i.e. marks it ready.

Here is what clean_tx_ring() does:

1. reads skbs from tx_queue->tx_skbuff
2. Checks if the *last* BD is ready. If it's still ready [to send]
   then it it isn't transmitted, so clean_tx_ring() returns.
   Otherwise it actually cleanups BDs. All is OK.

Now, if there is just one BD, code flow:

- start_xmit(): stores skb into tx_skbuff. Note that the first BD
  (which is also the last one) isn't marked as ready, yet.
- clean_tx_ring(): sees that skb is not null, *and* its lstatus
  says that it is NOT ready (like if BD was sent), so it cleans
  it up (bad!)
- start_xmit(): marks BD as ready [to send], but it's too late.

We can fix this simply by reordering lstatus/tx_skbuff writes.

It works flawlessly on my p2020, please try it.

Thanks!


diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 8bd3c9f..cccb409 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2021,7 +2021,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	/* setup the TxBD length and buffer pointer for the first BD */
-	tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
 	txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
 			skb_headlen(skb), DMA_TO_DEVICE);
 
@@ -2053,6 +2052,10 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	txbdp_start->lstatus = lstatus;
 
+	eieio(); /* force lstatus write before tx_skbuff */
+
+	tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
+
 	/* Update the current skb pointer to the next entry we will use
 	 * (wrapping if necessary) */
 	tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) &
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Gianfar driver failing on MPC8641D based board, Martyn Welch, (Fri Feb 5, 7:00 am)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Thu Feb 25, 3:31 am)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Thu Feb 25, 9:46 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Thu Feb 25, 9:51 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Thu Feb 25, 10:49 am)
Re: Gianfar driver failing on MPC8641D based board, Kumar Gala, (Thu Feb 25, 11:27 am)
Re: Gianfar driver failing on MPC8641D based board, Paul Gortmaker, (Thu Feb 25, 5:53 pm)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Thu Feb 25, 8:14 pm)
RE: Gianfar driver failing on MPC8641D based board, Kumar Gopalpet-B05799, (Thu Feb 25, 9:58 pm)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Fri Feb 26, 4:51 am)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Fri Feb 26, 5:06 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Fri Feb 26, 7:35 am)
Re: Gianfar driver failing on MPC8641D based board, Paul Gortmaker, (Fri Feb 26, 7:52 am)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Fri Feb 26, 8:18 am)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Fri Feb 26, 8:34 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Fri Feb 26, 9:10 am)
Re: Gianfar driver failing on MPC8641D based board, Paul Gortmaker, (Fri Feb 26, 9:27 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Fri Feb 26, 2:38 pm)
Re: Gianfar driver failing on MPC8641D based board, Paul Gortmaker, (Fri Feb 26, 3:12 pm)
RE: Gianfar driver failing on MPC8641D based board, Kumar Gopalpet-B05799, (Fri Feb 26, 10:35 pm)
Re: Gianfar driver failing on MPC8641D based board, Martyn Welch, (Mon Mar 1, 6:07 am)
Re: Gianfar driver failing on MPC8641D based board, Anton Vorontsov, (Tue Mar 2, 7:02 am)