[PATCH rdma-core] mlx5: Don't assume that input is rounded to power two

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxxxx>

The simple arithmetic can be done in order to stop assume
that code provided to ilog32() used in mlx5 is rounded to
power two.

Reviewed-by: Yishai Hadas <yishaih@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 providers/mlx5/dr_devx.c | 4 ++--
 providers/mlx5/dr_send.c | 4 ++--
 providers/mlx5/srq.c     | 2 +-
 providers/mlx5/verbs.c   | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/providers/mlx5/dr_devx.c b/providers/mlx5/dr_devx.c
index ee1b5486e..cc8c20d34 100644
--- a/providers/mlx5/dr_devx.c
+++ b/providers/mlx5/dr_devx.c
@@ -324,9 +324,9 @@ struct mlx5dv_devx_obj *dr_devx_create_qp(struct ibv_context *ctx,
 	DEVX_SET(qpc, qpc, uar_page, attr->page_id);
 	DEVX_SET(qpc, qpc, cqn_snd, attr->cqn);
 	DEVX_SET(qpc, qpc, cqn_rcv, attr->cqn);
-	DEVX_SET(qpc, qpc, log_sq_size, ilog32(attr->sq_wqe_cnt) - 1);
+	DEVX_SET(qpc, qpc, log_sq_size, ilog32(attr->sq_wqe_cnt - 1));
 	DEVX_SET(qpc, qpc, log_rq_stride, attr->rq_wqe_shift - 4);
-	DEVX_SET(qpc, qpc, log_rq_size, ilog32(attr->rq_wqe_cnt) - 1);
+	DEVX_SET(qpc, qpc, log_rq_size, ilog32(attr->rq_wqe_cnt - 1));
 	DEVX_SET(qpc, qpc, dbr_umem_id, attr->db_umem_id);
 
 	DEVX_SET(create_qp_in, in, wq_umem_id, attr->buff_umem_id);
diff --git a/providers/mlx5/dr_send.c b/providers/mlx5/dr_send.c
index dd9d6eda3..32a60fd95 100644
--- a/providers/mlx5/dr_send.c
+++ b/providers/mlx5/dr_send.c
@@ -210,8 +210,8 @@ static int dr_calc_rq_size(struct dr_qp *dr_qp,
 	wq_size = roundup_pow_of_two(attr->cap.max_recv_wr) * wqe_size;
 	wq_size = max(wq_size, MLX5_SEND_WQE_BB);
 	dr_qp->rq.wqe_cnt = wq_size / wqe_size;
-	dr_qp->rq.wqe_shift = ilog32(wqe_size) - 1;
-	dr_qp->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1);
+	dr_qp->rq.wqe_shift = ilog32(wqe_size - 1);
+	dr_qp->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1);
 	dr_qp->rq.max_gs = wqe_size / sizeof(struct mlx5_wqe_data_seg);
 
 	return wq_size;
diff --git a/providers/mlx5/srq.c b/providers/mlx5/srq.c
index 2124480cd..1c15656f6 100644
--- a/providers/mlx5/srq.c
+++ b/providers/mlx5/srq.c
@@ -291,7 +291,7 @@ int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq,
 	srq->max_gs = (size - sizeof(struct mlx5_wqe_srq_next_seg)) /
 		sizeof(struct mlx5_wqe_data_seg);
 
-	srq->wqe_shift = ilog32(size) - 1;
+	srq->wqe_shift = ilog32(size - 1);
 
 	srq->max = align_queue_size(max_wr);
 	buf_size = srq->max * size;
diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index a6cd3afe3..aa8920825 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -1400,8 +1400,8 @@ static int mlx5_calc_rwq_size(struct mlx5_context *ctx,
 	wq_size = roundup_pow_of_two(attr->max_wr) * wqe_size;
 	wq_size = max(wq_size, MLX5_SEND_WQE_BB);
 	rwq->rq.wqe_cnt = wq_size / wqe_size;
-	rwq->rq.wqe_shift = ilog32(wqe_size) - 1;
-	rwq->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1);
+	rwq->rq.wqe_shift = ilog32(wqe_size - 1);
+	rwq->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1);
 	scat_spc = wqe_size -
 		((rwq->wq_sig) ? sizeof(struct mlx5_rwqe_sig) : 0) -
 		is_mprq * sizeof(struct mlx5_wqe_srq_next_seg);
@@ -1436,8 +1436,8 @@ static int mlx5_calc_rq_size(struct mlx5_context *ctx,
 	if (wqe_size) {
 		wq_size = max(wq_size, MLX5_SEND_WQE_BB);
 		qp->rq.wqe_cnt = wq_size / wqe_size;
-		qp->rq.wqe_shift = ilog32(wqe_size) - 1;
-		qp->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1);
+		qp->rq.wqe_shift = ilog32(wqe_size - 1);
+		qp->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1);
 		scat_spc = wqe_size -
 			(qp->wq_sig ? sizeof(struct mlx5_rwqe_sig) : 0);
 		qp->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg);
-- 
2.20.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux