Do not add an extra CQE when creating a CQ.
Sanity-check against returned device capabilities,
to avoid breaking ABI.

Set minimum to 2, to avoid rejection by kernel.
    
Signed-off-by: Jack Morgenstein <[EMAIL PROTECTED]>

diff --git a/src/verbs.c b/src/verbs.c
index 059b534..4e92ec7 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -168,11 +168,15 @@ struct ibv_cq *mlx4_create_cq(struct ibv_context 
*context, int cqe,
        struct mlx4_create_cq_resp resp;
        struct mlx4_cq            *cq;
        int                        ret;
+       struct mlx4_context       *mctx = to_mctx(context);
 
        /* Sanity check CQ size before proceeding */
-       if (cqe > 0x3fffff)
+       if (cqe < 1 || cqe > mctx->max_cqe)
                return NULL;
 
+       /* raise minimum, to avoid breaking ABI */
+       cqe = (cqe == 1) ? 2 : cqe;
+
        cq = malloc(sizeof *cq);
        if (!cq)
                return NULL;
@@ -182,7 +186,7 @@ struct ibv_cq *mlx4_create_cq(struct ibv_context *context, 
int cqe,
        if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
                goto err;
 
-       cqe = align_queue_size(cqe + 1);
+       cqe = align_queue_size(cqe);
 
        if (mlx4_alloc_buf(&cq->buf, cqe * MLX4_CQ_ENTRY_SIZE,
                           to_mdev(context->device)->page_size))
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to