aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mlx5/cq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mlx5/cq.c')
-rw-r--r--drivers/infiniband/hw/mlx5/cq.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
index dabcc65bd65e..9c0e67bd2ba7 100644
--- a/drivers/infiniband/hw/mlx5/cq.c
+++ b/drivers/infiniband/hw/mlx5/cq.c
@@ -822,7 +822,8 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
822 int eqn; 822 int eqn;
823 int err; 823 int err;
824 824
825 if (entries < 0) 825 if (entries < 0 ||
826 (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))))
826 return ERR_PTR(-EINVAL); 827 return ERR_PTR(-EINVAL);
827 828
828 if (check_cq_create_flags(attr->flags)) 829 if (check_cq_create_flags(attr->flags))
@@ -1168,11 +1169,16 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
1168 return -ENOSYS; 1169 return -ENOSYS;
1169 } 1170 }
1170 1171
1171 if (entries < 1) 1172 if (entries < 1 ||
1173 entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) {
1174 mlx5_ib_warn(dev, "wrong entries number %d, max %d\n",
1175 entries,
1176 1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz));
1172 return -EINVAL; 1177 return -EINVAL;
1178 }
1173 1179
1174 entries = roundup_pow_of_two(entries + 1); 1180 entries = roundup_pow_of_two(entries + 1);
1175 if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1) 1181 if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1)
1176 return -EINVAL; 1182 return -EINVAL;
1177 1183
1178 if (entries == ibcq->cqe + 1) 1184 if (entries == ibcq->cqe + 1)