lib/scatterlist: Do not limit max_segment to PAGE_ALIGNED values
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 16 Oct 2020 11:46:01 +0000 (08:46 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 16 Oct 2020 15:41:33 +0000 (12:41 -0300)
commit9a40401cfa1356b0d169be8470ed7b2edc33b98f
treed5a06663aaea0288eacc183ac2d41ef785191987
parent16e7483e6f02973972f832b18042fd6c45fe26c0
lib/scatterlist: Do not limit max_segment to PAGE_ALIGNED values

The main intention of the max_segment argument to
__sg_alloc_table_from_pages() is to match the DMA layer segment size set
by dma_set_max_seg_size().

Restricting the input to be page aligned makes it impossible to just
connect the DMA layer to this API.

The only reason for a page alignment here is because the algorithm will
overshoot the max_segment if it is not a multiple of PAGE_SIZE. Simply fix
the alignment before starting and don't expose this implementation detail
to the callers.

A future patch will completely remove SCATTERLIST_MAX_SEGMENT.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
lib/scatterlist.c