Lines Matching refs:sgt
53 static void vb2_dc_sgt_foreach_page(struct sg_table *sgt, in vb2_dc_sgt_foreach_page() argument
59 for_each_sg(sgt->sgl, s, sgt->orig_nents, i) { in vb2_dc_sgt_foreach_page()
70 static unsigned long vb2_dc_get_contiguous_size(struct sg_table *sgt) in vb2_dc_get_contiguous_size() argument
73 dma_addr_t expected = sg_dma_address(sgt->sgl); in vb2_dc_get_contiguous_size()
77 for_each_sg(sgt->sgl, s, sgt->nents, i) { in vb2_dc_get_contiguous_size()
117 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_prepare() local
120 if (!sgt || buf->db_attach) in vb2_dc_prepare()
123 dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); in vb2_dc_prepare()
129 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_finish() local
132 if (!sgt || buf->db_attach) in vb2_dc_finish()
135 dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir); in vb2_dc_finish()
233 struct sg_table sgt; member
243 struct sg_table *sgt; in vb2_dc_dmabuf_ops_attach() local
251 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_attach()
255 ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL); in vb2_dc_dmabuf_ops_attach()
262 wr = sgt->sgl; in vb2_dc_dmabuf_ops_attach()
263 for (i = 0; i < sgt->orig_nents; ++i) { in vb2_dc_dmabuf_ops_attach()
279 struct sg_table *sgt; in vb2_dc_dmabuf_ops_detach() local
284 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_detach()
288 dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, in vb2_dc_dmabuf_ops_detach()
290 sg_free_table(sgt); in vb2_dc_dmabuf_ops_detach()
301 struct sg_table *sgt; in vb2_dc_dmabuf_ops_map() local
306 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_map()
310 return sgt; in vb2_dc_dmabuf_ops_map()
315 dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, in vb2_dc_dmabuf_ops_map()
321 ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dma_dir); in vb2_dc_dmabuf_ops_map()
332 return sgt; in vb2_dc_dmabuf_ops_map()
336 struct sg_table *sgt, enum dma_data_direction dma_dir) in vb2_dc_dmabuf_ops_unmap() argument
382 struct sg_table *sgt; in vb2_dc_get_base_sgt() local
384 sgt = kmalloc(sizeof(*sgt), GFP_KERNEL); in vb2_dc_get_base_sgt()
385 if (!sgt) { in vb2_dc_get_base_sgt()
390 ret = dma_get_sgtable(buf->dev, sgt, buf->vaddr, buf->dma_addr, in vb2_dc_get_base_sgt()
394 kfree(sgt); in vb2_dc_get_base_sgt()
398 return sgt; in vb2_dc_get_base_sgt()
517 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_put_userptr() local
519 if (sgt) { in vb2_dc_put_userptr()
527 dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, in vb2_dc_put_userptr()
530 vb2_dc_sgt_foreach_page(sgt, vb2_dc_put_dirty_page); in vb2_dc_put_userptr()
532 sg_free_table(sgt); in vb2_dc_put_userptr()
533 kfree(sgt); in vb2_dc_put_userptr()
582 struct sg_table *sgt; in vb2_dc_get_userptr() local
655 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); in vb2_dc_get_userptr()
656 if (!sgt) { in vb2_dc_get_userptr()
662 ret = sg_alloc_table_from_pages(sgt, pages, n_pages, in vb2_dc_get_userptr()
677 sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, in vb2_dc_get_userptr()
679 if (sgt->nents <= 0) { in vb2_dc_get_userptr()
685 contig_size = vb2_dc_get_contiguous_size(sgt); in vb2_dc_get_userptr()
693 buf->dma_addr = sg_dma_address(sgt->sgl); in vb2_dc_get_userptr()
695 buf->dma_sgt = sgt; in vb2_dc_get_userptr()
700 dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents, in vb2_dc_get_userptr()
705 vb2_dc_sgt_foreach_page(sgt, put_page); in vb2_dc_get_userptr()
706 sg_free_table(sgt); in vb2_dc_get_userptr()
709 kfree(sgt); in vb2_dc_get_userptr()
735 struct sg_table *sgt; in vb2_dc_map_dmabuf() local
749 sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir); in vb2_dc_map_dmabuf()
750 if (IS_ERR(sgt)) { in vb2_dc_map_dmabuf()
756 contig_size = vb2_dc_get_contiguous_size(sgt); in vb2_dc_map_dmabuf()
760 dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir); in vb2_dc_map_dmabuf()
764 buf->dma_addr = sg_dma_address(sgt->sgl); in vb2_dc_map_dmabuf()
765 buf->dma_sgt = sgt; in vb2_dc_map_dmabuf()
774 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_unmap_dmabuf() local
781 if (WARN_ON(!sgt)) { in vb2_dc_unmap_dmabuf()
790 dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir); in vb2_dc_unmap_dmabuf()