netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lijun Pan <ljp@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Lijun Pan <ljp@linux.ibm.com>
Subject: [PATCH net 3/3] ibmvnic: Ensure that CRQ entry read/write are correctly ordered
Date: Thu, 21 Jan 2021 00:17:10 -0600	[thread overview]
Message-ID: <20210121061710.53217-4-ljp@linux.ibm.com> (raw)
In-Reply-To: <20210121061710.53217-1-ljp@linux.ibm.com>

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 --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
-- 
2.23.0


      parent reply	other threads:[~2021-01-21  6:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21  6:17 [PATCH net 0/3] fixes the memory barrier for SCRQ/CRQ entry Lijun Pan
2021-01-21  6:17 ` [PATCH net 1/3] ibmvnic: rework to ensure SCRQ entry reads are properly ordered Lijun Pan
2021-01-24  5:08   ` Jakub Kicinski
2021-01-25  4:34     ` Lijun Pan
2021-01-21  6:17 ` [PATCH net 2/3] ibmvnic: remove unnecessary rmb() inside ibmvnic_poll Lijun Pan
2021-01-24  5:09   ` Jakub Kicinski
2021-01-25  4:38     ` Lijun Pan
2021-01-25 20:35       ` Jakub Kicinski
2021-01-21  6:17 ` Lijun Pan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210121061710.53217-4-ljp@linux.ibm.com \
    --to=ljp@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).