Skip to contentSkip to conversation

ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

PATCH New Richard Zhao 5 participants 7 messages Jun 20, 2013 – Jun 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

__iommu_alloc_buffer 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

One failure example is snd_malloc_dev_pages call dma_alloc_coherent with __GFP_COMP.

---
 arch/arm/mm/dma-mapping.c |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/mm/dma-mapping.c +9 -0
index ef3e0f3..f7efffd 100644
@@ -1314,6 +1314,15 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
 	if (gfp & GFP_ATOMIC)
 		return __iommu_alloc_atomic(dev, size, handle);
 
+	/*
+	 * 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);
 	if (!pages)
 		return NULL;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

Hello.

Quoted 18 lines · Richard Zhao

__iommu_alloc_buffer 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

One failure example is snd_malloc_dev_pages call dma_alloc_coherent with __GFP_COMP.

---
  arch/arm/mm/dma-mapping.c |    9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mm/dma-mapping.c +0 -0
index ef3e0f3..f7efffd 100644
@@ -1314,6 +1314,15 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
  	if (gfp & GFP_ATOMIC)

arch/arm/mm/dma-mapping.c static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, · line 1324

Quoted 10 lines
arch/arm/mm/dma-mapping.c +8 -0
  		return __iommu_alloc_atomic(dev, size, handle);
 
+	/*
+	 * 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);

Hm, what exactly is the sense you meant in using ()?

WBR, Sergei

#2 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

Quoted 29 lines · Sergei Shtylyov

Hello.

Quoted 24 lines · Richard Zhao

__iommu_alloc_buffer 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

One failure example is snd_malloc_dev_pages call dma_alloc_coherent with __GFP_COMP.

---
  arch/arm/mm/dma-mapping.c |    9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mm/dma-mapping.c +0 -0
index ef3e0f3..f7efffd 100644
@@ -1314,6 +1314,15 @@ static void *arm_iommu_alloc_attrs(struct device
 *dev, size_t size,
        if (gfp & GFP_ATOMIC)
                return __iommu_alloc_atomic(dev, size, handle);
 
Quoted 11 lines

arch/arm/mm/dma-mapping.c static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, · line 1324

Quoted 8 lines
arch/arm/mm/dma-mapping.c +8 -0
+       /*
+        * 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);

Hm, what exactly is the sense you meant in using ()?

It's copy/paste from elsewhere in this file. At least it's consistent? :)

#3 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

Richard Zhao <[email protected]> wrote @ Thu, 20 Jun 2013 15:40:50 +0200:

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
(quoted diff) +8 -0
+       /*
+        * 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);
Quoted 3 lines
Quoted 1 line

Hm, what exactly is the sense you meant in using ()?

It's copy/paste from elsewhere in this file. At least it's consistent? :)

I almost sent the exact same one, actually it was under internal reivew;)

This patch is similar but is the iommu version of:

commit ea2e7057c0234cfb8b09467d8f137760d371fc72

Author: Sumit Bhattacharya <[email protected]>
Date:   Thu Nov 24 00:47:12 2011 +0100

ARM: 7172/1: dma: Drop GFP_COMP for DMA memory allocations

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).

[swarren: s/HUGETLB_PAGE/HUGETLBFS/ in comment, minor comment cleanup]

arch/arm/mm/dma-mapping.c +9 -0
index ab58456..1aa664a 100644
@@ -332,6 +332,15 @@ __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_HUGETLBFS.
+        */
+       gfp &= ~(__GFP_COMP);
+
        *handle = ~0;
        size = PAGE_ALIGN(size);
#4 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

Quoted 12 lines · Hiroshi Doyu

Richard Zhao <[email protected]> wrote @ Thu, 20 Jun 2013 15:40:50 +0200:

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
arch/arm/mm/dma-mapping.c +8 -0
+       /*
+        * 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);
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Hm, what exactly is the sense you meant in using ()?

It's copy/paste from elsewhere in this file. At least it's consistent? :)

I almost sent the exact same one, actually it was under internal reivew;)

Ah, sorry I didn't search internal mails but only arm mail list for related fix, since I thought it's not specific to tegra. Why not give it a Reviewed-by or Tested-by?

Quoted 2 lines

This patch is similar but is the iommu version of:

Exactly.

Thanks
Richard

Quoted 41 lines

commit ea2e7057c0234cfb8b09467d8f137760d371fc72

Author: Sumit Bhattacharya <[email protected]>
Date:   Thu Nov 24 00:47:12 2011 +0100

ARM: 7172/1: dma: Drop GFP_COMP for DMA memory allocations

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).

[swarren: s/HUGETLB_PAGE/HUGETLBFS/ in comment, minor comment cleanup]

arch/arm/mm/dma-mapping.c +9 -0
index ab58456..1aa664a 100644
@@ -332,6 +332,15 @@ __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_HUGETLBFS.
+        */
+       gfp &= ~(__GFP_COMP);
+
        *handle = ~0;
        size = PAGE_ALIGN(size);
#5 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

In reply to Sergei Shtylyov

Hello,

Quoted 25 lines · Sergei Shtylyov

Hello.

Quoted 21 lines · Richard Zhao

__iommu_alloc_buffer 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

One failure example is snd_malloc_dev_pages call dma_alloc_coherent with __GFP_COMP.

---
  arch/arm/mm/dma-mapping.c |    9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mm/dma-mapping.c +0 -0
index ef3e0f3..f7efffd 100644
@@ -1314,6 +1314,15 @@ static void *arm_iommu_alloc_attrs(struct 
 device *dev, size_t size,
      if (gfp & GFP_ATOMIC)
          return __iommu_alloc_atomic(dev, size, handle);
 
Quoted 10 lines

arch/arm/mm/dma-mapping.c static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, · line 1324

Quoted 8 lines
arch/arm/mm/dma-mapping.c +8 -0
+    /*
+     * 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);

Hm, what exactly is the sense you meant in using ()?

I think that those parentheses come from the first patch, which disabled __GFP_COMP
in dma-mapping allocations: 3611553ef98 ("[AVR32] Drop GFP_COMP for DMA memory
allocations"). I would like to take this patch to the dma-mapping tree together with
other changes related to iommu integration code.

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung R&D Institute Poland
#6 lore raw

PATCH 1/1 ARM: dma: Drop __GFP_COMP for iommu dma memory allocations

On Fri, Jun 21, 2013 at 5:33 PM, Marek Szyprowski
<[email protected]> wrote:> Hello,

Quoted 45 lines · Sergei Shtylyov
Quoted 29 lines

Hello.

Quoted 24 lines · Richard Zhao

__iommu_alloc_buffer 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

One failure example is snd_malloc_dev_pages call dma_alloc_coherent with __GFP_COMP.

---
  arch/arm/mm/dma-mapping.c |    9 +++++++++
  1 file changed, 9 insertions(+)
arch/arm/mm/dma-mapping.c +0 -0
index ef3e0f3..f7efffd 100644
@@ -1314,6 +1314,15 @@ static void *arm_iommu_alloc_attrs(struct device
 *dev, size_t size,
      if (gfp & GFP_ATOMIC)
          return __iommu_alloc_atomic(dev, size, handle);
 
Quoted 11 lines

arch/arm/mm/dma-mapping.c static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, · line 1324

Quoted 8 lines
arch/arm/mm/dma-mapping.c +8 -0
+    /*
+     * 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);

Hm, what exactly is the sense you meant in using ()?

Quoted 7 lines

I think that those parentheses come from the first patch, which disabled __GFP_COMP
in dma-mapping allocations: 3611553ef98 ("[AVR32] Drop GFP_COMP for DMA memory
allocations"). I would like to take this patch to the dma-mapping tree together with
other changes related to iommu integration code.

Thanks! I'm not sure. Do we still have time to have this fix on 3.10?

Richard

Quoted 13 lines

Best regards
--
Marek Szyprowski
Samsung R&D Institute Poland

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel