On Mon, Jan 02, 2023 at 06:03:17PM +0200, Yonatan Nachum wrote: > When registering a new DMA MR after selecting the best aligned page size > for it, we iterate over the given sglist to split each entry to smaller, > aligned to the selected page size, DMA blocks. > > In given circumstances where the sg entry and page size fit certain sizes > and the sg entry is not aligned to the selected page size, the total size > of the aligned pages we need to cover the sg entry is >= 4GB. Huh? The max length of a scatterlist element is unsigned int: struct scatterlist { unsigned long page_link; unsigned int offset; unsigned int length; The problem is the construction of the end of iteration test: block_offset = biter->__dma_addr & (BIT_ULL(biter->__pg_bit) - 1); biter->__sg_advance += BIT_ULL(biter->__pg_bit) - block_offset; if (biter->__sg_advance >= sg_dma_len(biter->__sg)) { This should be reworked so it doesn't increment until it knows it is OK and leave the types alone. Jason