diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2005-11-18 22:11:17 (GMT) |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-11-18 22:11:17 (GMT) |
commit | 48fd0d1fdd357caa2de8cb4ce6af810df7535f43 (patch) | |
tree | 09e6f5113d908a7f059cc0b374c545d69e0f2a1d /drivers/infiniband/hw/mthca/mthca_qp.c | |
parent | cbc5b2bb9e226c2b2b981836d2289912e2ef3c1c (diff) | |
download | linux-fsl-qoriq-48fd0d1fdd357caa2de8cb4ce6af810df7535f43.tar.xz |
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 <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_qp.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 10 |
1 files changed, 6 insertions, 4 deletions
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)); } /* |