Skip to contentSkip to conversation

arm: dma: Drop GFP_COMP for DMA memory allocations

RFC PATCH In review Stephen Warren 2 participants 2 messages Oct 28, 2011 – Oct 31, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 arm: dma: Drop GFP_COMP for DMA memory allocations

From: Sumit Bhattacharya <[email protected]>

dma_alloc_coherent wants to split pages after allocation in order to reduce the memory footprint. This does not work well with GFP_COMP pages, so drop this flag before allocation.

This patch is ported from arch/avr32 (commit 3611553ef985ef7c5863c8a94641738addd04cff).

---
Russell, for background, please see:
http://www.spinics.net/lists/alsa-devel/msg05399.html
https://lkml.org/lkml/2006/7/8/236

I believe the patch below was once posted to solve this for ARM, but never got picked up. Evidently, AVR32 did pick it up. I'm wondering if we should pick this up for ARM now, or if there's some other solution?

(note: This patch is actually based on one of our older internal kernels; I'd need to rebase it if we do decide to go ahead with it. I also haven't tested it in mainline, and would have difficulty doing so, since the issue this solves only shows up when using our HD-Audio controller on Tegra30, and that isn't upstream yet.)

 arch/arm/mm/dma-mapping.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mm/dma-mapping.c +7 -0
index 82a093c..93b86e6 100644
@@ -308,6 +308,13 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
 	struct page *page;
 	void *addr;
 
+	/* 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_HUGETLB_PAGE. */
+	gfp &= ~(__GFP_COMP);
+
 	*handle = ~0;
 	size = PAGE_ALIGN(size);
 
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 3 lines · Stephen Warren

I believe the patch below was once posted to solve this for ARM, but never got picked up. Evidently, AVR32 did pick it up. I'm wondering if we should pick this up for ARM now, or if there's some other solution?

Well, Nick did talk about a solution using GFP_USERMAP in one of those threads, which doesn't seem to have gone anywhere. So I guess we need this patch.

arch/arm/mm/dma-mapping.c __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, · line 315

Quoted 13 lines
arch/arm/mm/dma-mapping.c +5 -0
index 82a093c..93b86e6 100644
@@ -308,6 +308,13 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
 	struct page *page;
 	void *addr;
 
+	/* 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_HUGETLB_PAGE. */

I don't think this comment makes sense anymore - HUGETLB_PAGE doesn't have any help text.

Quoted 9 lines
arch/arm/mm/dma-mapping.c +2 -0
+	gfp &= ~(__GFP_COMP);
+
 	*handle = ~0;
 	size = PAGE_ALIGN(size);
 
Signature · 1 line
1.7.0.4