diff mbox series

[net,3/3] ibmvnic: Ensure that CRQ entry read/write are correctly ordered

Message ID 20210121061710.53217-4-ljp@linux.ibm.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series fixes the memory barrier for SCRQ/CRQ entry | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 10 maintainers not CCed: drt@linux.ibm.com benh@kernel.crashing.org mpe@ellerman.id.au paulus@samba.org sukadev@linux.ibm.com jallen@linux.vnet.ibm.com linuxppc-dev@lists.ozlabs.org davem@davemloft.net tlfalcon@linux.vnet.ibm.com kuba@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 19 this patch: 19
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Lijun Pan Jan. 21, 2021, 6:17 a.m. UTC
Ensure that received Command-Response Queue (CRQ) entries are
properly read/written in order by the driver. dma_rmb barrier
has been added before accessing the CRQ descriptor to ensure
the entire descriptor is read before processing. dma_wmb barrier
is also added to ensure the entire descriptor is written before
future processing.

Fixes: 032c5e82847a ("Driver for IBM System i/p VNIC protocol")
Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 933e8fb71a8b..e947eb068163 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -5090,8 +5090,20 @@  static void ibmvnic_tasklet(struct tasklet_struct *t)
 	while (!done) {
 		/* Pull all the valid messages off the CRQ */
 		while ((crq = ibmvnic_next_crq(adapter)) != NULL) {
+			/* Ensure that the entire CRQ descriptor queue->msgs
+			 * has been loaded before reading its contents.
+			 * This barrier makes sure ibmvnic_next_crq()'s
+			 * crq->generic.first & IBMVNIC_CRQ_CMD_RSP is loaded
+			 * before ibmvnic_handle_crq()'s
+			 * switch(gen_crq->first) and switch(gen_crq->cmd).
+			 */
+			dma_rmb();
 			ibmvnic_handle_crq(crq, adapter);
 			crq->generic.first = 0;
+			/* Ensure the entire CRQ descriptor is written before
+			 * future writing.
+			 */
+			dma_wmb();
 		}
 
 		/* remain in tasklet until all