Commit b8387f81 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/ocrdma: Use ib_umem_num_dma_blocks() instead of ib_umem_page_count()

This driver always uses a DMA array made up of PAGE_SIZE elements, so just
use ib_umem_num_dma_blocks().

Since rdma_for_each_dma_block() always iterates exactly
ib_umem_num_dma_blocks() there is no need for the early exit check in
build_user_pbes(), delete it.

Link: https://lore.kernel.org/r/13-v2-270386b7e60b+28f4-umem_1_jgg@nvidia.comSigned-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent cf9ce3c8
...@@ -811,13 +811,12 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr) ...@@ -811,13 +811,12 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)
return status; return status;
} }
static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr, static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr)
u32 num_pbes)
{ {
struct ocrdma_pbe *pbe; struct ocrdma_pbe *pbe;
struct ib_block_iter biter; struct ib_block_iter biter;
struct ocrdma_pbl *pbl_tbl = mr->hwmr.pbl_table; struct ocrdma_pbl *pbl_tbl = mr->hwmr.pbl_table;
int pbe_cnt, total_num_pbes = 0; int pbe_cnt;
u64 pg_addr; u64 pg_addr;
if (!mr->hwmr.num_pbes) if (!mr->hwmr.num_pbes)
...@@ -832,13 +831,8 @@ static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr, ...@@ -832,13 +831,8 @@ static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
pbe->pa_lo = cpu_to_le32(pg_addr); pbe->pa_lo = cpu_to_le32(pg_addr);
pbe->pa_hi = cpu_to_le32(upper_32_bits(pg_addr)); pbe->pa_hi = cpu_to_le32(upper_32_bits(pg_addr));
pbe_cnt += 1; pbe_cnt += 1;
total_num_pbes += 1;
pbe++; pbe++;
/* if done building pbes, issue the mbx cmd. */
if (total_num_pbes == num_pbes)
return;
/* if the given pbl is full storing the pbes, /* if the given pbl is full storing the pbes,
* move to next pbl. * move to next pbl.
*/ */
...@@ -857,7 +851,6 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, ...@@ -857,7 +851,6 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device); struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
struct ocrdma_mr *mr; struct ocrdma_mr *mr;
struct ocrdma_pd *pd; struct ocrdma_pd *pd;
u32 num_pbes;
pd = get_ocrdma_pd(ibpd); pd = get_ocrdma_pd(ibpd);
...@@ -872,8 +865,8 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, ...@@ -872,8 +865,8 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
status = -EFAULT; status = -EFAULT;
goto umem_err; goto umem_err;
} }
num_pbes = ib_umem_page_count(mr->umem); status = ocrdma_get_pbl_info(
status = ocrdma_get_pbl_info(dev, mr, num_pbes); dev, mr, ib_umem_num_dma_blocks(mr->umem, PAGE_SIZE));
if (status) if (status)
goto umem_err; goto umem_err;
...@@ -889,7 +882,7 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len, ...@@ -889,7 +882,7 @@ struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
status = ocrdma_build_pbl_tbl(dev, &mr->hwmr); status = ocrdma_build_pbl_tbl(dev, &mr->hwmr);
if (status) if (status)
goto umem_err; goto umem_err;
build_user_pbes(dev, mr, num_pbes); build_user_pbes(dev, mr);
status = ocrdma_reg_mr(dev, &mr->hwmr, pd->id, acc); status = ocrdma_reg_mr(dev, &mr->hwmr, pd->id, acc);
if (status) if (status)
goto mbx_err; goto mbx_err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment