Skip to content

Commit 7f332fc

Browse files
takeshikiharawildea01
authored andcommitted
arm64: Add support for DMA_ATTR_SKIP_CPU_SYNC attribute to swiotlb
This patch adds support for DMA_ATTR_SKIP_CPU_SYNC attribute for dma_{un}map_{page,sg} functions family to swiotlb. DMA_ATTR_SKIP_CPU_SYNC allows platform code to skip synchronization of the CPU cache for the given buffer assuming that it has been already transferred to 'device' domain. Ported from IOMMU .{un}map_{sg,page} ops. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent ec6d06e commit 7f332fc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

arch/arm64/mm/dma-mapping.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ static dma_addr_t __swiotlb_map_page(struct device *dev, struct page *page,
211211
dma_addr_t dev_addr;
212212

213213
dev_addr = swiotlb_map_page(dev, page, offset, size, dir, attrs);
214-
if (!is_device_dma_coherent(dev))
214+
if (!is_device_dma_coherent(dev) &&
215+
(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
215216
__dma_map_area(phys_to_virt(dma_to_phys(dev, dev_addr)), size, dir);
216217

217218
return dev_addr;
@@ -222,7 +223,8 @@ static void __swiotlb_unmap_page(struct device *dev, dma_addr_t dev_addr,
222223
size_t size, enum dma_data_direction dir,
223224
unsigned long attrs)
224225
{
225-
if (!is_device_dma_coherent(dev))
226+
if (!is_device_dma_coherent(dev) &&
227+
(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
226228
__dma_unmap_area(phys_to_virt(dma_to_phys(dev, dev_addr)), size, dir);
227229
swiotlb_unmap_page(dev, dev_addr, size, dir, attrs);
228230
}
@@ -235,7 +237,8 @@ static int __swiotlb_map_sg_attrs(struct device *dev, struct scatterlist *sgl,
235237
int i, ret;
236238

237239
ret = swiotlb_map_sg_attrs(dev, sgl, nelems, dir, attrs);
238-
if (!is_device_dma_coherent(dev))
240+
if (!is_device_dma_coherent(dev) &&
241+
(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
239242
for_each_sg(sgl, sg, ret, i)
240243
__dma_map_area(phys_to_virt(dma_to_phys(dev, sg->dma_address)),
241244
sg->length, dir);
@@ -251,7 +254,8 @@ static void __swiotlb_unmap_sg_attrs(struct device *dev,
251254
struct scatterlist *sg;
252255
int i;
253256

254-
if (!is_device_dma_coherent(dev))
257+
if (!is_device_dma_coherent(dev) &&
258+
(attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0)
255259
for_each_sg(sgl, sg, nelems, i)
256260
__dma_unmap_area(phys_to_virt(dma_to_phys(dev, sg->dma_address)),
257261
sg->length, dir);

0 commit comments

Comments
 (0)