Lines Matching refs:sg
23 struct scatterlist *sg_next(struct scatterlist *sg) in sg_next() argument
25 if (sg_is_last(sg)) in sg_next()
28 sg++; in sg_next()
29 if (unlikely(sg_is_chain(sg))) in sg_next()
30 sg = sg_chain_ptr(sg); in sg_next()
32 return sg; in sg_next()
45 int sg_nents(struct scatterlist *sg) in sg_nents() argument
48 for (nents = 0; sg; sg = sg_next(sg)) in sg_nents()
68 int sg_nents_for_len(struct scatterlist *sg, u64 len) in sg_nents_for_len() argument
76 for (nents = 0, total = 0; sg; sg = sg_next(sg)) { in sg_nents_for_len()
78 total += sg->length; in sg_nents_for_len()
103 struct scatterlist *sg, *ret = NULL; in sg_last() local
106 for_each_sg(sgl, sg, nents, i) in sg_last()
107 ret = sg; in sg_last()
138 void sg_init_one(struct scatterlist *sg, const void *buf, unsigned int buflen) in sg_init_one() argument
140 sg_init_table(sg, 1); in sg_init_one()
141 sg_set_buf(sg, buf, buflen); in sg_init_one()
169 static void sg_kfree(struct scatterlist *sg, unsigned int nents) in sg_kfree() argument
172 kmemleak_free(sg); in sg_kfree()
173 free_page((unsigned long) sg); in sg_kfree()
175 kfree(sg); in sg_kfree()
287 struct scatterlist *sg, *prv; in __sg_alloc_table() local
315 sg = first_chunk; in __sg_alloc_table()
318 sg = alloc_fn(alloc_size, gfp_mask); in __sg_alloc_table()
320 if (unlikely(!sg)) { in __sg_alloc_table()
333 sg_init_table(sg, alloc_size); in __sg_alloc_table()
341 sg_chain(prv, prv_max_ents, sg); in __sg_alloc_table()
343 table->sgl = sg; in __sg_alloc_table()
349 sg_mark_end(&sg[sg_size - 1]); in __sg_alloc_table()
351 prv = sg; in __sg_alloc_table()
602 struct scatterlist *sgl, *sg; in sgl_alloc_order() local
624 sg = sgl; in sgl_alloc_order()
633 sg_set_page(sg, page, elem_len, 0); in sgl_alloc_order()
635 sg = sg_next(sg); in sgl_alloc_order()
674 struct scatterlist *sg; in sgl_free_n_order() local
678 for_each_sg(sgl, sg, nents, i) { in sgl_free_n_order()
679 if (!sg) in sgl_free_n_order()
681 page = sg_page(sg); in sgl_free_n_order()
719 piter->sg = sglist; in __sg_page_iter_start()
724 static int sg_page_count(struct scatterlist *sg) in sg_page_count() argument
726 return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT; in sg_page_count()
731 if (!piter->__nents || !piter->sg) in __sg_page_iter_next()
737 while (piter->sg_pgoffset >= sg_page_count(piter->sg)) { in __sg_page_iter_next()
738 piter->sg_pgoffset -= sg_page_count(piter->sg); in __sg_page_iter_next()
739 piter->sg = sg_next(piter->sg); in __sg_page_iter_next()
740 if (!--piter->__nents || !piter->sg) in __sg_page_iter_next()
748 static int sg_dma_page_count(struct scatterlist *sg) in sg_dma_page_count() argument
750 return PAGE_ALIGN(sg->offset + sg_dma_len(sg)) >> PAGE_SHIFT; in sg_dma_page_count()
757 if (!piter->__nents || !piter->sg) in __sg_page_iter_dma_next()
763 while (piter->sg_pgoffset >= sg_dma_page_count(piter->sg)) { in __sg_page_iter_dma_next()
764 piter->sg_pgoffset -= sg_dma_page_count(piter->sg); in __sg_page_iter_dma_next()
765 piter->sg = sg_next(piter->sg); in __sg_page_iter_dma_next()
766 if (!--piter->__nents || !piter->sg) in __sg_page_iter_dma_next()
800 struct scatterlist *sg; in sg_miter_get_next_page() local
805 sg = miter->piter.sg; in sg_miter_get_next_page()
807 miter->__offset = miter->piter.sg_pgoffset ? 0 : sg->offset; in sg_miter_get_next_page()
810 miter->__remaining = sg->offset + sg->length - in sg_miter_get_next_page()