[PATCH] arm64: Fix the DMA mmap and get_sgtable API with DMA_ATTR_FORCE_CONTIGUOUS

Catalin Marinas catalin.marinas at arm.com
Thu May 4 07:03:07 PDT 2017


On Thu, May 04, 2017 at 12:29:37PM +0100, Robin Murphy wrote:
> On 25/04/17 19:00, Catalin Marinas wrote:
> > While honouring the DMA_ATTR_FORCE_CONTIGUOUS on arm64 (commit
> > 44176bb38fa4: "arm64: Add support for DMA_ATTR_FORCE_CONTIGUOUS to
> > IOMMU"), the existing uses of dma_mmap_attrs() and dma_get_sgtable()
> > have been broken by passing a physically contiguous vm_struct with an
> > invalid pages pointer through the common iommu API.
> > 
> > Since the coherent allocation with DMA_ATTR_FORCE_CONTIGUOUS uses CMA,
> > this patch simply reuses the existing swiotlb logic for mmap and
> > get_sgtable.
> > 
> > Note that the current implementation of get_sgtable (both swiotlb and
> > iommu) is broken if dma_declare_coherent_memory() is used since such
> > memory does not have a corresponding struct page. To be addressed in a
> > separate patch.
> > 
> > Fixes: 44176bb38fa4 ("arm64: Add support for DMA_ATTR_FORCE_CONTIGUOUS to IOMMU")
> > Reported-by: Andrzej Hajda <a.hajda at samsung.com>
> > Cc: Andrzej Hajda <a.hajda at samsung.com>
> > Cc: Geert Uytterhoeven <geert+renesas at glider.be>
> > Cc: Robin Murphy <robin.murphy at arm.com>
> > Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
> > ---
> > 
> > Here's my attempt of fixing this, though I'd like to wait for Robin's review
> > (who's currently on holiday until next week).
> > 
> > Not tested.
> 
> The general approach is sound, and I can't see anything that looks
> obviously wrong with the implementation, although I have no easy way of
> testing it either:
> 
> Acked-by: Robin Murphy <robin.murphy at arm.com>

Thanks for looking at this patch.

Going through the past threads on this, I wonder whether the attribute
is actually used anywhere (in which case we may be better off reverting
the original patch). If improved IOMMU performance is required, there
are likely better ways to achieve this like using a different page size
at the IOMMU level.

-- 
Catalin



More information about the linux-arm-kernel mailing list