Skip to content

Commit 828affc

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add missing DMA memory barriers
Each completion ring entry has a valid bit to indicate that the entry contains a valid completion event. The driver's main poll loop __bnxt_poll_work() has the proper dma_rmb() to make sure the valid bit of the next entry has been checked before proceeding further. But when we call bnxt_rx_pkt() to process the RX event, the RX completion event consists of two completion entries and only the first entry has been checked to be valid. We need the same barrier after checking the next completion entry. Add missing dma_rmb() barriers in bnxt_rx_pkt() and other similar locations. Fixes: 67a95e2 ("bnxt_en: Need memory barrier when processing the completion ring.") Reported-by: Lance Richardson <[email protected]> Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Lance Richardson <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 976e52b commit 828affc

File tree

1 file changed

+12
-0
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+12
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
17881788
if (!RX_CMP_VALID(rxcmp1, tmp_raw_cons))
17891789
return -EBUSY;
17901790

1791+
/* The valid test of the entry must be done first before
1792+
* reading any further.
1793+
*/
1794+
dma_rmb();
17911795
prod = rxr->rx_prod;
17921796

17931797
if (cmp_type == CMP_TYPE_RX_L2_TPA_START_CMP) {
@@ -2010,6 +2014,10 @@ static int bnxt_force_rx_discard(struct bnxt *bp,
20102014
if (!RX_CMP_VALID(rxcmp1, tmp_raw_cons))
20112015
return -EBUSY;
20122016

2017+
/* The valid test of the entry must be done first before
2018+
* reading any further.
2019+
*/
2020+
dma_rmb();
20132021
cmp_type = RX_CMP_TYPE(rxcmp);
20142022
if (cmp_type == CMP_TYPE_RX_L2_CMP) {
20152023
rxcmp1->rx_cmp_cfa_code_errors_v2 |=
@@ -2475,6 +2483,10 @@ static int bnxt_poll_nitroa0(struct napi_struct *napi, int budget)
24752483
if (!TX_CMP_VALID(txcmp, raw_cons))
24762484
break;
24772485

2486+
/* The valid test of the entry must be done first before
2487+
* reading any further.
2488+
*/
2489+
dma_rmb();
24782490
if ((TX_CMP_TYPE(txcmp) & 0x30) == 0x10) {
24792491
tmp_raw_cons = NEXT_RAW_CMP(raw_cons);
24802492
cp_cons = RING_CMP(tmp_raw_cons);

0 commit comments

Comments
 (0)