amd-xgbe: Add a read memory barrier to Tx/Rx path
authorLendacky, Thomas <Thomas.Lendacky@amd.com>
Thu, 20 Nov 2014 17:03:26 +0000 (11:03 -0600)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Nov 2014 20:19:10 +0000 (15:19 -0500)
Add a read memory barrier to the Tx and Rx paths where the ownership
bit is checked to be sure that all descriptor fields are read after
having read the ownership bit for the descriptor.

This has not been an issue to date, but it's a good safe-guard to have.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
drivers/net/ethernet/amd/xgbe/xgbe-drv.c

index f6014d330b2e0ad6fc1c63563994cdee2ad98dc8..9b1d9fa682572e7af05cb4647bd4a643bc8f9dd0 100644 (file)
@@ -1558,6 +1558,9 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
        if (XGMAC_GET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN))
                return 1;
 
+       /* Make sure descriptor fields are read after reading the OWN bit */
+       rmb();
+
 #ifdef XGMAC_ENABLE_RX_DESC_DUMP
        xgbe_dump_rx_desc(ring, rdesc, ring->cur);
 #endif
index 0544931329d16143f8b14d8620616762504aaad2..eebb787251c481396a3f0519550c53fccd611069 100644 (file)
@@ -1791,6 +1791,10 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
                if (!hw_if->tx_complete(rdesc))
                        break;
 
+               /* Make sure descriptor fields are read after reading the OWN
+                * bit */
+               rmb();
+
 #ifdef XGMAC_ENABLE_TX_DESC_DUMP
                xgbe_dump_tx_desc(ring, ring->dirty, 1, 0);
 #endif