Skip to content

Commit 665ab1e

Browse files
Lijun Pankuba-moo
authored andcommitted
ibmvnic: rework to ensure SCRQ entry reads are properly ordered
Move the dma_rmb() between pending_scrq() and ibmvnic_next_scrq() into the end of pending_scrq() to save the duplicated code since this dma_rmb will be used 3 times. Signed-off-by: Lijun Pan <[email protected]> Acked-by: Thomas Falcon <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1a2b60f commit 665ab1e

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,12 +2444,6 @@ static int ibmvnic_poll(struct napi_struct *napi, int budget)
24442444

24452445
if (!pending_scrq(adapter, rx_scrq))
24462446
break;
2447-
/* The queue entry at the current index is peeked at above
2448-
* to determine that there is a valid descriptor awaiting
2449-
* processing. We want to be sure that the current slot
2450-
* holds a valid descriptor before reading its contents.
2451-
*/
2452-
dma_rmb();
24532447
next = ibmvnic_next_scrq(adapter, rx_scrq);
24542448
rx_buff =
24552449
(struct ibmvnic_rx_buff *)be64_to_cpu(next->
@@ -3189,13 +3183,6 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
31893183
int total_bytes = 0;
31903184
int num_packets = 0;
31913185

3192-
/* The queue entry at the current index is peeked at above
3193-
* to determine that there is a valid descriptor awaiting
3194-
* processing. We want to be sure that the current slot
3195-
* holds a valid descriptor before reading its contents.
3196-
*/
3197-
dma_rmb();
3198-
31993186
next = ibmvnic_next_scrq(adapter, scrq);
32003187
for (i = 0; i < next->tx_comp.num_comps; i++) {
32013188
if (next->tx_comp.rcs[i])
@@ -3569,11 +3556,16 @@ static int pending_scrq(struct ibmvnic_adapter *adapter,
35693556
struct ibmvnic_sub_crq_queue *scrq)
35703557
{
35713558
union sub_crq *entry = &scrq->msgs[scrq->cur];
3559+
int rc;
35723560

3573-
if (entry->generic.first & IBMVNIC_CRQ_CMD_RSP)
3574-
return 1;
3575-
else
3576-
return 0;
3561+
rc = !!(entry->generic.first & IBMVNIC_CRQ_CMD_RSP);
3562+
3563+
/* Ensure that the SCRQ valid flag is loaded prior to loading the
3564+
* contents of the SCRQ descriptor
3565+
*/
3566+
dma_rmb();
3567+
3568+
return rc;
35773569
}
35783570

35793571
static union sub_crq *ibmvnic_next_scrq(struct ibmvnic_adapter *adapter,
@@ -3592,8 +3584,8 @@ static union sub_crq *ibmvnic_next_scrq(struct ibmvnic_adapter *adapter,
35923584
}
35933585
spin_unlock_irqrestore(&scrq->lock, flags);
35943586

3595-
/* Ensure that the entire buffer descriptor has been
3596-
* loaded before reading its contents
3587+
/* Ensure that the SCRQ valid flag is loaded prior to loading the
3588+
* contents of the SCRQ descriptor
35973589
*/
35983590
dma_rmb();
35993591

0 commit comments

Comments
 (0)