diff mbox series

[08/14] RDMA/qedr: Use ib_umem_num_dma_blocks() instead of ib_umem_page_count()

Message ID 8-v1-00f59ce24f1f+19f50-umem_1_jgg@nvidia.com (mailing list archive)
State Superseded
Headers show
Series RDMA: Improve use of umem in DMA drivers | expand

Commit Message

Jason Gunthorpe Sept. 2, 2020, 12:43 a.m. UTC
The length of the list populated by qedr_populate_pbls() should be
calculated using ib_umem_num_blocks() with the same size/shift passed to
qedr_populate_pbls().

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/infiniband/hw/qedr/verbs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Michal Kalderon Sept. 2, 2020, 3:35 p.m. UTC | #1
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, September 2, 2020 3:44 AM
> To: Ariel Elior <aelior@marvell.com>; Doug Ledford <dledford@redhat.com>;
> linux-rdma@vger.kernel.org; Michal Kalderon <mkalderon@marvell.com>
> Subject: [EXT] [PATCH 08/14] RDMA/qedr: Use
> ib_umem_num_dma_blocks() instead of ib_umem_page_count()
> 
> The length of the list populated by qedr_populate_pbls() should be
> calculated using ib_umem_num_blocks() with the same size/shift passed to
> qedr_populate_pbls().
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/infiniband/hw/qedr/verbs.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/qedr/verbs.c
> b/drivers/infiniband/hw/qedr/verbs.c
> index cbb49168d9f7ed..278b48443aedba 100644
> --- a/drivers/infiniband/hw/qedr/verbs.c
> +++ b/drivers/infiniband/hw/qedr/verbs.c
> @@ -783,9 +783,7 @@ static inline int qedr_init_user_queue(struct ib_udata
> *udata,
>  		return PTR_ERR(q->umem);
>  	}
> 
> -	fw_pages = ib_umem_page_count(q->umem) <<
> -	    (PAGE_SHIFT - FW_PAGE_SHIFT);
> -
> +	fw_pages = ib_umem_num_dma_blocks(q->umem, 1 <<
> FW_PAGE_SHIFT);
>  	rc = qedr_prepare_pbl_tbl(dev, &q->pbl_info, fw_pages, 0);
>  	if (rc)
>  		goto err0;
> @@ -2852,7 +2850,8 @@ struct ib_mr *qedr_reg_user_mr(struct ib_pd
> *ibpd, u64 start, u64 len,
>  		goto err0;
>  	}
> 
> -	rc = init_mr_info(dev, &mr->info, ib_umem_page_count(mr-
> >umem), 1);
> +	rc = init_mr_info(dev, &mr->info,
> +			  ib_umem_num_dma_blocks(mr->umem,
> PAGE_SIZE), 1);
>  	if (rc)
>  		goto err1;
> 
> --
> 2.28.0

Thanks, 

Acked-by: Michal Kalderon <michal.kalderon@marvell.com>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index cbb49168d9f7ed..278b48443aedba 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -783,9 +783,7 @@  static inline int qedr_init_user_queue(struct ib_udata *udata,
 		return PTR_ERR(q->umem);
 	}
 
-	fw_pages = ib_umem_page_count(q->umem) <<
-	    (PAGE_SHIFT - FW_PAGE_SHIFT);
-
+	fw_pages = ib_umem_num_dma_blocks(q->umem, 1 << FW_PAGE_SHIFT);
 	rc = qedr_prepare_pbl_tbl(dev, &q->pbl_info, fw_pages, 0);
 	if (rc)
 		goto err0;
@@ -2852,7 +2850,8 @@  struct ib_mr *qedr_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
 		goto err0;
 	}
 
-	rc = init_mr_info(dev, &mr->info, ib_umem_page_count(mr->umem), 1);
+	rc = init_mr_info(dev, &mr->info,
+			  ib_umem_num_dma_blocks(mr->umem, PAGE_SIZE), 1);
 	if (rc)
 		goto err1;