Commit 68363052 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/qedr: Use rdma_umem_for_each_dma_block() instead of open-coding

This loop is splitting the DMA SGL into pg_shift sized pages, use the core
code for this directly.

Link: https://lore.kernel.org/r/9-v2-270386b7e60b+28f4-umem_1_jgg@nvidia.comAcked-by: default avatarMichal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 22123a0e
...@@ -601,11 +601,9 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem, ...@@ -601,11 +601,9 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem,
struct qedr_pbl_info *pbl_info, u32 pg_shift) struct qedr_pbl_info *pbl_info, u32 pg_shift)
{ {
int pbe_cnt, total_num_pbes = 0; int pbe_cnt, total_num_pbes = 0;
u32 fw_pg_cnt, fw_pg_per_umem_pg;
struct qedr_pbl *pbl_tbl; struct qedr_pbl *pbl_tbl;
struct sg_dma_page_iter sg_iter; struct ib_block_iter biter;
struct regpair *pbe; struct regpair *pbe;
u64 pg_addr;
if (!pbl_info->num_pbes) if (!pbl_info->num_pbes)
return; return;
...@@ -626,32 +624,25 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem, ...@@ -626,32 +624,25 @@ static void qedr_populate_pbls(struct qedr_dev *dev, struct ib_umem *umem,
pbe_cnt = 0; pbe_cnt = 0;
fw_pg_per_umem_pg = BIT(PAGE_SHIFT - pg_shift); rdma_umem_for_each_dma_block (umem, &biter, BIT(pg_shift)) {
u64 pg_addr = rdma_block_iter_dma_address(&biter);
for_each_sg_dma_page (umem->sg_head.sgl, &sg_iter, umem->nmap, 0) { pbe->lo = cpu_to_le32(pg_addr);
pg_addr = sg_page_iter_dma_address(&sg_iter); pbe->hi = cpu_to_le32(upper_32_bits(pg_addr));
for (fw_pg_cnt = 0; fw_pg_cnt < fw_pg_per_umem_pg;) {
pbe->lo = cpu_to_le32(pg_addr);
pbe->hi = cpu_to_le32(upper_32_bits(pg_addr));
pg_addr += BIT(pg_shift); pbe_cnt++;
pbe_cnt++; total_num_pbes++;
total_num_pbes++; pbe++;
pbe++;
if (total_num_pbes == pbl_info->num_pbes) if (total_num_pbes == pbl_info->num_pbes)
return; 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. */
*/ if (pbe_cnt == (pbl_info->pbl_size / sizeof(u64))) {
if (pbe_cnt == (pbl_info->pbl_size / sizeof(u64))) { pbl_tbl++;
pbl_tbl++; pbe = (struct regpair *)pbl_tbl->va;
pbe = (struct regpair *)pbl_tbl->va; pbe_cnt = 0;
pbe_cnt = 0;
}
fw_pg_cnt++;
} }
} }
} }
......
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