Skip to content

Commit ceb8f6b

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe: Use the new DMA memory barriers where appropriate
Use the new lighter weight memory barriers when working with the device descriptors. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 600c881 commit ceb8f6b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-dev.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ static void xgbe_tx_desc_reset(struct xgbe_ring_data *rdata)
10681068
rdesc->desc3 = 0;
10691069

10701070
/* Make sure ownership is written to the descriptor */
1071-
wmb();
1071+
dma_wmb();
10721072
}
10731073

10741074
static void xgbe_tx_desc_init(struct xgbe_channel *channel)
@@ -1124,12 +1124,12 @@ static void xgbe_rx_desc_reset(struct xgbe_ring_data *rdata)
11241124
* is written to the descriptor(s) before setting the OWN bit
11251125
* for the descriptor
11261126
*/
1127-
wmb();
1127+
dma_wmb();
11281128

11291129
XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN, 1);
11301130

11311131
/* Make sure ownership is written to the descriptor */
1132-
wmb();
1132+
dma_wmb();
11331133
}
11341134

11351135
static void xgbe_rx_desc_init(struct xgbe_channel *channel)
@@ -1358,6 +1358,9 @@ static void xgbe_tx_start_xmit(struct xgbe_channel *channel,
13581358
struct xgbe_prv_data *pdata = channel->pdata;
13591359
struct xgbe_ring_data *rdata;
13601360

1361+
/* Make sure everything is written before the register write */
1362+
wmb();
1363+
13611364
/* Issue a poll command to Tx DMA by writing address
13621365
* of next immediate free descriptor */
13631366
rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
@@ -1565,7 +1568,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
15651568
* is written to the descriptor(s) before setting the OWN bit
15661569
* for the first descriptor
15671570
*/
1568-
wmb();
1571+
dma_wmb();
15691572

15701573
/* Set OWN bit for the first descriptor */
15711574
rdata = XGBE_GET_DESC_DATA(ring, start_index);
@@ -1577,7 +1580,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
15771580
#endif
15781581

15791582
/* Make sure ownership is written to the descriptor */
1580-
wmb();
1583+
dma_wmb();
15811584

15821585
ring->cur = cur_index + 1;
15831586
if (!packet->skb->xmit_more ||
@@ -1613,7 +1616,7 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
16131616
return 1;
16141617

16151618
/* Make sure descriptor fields are read after reading the OWN bit */
1616-
rmb();
1619+
dma_rmb();
16171620

16181621
#ifdef XGMAC_ENABLE_RX_DESC_DUMP
16191622
xgbe_dump_rx_desc(ring, rdesc, ring->cur);

drivers/net/ethernet/amd/xgbe/xgbe-drv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,9 @@ static void xgbe_rx_refresh(struct xgbe_channel *channel)
18001800
ring->dirty++;
18011801
}
18021802

1803+
/* Make sure everything is written before the register write */
1804+
wmb();
1805+
18031806
/* Update the Rx Tail Pointer Register with address of
18041807
* the last cleaned entry */
18051808
rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1);
@@ -1863,7 +1866,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
18631866

18641867
/* Make sure descriptor fields are read after reading the OWN
18651868
* bit */
1866-
rmb();
1869+
dma_rmb();
18671870

18681871
#ifdef XGMAC_ENABLE_TX_DESC_DUMP
18691872
xgbe_dump_tx_desc(ring, ring->dirty, 1, 0);

0 commit comments

Comments
 (0)