Skip to content

Commit 9025944

Browse files
Shenwei Wangdavem330
authored andcommitted
net: fec: add dma_wmb to ensure correct descriptor values
Two dma_wmb() are added in the XDP TX path to ensure proper ordering of descriptor and buffer updates: 1. A dma_wmb() is added after updating the last BD to make sure the updates to rest of the descriptor are visible before transferring ownership to FEC. 2. A dma_wmb() is also added after updating the bdp to ensure these updates are visible before updating txq->bd.cur. 3. Start the xmit of the frame immediately right after configuring the tx descriptor. Fixes: 6d6b39f ("net: fec: add initial XDP support") Signed-off-by: Shenwei Wang <[email protected]> Reviewed-by: Wei Fang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3be5f6c commit 9025944

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,6 +3834,11 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep,
38343834
index = fec_enet_get_bd_index(last_bdp, &txq->bd);
38353835
txq->tx_skbuff[index] = NULL;
38363836

3837+
/* Make sure the updates to rest of the descriptor are performed before
3838+
* transferring ownership.
3839+
*/
3840+
dma_wmb();
3841+
38373842
/* Send it on its way. Tell FEC it's ready, interrupt when done,
38383843
* it's the last BD of the frame, and to put the CRC on the end.
38393844
*/
@@ -3843,8 +3848,14 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep,
38433848
/* If this was the last BD in the ring, start at the beginning again. */
38443849
bdp = fec_enet_get_nextdesc(last_bdp, &txq->bd);
38453850

3851+
/* Make sure the update to bdp are performed before txq->bd.cur. */
3852+
dma_wmb();
3853+
38463854
txq->bd.cur = bdp;
38473855

3856+
/* Trigger transmission start */
3857+
writel(0, txq->bd.reg_desc_active);
3858+
38483859
return 0;
38493860
}
38503861

@@ -3873,12 +3884,6 @@ static int fec_enet_xdp_xmit(struct net_device *dev,
38733884
sent_frames++;
38743885
}
38753886

3876-
/* Make sure the update to bdp and tx_skbuff are performed. */
3877-
wmb();
3878-
3879-
/* Trigger transmission start */
3880-
writel(0, txq->bd.reg_desc_active);
3881-
38823887
__netif_tx_unlock(nq);
38833888

38843889
return sent_frames;

0 commit comments

Comments
 (0)