public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 05/11] RDMA/cxgb4: Fix overflow bug in cq arm.
Date: Thu, 20 May 2010 16:57:49 -0500	[thread overview]
Message-ID: <20100520215748.32394.1063.stgit@build.ogc.int> (raw)
In-Reply-To: <20100520215727.32394.90669.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>

- wrap cq->cqidx_inc based on cq size.
- optimize t4_arm_cq logic.

Signed-off-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
---

 drivers/infiniband/hw/cxgb4/t4.h |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 712bc56..333abd3 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -449,25 +449,17 @@ struct t4_cq {
 static inline int t4_arm_cq(struct t4_cq *cq, int se)
 {
 	u32 val;
-	u16 inc;
-
-	do {
-		/*
-		 * inc must be less the both the max update value -and-
-		 * the size of the CQ.
-		 */
-		inc = cq->cidx_inc <= CIDXINC_MASK ? cq->cidx_inc :
-						     CIDXINC_MASK;
-		inc = inc <= (cq->size - 1) ? inc : (cq->size - 1);
-		if (inc == cq->cidx_inc)
-			val = SEINTARM(se) | CIDXINC(inc) | TIMERREG(6) |
-			      INGRESSQID(cq->cqid);
-		else
-			val = SEINTARM(0) | CIDXINC(inc) | TIMERREG(7) |
-			      INGRESSQID(cq->cqid);
-		cq->cidx_inc -= inc;
+
+	while (cq->cidx_inc > CIDXINC_MASK) {
+		val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) |
+		      INGRESSQID(cq->cqid);
 		writel(val, cq->gts);
-	} while (cq->cidx_inc);
+		cq->cidx_inc -= CIDXINC_MASK;
+	}
+	val = SEINTARM(se) | CIDXINC(cq->cidx_inc) | TIMERREG(6) |
+	      INGRESSQID(cq->cqid);
+	writel(val, cq->gts);
+	cq->cidx_inc = 0;
 	return 0;
 }
 
@@ -488,7 +480,8 @@ static inline void t4_swcq_consume(struct t4_cq *cq)
 static inline void t4_hwcq_consume(struct t4_cq *cq)
 {
 	cq->bits_type_ts = cq->queue[cq->cidx].bits_type_ts;
-	cq->cidx_inc++;
+	if (++cq->cidx_inc == cq->size)
+		cq->cidx_inc = 0;
 	if (++cq->cidx == cq->size) {
 		cq->cidx = 0;
 		cq->gen ^= 1;

--
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:[~2010-05-20 21:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20 21:57 [PATCH 01/11] RDMA/cxgb4: Detach from the LLD after unregistering with the RDMA core Steve Wise
     [not found] ` <20100520215727.32394.90669.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
2010-05-20 21:57   ` [PATCH 02/11] RDMA/cxgb4: register rdma provider based on LLD state_change events Steve Wise
2010-05-20 21:57   ` [PATCH 03/11] RDMA/cxgb4: CQ size must be IQ size - 2 Steve Wise
     [not found]     ` <20100520215738.32394.60360.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
2010-05-20 22:08       ` Sean Hefty
     [not found]         ` <27BBA4336B784434AAE16BB1126AD59C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-05-20 22:16           ` Steve Wise
2010-05-20 21:57   ` [PATCH 04/11] RDMA/cxgb4: Optimize CQ overflow detection Steve Wise
2010-05-20 21:57   ` Steve Wise [this message]
2010-05-20 21:57   ` [PATCH 06/11] RDMA/cxgb4: Return proper errors in fastreg mr/pbl allocation Steve Wise
2010-05-20 21:57   ` [PATCH 07/11] RDMA/cxgb4: Don't limit fastreg page list depth Steve Wise
2010-05-20 21:58   ` [PATCH 08/11] RDMA/cxgb4: Update some HW limits Steve Wise
2010-05-20 21:58   ` [PATCH 09/11] RDMA/cxgb4: Set fence flag for inv-local-stag work requests Steve Wise
2010-05-20 21:58   ` [PATCH 10/11] RDMA/cxgb4: Support IB_WR_READ_WITH_INV opcode Steve Wise
2010-05-20 21:58   ` [PATCH 11/11] RDMA/cxgb4: Only insert sq qid in lookup table Steve Wise
2010-05-25  4:08   ` [PATCH 01/11] RDMA/cxgb4: Detach from the LLD after unregistering with the RDMA core Roland Dreier

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=20100520215748.32394.1063.stgit@build.ogc.int \
    --to=swise-7bpotxp6k4+p2yhjcf5u+vpxobypeauw@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