On Tue, Sep 01, 2020 at 09:43:34PM -0300, Jason Gunthorpe wrote: > diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h > index b880512ba95f16..ba3b9be0d8c56a 100644 > +++ b/include/rdma/ib_umem.h > @@ -33,11 +33,17 @@ static inline int ib_umem_offset(struct ib_umem *umem) > return umem->address & ~PAGE_MASK; > } > > +static inline size_t ib_umem_num_dma_blocks(struct ib_umem *umem, > + unsigned long pgsz) > +{ > + return (ALIGN(umem->address + umem->length, pgsz) - > + ALIGN_DOWN(umem->address, pgsz)) / > + pgsz; > +} Like the other places, this is wrong as well. The IOVA needs to be used here or it can be +-1 page away from what rdma_umem_for_each_dma_block() returns. However, it does work if pgsz is PAGE_SIZE, or for the very common cases where umem->address == IOVA... Which, I suppose, is why nobody noticed this until now, as I found several drivers open coding the above. Jason