public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Devesh Sharma <devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling
Date: Wed, 15 Mar 2017 10:34:54 -0600	[thread overview]
Message-ID: <20170315163454.GD29562@obsidianresearch.com> (raw)
In-Reply-To: <1489574253-20300-5-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

On Wed, Mar 15, 2017 at 06:37:28AM -0400, Devesh Sharma wrote:
> +
> +	pthread_spin_lock(&dpi->db_lock);
> +	*dbval = htole64(*dbval);
> +	udma_ordering_write_barrier();

The ordering_write_barrier is basically an equivalent barrier to a
spinlock, so this is an unnecessary pattern.

However, you still always need udma_to_device_barrier before
triggering chip DMA.

There is also no udma_from_device_barrier() in this driver, which
can't be right, please add one around bnxt_re_is_cqe_valid most
likely.

Your github branch doesn't compile, btw.

I ran it through sparse, this is what I suggest..

diff --git a/providers/bnxt_re/bnxt_re-abi.h b/providers/bnxt_re/bnxt_re-abi.h
index 8dbb7b985fa0cd..8fcb2517a23028 100644
--- a/providers/bnxt_re/bnxt_re-abi.h
+++ b/providers/bnxt_re/bnxt_re-abi.h
@@ -243,7 +243,7 @@ struct bnxt_re_req_cqe {
 
 struct bnxt_re_rc_cqe {
 	__u32 length;
-	__u32 imm_key;
+	__be32 imm_key;
 	__u64 qp_handle;
 	__u64 mr_handle;
 };
@@ -282,7 +282,7 @@ struct bnxt_re_bsqe {
 };
 
 struct bnxt_re_psns {
-	__u32 opc_spsn;
+	__le32 opc_spsn;
 	__u32 flg_npsn;
 };
 
diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c
index dafe55b74aefe8..3e31845b4d6b47 100644
--- a/providers/bnxt_re/verbs.c
+++ b/providers/bnxt_re/verbs.c
@@ -581,9 +581,10 @@ static int bnxt_re_poll_flush_wcs(struct bnxt_re_queue *que,
 		wrid = &wridp[head];
 		if (wrid->psns) {
 			psns = wrid->psns;
-			opcode = (psns->opc_spsn >> BNXT_RE_PSNS_OPCD_SHIFT) &
-				  BNXT_RE_PSNS_OPCD_MASK;
-		}
+                        opcode = (le32toh(psns->opc_spsn) >>
+                                  BNXT_RE_PSNS_OPCD_SHIFT) &
+                                 BNXT_RE_PSNS_OPCD_MASK;
+                }
 
 		ibvwc->status = IBV_WC_WR_FLUSH_ERR;
 		ibvwc->opcode = opcode;
@@ -1032,10 +1033,11 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns,
 			      uint8_t opcode, uint32_t len)
 {
 	uint32_t pkt_cnt = 0, nxt_psn;
+	uint32_t opc_spsn = 0;
 
 	memset(psns, 0, sizeof(*psns));
 	if (qp->qptyp == IBV_QPT_RC) {
-		psns->opc_spsn = qp->sq_psn & BNXT_RE_PSNS_SPSN_MASK;
+		opc_spsn = qp->sq_psn & BNXT_RE_PSNS_SPSN_MASK;
 		pkt_cnt = (len / qp->mtu);
 		if (len % qp->mtu)
 			pkt_cnt++;
@@ -1044,9 +1046,9 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns,
 		qp->sq_psn = nxt_psn;
 	}
 	opcode = bnxt_re_ibv_wr_to_wc_opcd(opcode);
-	psns->opc_spsn |= ((opcode & BNXT_RE_PSNS_OPCD_MASK) <<
-			    BNXT_RE_PSNS_OPCD_SHIFT);
-	*(uint64_t *)psns = htole64(*(uint64_t *)psns);
+        opc_spsn |=
+            ((opcode & BNXT_RE_PSNS_OPCD_MASK) << BNXT_RE_PSNS_OPCD_SHIFT);
+        psns->opc_spsn = htole32(opc_spsn);
 }
 
 static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-03-15 16:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 10:37 [rdma-core v3 0/9] Broadcom User Space RoCE Driver Devesh Sharma
     [not found] ` <1489574253-20300-1-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-03-15 10:37   ` [rdma-core v3 1/9] libbnxt_re: introduce bnxtre user space RDMA provider Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 2/9] libbnxt_re: Add support for user memory regions Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 3/9] libbnxt_re: Add support for CQ and QP management Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling Devesh Sharma
     [not found]     ` <1489574253-20300-5-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-03-15 16:34       ` Jason Gunthorpe [this message]
     [not found]         ` <20170315163454.GD29562-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-16  3:04           ` Devesh Sharma
     [not found]             ` <CANjDDBh9JP-0W4NDW4p-Jx2fivcSKS9ZAt5AdLRdQPXH8WxxCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 16:17               ` Jason Gunthorpe
     [not found]                 ` <20170316161754.GF23821-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-16 16:53                   ` Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions Devesh Sharma
     [not found]     ` <1489574253-20300-6-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-03-15 19:20       ` Leon Romanovsky
     [not found]         ` <20170315192028.GI2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-16 15:22           ` Devesh Sharma
     [not found]             ` <CANjDDBgPrPPDBOy9N4X=XdU9AUTFpL2pE9-9kPvqAcYj09vDLA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-19  8:12               ` Leon Romanovsky
     [not found]                 ` <20170319081258.GR2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-19 14:36                   ` Devesh Sharma
     [not found]                     ` <CANjDDBiLnAhJWGfJ2TfJ=3_RoQW_KrfDBkxcSp586JuEL4hQXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-20  6:37                       ` Leon Romanovsky
2017-03-15 10:37   ` [rdma-core v3 6/9] libbnxt_re: Enable UD control path and wqe posting Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 7/9] libbnxt_re: Enable polling for UD completions Devesh Sharma
2017-03-15 10:37   ` [rdma-core v3 8/9] libbnxt_re: Add support for atomic operations Devesh Sharma
     [not found]     ` <1489574253-20300-9-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-03-15 19:15       ` Leon Romanovsky
     [not found]         ` <20170315191515.GH2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-16 15:54           ` Devesh Sharma
     [not found]             ` <CANjDDBjGCCc8MLLQ3jhToWyc0Z+Qm3pYejz3BrMrRketDdZbEw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 16:07               ` Bart Van Assche
     [not found]                 ` <1489680444.2574.9.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-16 16:40                   ` Jason Gunthorpe
2017-03-15 10:37   ` [rdma-core v3 9/9] libbnxt_re: Add support for SRQ in user lib Devesh Sharma
     [not found]     ` <1489574253-20300-10-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-03-15 19:24       ` Leon Romanovsky
     [not found]         ` <20170315192408.GJ2079-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-03-19 14:34           ` Devesh Sharma

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=20170315163454.GD29562@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.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