On Wed, Feb 20, 2019 at 04:55:39PM +0200, Leon Romanovsky wrote: > On Tue, Feb 19, 2019 at 08:57:42AM -0600, Shiraz Saleem wrote: > > This helper iterates over the SG list and returns contiguous > > memory blocks aligned to a HW supported page size. > > The implementation is intended to work for HW that support > > single page sizes or mixed page sizes in an MR. Drivers > > can use this helper to retreive the DMA addresses aligned > > to their best supported page size. > > > > Suggested-by: Jason Gunthorpe <jgg@xxxxxxxx> > > Reviewed-by: Michael J. Ruhl <michael.j.ruhl@xxxxxxxxx> > > Signed-off-by: Shiraz Saleem <shiraz.saleem@xxxxxxxxx> > > --- > > drivers/infiniband/core/umem.c | 90 ++++++++++++++++++++++++++++++++++++++++++ > > include/rdma/ib_umem.h | 23 +++++++++++ > > 2 files changed, 113 insertions(+) > > > > diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c > > index d3b572e..8c3ec1b 100644 > > --- a/drivers/infiniband/core/umem.c > > +++ b/drivers/infiniband/core/umem.c > > @@ -214,6 +214,96 @@ unsigned long ib_umem_find_single_pg_size(struct ib_umem *umem, > > } > > EXPORT_SYMBOL(ib_umem_find_single_pg_size); > > > > +static unsigned int ib_umem_find_mixed_pg_bit(struct scatterlist *sgl_head, > > + struct sg_phys_iter *sg_phys_iter) > > +{ > > + unsigned long dma_addr_start, dma_addr_end; > > + > > + dma_addr_start = sg_dma_address(sg_phys_iter->sg); > > + dma_addr_end = sg_dma_address(sg_phys_iter->sg) + > > + sg_dma_len(sg_phys_iter->sg); > > + > > + if (sg_phys_iter->sg == sgl_head) > > + return ib_umem_find_pg_bit(dma_addr_end, > > + sg_phys_iter->supported_pgsz); > > + else if (sg_is_last(sg_phys_iter->sg)) > > + return ib_umem_find_pg_bit(dma_addr_start, > > + sg_phys_iter->supported_pgsz); > > + else > > + return ib_umem_find_pg_bit(sg_phys_iter->phyaddr, > > + sg_phys_iter->supported_pgsz); > > It is very confusing, at least for me, the usage of first argument of > ib_umem_find_pg_bit(). In previous patch, you wrote that it is > phys address, but here you are mixing physical and DMA addresses. > The helper ib_umem_find_pg_bit() really is generic to work with any addr. I should however, not tie it to any type in the description. Shiraz