Commit 43fae912 authored by Shiraz, Saleem's avatar Shiraz, Saleem Committed by Jason Gunthorpe

RDMA/i40iw: Use for_each_sg_dma_page iterator on umem SGL

Use the for_each_sg_dma_page iterator variant to walk the umem DMA-mapped
SGL and get the page DMA address. This avoids the extra loop to iterate
pages in the SGE when for_each_sg iterator is used.

Additionally, purge umem->page_shift usage in the driver as its only
relevant for ODP MRs. Use system page size and shift instead.
Signed-off-by: default avatarShiraz, Saleem <shiraz.saleem@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 8d249af3
...@@ -1360,32 +1360,29 @@ static void i40iw_copy_user_pgaddrs(struct i40iw_mr *iwmr, ...@@ -1360,32 +1360,29 @@ static void i40iw_copy_user_pgaddrs(struct i40iw_mr *iwmr,
{ {
struct ib_umem *region = iwmr->region; struct ib_umem *region = iwmr->region;
struct i40iw_pbl *iwpbl = &iwmr->iwpbl; struct i40iw_pbl *iwpbl = &iwmr->iwpbl;
int chunk_pages, entry, i;
struct i40iw_pble_alloc *palloc = &iwpbl->pble_alloc; struct i40iw_pble_alloc *palloc = &iwpbl->pble_alloc;
struct i40iw_pble_info *pinfo; struct i40iw_pble_info *pinfo;
struct scatterlist *sg; struct sg_dma_page_iter sg_iter;
u64 pg_addr = 0; u64 pg_addr = 0;
u32 idx = 0; u32 idx = 0;
bool first_pg = true;
pinfo = (level == I40IW_LEVEL_1) ? NULL : palloc->level2.leaf; pinfo = (level == I40IW_LEVEL_1) ? NULL : palloc->level2.leaf;
for_each_sg(region->sg_head.sgl, sg, region->nmap, entry) { if (iwmr->type == IW_MEMREG_TYPE_QP)
chunk_pages = sg_dma_len(sg) >> region->page_shift; iwpbl->qp_mr.sq_page = sg_page(region->sg_head.sgl);
if ((iwmr->type == IW_MEMREG_TYPE_QP) &&
!iwpbl->qp_mr.sq_page) for_each_sg_dma_page (region->sg_head.sgl, &sg_iter, region->nmap, 0) {
iwpbl->qp_mr.sq_page = sg_page(sg); pg_addr = sg_page_iter_dma_address(&sg_iter);
for (i = 0; i < chunk_pages; i++) { if (first_pg)
pg_addr = sg_dma_address(sg) + *pbl = cpu_to_le64(pg_addr & iwmr->page_msk);
(i << region->page_shift); else if (!(pg_addr & ~iwmr->page_msk))
*pbl = cpu_to_le64(pg_addr);
if ((entry + i) == 0) else
*pbl = cpu_to_le64(pg_addr & iwmr->page_msk); continue;
else if (!(pg_addr & ~iwmr->page_msk))
*pbl = cpu_to_le64(pg_addr); first_pg = false;
else pbl = i40iw_next_pbl_addr(pbl, &pinfo, &idx);
continue;
pbl = i40iw_next_pbl_addr(pbl, &pinfo, &idx);
}
} }
} }
......
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