Lines Matching full:sg
15 * @sg: The current sg entry
18 * Usually the next entry will be @sg@ + 1, but if this sg element is part
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()
38 * @sg: The scatterlist
41 * Allows to know how many entries are in sg, taking into account
45 int sg_nents(struct scatterlist *sg) in sg_nents() argument
48 for (nents = 0; sg; sg = sg_next(sg)) in sg_nents()
57 * @sg: The scatterlist
61 * Determines the number of entries in sg that are required to meet
65 * the number of sg entries needed, negative error on failure
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()
115 * sg_init_table - Initialize SG table
116 * @sgl: The SG table
120 * If this is part of a chained sg table, sg_mark_end() should be
132 * sg_init_one - Initialize a single entry sg list
133 * @sg: SG entry
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()
179 * __sg_free_table - Free a previously mapped sg table
180 * @table: The sg table header to use
188 * Free an sg table previously allocated and setup with
210 * then assign 'next' to the sg table after the current one. in __sg_free_table()
237 * sg_free_append_table - Free a previously allocated append sg table.
238 * @table: The mapped sg append table header
250 * sg_free_table - Free a previously allocated sg table
251 * @table: The mapped sg table header
262 * __sg_alloc_table - Allocate and initialize an sg table with given allocator
263 * @table: The sg table header to use
264 * @nents: Number of entries in sg list
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()
337 * If this is the first mapping, assign the sg table header. 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()
361 * sg_alloc_table - Allocate and initialize an sg table
362 * @table: The sg table header to use
363 * @nents: Number of entries in sg list
367 * Allocate and initialize an sg table. If @nents@ is larger than
368 * SG_MAX_SINGLE_ALLOC a chained sg table will be setup.
414 * sg_alloc_append_table_from_pages - Allocate and initialize an append sg
416 * @sgt_append: The sg append table to use
426 * In the first call it allocate and initialize an sg table from a list of
431 * returned sg table is released by sg_free_append_table
471 /* Merge contiguous pages into the last SG */ in sg_alloc_append_table_from_pages()
543 * sg_alloc_table_from_pages_segment - Allocate and initialize an sg table from
546 * @sgt: The sg table header to use
555 * Allocate and initialize an sg table from a list of pages. Contiguous
560 * The returned sg table is released by sg_free_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()
775 * sg_miter_start - start mapping iteration over a sg list
776 * @miter: sg mapping iter to be started
777 * @sgl: sg list to iterate over
778 * @nents: number of sg entries
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()
822 * @miter: sg mapping iter to be skipped
834 * true if @miter contains the valid mapping. false if end of sg
859 * @miter: sg mapping iter to proceed
870 * true if @miter contains the next mapping. false if end of sg
898 * @miter: sg mapping iter to be stopped
936 * sg_copy_buffer - Copy data between a linear buffer and an SG list
937 * @sgl: The SG list
938 * @nents: Number of SG entries
942 * @to_buffer: transfer direction (true == from an sg list to a
943 * buffer, false == from a buffer to an sg list)
985 * sg_copy_from_buffer - Copy from a linear buffer to an SG list
986 * @sgl: The SG list
987 * @nents: Number of SG entries
1002 * sg_copy_to_buffer - Copy from an SG list to a linear buffer
1003 * @sgl: The SG list
1004 * @nents: Number of SG entries
1019 * sg_pcopy_from_buffer - Copy from a linear buffer to an SG list
1020 * @sgl: The SG list
1021 * @nents: Number of SG entries
1037 * sg_pcopy_to_buffer - Copy from an SG list to a linear buffer
1038 * @sgl: The SG list
1039 * @nents: Number of SG entries
1055 * sg_zero_buffer - Zero-out a part of a SG list
1056 * @sgl: The SG list
1057 * @nents: Number of SG entries