Lines Matching refs:sgt
53 static unsigned long vb2_dc_get_contiguous_size(struct sg_table *sgt) in vb2_dc_get_contiguous_size() argument
56 dma_addr_t expected = sg_dma_address(sgt->sgl); in vb2_dc_get_contiguous_size()
60 for_each_sgtable_dma_sg(sgt, s, i) { in vb2_dc_get_contiguous_size()
126 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_prepare() local
140 dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir); in vb2_dc_prepare()
146 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_finish() local
160 dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir); in vb2_dc_finish()
313 struct sg_table sgt; member
323 struct sg_table *sgt; in vb2_dc_dmabuf_ops_attach() local
331 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_attach()
335 ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL); in vb2_dc_dmabuf_ops_attach()
342 wr = sgt->sgl; in vb2_dc_dmabuf_ops_attach()
343 for (i = 0; i < sgt->orig_nents; ++i) { in vb2_dc_dmabuf_ops_attach()
359 struct sg_table *sgt; in vb2_dc_dmabuf_ops_detach() local
364 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_detach()
374 dma_unmap_sgtable(db_attach->dev, sgt, attach->dma_dir, in vb2_dc_dmabuf_ops_detach()
376 sg_free_table(sgt); in vb2_dc_dmabuf_ops_detach()
385 struct sg_table *sgt; in vb2_dc_dmabuf_ops_map() local
387 sgt = &attach->sgt; in vb2_dc_dmabuf_ops_map()
390 return sgt; in vb2_dc_dmabuf_ops_map()
394 dma_unmap_sgtable(db_attach->dev, sgt, attach->dma_dir, in vb2_dc_dmabuf_ops_map()
403 if (dma_map_sgtable(db_attach->dev, sgt, dma_dir, in vb2_dc_dmabuf_ops_map()
411 return sgt; in vb2_dc_dmabuf_ops_map()
415 struct sg_table *sgt, enum dma_data_direction dma_dir) in vb2_dc_dmabuf_ops_unmap() argument
476 struct sg_table *sgt; in vb2_dc_get_base_sgt() local
481 sgt = kmalloc(sizeof(*sgt), GFP_KERNEL); in vb2_dc_get_base_sgt()
482 if (!sgt) { in vb2_dc_get_base_sgt()
487 ret = dma_get_sgtable_attrs(buf->dev, sgt, buf->cookie, buf->dma_addr, in vb2_dc_get_base_sgt()
491 kfree(sgt); in vb2_dc_get_base_sgt()
495 return sgt; in vb2_dc_get_base_sgt()
534 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_put_userptr() local
538 if (sgt) { in vb2_dc_put_userptr()
543 dma_unmap_sgtable(buf->dev, sgt, buf->dma_dir, in vb2_dc_put_userptr()
552 sg_free_table(sgt); in vb2_dc_put_userptr()
553 kfree(sgt); in vb2_dc_put_userptr()
570 struct sg_table *sgt; in vb2_dc_get_userptr() local
625 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); in vb2_dc_get_userptr()
626 if (!sgt) { in vb2_dc_get_userptr()
632 ret = sg_alloc_table_from_pages(sgt, frame_vector_pages(vec), n_pages, in vb2_dc_get_userptr()
643 if (dma_map_sgtable(buf->dev, sgt, buf->dma_dir, in vb2_dc_get_userptr()
650 contig_size = vb2_dc_get_contiguous_size(sgt); in vb2_dc_get_userptr()
658 buf->dma_addr = sg_dma_address(sgt->sgl); in vb2_dc_get_userptr()
659 buf->dma_sgt = sgt; in vb2_dc_get_userptr()
668 dma_unmap_sgtable(buf->dev, sgt, buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC); in vb2_dc_get_userptr()
671 sg_free_table(sgt); in vb2_dc_get_userptr()
674 kfree(sgt); in vb2_dc_get_userptr()
692 struct sg_table *sgt; in vb2_dc_map_dmabuf() local
706 sgt = dma_buf_map_attachment_unlocked(buf->db_attach, buf->dma_dir); in vb2_dc_map_dmabuf()
707 if (IS_ERR(sgt)) { in vb2_dc_map_dmabuf()
713 contig_size = vb2_dc_get_contiguous_size(sgt); in vb2_dc_map_dmabuf()
717 dma_buf_unmap_attachment_unlocked(buf->db_attach, sgt, in vb2_dc_map_dmabuf()
722 buf->dma_addr = sg_dma_address(sgt->sgl); in vb2_dc_map_dmabuf()
723 buf->dma_sgt = sgt; in vb2_dc_map_dmabuf()
732 struct sg_table *sgt = buf->dma_sgt; in vb2_dc_unmap_dmabuf() local
740 if (WARN_ON(!sgt)) { in vb2_dc_unmap_dmabuf()
749 dma_buf_unmap_attachment_unlocked(buf->db_attach, sgt, buf->dma_dir); in vb2_dc_unmap_dmabuf()