Skip to content

Commit e270ee3

Browse files
committed
Revert "dma-mapping: reject __GFP_COMP in dma_alloc_attrs"
JIRA: https://issues.redhat.com/browse/RHEL-2542 Upstream Status: RHEL Only This reverts commit a2cfbf0. bnx2i/cnic currently fails to properly mmap its dma_alloc_coherent buffers through a uio interface without being able to allocate compound pages. Revert this until we can get a better cnic fix. Signed-off-by: Chris Leech <cleech@redhat.com>
1 parent 5f90fb4 commit e270ee3

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,14 @@ 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);
698706
args.gfp = gfp;
699707

700708
*handle = DMA_MAPPING_ERROR;
@@ -1427,6 +1435,15 @@ static void *__arm_iommu_alloc_attrs(struct device *dev, size_t size,
14271435
return __iommu_alloc_simple(dev, size, gfp, handle,
14281436
coherent_flag, attrs);
14291437

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+
14301447
pages = __iommu_alloc_buffer(dev, size, gfp, attrs, coherent_flag);
14311448
if (!pages)
14321449
return NULL;

drivers/iommu/dma-iommu.c

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

750+
/* It makes no sense to muck about with huge pages */
751+
gfp &= ~__GFP_COMP;
752+
750753
while (count) {
751754
struct page *page = NULL;
752755
unsigned int order_size;

kernel/dma/mapping.c

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

495495
WARN_ON_ONCE(!dev->coherent_dma_mask);
496496

497-
/*
498-
* DMA allocations can never be turned back into a page pointer, so
499-
* requesting compound pages doesn't make sense (and can't even be
500-
* supported at all by various backends).
501-
*/
502-
if (WARN_ON_ONCE(flag & __GFP_COMP))
503-
return NULL;
504-
505497
if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
506498
return cpu_addr;
507499

0 commit comments

Comments
 (0)