Skip to content

Commit 3e2dc04

Browse files
committed
Reapply "dma-mapping: reject __GFP_COMP in dma_alloc_attrs"
JIRA: https://issues.redhat.com/browse/RHEL-26081 Upstream Status: RHEL Only This reverts commit e270ee3. Signed-off-by: Chris Leech <cleech@redhat.com>
1 parent 57618e1 commit 3e2dc04

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,6 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
695695
if (mask < 0xffffffffULL)
696696
gfp |= GFP_DMA;
697697

698-
/*
699-
* Following is a work-around (a.k.a. hack) to prevent pages
700-
* with __GFP_COMP being passed to split_page() which cannot
701-
* handle them. The real problem is that this flag probably
702-
* should be 0 on ARM as it is not supported on this
703-
* platform; see CONFIG_HUGETLBFS.
704-
*/
705-
gfp &= ~(__GFP_COMP);
706698
args.gfp = gfp;
707699

708700
*handle = DMA_MAPPING_ERROR;
@@ -1435,15 +1427,6 @@ static void *__arm_iommu_alloc_attrs(struct device *dev, size_t size,
14351427
return __iommu_alloc_simple(dev, size, gfp, handle,
14361428
coherent_flag, attrs);
14371429

1438-
/*
1439-
* Following is a work-around (a.k.a. hack) to prevent pages
1440-
* with __GFP_COMP being passed to split_page() which cannot
1441-
* handle them. The real problem is that this flag probably
1442-
* should be 0 on ARM as it is not supported on this
1443-
* platform; see CONFIG_HUGETLBFS.
1444-
*/
1445-
gfp &= ~(__GFP_COMP);
1446-
14471430
pages = __iommu_alloc_buffer(dev, size, gfp, attrs, coherent_flag);
14481431
if (!pages)
14491432
return NULL;

drivers/iommu/dma-iommu.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,6 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
791791
/* IOMMU can map any pages, so himem can also be used here */
792792
gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
793793

794-
/* It makes no sense to muck about with huge pages */
795-
gfp &= ~__GFP_COMP;
796-
797794
while (count) {
798795
struct page *page = NULL;
799796
unsigned int order_size;

kernel/dma/mapping.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,14 @@ void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
502502

503503
WARN_ON_ONCE(!dev->coherent_dma_mask);
504504

505+
/*
506+
* DMA allocations can never be turned back into a page pointer, so
507+
* requesting compound pages doesn't make sense (and can't even be
508+
* supported at all by various backends).
509+
*/
510+
if (WARN_ON_ONCE(flag & __GFP_COMP))
511+
return NULL;
512+
505513
if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
506514
return cpu_addr;
507515

0 commit comments

Comments
 (0)