diff mbox series

[rdma-core,V2,3/4] bnxt_re/lib: Fix the frequency of acquiring flush lock

Message ID 1539152850-24357-4-git-send-email-devesh.sharma@broadcom.com (mailing list archive)
State Not Applicable
Headers show
Series [rdma-core,V2,1/4] bnxt_re/lib: Reduce memory barrier calls | expand

Commit Message

Devesh Sharma Oct. 10, 2018, 6:27 a.m. UTC
The flush lock should be tried only if there is some room
left in the WC array supplied from consumer.

Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
---
 providers/bnxt_re/verbs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c
index 8e9fd8c..570dfc1 100644
--- a/providers/bnxt_re/verbs.c
+++ b/providers/bnxt_re/verbs.c
@@ -686,12 +686,13 @@  int bnxt_re_poll_cq(struct ibv_cq *ibvcq, int nwc, struct ibv_wc *wc)
 		cq->deferred_arm_flags = 0;
 	}
 	pthread_spin_unlock(&cq->cqq.qlock);
-	/* Check if anything is there to flush. */
-	pthread_spin_lock(&cntx->fqlock);
 	left = nwc - dqed;
-	if (left)
+	if (left) {
+		/* Check if anything is there to flush. */
+		pthread_spin_lock(&cntx->fqlock);
 		dqed += bnxt_re_poll_flush_lists(cq, left, (wc + dqed));
-	pthread_spin_unlock(&cntx->fqlock);
+		pthread_spin_unlock(&cntx->fqlock);
+	}
 
 	return dqed;
 }