All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Consolidate zone adjustment
@ 2011-05-11 16:24 Russell King - ARM Linux
  2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2011-05-11 16:24 UTC (permalink / raw)
  To: linux-arm-kernel

This patch mini-series consolidates the adjustment to system zones
which some of our platforms require.  Rather than having each
platform/machine class specify ISA_DMA_THRESHOLD, MAX_DMA_ADDRESS
and an arch_adjust_zones function, they really only need to provide
a single sizing definition, which in this series will be called
ARM_DMA_ZONE_SIZE.

 arch/arm/common/sa1111.c                     |    8 -------
 arch/arm/include/asm/dma.h                   |    4 ++-
 arch/arm/include/asm/memory.h                |   10 ++------
 arch/arm/mach-davinci/include/mach/memory.h  |   18 +----------------
 arch/arm/mach-h720x/include/mach/memory.h    |    3 +-
 arch/arm/mach-ixp4xx/common-pci.c            |   23 ----------------------
 arch/arm/mach-ixp4xx/include/mach/memory.h   |   12 +---------
 arch/arm/mach-pxa/cm-x2xx-pci.c              |   27 --------------------------
 arch/arm/mach-pxa/include/mach/memory.h      |   10 +-------
 arch/arm/mach-realview/core.c                |   19 ------------------
 arch/arm/mach-realview/include/mach/memory.h |    9 +------
 arch/arm/mach-sa1100/include/mach/memory.h   |   12 +----------
 arch/arm/mach-shark/include/mach/memory.h    |   20 +------------------
 arch/arm/mm/init.c                           |   23 +++++++++++++++++++++-
 14 files changed, 38 insertions(+), 160 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
  2011-05-11 16:24 [PATCH 0/2] Consolidate zone adjustment Russell King - ARM Linux
@ 2011-05-11 16:25 ` Russell King - ARM Linux
  2011-05-11 17:22   ` Catalin Marinas
  2011-05-12  7:16   ` Nicolas Pitre
  2011-05-11 16:25 ` [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes Russell King - ARM Linux
  2011-05-19 10:56 ` [PATCH 0/2] Consolidate zone adjustment Nori, Sekhar
  2 siblings, 2 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2011-05-11 16:25 UTC (permalink / raw)
  To: linux-arm-kernel

The values of ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS are related; one is
the physical/bus address, the other is the virtual address.  Both need
to be kept in step, so rather than having platforms define both, allow
them to define a single macro which sets both of these macros
appropraitely.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/dma.h                   |    4 +++-
 arch/arm/include/asm/memory.h                |    4 +++-
 arch/arm/mach-davinci/include/mach/memory.h  |    3 +--
 arch/arm/mach-h720x/include/mach/memory.h    |    3 +--
 arch/arm/mach-ixp4xx/include/mach/memory.h   |    3 +--
 arch/arm/mach-pxa/include/mach/memory.h      |    3 +--
 arch/arm/mach-realview/include/mach/memory.h |    3 +--
 arch/arm/mach-sa1100/include/mach/memory.h   |    3 +--
 arch/arm/mach-shark/include/mach/memory.h    |    3 +--
 9 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index ca51143..4200554 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -6,8 +6,10 @@
 /*
  * This is the maximum virtual address which can be DMA'd from.
  */
-#ifndef MAX_DMA_ADDRESS
+#ifndef ARM_DMA_ZONE_SIZE
 #define MAX_DMA_ADDRESS	0xffffffff
+#else
+#define MAX_DMA_ADDRESS	(PAGE_OFFSET + ARM_DMA_ZONE_SIZE)
 #endif
 
 #ifdef CONFIG_ISA_DMA_API
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 431077c..ee5ff41 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -209,8 +209,10 @@ static inline unsigned long __phys_to_virt(unsigned long x)
  * allocations.  This must be the smallest DMA mask in the system,
  * so a successful GFP_DMA allocation will always satisfy this.
  */
-#ifndef ISA_DMA_THRESHOLD
+#ifndef ARM_DMA_ZONE_SIZE
 #define ISA_DMA_THRESHOLD	(0xffffffffULL)
+#else
+#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
 #endif
 
 #ifndef arch_adjust_zones
diff --git a/arch/arm/mach-davinci/include/mach/memory.h b/arch/arm/mach-davinci/include/mach/memory.h
index 7882272..8d27246 100644
--- a/arch/arm/mach-davinci/include/mach/memory.h
+++ b/arch/arm/mach-davinci/include/mach/memory.h
@@ -59,8 +59,7 @@ __arch_adjust_zones(unsigned long *size, unsigned long *holes)
 #define arch_adjust_zones(zone_size, holes) \
         if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes)
 
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + (128<<20) - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + (128<<20))
+#define ARM_DMA_ZONE_SIZE	SZ_128M
 
 #endif
 
diff --git a/arch/arm/mach-h720x/include/mach/memory.h b/arch/arm/mach-h720x/include/mach/memory.h
index 9d36876..b0b3bae 100644
--- a/arch/arm/mach-h720x/include/mach/memory.h
+++ b/arch/arm/mach-h720x/include/mach/memory.h
@@ -13,7 +13,6 @@
  * There should not be more than (0xd0000000 - 0xc0000000)
  * bytes of RAM.
  */
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
+#define ARM_DMA_ZONE_SIZE	SZ_256M
 
 #endif
diff --git a/arch/arm/mach-ixp4xx/include/mach/memory.h b/arch/arm/mach-ixp4xx/include/mach/memory.h
index 6d388c9..a5c26f8 100644
--- a/arch/arm/mach-ixp4xx/include/mach/memory.h
+++ b/arch/arm/mach-ixp4xx/include/mach/memory.h
@@ -21,8 +21,7 @@ void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);
 #define arch_adjust_zones(size, holes) \
 	ixp4xx_adjust_zones(size, holes)
 
-#define ISA_DMA_THRESHOLD (SZ_64M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_64M)
+#define ARM_DMA_ZONE_SIZE	SZ_64M
 
 #endif
 
diff --git a/arch/arm/mach-pxa/include/mach/memory.h b/arch/arm/mach-pxa/include/mach/memory.h
index 7f68724..57a0b68 100644
--- a/arch/arm/mach-pxa/include/mach/memory.h
+++ b/arch/arm/mach-pxa/include/mach/memory.h
@@ -23,8 +23,7 @@ void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);
 #define arch_adjust_zones(size, holes) \
 	cmx2xx_pci_adjust_zones(size, holes)
 
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_64M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_64M)
+#define ARM_DMA_ZONE_SIZE	SZ_64M
 #endif
 
 #endif
diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
index e05fc2c..973428d 100644
--- a/arch/arm/mach-realview/include/mach/memory.h
+++ b/arch/arm/mach-realview/include/mach/memory.h
@@ -34,8 +34,7 @@ extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
 #define arch_adjust_zones(size, hole) \
 	realview_adjust_zones(size, hole)
 
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
+#define ARM_DMA_ZONE_SIZE	SZ_256M
 #endif
 
 #ifdef CONFIG_SPARSEMEM
diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
index a44da6a..090b829 100644
--- a/arch/arm/mach-sa1100/include/mach/memory.h
+++ b/arch/arm/mach-sa1100/include/mach/memory.h
@@ -22,8 +22,7 @@ void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);
 #define arch_adjust_zones(size, holes) \
 	sa1111_adjust_zones(size, holes)
 
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_1M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_1M)
+#define ARM_DMA_ZONE_SIZE	SZ_1M
 
 #endif
 #endif
diff --git a/arch/arm/mach-shark/include/mach/memory.h b/arch/arm/mach-shark/include/mach/memory.h
index 9afb170..48fe84b 100644
--- a/arch/arm/mach-shark/include/mach/memory.h
+++ b/arch/arm/mach-shark/include/mach/memory.h
@@ -32,8 +32,7 @@ static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *
 #define arch_adjust_zones(size, holes) \
 	__arch_adjust_zones(size, holes)
 
-#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_4M - 1)
-#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_4M)
+#define ARM_DMA_ZONE_SIZE	SZ_4M
 
 #endif
 
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
  2011-05-11 16:24 [PATCH 0/2] Consolidate zone adjustment Russell King - ARM Linux
  2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
@ 2011-05-11 16:25 ` Russell King - ARM Linux
  2011-05-11 17:21   ` Catalin Marinas
  2011-05-12  7:28   ` Nicolas Pitre
  2011-05-19 10:56 ` [PATCH 0/2] Consolidate zone adjustment Nori, Sekhar
  2 siblings, 2 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2011-05-11 16:25 UTC (permalink / raw)
  To: linux-arm-kernel

Rather than each platform providing its own function to adjust the
zone sizes, use the new ARM_DMA_ZONE_SIZE definition to perform this
adjustment.  This ensures that the actual DMA zone size and the
ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with
each other, and moves this complexity out of the platform code.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/common/sa1111.c                     |    8 -------
 arch/arm/include/asm/memory.h                |    6 -----
 arch/arm/mach-davinci/include/mach/memory.h  |   15 --------------
 arch/arm/mach-ixp4xx/common-pci.c            |   23 ----------------------
 arch/arm/mach-ixp4xx/include/mach/memory.h   |    9 +-------
 arch/arm/mach-pxa/cm-x2xx-pci.c              |   27 --------------------------
 arch/arm/mach-pxa/include/mach/memory.h      |    7 +-----
 arch/arm/mach-realview/core.c                |   19 ------------------
 arch/arm/mach-realview/include/mach/memory.h |    6 +----
 arch/arm/mach-sa1100/include/mach/memory.h   |    9 --------
 arch/arm/mach-shark/include/mach/memory.h    |   17 ----------------
 arch/arm/mm/init.c                           |   23 +++++++++++++++++++++-
 12 files changed, 25 insertions(+), 144 deletions(-)

diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index a12b33c..9c49a46 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -185,14 +185,6 @@ static struct sa1111_dev_info sa1111_devices[] = {
 	},
 };
 
-void __init sa1111_adjust_zones(unsigned long *size, unsigned long *holes)
-{
-	unsigned int sz = SZ_1M >> PAGE_SHIFT;
-
-	size[1] = size[0] - sz;
-	size[0] = sz;
-}
-
 /*
  * SA1111 interrupt support.  Since clearing an IRQ while there are
  * active IRQs causes the interrupt output to pulse, the upper levels
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index ee5ff41..af44a8f 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -215,12 +215,6 @@ static inline unsigned long __phys_to_virt(unsigned long x)
 #define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
 #endif
 
-#ifndef arch_adjust_zones
-#define arch_adjust_zones(size,holes) do { } while (0)
-#elif !defined(CONFIG_ZONE_DMA)
-#error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA"
-#endif
-
 /*
  * PFNs are used to describe any physical page; this means
  * PFN 0 == physical address 0.
diff --git a/arch/arm/mach-davinci/include/mach/memory.h b/arch/arm/mach-davinci/include/mach/memory.h
index 8d27246..491249e 100644
--- a/arch/arm/mach-davinci/include/mach/memory.h
+++ b/arch/arm/mach-davinci/include/mach/memory.h
@@ -41,26 +41,11 @@
  */
 #define CONSISTENT_DMA_SIZE (14<<20)
 
-#ifndef __ASSEMBLY__
 /*
  * Restrict DMA-able region to workaround silicon bug.  The bug
  * restricts buffers available for DMA to video hardware to be
  * below 128M
  */
-static inline void
-__arch_adjust_zones(unsigned long *size, unsigned long *holes)
-{
-	unsigned int sz = (128<<20) >> PAGE_SHIFT;
-
-	size[1] = size[0] - sz;
-	size[0] = sz;
-}
-
-#define arch_adjust_zones(zone_size, holes) \
-        if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes)
-
 #define ARM_DMA_ZONE_SIZE	SZ_128M
 
-#endif
-
 #endif /* __ASM_ARCH_MEMORY_H */
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index a54b3db..e9a5893 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -342,29 +342,6 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
 	return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M);
 }
 
-/*
- * Only first 64MB of memory can be accessed via PCI.
- * We use GFP_DMA to allocate safe buffers to do map/unmap.
- * This is really ugly and we need a better way of specifying
- * DMA-capable regions of memory.
- */
-void __init ixp4xx_adjust_zones(unsigned long *zone_size,
-	unsigned long *zhole_size)
-{
-	unsigned int sz = SZ_64M >> PAGE_SHIFT;
-
-	/*
-	 * Only adjust if > 64M on current system
-	 */
-	if (zone_size[0] <= sz)
-		return;
-
-	zone_size[1] = zone_size[0] - sz;
-	zone_size[0] = sz;
-	zhole_size[1] = zhole_size[0];
-	zhole_size[0] = 0;
-}
-
 void __init ixp4xx_pci_preinit(void)
 {
 	unsigned long cpuid = read_cpuid_id();
diff --git a/arch/arm/mach-ixp4xx/include/mach/memory.h b/arch/arm/mach-ixp4xx/include/mach/memory.h
index a5c26f8..34e7940 100644
--- a/arch/arm/mach-ixp4xx/include/mach/memory.h
+++ b/arch/arm/mach-ixp4xx/include/mach/memory.h
@@ -14,15 +14,8 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0x00000000)
 
-#if !defined(__ASSEMBLY__) && defined(CONFIG_PCI)
-
-void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);
-
-#define arch_adjust_zones(size, holes) \
-	ixp4xx_adjust_zones(size, holes)
-
+#ifdef CONFIG_PCI
 #define ARM_DMA_ZONE_SIZE	SZ_64M
-
 #endif
 
 #endif
diff --git a/arch/arm/mach-pxa/cm-x2xx-pci.c b/arch/arm/mach-pxa/cm-x2xx-pci.c
index 8b1a309..1afc0fb 100644
--- a/arch/arm/mach-pxa/cm-x2xx-pci.c
+++ b/arch/arm/mach-pxa/cm-x2xx-pci.c
@@ -29,33 +29,6 @@
 unsigned long it8152_base_address;
 static int cmx2xx_it8152_irq_gpio;
 
-/*
- * Only first 64MB of memory can be accessed via PCI.
- * We use GFP_DMA to allocate safe buffers to do map/unmap.
- * This is really ugly and we need a better way of specifying
- * DMA-capable regions of memory.
- */
-void __init cmx2xx_pci_adjust_zones(unsigned long *zone_size,
-	unsigned long *zhole_size)
-{
-	unsigned int sz = SZ_64M >> PAGE_SHIFT;
-
-	if (machine_is_armcore()) {
-		pr_info("Adjusting zones for CM-X2XX\n");
-
-		/*
-		 * Only adjust if > 64M on current system
-		 */
-		if (zone_size[0] <= sz)
-			return;
-
-		zone_size[1] = zone_size[0] - sz;
-		zone_size[0] = sz;
-		zhole_size[1] = zhole_size[0];
-		zhole_size[0] = 0;
-	}
-}
-
 static void cmx2xx_it8152_irq_demux(unsigned int irq, struct irq_desc *desc)
 {
 	/* clear our parent irq */
diff --git a/arch/arm/mach-pxa/include/mach/memory.h b/arch/arm/mach-pxa/include/mach/memory.h
index 57a0b68..07734f3 100644
--- a/arch/arm/mach-pxa/include/mach/memory.h
+++ b/arch/arm/mach-pxa/include/mach/memory.h
@@ -17,12 +17,7 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0xa0000000)
 
-#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
-void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);
-
-#define arch_adjust_zones(size, holes) \
-	cmx2xx_pci_adjust_zones(size, holes)
-
+#if defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
 #define ARM_DMA_ZONE_SIZE	SZ_64M
 #endif
 
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 75dbc87..525ad17 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -56,25 +56,6 @@
 
 #include "core.h"
 
-#ifdef CONFIG_ZONE_DMA
-/*
- * Adjust the zones if there are restrictions for DMA access.
- */
-void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
-{
-	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
-
-	if (!machine_is_realview_pbx() || size[0] <= dma_size)
-		return;
-
-	size[ZONE_NORMAL] = size[0] - dma_size;
-	size[ZONE_DMA] = dma_size;
-	hole[ZONE_NORMAL] = hole[0];
-	hole[ZONE_DMA] = 0;
-}
-#endif
-
-
 #define REALVIEW_FLASHCTRL    (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
 
 static int realview_flash_init(void)
diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
index 973428d..1759fa6 100644
--- a/arch/arm/mach-realview/include/mach/memory.h
+++ b/arch/arm/mach-realview/include/mach/memory.h
@@ -29,11 +29,7 @@
 #define PLAT_PHYS_OFFSET		UL(0x00000000)
 #endif
 
-#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
-extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
-#define arch_adjust_zones(size, hole) \
-	realview_adjust_zones(size, hole)
-
+#ifdef CONFIG_ZONE_DMA
 #define ARM_DMA_ZONE_SIZE	SZ_256M
 #endif
 
diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
index 090b829..cff31ee 100644
--- a/arch/arm/mach-sa1100/include/mach/memory.h
+++ b/arch/arm/mach-sa1100/include/mach/memory.h
@@ -14,17 +14,8 @@
  */
 #define PLAT_PHYS_OFFSET	UL(0xc0000000)
 
-#ifndef __ASSEMBLY__
-
 #ifdef CONFIG_SA1111
-void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);
-
-#define arch_adjust_zones(size, holes) \
-	sa1111_adjust_zones(size, holes)
-
 #define ARM_DMA_ZONE_SIZE	SZ_1M
-
-#endif
 #endif
 
 /*
diff --git a/arch/arm/mach-shark/include/mach/memory.h b/arch/arm/mach-shark/include/mach/memory.h
index 48fe84b..4c0831f8 100644
--- a/arch/arm/mach-shark/include/mach/memory.h
+++ b/arch/arm/mach-shark/include/mach/memory.h
@@ -17,25 +17,8 @@
  */
 #define PLAT_PHYS_OFFSET     UL(0x08000000)
 
-#ifndef __ASSEMBLY__
-
-static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *zhole_size)
-{
-  /* Only the first 4 MB (=1024 Pages) are usable for DMA */
-  /* See dev / -> .properties in OpenFirmware. */
-  zone_size[1] = zone_size[0] - 1024;
-  zone_size[0] = 1024;
-  zhole_size[1] = zhole_size[0];
-  zhole_size[0] = 0;
-}
-
-#define arch_adjust_zones(size, holes) \
-	__arch_adjust_zones(size, holes)
-
 #define ARM_DMA_ZONE_SIZE	SZ_4M
 
-#endif
-
 /*
  * Cache flushing area
  */
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index e5f6fc4..49eaad9 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -201,6 +201,20 @@ static void __init arm_bootmem_init(unsigned long start_pfn,
 	}
 }
 
+#ifdef CONFIG_ZONE_DMA
+static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
+	unsigned long dma_size)
+{
+	if (size[0] <= dma_size)
+		return;
+
+	size[ZONE_NORMAL] = size[0] - dma_size;
+	size[ZONE_DMA] = dma_size;
+	hole[ZONE_NORMAL] = hole[0];
+	hole[ZONE_DMA] = 0;
+}
+#endif
+
 static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
 	unsigned long max_high)
 {
@@ -243,11 +257,18 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
 #endif
 	}
 
+#ifdef ARM_DMA_ZONE_SIZE
+#ifndef CONFIG_ZONE_DMA
+#error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations
+#endif
+
 	/*
 	 * Adjust the sizes according to any special requirements for
 	 * this machine type.
 	 */
-	arch_adjust_zones(zone_size, zhole_size);
+	arm_adjust_dma_zone(zone_size, zhole_size,
+		ARM_DMA_ZONE_SIZE >> PAGE_SHIFT);
+#endif
 
 	free_area_init_node(0, zone_size, min, zhole_size);
 }
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
  2011-05-11 16:25 ` [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes Russell King - ARM Linux
@ 2011-05-11 17:21   ` Catalin Marinas
  2011-05-11 17:24     ` Russell King - ARM Linux
  2011-05-12  7:28   ` Nicolas Pitre
  1 sibling, 1 reply; 9+ messages in thread
From: Catalin Marinas @ 2011-05-11 17:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2011-05-11 at 17:25 +0100, Russell King - ARM Linux wrote:
> Rather than each platform providing its own function to adjust the
> zone sizes, use the new ARM_DMA_ZONE_SIZE definition to perform this
> adjustment.  This ensures that the actual DMA zone size and the
> ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with
> each other, and moves this complexity out of the platform code.
...
> diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
> index 973428d..1759fa6 100644
> --- a/arch/arm/mach-realview/include/mach/memory.h
> +++ b/arch/arm/mach-realview/include/mach/memory.h
> @@ -29,11 +29,7 @@
>  #define PLAT_PHYS_OFFSET               UL(0x00000000)
>  #endif
> 
> -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
> -extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
> -#define arch_adjust_zones(size, hole) \
> -       realview_adjust_zones(size, hole)
> -
> +#ifdef CONFIG_ZONE_DMA
>  #define ARM_DMA_ZONE_SIZE      SZ_256M
>  #endif

We only use ZONE_DMA for PBX and realview_adjust_zones() does this
check. We end up with limiting the DMA zone to 256MB on all RealView
platforms if we compile a single kernel image that includes PBX. Not a
big problem though:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
  2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
@ 2011-05-11 17:22   ` Catalin Marinas
  2011-05-12  7:16   ` Nicolas Pitre
  1 sibling, 0 replies; 9+ messages in thread
From: Catalin Marinas @ 2011-05-11 17:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2011-05-11 at 17:25 +0100, Russell King - ARM Linux wrote:
> The values of ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS are related; one is
> the physical/bus address, the other is the virtual address.  Both need
> to be kept in step, so rather than having platforms define both, allow
> them to define a single macro which sets both of these macros
> appropraitely.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
  2011-05-11 17:21   ` Catalin Marinas
@ 2011-05-11 17:24     ` Russell King - ARM Linux
  0 siblings, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2011-05-11 17:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 11, 2011 at 06:21:38PM +0100, Catalin Marinas wrote:
> On Wed, 2011-05-11 at 17:25 +0100, Russell King - ARM Linux wrote:
> > Rather than each platform providing its own function to adjust the
> > zone sizes, use the new ARM_DMA_ZONE_SIZE definition to perform this
> > adjustment.  This ensures that the actual DMA zone size and the
> > ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with
> > each other, and moves this complexity out of the platform code.
> ...
> > diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
> > index 973428d..1759fa6 100644
> > --- a/arch/arm/mach-realview/include/mach/memory.h
> > +++ b/arch/arm/mach-realview/include/mach/memory.h
> > @@ -29,11 +29,7 @@
> >  #define PLAT_PHYS_OFFSET               UL(0x00000000)
> >  #endif
> > 
> > -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
> > -extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
> > -#define arch_adjust_zones(size, hole) \
> > -       realview_adjust_zones(size, hole)
> > -
> > +#ifdef CONFIG_ZONE_DMA
> >  #define ARM_DMA_ZONE_SIZE      SZ_256M
> >  #endif
> 
> We only use ZONE_DMA for PBX and realview_adjust_zones() does this
> check. We end up with limiting the DMA zone to 256MB on all RealView
> platforms if we compile a single kernel image that includes PBX. Not a
> big problem though:

You've already implicitly limited it by the ISA_DMA_THRESHOLD/
MAX_DMA_ADDRESS definition - what's left is an inconsistent relative
size of those definitions and the actual DMA zone.  That inconsistency
can cause the DMA allocator to fail unexpectedly as it assumes that
GFP_DMA will return a page which will satisfy ISA_DMA_THRESHOLD.

> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

Thanks.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS
  2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
  2011-05-11 17:22   ` Catalin Marinas
@ 2011-05-12  7:16   ` Nicolas Pitre
  1 sibling, 0 replies; 9+ messages in thread
From: Nicolas Pitre @ 2011-05-12  7:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 11 May 2011, Russell King - ARM Linux wrote:

> The values of ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS are related; one is
> the physical/bus address, the other is the virtual address.  Both need
> to be kept in step, so rather than having platforms define both, allow
> them to define a single macro which sets both of these macros
> appropraitely.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>

> ---
>  arch/arm/include/asm/dma.h                   |    4 +++-
>  arch/arm/include/asm/memory.h                |    4 +++-
>  arch/arm/mach-davinci/include/mach/memory.h  |    3 +--
>  arch/arm/mach-h720x/include/mach/memory.h    |    3 +--
>  arch/arm/mach-ixp4xx/include/mach/memory.h   |    3 +--
>  arch/arm/mach-pxa/include/mach/memory.h      |    3 +--
>  arch/arm/mach-realview/include/mach/memory.h |    3 +--
>  arch/arm/mach-sa1100/include/mach/memory.h   |    3 +--
>  arch/arm/mach-shark/include/mach/memory.h    |    3 +--
>  9 files changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
> index ca51143..4200554 100644
> --- a/arch/arm/include/asm/dma.h
> +++ b/arch/arm/include/asm/dma.h
> @@ -6,8 +6,10 @@
>  /*
>   * This is the maximum virtual address which can be DMA'd from.
>   */
> -#ifndef MAX_DMA_ADDRESS
> +#ifndef ARM_DMA_ZONE_SIZE
>  #define MAX_DMA_ADDRESS	0xffffffff
> +#else
> +#define MAX_DMA_ADDRESS	(PAGE_OFFSET + ARM_DMA_ZONE_SIZE)
>  #endif
>  
>  #ifdef CONFIG_ISA_DMA_API
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 431077c..ee5ff41 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -209,8 +209,10 @@ static inline unsigned long __phys_to_virt(unsigned long x)
>   * allocations.  This must be the smallest DMA mask in the system,
>   * so a successful GFP_DMA allocation will always satisfy this.
>   */
> -#ifndef ISA_DMA_THRESHOLD
> +#ifndef ARM_DMA_ZONE_SIZE
>  #define ISA_DMA_THRESHOLD	(0xffffffffULL)
> +#else
> +#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
>  #endif
>  
>  #ifndef arch_adjust_zones
> diff --git a/arch/arm/mach-davinci/include/mach/memory.h b/arch/arm/mach-davinci/include/mach/memory.h
> index 7882272..8d27246 100644
> --- a/arch/arm/mach-davinci/include/mach/memory.h
> +++ b/arch/arm/mach-davinci/include/mach/memory.h
> @@ -59,8 +59,7 @@ __arch_adjust_zones(unsigned long *size, unsigned long *holes)
>  #define arch_adjust_zones(zone_size, holes) \
>          if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes)
>  
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + (128<<20) - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + (128<<20))
> +#define ARM_DMA_ZONE_SIZE	SZ_128M
>  
>  #endif
>  
> diff --git a/arch/arm/mach-h720x/include/mach/memory.h b/arch/arm/mach-h720x/include/mach/memory.h
> index 9d36876..b0b3bae 100644
> --- a/arch/arm/mach-h720x/include/mach/memory.h
> +++ b/arch/arm/mach-h720x/include/mach/memory.h
> @@ -13,7 +13,6 @@
>   * There should not be more than (0xd0000000 - 0xc0000000)
>   * bytes of RAM.
>   */
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
> +#define ARM_DMA_ZONE_SIZE	SZ_256M
>  
>  #endif
> diff --git a/arch/arm/mach-ixp4xx/include/mach/memory.h b/arch/arm/mach-ixp4xx/include/mach/memory.h
> index 6d388c9..a5c26f8 100644
> --- a/arch/arm/mach-ixp4xx/include/mach/memory.h
> +++ b/arch/arm/mach-ixp4xx/include/mach/memory.h
> @@ -21,8 +21,7 @@ void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);
>  #define arch_adjust_zones(size, holes) \
>  	ixp4xx_adjust_zones(size, holes)
>  
> -#define ISA_DMA_THRESHOLD (SZ_64M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_64M)
> +#define ARM_DMA_ZONE_SIZE	SZ_64M
>  
>  #endif
>  
> diff --git a/arch/arm/mach-pxa/include/mach/memory.h b/arch/arm/mach-pxa/include/mach/memory.h
> index 7f68724..57a0b68 100644
> --- a/arch/arm/mach-pxa/include/mach/memory.h
> +++ b/arch/arm/mach-pxa/include/mach/memory.h
> @@ -23,8 +23,7 @@ void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);
>  #define arch_adjust_zones(size, holes) \
>  	cmx2xx_pci_adjust_zones(size, holes)
>  
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_64M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_64M)
> +#define ARM_DMA_ZONE_SIZE	SZ_64M
>  #endif
>  
>  #endif
> diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
> index e05fc2c..973428d 100644
> --- a/arch/arm/mach-realview/include/mach/memory.h
> +++ b/arch/arm/mach-realview/include/mach/memory.h
> @@ -34,8 +34,7 @@ extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
>  #define arch_adjust_zones(size, hole) \
>  	realview_adjust_zones(size, hole)
>  
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
> +#define ARM_DMA_ZONE_SIZE	SZ_256M
>  #endif
>  
>  #ifdef CONFIG_SPARSEMEM
> diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
> index a44da6a..090b829 100644
> --- a/arch/arm/mach-sa1100/include/mach/memory.h
> +++ b/arch/arm/mach-sa1100/include/mach/memory.h
> @@ -22,8 +22,7 @@ void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);
>  #define arch_adjust_zones(size, holes) \
>  	sa1111_adjust_zones(size, holes)
>  
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_1M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_1M)
> +#define ARM_DMA_ZONE_SIZE	SZ_1M
>  
>  #endif
>  #endif
> diff --git a/arch/arm/mach-shark/include/mach/memory.h b/arch/arm/mach-shark/include/mach/memory.h
> index 9afb170..48fe84b 100644
> --- a/arch/arm/mach-shark/include/mach/memory.h
> +++ b/arch/arm/mach-shark/include/mach/memory.h
> @@ -32,8 +32,7 @@ static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *
>  #define arch_adjust_zones(size, holes) \
>  	__arch_adjust_zones(size, holes)
>  
> -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_4M - 1)
> -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_4M)
> +#define ARM_DMA_ZONE_SIZE	SZ_4M
>  
>  #endif
>  
> -- 
> 1.7.4.4
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes
  2011-05-11 16:25 ` [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes Russell King - ARM Linux
  2011-05-11 17:21   ` Catalin Marinas
@ 2011-05-12  7:28   ` Nicolas Pitre
  1 sibling, 0 replies; 9+ messages in thread
From: Nicolas Pitre @ 2011-05-12  7:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 11 May 2011, Russell King - ARM Linux wrote:

> Rather than each platform providing its own function to adjust the
> zone sizes, use the new ARM_DMA_ZONE_SIZE definition to perform this
> adjustment.  This ensures that the actual DMA zone size and the
> ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS definitions are consistent with
> each other, and moves this complexity out of the platform code.
> 
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>

> ---
>  arch/arm/common/sa1111.c                     |    8 -------
>  arch/arm/include/asm/memory.h                |    6 -----
>  arch/arm/mach-davinci/include/mach/memory.h  |   15 --------------
>  arch/arm/mach-ixp4xx/common-pci.c            |   23 ----------------------
>  arch/arm/mach-ixp4xx/include/mach/memory.h   |    9 +-------
>  arch/arm/mach-pxa/cm-x2xx-pci.c              |   27 --------------------------
>  arch/arm/mach-pxa/include/mach/memory.h      |    7 +-----
>  arch/arm/mach-realview/core.c                |   19 ------------------
>  arch/arm/mach-realview/include/mach/memory.h |    6 +----
>  arch/arm/mach-sa1100/include/mach/memory.h   |    9 --------
>  arch/arm/mach-shark/include/mach/memory.h    |   17 ----------------
>  arch/arm/mm/init.c                           |   23 +++++++++++++++++++++-
>  12 files changed, 25 insertions(+), 144 deletions(-)
> 
> diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
> index a12b33c..9c49a46 100644
> --- a/arch/arm/common/sa1111.c
> +++ b/arch/arm/common/sa1111.c
> @@ -185,14 +185,6 @@ static struct sa1111_dev_info sa1111_devices[] = {
>  	},
>  };
>  
> -void __init sa1111_adjust_zones(unsigned long *size, unsigned long *holes)
> -{
> -	unsigned int sz = SZ_1M >> PAGE_SHIFT;
> -
> -	size[1] = size[0] - sz;
> -	size[0] = sz;
> -}
> -
>  /*
>   * SA1111 interrupt support.  Since clearing an IRQ while there are
>   * active IRQs causes the interrupt output to pulse, the upper levels
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index ee5ff41..af44a8f 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -215,12 +215,6 @@ static inline unsigned long __phys_to_virt(unsigned long x)
>  #define ISA_DMA_THRESHOLD	(PHYS_OFFSET + ARM_DMA_ZONE_SIZE - 1)
>  #endif
>  
> -#ifndef arch_adjust_zones
> -#define arch_adjust_zones(size,holes) do { } while (0)
> -#elif !defined(CONFIG_ZONE_DMA)
> -#error "custom arch_adjust_zones() requires CONFIG_ZONE_DMA"
> -#endif
> -
>  /*
>   * PFNs are used to describe any physical page; this means
>   * PFN 0 == physical address 0.
> diff --git a/arch/arm/mach-davinci/include/mach/memory.h b/arch/arm/mach-davinci/include/mach/memory.h
> index 8d27246..491249e 100644
> --- a/arch/arm/mach-davinci/include/mach/memory.h
> +++ b/arch/arm/mach-davinci/include/mach/memory.h
> @@ -41,26 +41,11 @@
>   */
>  #define CONSISTENT_DMA_SIZE (14<<20)
>  
> -#ifndef __ASSEMBLY__
>  /*
>   * Restrict DMA-able region to workaround silicon bug.  The bug
>   * restricts buffers available for DMA to video hardware to be
>   * below 128M
>   */
> -static inline void
> -__arch_adjust_zones(unsigned long *size, unsigned long *holes)
> -{
> -	unsigned int sz = (128<<20) >> PAGE_SHIFT;
> -
> -	size[1] = size[0] - sz;
> -	size[0] = sz;
> -}
> -
> -#define arch_adjust_zones(zone_size, holes) \
> -        if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes)
> -
>  #define ARM_DMA_ZONE_SIZE	SZ_128M
>  
> -#endif
> -
>  #endif /* __ASM_ARCH_MEMORY_H */
> diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
> index a54b3db..e9a5893 100644
> --- a/arch/arm/mach-ixp4xx/common-pci.c
> +++ b/arch/arm/mach-ixp4xx/common-pci.c
> @@ -342,29 +342,6 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
>  	return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M);
>  }
>  
> -/*
> - * Only first 64MB of memory can be accessed via PCI.
> - * We use GFP_DMA to allocate safe buffers to do map/unmap.
> - * This is really ugly and we need a better way of specifying
> - * DMA-capable regions of memory.
> - */
> -void __init ixp4xx_adjust_zones(unsigned long *zone_size,
> -	unsigned long *zhole_size)
> -{
> -	unsigned int sz = SZ_64M >> PAGE_SHIFT;
> -
> -	/*
> -	 * Only adjust if > 64M on current system
> -	 */
> -	if (zone_size[0] <= sz)
> -		return;
> -
> -	zone_size[1] = zone_size[0] - sz;
> -	zone_size[0] = sz;
> -	zhole_size[1] = zhole_size[0];
> -	zhole_size[0] = 0;
> -}
> -
>  void __init ixp4xx_pci_preinit(void)
>  {
>  	unsigned long cpuid = read_cpuid_id();
> diff --git a/arch/arm/mach-ixp4xx/include/mach/memory.h b/arch/arm/mach-ixp4xx/include/mach/memory.h
> index a5c26f8..34e7940 100644
> --- a/arch/arm/mach-ixp4xx/include/mach/memory.h
> +++ b/arch/arm/mach-ixp4xx/include/mach/memory.h
> @@ -14,15 +14,8 @@
>   */
>  #define PLAT_PHYS_OFFSET	UL(0x00000000)
>  
> -#if !defined(__ASSEMBLY__) && defined(CONFIG_PCI)
> -
> -void ixp4xx_adjust_zones(unsigned long *size, unsigned long *holes);
> -
> -#define arch_adjust_zones(size, holes) \
> -	ixp4xx_adjust_zones(size, holes)
> -
> +#ifdef CONFIG_PCI
>  #define ARM_DMA_ZONE_SIZE	SZ_64M
> -
>  #endif
>  
>  #endif
> diff --git a/arch/arm/mach-pxa/cm-x2xx-pci.c b/arch/arm/mach-pxa/cm-x2xx-pci.c
> index 8b1a309..1afc0fb 100644
> --- a/arch/arm/mach-pxa/cm-x2xx-pci.c
> +++ b/arch/arm/mach-pxa/cm-x2xx-pci.c
> @@ -29,33 +29,6 @@
>  unsigned long it8152_base_address;
>  static int cmx2xx_it8152_irq_gpio;
>  
> -/*
> - * Only first 64MB of memory can be accessed via PCI.
> - * We use GFP_DMA to allocate safe buffers to do map/unmap.
> - * This is really ugly and we need a better way of specifying
> - * DMA-capable regions of memory.
> - */
> -void __init cmx2xx_pci_adjust_zones(unsigned long *zone_size,
> -	unsigned long *zhole_size)
> -{
> -	unsigned int sz = SZ_64M >> PAGE_SHIFT;
> -
> -	if (machine_is_armcore()) {
> -		pr_info("Adjusting zones for CM-X2XX\n");
> -
> -		/*
> -		 * Only adjust if > 64M on current system
> -		 */
> -		if (zone_size[0] <= sz)
> -			return;
> -
> -		zone_size[1] = zone_size[0] - sz;
> -		zone_size[0] = sz;
> -		zhole_size[1] = zhole_size[0];
> -		zhole_size[0] = 0;
> -	}
> -}
> -
>  static void cmx2xx_it8152_irq_demux(unsigned int irq, struct irq_desc *desc)
>  {
>  	/* clear our parent irq */
> diff --git a/arch/arm/mach-pxa/include/mach/memory.h b/arch/arm/mach-pxa/include/mach/memory.h
> index 57a0b68..07734f3 100644
> --- a/arch/arm/mach-pxa/include/mach/memory.h
> +++ b/arch/arm/mach-pxa/include/mach/memory.h
> @@ -17,12 +17,7 @@
>   */
>  #define PLAT_PHYS_OFFSET	UL(0xa0000000)
>  
> -#if !defined(__ASSEMBLY__) && defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
> -void cmx2xx_pci_adjust_zones(unsigned long *size, unsigned long *holes);
> -
> -#define arch_adjust_zones(size, holes) \
> -	cmx2xx_pci_adjust_zones(size, holes)
> -
> +#if defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
>  #define ARM_DMA_ZONE_SIZE	SZ_64M
>  #endif
>  
> diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
> index 75dbc87..525ad17 100644
> --- a/arch/arm/mach-realview/core.c
> +++ b/arch/arm/mach-realview/core.c
> @@ -56,25 +56,6 @@
>  
>  #include "core.h"
>  
> -#ifdef CONFIG_ZONE_DMA
> -/*
> - * Adjust the zones if there are restrictions for DMA access.
> - */
> -void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
> -{
> -	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
> -
> -	if (!machine_is_realview_pbx() || size[0] <= dma_size)
> -		return;
> -
> -	size[ZONE_NORMAL] = size[0] - dma_size;
> -	size[ZONE_DMA] = dma_size;
> -	hole[ZONE_NORMAL] = hole[0];
> -	hole[ZONE_DMA] = 0;
> -}
> -#endif
> -
> -
>  #define REALVIEW_FLASHCTRL    (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
>  
>  static int realview_flash_init(void)
> diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
> index 973428d..1759fa6 100644
> --- a/arch/arm/mach-realview/include/mach/memory.h
> +++ b/arch/arm/mach-realview/include/mach/memory.h
> @@ -29,11 +29,7 @@
>  #define PLAT_PHYS_OFFSET		UL(0x00000000)
>  #endif
>  
> -#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
> -extern void realview_adjust_zones(unsigned long *size, unsigned long *hole);
> -#define arch_adjust_zones(size, hole) \
> -	realview_adjust_zones(size, hole)
> -
> +#ifdef CONFIG_ZONE_DMA
>  #define ARM_DMA_ZONE_SIZE	SZ_256M
>  #endif
>  
> diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
> index 090b829..cff31ee 100644
> --- a/arch/arm/mach-sa1100/include/mach/memory.h
> +++ b/arch/arm/mach-sa1100/include/mach/memory.h
> @@ -14,17 +14,8 @@
>   */
>  #define PLAT_PHYS_OFFSET	UL(0xc0000000)
>  
> -#ifndef __ASSEMBLY__
> -
>  #ifdef CONFIG_SA1111
> -void sa1111_adjust_zones(unsigned long *size, unsigned long *holes);
> -
> -#define arch_adjust_zones(size, holes) \
> -	sa1111_adjust_zones(size, holes)
> -
>  #define ARM_DMA_ZONE_SIZE	SZ_1M
> -
> -#endif
>  #endif
>  
>  /*
> diff --git a/arch/arm/mach-shark/include/mach/memory.h b/arch/arm/mach-shark/include/mach/memory.h
> index 48fe84b..4c0831f8 100644
> --- a/arch/arm/mach-shark/include/mach/memory.h
> +++ b/arch/arm/mach-shark/include/mach/memory.h
> @@ -17,25 +17,8 @@
>   */
>  #define PLAT_PHYS_OFFSET     UL(0x08000000)
>  
> -#ifndef __ASSEMBLY__
> -
> -static inline void __arch_adjust_zones(unsigned long *zone_size, unsigned long *zhole_size)
> -{
> -  /* Only the first 4 MB (=1024 Pages) are usable for DMA */
> -  /* See dev / -> .properties in OpenFirmware. */
> -  zone_size[1] = zone_size[0] - 1024;
> -  zone_size[0] = 1024;
> -  zhole_size[1] = zhole_size[0];
> -  zhole_size[0] = 0;
> -}
> -
> -#define arch_adjust_zones(size, holes) \
> -	__arch_adjust_zones(size, holes)
> -
>  #define ARM_DMA_ZONE_SIZE	SZ_4M
>  
> -#endif
> -
>  /*
>   * Cache flushing area
>   */
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index e5f6fc4..49eaad9 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -201,6 +201,20 @@ static void __init arm_bootmem_init(unsigned long start_pfn,
>  	}
>  }
>  
> +#ifdef CONFIG_ZONE_DMA
> +static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
> +	unsigned long dma_size)
> +{
> +	if (size[0] <= dma_size)
> +		return;
> +
> +	size[ZONE_NORMAL] = size[0] - dma_size;
> +	size[ZONE_DMA] = dma_size;
> +	hole[ZONE_NORMAL] = hole[0];
> +	hole[ZONE_DMA] = 0;
> +}
> +#endif
> +
>  static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
>  	unsigned long max_high)
>  {
> @@ -243,11 +257,18 @@ static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
>  #endif
>  	}
>  
> +#ifdef ARM_DMA_ZONE_SIZE
> +#ifndef CONFIG_ZONE_DMA
> +#error ARM_DMA_ZONE_SIZE set but no DMA zone to limit allocations
> +#endif
> +
>  	/*
>  	 * Adjust the sizes according to any special requirements for
>  	 * this machine type.
>  	 */
> -	arch_adjust_zones(zone_size, zhole_size);
> +	arm_adjust_dma_zone(zone_size, zhole_size,
> +		ARM_DMA_ZONE_SIZE >> PAGE_SHIFT);
> +#endif
>  
>  	free_area_init_node(0, zone_size, min, zhole_size);
>  }
> -- 
> 1.7.4.4
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/2] Consolidate zone adjustment
  2011-05-11 16:24 [PATCH 0/2] Consolidate zone adjustment Russell King - ARM Linux
  2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
  2011-05-11 16:25 ` [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes Russell King - ARM Linux
@ 2011-05-19 10:56 ` Nori, Sekhar
  2 siblings, 0 replies; 9+ messages in thread
From: Nori, Sekhar @ 2011-05-19 10:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 11, 2011 at 21:54:50, Russell King - ARM Linux wrote:
> This patch mini-series consolidates the adjustment to system zones
> which some of our platforms require.  Rather than having each
> platform/machine class specify ISA_DMA_THRESHOLD, MAX_DMA_ADDRESS
> and an arch_adjust_zones function, they really only need to provide
> a single sizing definition, which in this series will be called
> ARM_DMA_ZONE_SIZE.

Boot tested this series on DaVinci DA850.

Tested-by: Sekhar Nori <nsekhar@ti.com>

Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-05-19 10:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-11 16:24 [PATCH 0/2] Consolidate zone adjustment Russell King - ARM Linux
2011-05-11 16:25 ` [PATCH 1/2] ARM: Replace platform definition of ISA_DMA_THRESHOLD/MAX_DMA_ADDRESS Russell King - ARM Linux
2011-05-11 17:22   ` Catalin Marinas
2011-05-12  7:16   ` Nicolas Pitre
2011-05-11 16:25 ` [PATCH 2/2] ARM: use ARM_DMA_ZONE_SIZE to adjust the zone sizes Russell King - ARM Linux
2011-05-11 17:21   ` Catalin Marinas
2011-05-11 17:24     ` Russell King - ARM Linux
2011-05-12  7:28   ` Nicolas Pitre
2011-05-19 10:56 ` [PATCH 0/2] Consolidate zone adjustment Nori, Sekhar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.