Re: [PATCH v3 3/5] dma-iommu: add SKIP_CPU_SYNC after syncing
From: Christoph Hellwig
Date: Wed Aug 11 2021 - 02:08:21 EST
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 4f0cc4a0a61f..be0214b1455c 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -859,8 +859,11 @@ static dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
> static void iommu_dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
> size_t size, enum dma_data_direction dir, unsigned long attrs)
> {
> - if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
> iommu_dma_sync_single_for_cpu(dev, dma_handle, size, dir);
> + attrs |= DMA_ATTR_SKIP_CPU_SYNC;
> + }
> +
> __iommu_dma_unmap_swiotlb(dev, dma_handle, size, dir, attrs);
I don't think this is the correct way to go. Instead just call the
raw cache sync helper instead of iommu_dma_sync_single_for_cpu, similar
to what dma-direct does. Same for the map side.