]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs
authorChristoph Hellwig <hch@lst.de>
Wed, 28 Mar 2018 13:35:35 +0000 (15:35 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 28 Mar 2018 15:34:23 +0000 (17:34 +0200)
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
include/linux/dma-mapping.h
lib/dma-direct.c

index eb9eab4ecd6d7a050115b54ac81cde94f15e6591..12fedcba9a9a1dea18654e91759f9f4183fbb55f 100644 (file)
@@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
        if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
                return cpu_addr;
 
-       /*
-        * Let the implementation decide on the zone to allocate from, and
-        * decide on the way of zeroing the memory given that the memory
-        * returned should always be zeroed.
-        */
-       flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
+       /* let the implementation decide on the zone to allocate from: */
+       flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
 
        if (!arch_dma_alloc_attrs(&dev, &flag))
                return NULL;
index 1277d293d4da5b653b0b4581ca71cf68f57e2b0f..c0bba30fef0ac1f8bda32af158b5596fcc14ce09 100644 (file)
@@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
        struct page *page = NULL;
        void *ret;
 
+       /* we always manually zero the memory once we are done: */
+       gfp &= ~__GFP_ZERO;
+
        /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
        if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
                gfp |= GFP_DMA;