aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2010-03-03 03:18:58 -0500
committerDavid S. Miller <davem@davemloft.net>2010-03-04 03:53:53 -0500
commit0eddba525cf4c3a4aab9feaf36b12b465290d4a7 (patch)
treeb41b9a6ba53635c1c7137bc0993e4c7f03ef721b
parent4c020a961a812ffae9846b917304cea504c3a733 (diff)
gianfar: Fix TX ring processing on SMP machines
Starting with commit a3bc1f11e9b867a4f49505 ("gianfar: Revive SKB recycling") gianfar driver sooner or later stops transmitting any packets on SMP machines. 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. Reported-by: Martyn Welch <martyn.welch@ge.com> Bisected-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Tested-by: Paul Gortmaker <paul.gortmaker@windriver.com> Tested-by: Martyn Welch <martyn.welch@ge.com> Cc: Sandeep Gopalpet <Sandeep.Kumar@freescale.com> Cc: Stable <stable@vger.kernel.org> [2.6.33] Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/gianfar.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6aa526ee9096..c3f061957c04 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)
2021 } 2021 }
2022 2022
2023 /* setup the TxBD length and buffer pointer for the first BD */ 2023 /* setup the TxBD length and buffer pointer for the first BD */
2024 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2025 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, 2024 txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
2026 skb_headlen(skb), DMA_TO_DEVICE); 2025 skb_headlen(skb), DMA_TO_DEVICE);
2027 2026
@@ -2053,6 +2052,10 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2053 2052
2054 txbdp_start->lstatus = lstatus; 2053 txbdp_start->lstatus = lstatus;
2055 2054
2055 eieio(); /* force lstatus write before tx_skbuff */
2056
2057 tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
2058
2056 /* Update the current skb pointer to the next entry we will use 2059 /* Update the current skb pointer to the next entry we will use
2057 * (wrapping if necessary) */ 2060 * (wrapping if necessary) */
2058 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) & 2061 tx_queue->skb_curtx = (tx_queue->skb_curtx + 1) &