From: Michael S. Tsirkin Date: Fri, 18 Nov 2005 22:11:17 +0000 (-0800) Subject: IB/mthca: Safer max_send_sge/max_recv_sge calculation X-Git-Tag: v2.6.15-rc2~15^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48fd0d1fdd357caa2de8cb4ce6af810df7535f43;p=platform%2Fkernel%2Flinux-exynos.git IB/mthca: Safer max_send_sge/max_recv_sge calculation Calculation of QP capabilities still isn't exactly right in mthca: max_send_sge/max_recv_sge fields returned in create_qp can exceed the handware supported limits. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 5899f0c..dd4e133 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -918,10 +918,12 @@ static void mthca_adjust_qp_caps(struct mthca_dev *dev, else qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE; - qp->sq.max_gs = max_data_size / sizeof (struct mthca_data_seg); - qp->rq.max_gs = (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) - - sizeof (struct mthca_next_seg)) / - sizeof (struct mthca_data_seg); + qp->sq.max_gs = min_t(int, dev->limits.max_sg, + max_data_size / sizeof (struct mthca_data_seg)); + qp->rq.max_gs = min_t(int, dev->limits.max_sg, + (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) - + sizeof (struct mthca_next_seg)) / + sizeof (struct mthca_data_seg)); } /*