IB/mthca: Fix SRQ limit event range check
authorDotan Barak <dotanb@mellanox.co.il>
Thu, 13 Jul 2006 08:05:49 +0000 (11:05 +0300)
committerRoland Dreier <rolandd@cisco.com>
Mon, 24 Jul 2006 14:20:32 +0000 (07:20 -0700)
Mem-free HCAs always keep one spare SRQ WQE, so the SRQ limit cannot
be set beyond srq->max - 1.

Signed-off-by: Dotan Barak <dotanb@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/mthca/mthca_srq.c

index fab417c5cf43671f329b9b8c26dddc87bd9345ad..b60a9d79ae54ae569e7e7c765389c0ee05fd8260 100644 (file)
@@ -370,7 +370,8 @@ int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
                return -EINVAL;
 
        if (attr_mask & IB_SRQ_LIMIT) {
-               if (attr->srq_limit > srq->max)
+               u32 max_wr = mthca_is_memfree(dev) ? srq->max - 1 : srq->max;
+               if (attr->srq_limit > max_wr)
                        return -EINVAL;
 
                mutex_lock(&srq->mutex);