Commit 3238c359 authored by Robin Murphy's avatar Robin Murphy Committed by Catalin Marinas

arm64: dma-mapping: Fix FORCE_CONTIGUOUS buffer clearing

We need to invalidate the caches *before* clearing the buffer via the
non-cacheable alias, else in the worst case __dma_flush_area() may
write back dirty lines over the top of our nice new zeros.

Fixes: dd65a941 ("arm64: dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag")
Cc: <stable@vger.kernel.org> # 4.18.x-
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 40e020c1
...@@ -429,9 +429,9 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, ...@@ -429,9 +429,9 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
prot, prot,
__builtin_return_address(0)); __builtin_return_address(0));
if (addr) { if (addr) {
memset(addr, 0, size);
if (!coherent) if (!coherent)
__dma_flush_area(page_to_virt(page), iosize); __dma_flush_area(page_to_virt(page), iosize);
memset(addr, 0, size);
} else { } else {
iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs); iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs);
dma_release_from_contiguous(dev, page, dma_release_from_contiguous(dev, page,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment