From 4bb06438788fc7eea2b7cfa448b30bcb812bf417 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Thu, 13 Feb 2020 10:11:33 -0800 Subject: [PATCH] dma-mapping-fast: Align memory allocation to dma_alloc_attrs expectations On newer kernels, memory allocated by dma_alloc_attrs() is expected to be zeroed out upon allocation. The allocation paths in fastmap do not currently account for this new requirement, so update them to zero out memory, unless the client explicitly asks for memory to not be zeroed out. Change-Id: I5c7fa81ab4b8fa98890036082883769ab12443c6 Signed-off-by: Isaac J. Manjarres --- drivers/iommu/dma-mapping-fast.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/dma-mapping-fast.c b/drivers/iommu/dma-mapping-fast.c index e309014e22d1..0c02eeb3bb48 100644 --- a/drivers/iommu/dma-mapping-fast.c +++ b/drivers/iommu/dma-mapping-fast.c @@ -643,6 +643,7 @@ static void *__fast_smmu_alloc_contiguous(struct device *dev, size_t size, coherent_addr = page_address(page); } + memset(coherent_addr, 0, size); *handle = iova; return coherent_addr; @@ -681,6 +682,9 @@ static void *fast_smmu_alloc(struct device *dev, size_t size, return NULL; } + if (!(attrs & DMA_ATTR_SKIP_ZEROING)) + gfp |= __GFP_ZERO; + *handle = DMA_ERROR_CODE; size = ALIGN(size, SZ_4K);