]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
kernel/dma: remove unsupported gfp_mask parameter from dma_alloc_from_contiguous()
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 17 Aug 2018 22:49:00 +0000 (15:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 17 Aug 2018 23:20:32 +0000 (16:20 -0700)
The CMA memory allocator doesn't support standard gfp flags for memory
allocation, so there is no point having it as a parameter for
dma_alloc_from_contiguous() function.  Replace it by a boolean no_warn
argument, which covers all the underlaying cma_alloc() function
supports.

This will help to avoid giving false feeling that this function supports
standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
what has already been an issue: see commit dd65a941f6ba ("arm64:
dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").

Link: http://lkml.kernel.org/r/20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y@eucas1p2.samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: MichaƂ Nazarewicz <mina86@mina86.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/arm/mm/dma-mapping.c
arch/arm64/mm/dma-mapping.c
arch/xtensa/kernel/pci-dma.c
drivers/iommu/amd_iommu.c
drivers/iommu/intel-iommu.c
include/linux/dma-contiguous.h
kernel/dma/contiguous.c
kernel/dma/direct.c

index ba0e786c952e70a1989ccb93043bb08e4d721d28..66566472c15384c6eb9fc0bea6045b8c8287e972 100644 (file)
@@ -594,7 +594,7 @@ static void *__alloc_from_contiguous(struct device *dev, size_t size,
        struct page *page;
        void *ptr = NULL;
 
-       page = dma_alloc_from_contiguous(dev, count, order, gfp);
+       page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN);
        if (!page)
                return NULL;
 
@@ -1299,7 +1299,8 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
                unsigned long order = get_order(size);
                struct page *page;
 
-               page = dma_alloc_from_contiguous(dev, count, order, gfp);
+               page = dma_alloc_from_contiguous(dev, count, order,
+                                                gfp & __GFP_NOWARN);
                if (!page)
                        goto error;
 
index 61e93f0b548228f57a08f25a14291a1e46437115..072c51fb07d73031578267eea0d5f877685f2676 100644 (file)
@@ -355,7 +355,7 @@ static int __init atomic_pool_init(void)
 
        if (dev_get_cma_area(NULL))
                page = dma_alloc_from_contiguous(NULL, nr_pages,
-                                                pool_size_order, GFP_KERNEL);
+                                                pool_size_order, false);
        else
                page = alloc_pages(GFP_DMA32, pool_size_order);
 
@@ -573,7 +573,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
                struct page *page;
 
                page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
-                                                get_order(size), gfp);
+                                       get_order(size), gfp & __GFP_NOWARN);
                if (!page)
                        return NULL;
 
index 392b4a80ebc2f04835cbd450ea8b88ea034efca9..a02dc563d2904ff0e9eb4387b56792dce5c63fd0 100644 (file)
@@ -137,7 +137,7 @@ static void *xtensa_dma_alloc(struct device *dev, size_t size,
 
        if (gfpflags_allow_blocking(flag))
                page = dma_alloc_from_contiguous(dev, count, get_order(size),
-                                                flag);
+                                                flag & __GFP_NOWARN);
 
        if (!page)
                page = alloc_pages(flag, get_order(size));
index 596b95c50051dcb75adb67496579af4b501d0ace..60b2eab29cd8fb1c80985085eee96f99ccb960e3 100644 (file)
@@ -2620,7 +2620,7 @@ static void *alloc_coherent(struct device *dev, size_t size,
                        return NULL;
 
                page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
-                                                get_order(size), flag);
+                                       get_order(size), flag & __GFP_NOWARN);
                if (!page)
                        return NULL;
        }
index 115ff26e9cede3494a75d59ee7c87655c72f4090..6a237d18fabff7f5c9c5172eec046194b46bf4ac 100644 (file)
@@ -3758,7 +3758,8 @@ static void *intel_alloc_coherent(struct device *dev, size_t size,
        if (gfpflags_allow_blocking(flags)) {
                unsigned int count = size >> PAGE_SHIFT;
 
-               page = dma_alloc_from_contiguous(dev, count, order, flags);
+               page = dma_alloc_from_contiguous(dev, count, order,
+                                                flags & __GFP_NOWARN);
                if (page && iommu_no_mapping(dev) &&
                    page_to_phys(page) + size > dev->coherent_dma_mask) {
                        dma_release_from_contiguous(dev, page, count);
index 3c5a4cb3eb953174c688c4b965ba09d87925fdb3..f247e8aa5e3d790e9f2baa28411eb15c39b3753d 100644 (file)
@@ -112,7 +112,7 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size,
 }
 
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-                                      unsigned int order, gfp_t gfp_mask);
+                                      unsigned int order, bool no_warn);
 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
                                 int count);
 
@@ -145,7 +145,7 @@ int dma_declare_contiguous(struct device *dev, phys_addr_t size,
 
 static inline
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-                                      unsigned int order, gfp_t gfp_mask)
+                                      unsigned int order, bool no_warn)
 {
        return NULL;
 }
index 19ea5d70150ca98e29d930025c1ea5520ab90ba9..286d82329eb087adeacc8a40e0de8ab191a8f926 100644 (file)
@@ -178,7 +178,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
  * @dev:   Pointer to device for which the allocation is performed.
  * @count: Requested number of pages.
  * @align: Requested alignment of pages (in PAGE_SIZE order).
- * @gfp_mask: GFP flags to use for this allocation.
+ * @no_warn: Avoid printing message about failed allocation.
  *
  * This function allocates memory buffer for specified device. It uses
  * device specific contiguous memory area if available or the default
@@ -186,13 +186,12 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
  * function.
  */
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-                                      unsigned int align, gfp_t gfp_mask)
+                                      unsigned int align, bool no_warn)
 {
        if (align > CONFIG_CMA_ALIGNMENT)
                align = CONFIG_CMA_ALIGNMENT;
 
-       return cma_alloc(dev_get_cma_area(dev), count, align,
-                        gfp_mask & __GFP_NOWARN);
+       return cma_alloc(dev_get_cma_area(dev), count, align, no_warn);
 }
 
 /**
index c2860c5a9e963ea5b03fad01a2cd812f3a78e5c9..1c35b7b945d034d320fb942109bb218c9c1eff8c 100644 (file)
@@ -78,7 +78,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 again:
        /* CMA can be used only in the context which permits sleeping */
        if (gfpflags_allow_blocking(gfp)) {
-               page = dma_alloc_from_contiguous(dev, count, page_order, gfp);
+               page = dma_alloc_from_contiguous(dev, count, page_order,
+                                                gfp & __GFP_NOWARN);
                if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
                        dma_release_from_contiguous(dev, page, count);
                        page = NULL;