aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2015-06-01 11:15:25 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-03 10:51:27 +0800
commitcfaed10d1f27d036b72bbdc6b1e59ea28c38ec7f (patch)
tree41afa11a44a4486966af9f1b89025bc9f8e2c8e7 /include
parentcrypto: scatterwalk - Hide PageSlab call to optimise away flush_dcache_page (diff)
downloadlinux-dev-cfaed10d1f27d036b72bbdc6b1e59ea28c38ec7f.tar.xz
linux-dev-cfaed10d1f27d036b72bbdc6b1e59ea28c38ec7f.zip
scatterlist: introduce sg_nents_for_len
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/scatterlist.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index ed8f9e70df9b..a0edb992c9c3 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -221,6 +221,7 @@ static inline void *sg_virt(struct scatterlist *sg)
}
int sg_nents(struct scatterlist *sg);
+int sg_nents_for_len(struct scatterlist *sg, u64 len);
struct scatterlist *sg_next(struct scatterlist *);
struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
void sg_init_table(struct scatterlist *, unsigned int);