Re: [PATCH 4/9] iommu/dma-iommu: Add iommu_dma_map_page_coherent

From: Christoph Hellwig
Date: Mon Apr 15 2019 - 02:33:24 EST


> @@ -693,7 +694,19 @@ dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page,
> unsigned long offset, size_t size, int prot)
> {
> return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot,
> - iommu_get_dma_domain(dev));
> + iommu_get_dma_domain(dev), dma_get_mask(dev));
> +}
> +
> +dma_addr_t iommu_dma_map_page_coherent(struct device *dev, struct page *page,
> + unsigned long offset, size_t size, int prot)
> +{

Note that my tree pointed to above removes the iommu_dma_map_page
wrapper. I think for the coherent mappign we should also just
call __iommu_dma_map directly and not introduce another wrapper.

> + dma_addr_t dma_mask = dev->coherent_dma_mask;
> +
> + if (!dma_mask)
> + dma_mask = dma_get_mask(dev);
> +
> + return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot,
> + iommu_get_dma_domain(dev), dma_mask);
> }

In the DMA API there is no fallback when the coherent_dma_mask is not
set. While various bits of legacy code do that we should not copy it
to new code.