aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-03-28 09:35:35 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-03-28 11:34:23 -0400
commite89f5b37015309a8bdf0b21d08007580b92f92a4 (patch)
tree194c925657ddd394d26ccc1ae707ffdac31c8534
parentea2301b6220117398a1de4f4bc853fbe886d5e08 (diff)
dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs
Revert the clearing of __GFP_ZERO in dma_alloc_attrs and move it to dma_direct_alloc for now. While most common architectures always zero dma cohereny allocations (and x86 did so since day one) this is not documented and at least arc and s390 do not zero without the explicit __GFP_ZERO argument. Fixes: 57bf5a8963f8 ("dma-mapping: clear harmful GFP_* flags in common code") Reported-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com> Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com> Cc: iommu@lists.linux-foundation.org Link: https://lkml.kernel.org/r/20180328133535.17302-2-hch@lst.de
-rw-r--r--include/linux/dma-mapping.h8
-rw-r--r--lib/dma-direct.c3
2 files changed, 5 insertions, 6 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4ecd6d..12fedcba9a9a 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
518 if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr)) 518 if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
519 return cpu_addr; 519 return cpu_addr;
520 520
521 /* 521 /* let the implementation decide on the zone to allocate from: */
522 * Let the implementation decide on the zone to allocate from, and 522 flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
523 * decide on the way of zeroing the memory given that the memory
524 * returned should always be zeroed.
525 */
526 flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
527 523
528 if (!arch_dma_alloc_attrs(&dev, &flag)) 524 if (!arch_dma_alloc_attrs(&dev, &flag))
529 return NULL; 525 return NULL;
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index 1277d293d4da..c0bba30fef0a 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
59 struct page *page = NULL; 59 struct page *page = NULL;
60 void *ret; 60 void *ret;
61 61
62 /* we always manually zero the memory once we are done: */
63 gfp &= ~__GFP_ZERO;
64
62 /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */ 65 /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
63 if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)) 66 if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
64 gfp |= GFP_DMA; 67 gfp |= GFP_DMA;