aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorMajd Dibbiny <majd@mellanox.com>2015-01-29 03:41:42 -0500
committerRoland Dreier <roland@purestorage.com>2015-02-18 01:11:40 -0500
commit8ab9406a41c8245dbab16e65ada51b62182a463e (patch)
tree813287051366c3a6a34190d2bd2141b821075ff8 /drivers/infiniband
parentbede98e781747623ae170667694a71ef19c6ba7f (diff)
IB/mlx4: Bug fixes in mlx4_ib_resize_cq
1. Before the entries alignment, we need to check that the entries doesn't exceed the device's max cqe. 2. After the alignment, we need to make sure that the aligned number doesn't exceed the max cqes+1. The additional cqe is used to denote that the resizing operation has completed. 3. If the users asks to resize the CQ with entries less than the oustanding cqes we should fail instead of returning 0. Signed-off-by: Majd Dibbiny <majd@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index a3b70f6c4035..cb63ecd2276f 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -367,8 +367,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
367 int err; 367 int err;
368 368
369 mutex_lock(&cq->resize_mutex); 369 mutex_lock(&cq->resize_mutex);
370 370 if (entries < 1 || entries > dev->dev->caps.max_cqes) {
371 if (entries < 1) {
372 err = -EINVAL; 371 err = -EINVAL;
373 goto out; 372 goto out;
374 } 373 }
@@ -379,7 +378,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
379 goto out; 378 goto out;
380 } 379 }
381 380
382 if (entries > dev->dev->caps.max_cqes) { 381 if (entries > dev->dev->caps.max_cqes + 1) {
383 err = -EINVAL; 382 err = -EINVAL;
384 goto out; 383 goto out;
385 } 384 }
@@ -392,7 +391,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
392 /* Can't be smaller than the number of outstanding CQEs */ 391 /* Can't be smaller than the number of outstanding CQEs */
393 outst_cqe = mlx4_ib_get_outstanding_cqes(cq); 392 outst_cqe = mlx4_ib_get_outstanding_cqes(cq);
394 if (entries < outst_cqe + 1) { 393 if (entries < outst_cqe + 1) {
395 err = 0; 394 err = -EINVAL;
396 goto out; 395 goto out;
397 } 396 }
398 397