Skip to content

Commit b1a086c

Browse files
yishaihMukesh Kacker
authored andcommitted
mlx4_ib: contig support for control objects
Reviewer: Shachar Raindel <[email protected]> Signed-off-by: Yishai Hadas <[email protected]> (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker <[email protected]>
1 parent 03857fc commit b1a086c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

drivers/infiniband/hw/mlx4/cq.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ static int mlx4_ib_get_cq_umem(struct mlx4_ib_dev *dev, struct ib_ucontext *cont
140140
{
141141
int err;
142142
int cqe_size = dev->dev->caps.cqe_size;
143+
int shift;
144+
int n;
143145

144146
*umem = ib_umem_get(context, buf_addr, cqe * cqe_size,
145147
IB_ACCESS_LOCAL_WRITE, 1);
146148
if (IS_ERR(*umem))
147149
return PTR_ERR(*umem);
148150

149-
err = mlx4_mtt_init(dev->dev, ib_umem_page_count(*umem),
150-
ilog2((*umem)->page_size), &buf->mtt);
151+
n = ib_umem_page_count(*umem);
152+
shift = mlx4_ib_umem_calc_optimal_mtt_size(*umem, 0, &n);
153+
err = mlx4_mtt_init(dev->dev, n, shift, &buf->mtt);
154+
151155
if (err)
152156
goto err_buf;
153157

drivers/infiniband/hw/mlx4/mlx4_ib.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ void mlx4_ib_db_unmap_user(struct mlx4_ib_ucontext *context, struct mlx4_db *db)
652652
struct ib_mr *mlx4_ib_get_dma_mr(struct ib_pd *pd, int acc);
653653
int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
654654
struct ib_umem *umem);
655+
int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem,
656+
u64 start_va,
657+
int *num_of_mtts);
655658
struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
656659
u64 virt_addr, int access_flags,
657660
struct ib_udata *udata);

drivers/infiniband/hw/mlx4/mr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int mlx4_ib_umem_calc_block_mtt(u64 next_block_start,
263263
All chunks in the middle already handled as part of mtt shift calculation
264264
for both their start & end addresses.
265265
*/
266-
static int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem,
266+
int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem,
267267
u64 start_va,
268268
int *num_of_mtts)
269269
{

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
709709

710710
if (pd->uobject) {
711711
struct mlx4_ib_create_qp ucmd;
712+
int shift;
713+
int n;
712714

713715
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
714716
err = -EFAULT;
@@ -728,8 +730,10 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
728730
goto err;
729731
}
730732

731-
err = mlx4_mtt_init(dev->dev, ib_umem_page_count(qp->umem),
732-
ilog2(qp->umem->page_size), &qp->mtt);
733+
n = ib_umem_page_count(qp->umem);
734+
shift = mlx4_ib_umem_calc_optimal_mtt_size(qp->umem, 0, &n);
735+
err = mlx4_mtt_init(dev->dev, n, shift, &qp->mtt);
736+
733737
if (err)
734738
goto err_buf;
735739

0 commit comments

Comments
 (0)