[openib-general] [PATCHv2] IB/mthca: fix off-by-one in mthca srq creation

Michael S. Tsirkin mst at mellanox.co.il
Mon Oct 9 03:39:13 PDT 2006


IB/mthca: fix off-by-one in mthca srq creation
note that in userspace libmthca already handles this correctly
Noted by Jack Morgenstein <jackm at mellanox.co.il>

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

---

Update: the previous version failed to update attr->max_wr correctly.

diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 0f316c8..46b2747 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -201,6 +201,8 @@ int mthca_alloc_srq(struct mthca_dev *de
 
 	if (mthca_is_memfree(dev))
 		srq->max = roundup_pow_of_two(srq->max + 1);
+	else
+		srq->max = srq->max + 1;
 
 	ds = max(64UL,
 		 roundup_pow_of_two(sizeof (struct mthca_next_seg) +
@@ -279,7 +279,7 @@ int mthca_alloc_srq(struct mthca_dev *de
 	srq->first_free = 0;
 	srq->last_free  = srq->max - 1;
 
-	attr->max_wr    = (mthca_is_memfree(dev)) ? srq->max - 1 : srq->max;
+	attr->max_wr    = srq->max - 1;
 	attr->max_sge   = srq->max_gs;
 
 	return 0;
-- 
MST




More information about the general mailing list