Lines Matching refs:sg
27 struct sg_table *sg; member
64 struct sg_table *sg; in get_sg_table() local
67 sg = kzalloc(sizeof(*sg), GFP_KERNEL); in get_sg_table()
68 if (!sg) in get_sg_table()
70 ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->pagecount, in get_sg_table()
75 ret = dma_map_sgtable(dev, sg, direction, 0); in get_sg_table()
78 return sg; in get_sg_table()
81 sg_free_table(sg); in get_sg_table()
82 kfree(sg); in get_sg_table()
86 static void put_sg_table(struct device *dev, struct sg_table *sg, in put_sg_table() argument
89 dma_unmap_sgtable(dev, sg, direction, 0); in put_sg_table()
90 sg_free_table(sg); in put_sg_table()
91 kfree(sg); in put_sg_table()
101 struct sg_table *sg, in unmap_udmabuf() argument
104 return put_sg_table(at->dev, sg, direction); in unmap_udmabuf()
113 if (ubuf->sg) in release_udmabuf()
114 put_sg_table(dev, ubuf->sg, DMA_BIDIRECTIONAL); in release_udmabuf()
129 if (!ubuf->sg) { in begin_cpu_udmabuf()
130 ubuf->sg = get_sg_table(dev, buf, direction); in begin_cpu_udmabuf()
131 if (IS_ERR(ubuf->sg)) { in begin_cpu_udmabuf()
132 ret = PTR_ERR(ubuf->sg); in begin_cpu_udmabuf()
133 ubuf->sg = NULL; in begin_cpu_udmabuf()
136 dma_sync_sg_for_cpu(dev, ubuf->sg->sgl, ubuf->sg->nents, in begin_cpu_udmabuf()
149 if (!ubuf->sg) in end_cpu_udmabuf()
152 dma_sync_sg_for_device(dev, ubuf->sg->sgl, ubuf->sg->nents, direction); in end_cpu_udmabuf()