]> www.infradead.org Git - users/jedix/linux-maple.git/commit
scatterlist: introduce sg_nents_for_len
authorTom Lendacky <thomas.lendacky@amd.com>
Mon, 1 Jun 2015 16:15:25 +0000 (11:15 -0500)
committerSomasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Thu, 24 Aug 2017 17:52:42 +0000 (10:52 -0700)
commit1bbc83ae7084081e0ff33724aa8bcba8a1fa73aa
treedd5398e2808d3a1378aca85c89a368111b23e997
parent0ac158c418834d0ce44746f057fdc85ce6bad0f0
scatterlist: introduce sg_nents_for_len

Orabug: 26644685

When performing a dma_map_sg() call, the number of sg entries to map is
required. Using sg_nents to retrieve the number of sg entries will
return the total number of entries in the sg list up to the entry marked
as the end. If there happen to be unused entries in the list, these will
still be counted. Some dma_map_sg() implementations will not handle the
unused entries correctly (lib/swiotlb.c) and execute a BUG_ON.

The sg_nents_for_len() function will traverse the sg list and return the
number of entries required to satisfy the supplied length argument. This
can then be supplied to the dma_map_sg() call to successfully map the
sg.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit cfaed10d1f27d036b72bbdc6b1e59ea28c38ec7f)
Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
include/linux/scatterlist.h
lib/scatterlist.c