Patch "IB/mlx5: Fix reported max SGE calculation" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
IB/mlx5: Fix reported max SGE calculation
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ib-mlx5-fix-reported-max-sge-calculation.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
288c01b746aab484651391ca6d64b585d3eb5ec6Mon Sep 17 00:00:00 2001
From: Eli Cohen <[email protected]>
Date: Thu, 27 Oct 2016 16:36:45 +0300
Subject: IB/mlx5: Fix reported max SGE calculation
From: Eli Cohen <[email protected]>
commit 288c01b746aab484651391ca6d64b585d3eb5ec6 upstream.
Add the 512 bytes limit of RDMA READ and the size of remote address to the max SGE calculation.
--- drivers/infiniband/hw/mlx5/main.c | 8 +++++--- drivers/infiniband/hw/mlx5/qp.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/main.c +5 -3
@@ -496,6 +496,7 @@ static int mlx5_ib_query_device(struct istruct mlx5_ib_dev *dev =to_mdev (ibdev);struct mlx5_core_dev *mdev = dev->mdev;int err = -ENOMEM ; +int max_sq_desc;int max_rq_sg;int max_sq_sg;u64 min_page_size =1ull <<MLX5_CAP_GEN (mdev, log_pg_sz);
@@ -618,9 +619,10 @@ static int mlx5_ib_query_device(struct i props->max_qp_wr =1 <<MLX5_CAP_GEN (mdev, log_max_qp_sz); max_rq_sg =MLX5_CAP_GEN (mdev, max_wqe_sz_rq) /sizeof (struct mlx5_wqe_data_seg ); - max_sq_sg = (MLX5_CAP_GEN (mdev, max_wqe_sz_sq) - -sizeof (struct mlx5_wqe_ctrl_seg )) / -sizeof (struct mlx5_wqe_data_seg ); + max_sq_desc =min_t (int,MLX5_CAP_GEN (mdev, max_wqe_sz_sq),512 ); + max_sq_sg = (max_sq_desc -sizeof (struct mlx5_wqe_ctrl_seg ) - +sizeof (struct mlx5_wqe_raddr_seg )) / +sizeof (struct mlx5_wqe_data_seg ); props->max_sge =min (max_rq_sg, max_sq_sg); props->max_sge_rd =MLX5_MAX_SGE_RD ; props->max_cq =1 <<MLX5_CAP_GEN (mdev, log_max_cq);
drivers/infiniband/hw/mlx5/qp.c +28 -1
@@ -351,6 +351,29 @@ static int calc_send_wqe(struct ib_qp_inreturn ALIGN (max_t (int, inl_size, size),MLX5_SEND_WQE_BB ); } +static int get_send_sge (struct ib_qp_init_attr *attr,int wqe_size) +{ +int max_sge; + +if (attr->qp_type ==IB_QPT_RC ) + max_sge = (min_t (int, wqe_size,512 ) - +sizeof (struct mlx5_wqe_ctrl_seg ) - +sizeof (struct mlx5_wqe_raddr_seg )) / +sizeof (struct mlx5_wqe_data_seg ); +else if (attr->qp_type ==IB_QPT_XRC_INI ) + max_sge = (min_t (int, wqe_size,512 ) - +sizeof (struct mlx5_wqe_ctrl_seg ) - +sizeof (struct mlx5_wqe_xrc_seg ) - +sizeof (struct mlx5_wqe_raddr_seg )) / +sizeof (struct mlx5_wqe_data_seg ); +else + max_sge = (wqe_size -sq_overhead (attr)) / +sizeof (struct mlx5_wqe_data_seg ); + +return min_t (int, max_sge, wqe_size -sq_overhead (attr) / +sizeof (struct mlx5_wqe_data_seg )); +} +static int calc_sq_size (struct mlx5_ib_dev *dev,struct ib_qp_init_attr *attr,struct mlx5_ib_qp *qp) {
@@ -387,7 +410,11 @@ static int calc_sq_size(struct mlx5_ib_dreturn -ENOMEM ; } qp->sq.wqe_shift =ilog2 (MLX5_SEND_WQE_BB ); - qp->sq.max_gs = attr->cap.max_send_sge; + qp->sq.max_gs =get_send_sge (attr, wqe_size); +if (qp->sq.max_gs < attr->cap.max_send_sge) +return -ENOMEM ; + + attr->cap.max_send_sge = qp->sq.max_gs; qp->sq.max_post = wq_size / wqe_size; attr->cap.max_send_wr = qp->sq.max_post;
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/ib-mlx5-avoid-system-crash-when-enabling-many-vfs.patch queue-4.9/ib-mlx5-wait-for-all-async-command-completions-to-complete.patch queue-4.9/ib-mlx5-fix-reported-max-sge-calculation.patch