Lines Matching refs:sgt
47 static inline unsigned int sgt_dma_count_chunks(struct sg_table *sgt) in sgt_dma_count_chunks() argument
49 return sg_dma_count_chunks(sgt->sgl, sgt->nents); in sgt_dma_count_chunks()
88 map->sgt = dma_buf_map_attachment_unlocked(map->attach, direction); in tegra_bo_pin()
89 if (IS_ERR(map->sgt)) { in tegra_bo_pin()
91 err = PTR_ERR(map->sgt); in tegra_bo_pin()
92 map->sgt = NULL; in tegra_bo_pin()
96 err = sgt_dma_count_chunks(map->sgt); in tegra_bo_pin()
106 map->sgt = kzalloc(sizeof(*map->sgt), GFP_KERNEL); in tegra_bo_pin()
107 if (!map->sgt) { in tegra_bo_pin()
117 err = sg_alloc_table_from_pages(map->sgt, obj->pages, obj->num_pages, 0, gem->size, in tegra_bo_pin()
127 err = dma_get_sgtable(dev, map->sgt, obj->vaddr, obj->iova, gem->size); in tegra_bo_pin()
132 err = dma_map_sgtable(dev, map->sgt, direction, 0); in tegra_bo_pin()
142 map->phys = sg_dma_address(map->sgt->sgl); in tegra_bo_pin()
154 sg_free_table(map->sgt); in tegra_bo_pin()
156 kfree(map->sgt); in tegra_bo_pin()
164 dma_buf_unmap_attachment_unlocked(map->attach, map->sgt, in tegra_bo_unpin()
168 dma_unmap_sgtable(map->dev, map->sgt, map->direction, 0); in tegra_bo_unpin()
169 sg_free_table(map->sgt); in tegra_bo_unpin()
170 kfree(map->sgt); in tegra_bo_unpin()
249 bo->size = iommu_map_sgtable(tegra->domain, bo->iova, bo->sgt, prot); in tegra_bo_iommu_map()
324 dma_unmap_sgtable(drm->dev, bo->sgt, DMA_FROM_DEVICE, 0); in tegra_bo_free()
326 sg_free_table(bo->sgt); in tegra_bo_free()
327 kfree(bo->sgt); in tegra_bo_free()
343 bo->sgt = drm_prime_pages_to_sg(bo->gem.dev, bo->pages, bo->num_pages); in tegra_bo_get_pages()
344 if (IS_ERR(bo->sgt)) { in tegra_bo_get_pages()
345 err = PTR_ERR(bo->sgt); in tegra_bo_get_pages()
349 err = dma_map_sgtable(drm->dev, bo->sgt, DMA_FROM_DEVICE, 0); in tegra_bo_get_pages()
356 sg_free_table(bo->sgt); in tegra_bo_get_pages()
357 kfree(bo->sgt); in tegra_bo_get_pages()
466 bo->sgt = dma_buf_map_attachment_unlocked(attach, DMA_TO_DEVICE); in tegra_bo_import()
467 if (IS_ERR(bo->sgt)) { in tegra_bo_import()
468 err = PTR_ERR(bo->sgt); in tegra_bo_import()
483 if (!IS_ERR_OR_NULL(bo->sgt)) in tegra_bo_import()
484 dma_buf_unmap_attachment_unlocked(attach, bo->sgt, DMA_TO_DEVICE); in tegra_bo_import()
513 dma_buf_unmap_attachment_unlocked(gem->import_attach, bo->sgt, in tegra_bo_free_object()
620 struct sg_table *sgt; in tegra_gem_prime_map_dma_buf() local
622 sgt = kmalloc(sizeof(*sgt), GFP_KERNEL); in tegra_gem_prime_map_dma_buf()
623 if (!sgt) in tegra_gem_prime_map_dma_buf()
627 if (sg_alloc_table_from_pages(sgt, bo->pages, bo->num_pages, in tegra_gem_prime_map_dma_buf()
631 if (dma_get_sgtable(attach->dev, sgt, bo->vaddr, bo->iova, in tegra_gem_prime_map_dma_buf()
636 if (dma_map_sgtable(attach->dev, sgt, dir, 0)) in tegra_gem_prime_map_dma_buf()
639 return sgt; in tegra_gem_prime_map_dma_buf()
642 sg_free_table(sgt); in tegra_gem_prime_map_dma_buf()
643 kfree(sgt); in tegra_gem_prime_map_dma_buf()
648 struct sg_table *sgt, in tegra_gem_prime_unmap_dma_buf() argument
655 dma_unmap_sgtable(attach->dev, sgt, dir, 0); in tegra_gem_prime_unmap_dma_buf()
657 sg_free_table(sgt); in tegra_gem_prime_unmap_dma_buf()
658 kfree(sgt); in tegra_gem_prime_unmap_dma_buf()
674 dma_sync_sgtable_for_cpu(drm->dev, bo->sgt, DMA_FROM_DEVICE); in tegra_gem_prime_begin_cpu_access()
687 dma_sync_sgtable_for_device(drm->dev, bo->sgt, DMA_TO_DEVICE); in tegra_gem_prime_end_cpu_access()