]> Git Repo - linux.git/commitdiff
dma-mapping: reject __GFP_COMP in dma_alloc_attrs
authorChristoph Hellwig <[email protected]>
Wed, 9 Nov 2022 07:37:17 +0000 (08:37 +0100)
committerChristoph Hellwig <[email protected]>
Mon, 21 Nov 2022 08:37:20 +0000 (09:37 +0100)
DMA allocations can never be turned back into a page pointer, so
requesting compound pages doesn't make sense and it can't even be
supported at all by various backends.

Reject __GFP_COMP with a warning in dma_alloc_attrs, and stop clearing
the flag in the arm dma ops and dma-iommu.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Marek Szyprowski <[email protected]>
arch/arm/mm/dma-mapping.c
drivers/iommu/dma-iommu.c
kernel/dma/mapping.c

index d7909091cf977b8fad32c447d6185947e1cf89b2..c135f6e37a00cadf827e6298fe24efa2db9ed85b 100644 (file)
@@ -564,14 +564,6 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
        if (mask < 0xffffffffULL)
                gfp |= GFP_DMA;
 
-       /*
-        * Following is a work-around (a.k.a. hack) to prevent pages
-        * with __GFP_COMP being passed to split_page() which cannot
-        * handle them.  The real problem is that this flag probably
-        * should be 0 on ARM as it is not supported on this
-        * platform; see CONFIG_HUGETLBFS.
-        */
-       gfp &= ~(__GFP_COMP);
        args.gfp = gfp;
 
        *handle = DMA_MAPPING_ERROR;
@@ -1093,15 +1085,6 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
                return __iommu_alloc_simple(dev, size, gfp, handle,
                                            coherent_flag, attrs);
 
-       /*
-        * Following is a work-around (a.k.a. hack) to prevent pages
-        * with __GFP_COMP being passed to split_page() which cannot
-        * handle them.  The real problem is that this flag probably
-        * should be 0 on ARM as it is not supported on this
-        * platform; see CONFIG_HUGETLBFS.
-        */
-       gfp &= ~(__GFP_COMP);
-
        pages = __iommu_alloc_buffer(dev, size, gfp, attrs, coherent_flag);
        if (!pages)
                return NULL;
index 9297b741f5e80e2408e864fc3f779410d6b04d49..f798c44e0903373fbfc973923ca8432c54a1b5f7 100644 (file)
@@ -744,9 +744,6 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
        /* IOMMU can map any pages, so himem can also be used here */
        gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
 
-       /* It makes no sense to muck about with huge pages */
-       gfp &= ~__GFP_COMP;
-
        while (count) {
                struct page *page = NULL;
                unsigned int order_size;
index 33437d6206445812b6d4d5b33c77235d18074dec..c026a5a5e0466e188b72bf6db620120e4daff2b3 100644 (file)
@@ -498,6 +498,14 @@ void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
 
        WARN_ON_ONCE(!dev->coherent_dma_mask);
 
+       /*
+        * DMA allocations can never be turned back into a page pointer, so
+        * requesting compound pages doesn't make sense (and can't even be
+        * supported at all by various backends).
+        */
+       if (WARN_ON_ONCE(flag & __GFP_COMP))
+               return NULL;
+
        if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
                return cpu_addr;
 
This page took 0.063364 seconds and 4 git commands to generate.