All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] RealView patches for 2.6.33
@ 2009-10-15 12:21 Catalin Marinas
  2009-10-15 12:21 ` [PATCH 1/4] RealView: Add default memory configuration Catalin Marinas
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-10-15 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

These are mostly RealView patches but the 2nd one re-adds the
conditional definition of __virt_to_phys and __phys_to_virt macros. The
PBX memory support requires non-linear virtual to physical translation
because of the huge gap between the memory blocks (more than 1GB).

Thanks.


Catalin Marinas (3):
      RealView: Add default memory configuration
      Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt)
      RealView: Add sparsemem support for the RealView PBX platform

Colin Tuckley (1):
      RealView: Remove duplicated #define REALVIEW_SYS_FLAGS* statements


 arch/arm/include/asm/memory.h                |    2 +
 arch/arm/mach-realview/Kconfig               |    8 ++++-
 arch/arm/mach-realview/core.c                |   42 +++++++++++++++++++++++-
 arch/arm/mach-realview/core.h                |    5 +++
 arch/arm/mach-realview/include/mach/memory.h |   46 ++++++++++++++++++++++++++
 arch/arm/mach-realview/platsmp.c             |    5 +--
 arch/arm/mach-realview/realview_eb.c         |    1 +
 arch/arm/mach-realview/realview_pb1176.c     |   13 +++++++
 arch/arm/mach-realview/realview_pb11mp.c     |    1 +
 arch/arm/mach-realview/realview_pba8.c       |    1 +
 arch/arm/mach-realview/realview_pbx.c        |   21 ++++++++++++
 11 files changed, 139 insertions(+), 6 deletions(-)

-- 
Catalin

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

* [PATCH 1/4] RealView: Add default memory configuration
  2009-10-15 12:21 [PATCH 0/4] RealView patches for 2.6.33 Catalin Marinas
@ 2009-10-15 12:21 ` Catalin Marinas
  2009-10-15 12:21 ` [PATCH 2/4] RealView: Remove duplicated #define REALVIEW_SYS_FLAGS* statements Catalin Marinas
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-10-15 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds a realview_fixup() function called during booting to set
up the memory banks. This way there is no need to pass a "mem=" argument
on the kernel command line.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm/mach-realview/core.c            |   21 +++++++++++++++++++++
 arch/arm/mach-realview/core.h            |    5 +++++
 arch/arm/mach-realview/realview_eb.c     |    1 +
 arch/arm/mach-realview/realview_pb1176.c |   13 +++++++++++++
 arch/arm/mach-realview/realview_pb11mp.c |    1 +
 arch/arm/mach-realview/realview_pba8.c   |    1 +
 arch/arm/mach-realview/realview_pbx.c    |    1 +
 7 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index a2083b6..c21b0fd 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -788,3 +788,24 @@ void __init realview_timer_init(unsigned int timer_irq)
 	realview_clocksource_init();
 	realview_clockevents_init(timer_irq);
 }
+
+/*
+ * Setup the memory banks.
+ */
+void realview_fixup(struct machine_desc *mdesc, struct tag *tags, char **from,
+		    struct meminfo *meminfo)
+{
+	/*
+	 * Most RealView platforms have 512MB contiguous RAM at 0x70000000.
+	 * Half of this is mirrored at 0.
+	 */
+#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
+	meminfo->bank[0].start = 0x70000000;
+	meminfo->bank[0].size = SZ_512M;
+	meminfo->nr_banks = 1;
+#else
+	meminfo->bank[0].start = 0;
+	meminfo->bank[0].size = SZ_256M;
+	meminfo->nr_banks = 1;
+#endif
+}
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 46cd6ac..1398854 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -25,6 +25,7 @@
 #include <linux/amba/bus.h>
 #include <linux/io.h>
 
+#include <asm/setup.h>
 #include <asm/leds.h>
 
 #define AMBA_DEVICE(name,busid,base,plat)			\
@@ -44,6 +45,8 @@ static struct amba_device name##_device = {			\
 	/* .dma		= base##_DMA,*/				\
 }
 
+struct machine_desc;
+
 extern struct platform_device realview_flash_device;
 extern struct platform_device realview_cf_device;
 extern struct platform_device realview_i2c_device;
@@ -61,5 +64,7 @@ extern void realview_timer_init(unsigned int timer_irq);
 extern int realview_flash_register(struct resource *res, u32 num);
 extern int realview_eth_register(const char *name, struct resource *res);
 extern int realview_usb_register(struct resource *res);
+extern void realview_fixup(struct machine_desc *mdesc, struct tag *tags,
+			   char **from, struct meminfo *meminfo);
 
 #endif
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 1d65e64..917f8ca 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -415,6 +415,7 @@ MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
 	.phys_io	= REALVIEW_EB_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_EB_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
+	.fixup		= realview_fixup,
 	.map_io		= realview_eb_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_eb_timer,
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index 2817fe0..b1cdd37 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -290,6 +290,18 @@ static struct sys_timer realview_pb1176_timer = {
 	.init		= realview_pb1176_timer_init,
 };
 
+static void realview_pb1176_fixup(struct machine_desc *mdesc,
+				  struct tag *tags, char **from,
+				  struct meminfo *meminfo)
+{
+	/*
+	 * RealView PB1176 only has 128MB of RAM mapped at 0.
+	 */
+	meminfo->bank[0].start = 0;
+	meminfo->bank[0].size = SZ_128M;
+	meminfo->nr_banks = 1;
+}
+
 static void __init realview_pb1176_init(void)
 {
 	int i;
@@ -320,6 +332,7 @@ MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
 	.phys_io	= REALVIEW_PB1176_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PB1176_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
+	.fixup		= realview_pb1176_fixup,
 	.map_io		= realview_pb1176_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb1176_timer,
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index 94680fc..22726b5 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -331,6 +331,7 @@ MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore")
 	.phys_io	= REALVIEW_PB11MP_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PB11MP_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
+	.fixup		= realview_fixup,
 	.map_io		= realview_pb11mp_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb11mp_timer,
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c
index 941beb2..fe861e9 100644
--- a/arch/arm/mach-realview/realview_pba8.c
+++ b/arch/arm/mach-realview/realview_pba8.c
@@ -298,6 +298,7 @@ MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8")
 	.phys_io	= REALVIEW_PBA8_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PBA8_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
+	.fixup		= realview_fixup,
 	.map_io		= realview_pba8_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pba8_timer,
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 7e4bc6c..5d09d8b 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -345,6 +345,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.phys_io	= REALVIEW_PBX_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
+	.fixup		= realview_fixup,
 	.map_io		= realview_pbx_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,

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

* [PATCH 2/4] RealView: Remove duplicated #define REALVIEW_SYS_FLAGS* statements
  2009-10-15 12:21 [PATCH 0/4] RealView patches for 2.6.33 Catalin Marinas
  2009-10-15 12:21 ` [PATCH 1/4] RealView: Add default memory configuration Catalin Marinas
@ 2009-10-15 12:21 ` Catalin Marinas
  2009-10-15 12:22 ` [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt) Catalin Marinas
  2009-10-15 12:22 ` [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform Catalin Marinas
  3 siblings, 0 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-10-15 12:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Colin Tuckley <colin.tuckley@arm.com>

The platsmp.c file defines the REALVIEW_SYS_FLAGS* macros which are
already present in platform.h. Just use the latter.

Signed-off-by: Colin Tuckley <colin.tuckley@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm/mach-realview/platsmp.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index a88458b..0092658 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -146,11 +146,8 @@ static void __init poke_milo(void)
 	 * register. The BootMonitor waits for this register to become
 	 * non-zero.
 	 */
-#define REALVIEW_SYS_FLAGSS_OFFSET 0x30
-#define REALVIEW_SYS_FLAGSC_OFFSET 0x34
 	__raw_writel(BSYM(virt_to_phys(realview_secondary_startup)),
-		     __io_address(REALVIEW_SYS_BASE) +
-		     REALVIEW_SYS_FLAGSS_OFFSET);
+		     __io_address(REALVIEW_SYS_FLAGSSET));
 
 	mb();
 }

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

* [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt)
  2009-10-15 12:21 [PATCH 0/4] RealView patches for 2.6.33 Catalin Marinas
  2009-10-15 12:21 ` [PATCH 1/4] RealView: Add default memory configuration Catalin Marinas
  2009-10-15 12:21 ` [PATCH 2/4] RealView: Remove duplicated #define REALVIEW_SYS_FLAGS* statements Catalin Marinas
@ 2009-10-15 12:22 ` Catalin Marinas
  2009-10-19 15:34   ` Russell King - ARM Linux
  2009-10-15 12:22 ` [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform Catalin Marinas
  3 siblings, 1 reply; 16+ messages in thread
From: Catalin Marinas @ 2009-10-15 12:22 UTC (permalink / raw)
  To: linux-arm-kernel

The SPARSEMEM support for RealView PBX requires non-linear physical to
virtual address translation.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Nicolas Pitre <nico@cam.org>
---
 arch/arm/include/asm/memory.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index cefedf0..bc2ff8b 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -125,8 +125,10 @@
  * private definitions which should NOT be used outside memory.h
  * files.  Use virt_to_phys/phys_to_virt/__pa/__va instead.
  */
+#ifndef __virt_to_phys
 #define __virt_to_phys(x)	((x) - PAGE_OFFSET + PHYS_OFFSET)
 #define __phys_to_virt(x)	((x) - PHYS_OFFSET + PAGE_OFFSET)
+#endif
 
 /*
  * Convert a physical address to a Page Frame Number and back

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-10-15 12:21 [PATCH 0/4] RealView patches for 2.6.33 Catalin Marinas
                   ` (2 preceding siblings ...)
  2009-10-15 12:22 ` [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt) Catalin Marinas
@ 2009-10-15 12:22 ` Catalin Marinas
  2009-10-19 15:46   ` Russell King - ARM Linux
  2009-11-08 17:45   ` Russell King - ARM Linux
  3 siblings, 2 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-10-15 12:22 UTC (permalink / raw)
  To: linux-arm-kernel

The RealView PBX board has two 512MB blocks of memory - one at
0x70000000 (with 256MB mirror at 0) and another at 0x20000000. Only the
block at 0x70000000 (or the mirror at 0) may be used for DMA (e.g.
framebuffer). This patch adds the sparsemem definitions to allow the use
of all the memory split as follows:

  256MB @ 0x00000000 (ZONE_DMA)
  512MB @ 0x20000000 (ZONE_NORMAL)
  256MB @ 0x80000000 (ZONE_NORMAL)

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm/mach-realview/Kconfig               |    8 ++++-
 arch/arm/mach-realview/core.c                |   21 +++++++++++-
 arch/arm/mach-realview/include/mach/memory.h |   46 ++++++++++++++++++++++++++
 arch/arm/mach-realview/realview_pbx.c        |   22 ++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index dfc9b0b..ba548ab 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -70,12 +70,14 @@ config MACH_REALVIEW_PBX
 	bool "Support RealView/PBX platform"
 	select ARM_GIC
 	select HAVE_PATA_PLATFORM
+	select ARCH_SPARSEMEM_ENABLE if CPU_V7
+	select ZONE_DMA if SPARSEMEM
 	help
 	  Include support for the ARM(R) RealView PBX platform.
 
 config REALVIEW_HIGH_PHYS_OFFSET
 	bool "High physical base address for the RealView platform"
-	depends on MMU && !MACH_REALVIEW_PB1176
+	depends on MMU && !MACH_REALVIEW_PB1176 && !SPARSEMEM
 	default y
 	help
 	  RealView boards other than PB1176 have the RAM available at
@@ -84,4 +86,8 @@ config REALVIEW_HIGH_PHYS_OFFSET
 	  memory to be accessed contiguously at the high physical
 	  offset.
 
+config ARCH_FLATMEM_ENABLE
+	bool
+	default y if ARCH_SPARSEMEM_ENABLE
+
 endmenu
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index c21b0fd..9f29343 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -59,6 +59,25 @@
 /* used by entry-macro.S and platsmp.c */
 void __iomem *gic_cpu_base_addr;
 
+#ifdef CONFIG_ZONE_DMA
+/*
+ * Adjust the zones if there are restrictions for DMA access.
+ */
+void __init realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole)
+{
+	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
+
+	if (!machine_is_realview_pbx() || node || (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
+
 /*
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
@@ -543,7 +562,7 @@ static int realview_clcd_setup(struct clcd_fb *fb)
 	fb->panel		= realview_clcd_panel();
 
 	fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
-						    &dma, GFP_KERNEL);
+						    &dma, GFP_KERNEL | GFP_DMA);
 	if (!fb->fb.screen_base) {
 		printk(KERN_ERR "CLCD: unable to map framebuffer\n");
 		return -ENOMEM;
diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
index 293c300..bbf7e3b 100644
--- a/arch/arm/mach-realview/include/mach/memory.h
+++ b/arch/arm/mach-realview/include/mach/memory.h
@@ -29,4 +29,50 @@
 #define PHYS_OFFSET		UL(0x00000000)
 #endif
 
+#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
+extern void realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole);
+#define arch_adjust_zones(node, size, hole) \
+	realview_adjust_zones(node, size, hole)
+#endif
+
+#ifdef CONFIG_SPARSEMEM
+
+/*
+ * Sparsemem definitions for RealView PBX.
+ *
+ * The RealView PBX board has another block of 512MB of RAM at 0x20000000,
+ * however only the block at 0x70000000 (or the 256MB mirror at 0x00000000)
+ * may be used for DMA.
+ *
+ * The macros below define a section size of 256MB and a non-linear virtual to
+ * physical mapping:
+ *
+ * 256MB @ 0x00000000 -> PAGE_OFFSET
+ * 512MB @ 0x20000000 -> PAGE_OFFSET + 0x10000000
+ * 256MB @ 0x80000000 -> PAGE_OFFSET + 0x30000000
+ */
+#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
+#error "SPARSEMEM not available with REALVIEW_HIGH_PHYS_OFFSET"
+#endif
+
+#define MAX_PHYSMEM_BITS	32
+#define SECTION_SIZE_BITS	28
+
+/* bank page offsets */
+#define PAGE_OFFSET1	(PAGE_OFFSET + 0x10000000)
+#define PAGE_OFFSET2	(PAGE_OFFSET + 0x30000000)
+
+#define __phys_to_virt(phys)						\
+	((phys) >= 0x80000000 ?	(phys) - 0x80000000 + PAGE_OFFSET2 :	\
+	 (phys) >= 0x20000000 ?	(phys) - 0x20000000 + PAGE_OFFSET1 :	\
+	 (phys) + PAGE_OFFSET)
+
+#define __virt_to_phys(virt)						\
+	 ((virt) >= PAGE_OFFSET2 ? (virt) - PAGE_OFFSET2 + 0x80000000 :	\
+	  (virt) >= PAGE_OFFSET1 ? (virt) - PAGE_OFFSET1 + 0x20000000 :	\
+	  (virt) - PAGE_OFFSET)
+
+#endif	/* CONFIG_SPARSEMEM */
+
 #endif
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 5d09d8b..ec39488 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -304,6 +304,26 @@ static struct sys_timer realview_pbx_timer = {
 	.init		= realview_pbx_timer_init,
 };
 
+static void realview_pbx_fixup(struct machine_desc *mdesc, struct tag *tags,
+			       char **from, struct meminfo *meminfo)
+{
+#ifdef CONFIG_SPARSEMEM
+	/*
+	 * Memory configuration with SPARSEMEM enabled on RealView PBX (see
+	 * asm/mach/memory.h for more information).
+	 */
+	meminfo->bank[0].start = 0;
+	meminfo->bank[0].size = SZ_256M;
+	meminfo->bank[1].start = 0x20000000;
+	meminfo->bank[1].size = SZ_512M;
+	meminfo->bank[2].start = 0x80000000;
+	meminfo->bank[2].size = SZ_256M;
+	meminfo->nr_banks = 3;
+#else
+	realview_fixup(mdesc, tags, from, meminfo);
+#endif
+}
+
 static void __init realview_pbx_init(void)
 {
 	int i;
@@ -345,7 +365,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.phys_io	= REALVIEW_PBX_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
-	.fixup		= realview_fixup,
+	.fixup		= realview_pbx_fixup,
 	.map_io		= realview_pbx_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,

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

* [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt)
  2009-10-15 12:22 ` [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt) Catalin Marinas
@ 2009-10-19 15:34   ` Russell King - ARM Linux
  2009-10-19 15:46     ` Catalin Marinas
  0 siblings, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-10-19 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 15, 2009 at 01:22:04PM +0100, Catalin Marinas wrote:
> The SPARSEMEM support for RealView PBX requires non-linear physical to
> virtual address translation.

Since we have two platforms which are wanting this, I think this shouldn't
be a separate patch, but merely just a 'git revert' of the original.

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-10-15 12:22 ` [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform Catalin Marinas
@ 2009-10-19 15:46   ` Russell King - ARM Linux
  2009-10-19 16:03     ` Catalin Marinas
  2009-11-08 17:45   ` Russell King - ARM Linux
  1 sibling, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-10-19 15:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> +#ifdef CONFIG_ZONE_DMA
> +/*
> + * Adjust the zones if there are restrictions for DMA access.
> + */
> +void __init realview_adjust_zones(int node, unsigned long *size,
> +				  unsigned long *hole)
> +{
> +	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
> +
> +	if (!machine_is_realview_pbx() || node || (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;
> +}

You also need to set ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS:

#define ISA_DMA_THRESHOLD       (PHYS_OFFSET + SZ_256M - 1)
#define MAX_DMA_ADDRESS         (PAGE_OFFSET + SZ_256M)

so that other bits of code know what to expect from a GFP_DMA-type
allocation.

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

* [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt)
  2009-10-19 15:34   ` Russell King - ARM Linux
@ 2009-10-19 15:46     ` Catalin Marinas
  2009-10-19 15:54       ` Russell King - ARM Linux
  0 siblings, 1 reply; 16+ messages in thread
From: Catalin Marinas @ 2009-10-19 15:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2009-10-19 at 16:34 +0100, Russell King - ARM Linux wrote:
> On Thu, Oct 15, 2009 at 01:22:04PM +0100, Catalin Marinas wrote:
> > The SPARSEMEM support for RealView PBX requires non-linear physical to
> > virtual address translation.
> 
> Since we have two platforms which are wanting this, I think this shouldn't
> be a separate patch, but merely just a 'git revert' of the original.

Well, git revert just generates another commit with a different author
and a reverted diff from the original commit. My patch just adds a
different comment from the standard one.

Will you revert this commit in your tree? I don't know how to submit
"git revert" commands to the patch system :-).

-- 
Catalin

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

* [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt)
  2009-10-19 15:46     ` Catalin Marinas
@ 2009-10-19 15:54       ` Russell King - ARM Linux
  0 siblings, 0 replies; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-10-19 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 19, 2009 at 04:46:57PM +0100, Catalin Marinas wrote:
> On Mon, 2009-10-19 at 16:34 +0100, Russell King - ARM Linux wrote:
> > On Thu, Oct 15, 2009 at 01:22:04PM +0100, Catalin Marinas wrote:
> > > The SPARSEMEM support for RealView PBX requires non-linear physical to
> > > virtual address translation.
> > 
> > Since we have two platforms which are wanting this, I think this shouldn't
> > be a separate patch, but merely just a 'git revert' of the original.
> 
> Well, git revert just generates another commit with a different author
> and a reverted diff from the original commit. My patch just adds a
> different comment from the standard one.

I think it's sensible to keep at least the summary line of a 'git revert'
intact rather than inventing our own.

> Will you revert this commit in your tree? I don't know how to submit
> "git revert" commands to the patch system :-).

Done.

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-10-19 15:46   ` Russell King - ARM Linux
@ 2009-10-19 16:03     ` Catalin Marinas
  0 siblings, 0 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-10-19 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2009-10-19 at 16:46 +0100, Russell King - ARM Linux wrote:
> On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> > +#ifdef CONFIG_ZONE_DMA
> > +/*
> > + * Adjust the zones if there are restrictions for DMA access.
> > + */
> > +void __init realview_adjust_zones(int node, unsigned long *size,
> > +				  unsigned long *hole)
> > +{
> > +	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
> > +
> > +	if (!machine_is_realview_pbx() || node || (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;
> > +}
> 
> You also need to set ISA_DMA_THRESHOLD and MAX_DMA_ADDRESS:
> 
> #define ISA_DMA_THRESHOLD       (PHYS_OFFSET + SZ_256M - 1)
> #define MAX_DMA_ADDRESS         (PAGE_OFFSET + SZ_256M)
> 
> so that other bits of code know what to expect from a GFP_DMA-type
> allocation.

Thanks. Here's the updated patch:


RealView: Add sparsemem support for the RealView PBX platform

From: Catalin Marinas <catalin.marinas@arm.com>

The RealView PBX board has two 512MB blocks of memory - one at
0x70000000 (with 256MB mirror at 0) and another at 0x20000000. Only the
block at 0x70000000 (or the mirror at 0) may be used for DMA (e.g.
framebuffer). This patch adds the sparsemem definitions to allow the use
of all the memory split as follows:

  256MB @ 0x00000000 (ZONE_DMA)
  512MB @ 0x20000000 (ZONE_NORMAL)
  256MB @ 0x80000000 (ZONE_NORMAL)

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm/mach-realview/Kconfig               |    8 ++++
 arch/arm/mach-realview/core.c                |   21 +++++++++++
 arch/arm/mach-realview/include/mach/memory.h |   49 ++++++++++++++++++++++++++
 arch/arm/mach-realview/realview_pbx.c        |   22 +++++++++++-
 4 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index dfc9b0b..ba548ab 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -70,12 +70,14 @@ config MACH_REALVIEW_PBX
 	bool "Support RealView/PBX platform"
 	select ARM_GIC
 	select HAVE_PATA_PLATFORM
+	select ARCH_SPARSEMEM_ENABLE if CPU_V7
+	select ZONE_DMA if SPARSEMEM
 	help
 	  Include support for the ARM(R) RealView PBX platform.
 
 config REALVIEW_HIGH_PHYS_OFFSET
 	bool "High physical base address for the RealView platform"
-	depends on MMU && !MACH_REALVIEW_PB1176
+	depends on MMU && !MACH_REALVIEW_PB1176 && !SPARSEMEM
 	default y
 	help
 	  RealView boards other than PB1176 have the RAM available at
@@ -84,4 +86,8 @@ config REALVIEW_HIGH_PHYS_OFFSET
 	  memory to be accessed contiguously at the high physical
 	  offset.
 
+config ARCH_FLATMEM_ENABLE
+	bool
+	default y if ARCH_SPARSEMEM_ENABLE
+
 endmenu
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index c21b0fd..9f29343 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -59,6 +59,25 @@
 /* used by entry-macro.S and platsmp.c */
 void __iomem *gic_cpu_base_addr;
 
+#ifdef CONFIG_ZONE_DMA
+/*
+ * Adjust the zones if there are restrictions for DMA access.
+ */
+void __init realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole)
+{
+	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
+
+	if (!machine_is_realview_pbx() || node || (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
+
 /*
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
@@ -543,7 +562,7 @@ static int realview_clcd_setup(struct clcd_fb *fb)
 	fb->panel		= realview_clcd_panel();
 
 	fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
-						    &dma, GFP_KERNEL);
+						    &dma, GFP_KERNEL | GFP_DMA);
 	if (!fb->fb.screen_base) {
 		printk(KERN_ERR "CLCD: unable to map framebuffer\n");
 		return -ENOMEM;
diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
index 293c300..2417bbc 100644
--- a/arch/arm/mach-realview/include/mach/memory.h
+++ b/arch/arm/mach-realview/include/mach/memory.h
@@ -29,4 +29,53 @@
 #define PHYS_OFFSET		UL(0x00000000)
 #endif
 
+#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
+extern void realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole);
+#define arch_adjust_zones(node, size, hole) \
+	realview_adjust_zones(node, size, hole)
+
+#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
+#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
+#endif
+
+#ifdef CONFIG_SPARSEMEM
+
+/*
+ * Sparsemem definitions for RealView PBX.
+ *
+ * The RealView PBX board has another block of 512MB of RAM at 0x20000000,
+ * however only the block at 0x70000000 (or the 256MB mirror at 0x00000000)
+ * may be used for DMA.
+ *
+ * The macros below define a section size of 256MB and a non-linear virtual to
+ * physical mapping:
+ *
+ * 256MB @ 0x00000000 -> PAGE_OFFSET
+ * 512MB @ 0x20000000 -> PAGE_OFFSET + 0x10000000
+ * 256MB @ 0x80000000 -> PAGE_OFFSET + 0x30000000
+ */
+#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
+#error "SPARSEMEM not available with REALVIEW_HIGH_PHYS_OFFSET"
+#endif
+
+#define MAX_PHYSMEM_BITS	32
+#define SECTION_SIZE_BITS	28
+
+/* bank page offsets */
+#define PAGE_OFFSET1	(PAGE_OFFSET + 0x10000000)
+#define PAGE_OFFSET2	(PAGE_OFFSET + 0x30000000)
+
+#define __phys_to_virt(phys)						\
+	((phys) >= 0x80000000 ?	(phys) - 0x80000000 + PAGE_OFFSET2 :	\
+	 (phys) >= 0x20000000 ?	(phys) - 0x20000000 + PAGE_OFFSET1 :	\
+	 (phys) + PAGE_OFFSET)
+
+#define __virt_to_phys(virt)						\
+	 ((virt) >= PAGE_OFFSET2 ? (virt) - PAGE_OFFSET2 + 0x80000000 :	\
+	  (virt) >= PAGE_OFFSET1 ? (virt) - PAGE_OFFSET1 + 0x20000000 :	\
+	  (virt) - PAGE_OFFSET)
+
+#endif	/* CONFIG_SPARSEMEM */
+
 #endif
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 5d09d8b..ec39488 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -304,6 +304,26 @@ static struct sys_timer realview_pbx_timer = {
 	.init		= realview_pbx_timer_init,
 };
 
+static void realview_pbx_fixup(struct machine_desc *mdesc, struct tag *tags,
+			       char **from, struct meminfo *meminfo)
+{
+#ifdef CONFIG_SPARSEMEM
+	/*
+	 * Memory configuration with SPARSEMEM enabled on RealView PBX (see
+	 * asm/mach/memory.h for more information).
+	 */
+	meminfo->bank[0].start = 0;
+	meminfo->bank[0].size = SZ_256M;
+	meminfo->bank[1].start = 0x20000000;
+	meminfo->bank[1].size = SZ_512M;
+	meminfo->bank[2].start = 0x80000000;
+	meminfo->bank[2].size = SZ_256M;
+	meminfo->nr_banks = 3;
+#else
+	realview_fixup(mdesc, tags, from, meminfo);
+#endif
+}
+
 static void __init realview_pbx_init(void)
 {
 	int i;
@@ -345,7 +365,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.phys_io	= REALVIEW_PBX_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
-	.fixup		= realview_fixup,
+	.fixup		= realview_pbx_fixup,
 	.map_io		= realview_pbx_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,


-- 
Catalin

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-10-15 12:22 ` [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform Catalin Marinas
  2009-10-19 15:46   ` Russell King - ARM Linux
@ 2009-11-08 17:45   ` Russell King - ARM Linux
  2009-11-09  9:51     ` Catalin Marinas
  1 sibling, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-11-08 17:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
> index dfc9b0b..ba548ab 100644
> --- a/arch/arm/mach-realview/Kconfig
> +++ b/arch/arm/mach-realview/Kconfig
> @@ -70,12 +70,14 @@ config MACH_REALVIEW_PBX
>  	bool "Support RealView/PBX platform"
>  	select ARM_GIC
>  	select HAVE_PATA_PLATFORM
> +	select ARCH_SPARSEMEM_ENABLE if CPU_V7
> +	select ZONE_DMA if SPARSEMEM
>  	help
>  	  Include support for the ARM(R) RealView PBX platform.
>  
>  config REALVIEW_HIGH_PHYS_OFFSET
>  	bool "High physical base address for the RealView platform"
> -	depends on MMU && !MACH_REALVIEW_PB1176
> +	depends on MMU && !MACH_REALVIEW_PB1176 && !SPARSEMEM
>  	default y
>  	help
>  	  RealView boards other than PB1176 have the RAM available at
> @@ -84,4 +86,8 @@ config REALVIEW_HIGH_PHYS_OFFSET
>  	  memory to be accessed contiguously at the high physical
>  	  offset.
>  
> +config ARCH_FLATMEM_ENABLE
> +	bool
> +	default y if ARCH_SPARSEMEM_ENABLE
> +

I seem to have missed this.  Why do we want to enable flatmem support for
_everything_ which enables sparsemem?

In fact, why do you even have this at all?

Not pulling your latest pull request due to this.

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-11-08 17:45   ` Russell King - ARM Linux
@ 2009-11-09  9:51     ` Catalin Marinas
  2009-11-09 10:18       ` Russell King - ARM Linux
  0 siblings, 1 reply; 16+ messages in thread
From: Catalin Marinas @ 2009-11-09  9:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, 2009-11-08 at 17:45 +0000, Russell King - ARM Linux wrote:
> On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> > diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
> > index dfc9b0b..ba548ab 100644
> > --- a/arch/arm/mach-realview/Kconfig
> > +++ b/arch/arm/mach-realview/Kconfig
> > @@ -70,12 +70,14 @@ config MACH_REALVIEW_PBX
> >  	bool "Support RealView/PBX platform"
> >  	select ARM_GIC
> >  	select HAVE_PATA_PLATFORM
> > +	select ARCH_SPARSEMEM_ENABLE if CPU_V7
> > +	select ZONE_DMA if SPARSEMEM
> >  	help
> >  	  Include support for the ARM(R) RealView PBX platform.
> >  
> >  config REALVIEW_HIGH_PHYS_OFFSET
> >  	bool "High physical base address for the RealView platform"
> > -	depends on MMU && !MACH_REALVIEW_PB1176
> > +	depends on MMU && !MACH_REALVIEW_PB1176 && !SPARSEMEM
> >  	default y
> >  	help
> >  	  RealView boards other than PB1176 have the RAM available at
> > @@ -84,4 +86,8 @@ config REALVIEW_HIGH_PHYS_OFFSET
> >  	  memory to be accessed contiguously at the high physical
> >  	  offset.
> >  
> > +config ARCH_FLATMEM_ENABLE
> > +	bool
> > +	default y if ARCH_SPARSEMEM_ENABLE
> > +
> 
> I seem to have missed this.  Why do we want to enable flatmem support for
> _everything_ which enables sparsemem?

Just to have the option of selecting either flatmem or sparsemem with
PBX (though I don't have a strong opinion about this). This can also be
done transparently via REALVIEW_HIGH_PHYS_OFFSET.

If you like the approach below, I'll push it to the for-rmk branch:


RealView: Add sparsemem support for the RealView PBX platform

From: Catalin Marinas <catalin.marinas@arm.com>

The RealView PBX board has two 512MB blocks of memory - one at
0x70000000 (with 256MB mirror at 0) and another at 0x20000000. Only the
block at 0x70000000 (or the mirror at 0) may be used for DMA (e.g.
framebuffer). This patch adds the sparsemem definitions to allow the use
of all the memory split as follows:

  256MB @ 0x00000000 (ZONE_DMA)
  512MB @ 0x20000000 (ZONE_NORMAL)
  256MB @ 0x80000000 (ZONE_NORMAL)

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm/mach-realview/Kconfig               |    5 ++-
 arch/arm/mach-realview/core.c                |   21 +++++++++++
 arch/arm/mach-realview/include/mach/memory.h |   49 ++++++++++++++++++++++++++
 arch/arm/mach-realview/realview_pbx.c        |   22 +++++++++++-
 4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index dfc9b0b..c48e1f2 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -70,6 +70,8 @@ config MACH_REALVIEW_PBX
 	bool "Support RealView/PBX platform"
 	select ARM_GIC
 	select HAVE_PATA_PLATFORM
+	select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !HIGH_PHYS_OFFSET
+	select ZONE_DMA if SPARSEMEM
 	help
 	  Include support for the ARM(R) RealView PBX platform.
 
@@ -82,6 +84,7 @@ config REALVIEW_HIGH_PHYS_OFFSET
 	  0x70000000, 256MB of which being mirrored at 0x00000000. If
 	  the board supports 512MB of RAM, this option allows the
 	  memory to be accessed contiguously at the high physical
-	  offset.
+	  offset. On the PBX board, disabling this option allows 1GB of
+	  RAM to be used with SPARSEMEM.
 
 endmenu
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index c21b0fd..9f29343 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -59,6 +59,25 @@
 /* used by entry-macro.S and platsmp.c */
 void __iomem *gic_cpu_base_addr;
 
+#ifdef CONFIG_ZONE_DMA
+/*
+ * Adjust the zones if there are restrictions for DMA access.
+ */
+void __init realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole)
+{
+	unsigned long dma_size = SZ_256M >> PAGE_SHIFT;
+
+	if (!machine_is_realview_pbx() || node || (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
+
 /*
  * This is the RealView sched_clock implementation.  This has
  * a resolution of 41.7ns, and a maximum value of about 179s.
@@ -543,7 +562,7 @@ static int realview_clcd_setup(struct clcd_fb *fb)
 	fb->panel		= realview_clcd_panel();
 
 	fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
-						    &dma, GFP_KERNEL);
+						    &dma, GFP_KERNEL | GFP_DMA);
 	if (!fb->fb.screen_base) {
 		printk(KERN_ERR "CLCD: unable to map framebuffer\n");
 		return -ENOMEM;
diff --git a/arch/arm/mach-realview/include/mach/memory.h b/arch/arm/mach-realview/include/mach/memory.h
index 293c300..2417bbc 100644
--- a/arch/arm/mach-realview/include/mach/memory.h
+++ b/arch/arm/mach-realview/include/mach/memory.h
@@ -29,4 +29,53 @@
 #define PHYS_OFFSET		UL(0x00000000)
 #endif
 
+#if !defined(__ASSEMBLY__) && defined(CONFIG_ZONE_DMA)
+extern void realview_adjust_zones(int node, unsigned long *size,
+				  unsigned long *hole);
+#define arch_adjust_zones(node, size, hole) \
+	realview_adjust_zones(node, size, hole)
+
+#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + SZ_256M - 1)
+#define MAX_DMA_ADDRESS		(PAGE_OFFSET + SZ_256M)
+#endif
+
+#ifdef CONFIG_SPARSEMEM
+
+/*
+ * Sparsemem definitions for RealView PBX.
+ *
+ * The RealView PBX board has another block of 512MB of RAM at 0x20000000,
+ * however only the block at 0x70000000 (or the 256MB mirror at 0x00000000)
+ * may be used for DMA.
+ *
+ * The macros below define a section size of 256MB and a non-linear virtual to
+ * physical mapping:
+ *
+ * 256MB @ 0x00000000 -> PAGE_OFFSET
+ * 512MB @ 0x20000000 -> PAGE_OFFSET + 0x10000000
+ * 256MB @ 0x80000000 -> PAGE_OFFSET + 0x30000000
+ */
+#ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET
+#error "SPARSEMEM not available with REALVIEW_HIGH_PHYS_OFFSET"
+#endif
+
+#define MAX_PHYSMEM_BITS	32
+#define SECTION_SIZE_BITS	28
+
+/* bank page offsets */
+#define PAGE_OFFSET1	(PAGE_OFFSET + 0x10000000)
+#define PAGE_OFFSET2	(PAGE_OFFSET + 0x30000000)
+
+#define __phys_to_virt(phys)						\
+	((phys) >= 0x80000000 ?	(phys) - 0x80000000 + PAGE_OFFSET2 :	\
+	 (phys) >= 0x20000000 ?	(phys) - 0x20000000 + PAGE_OFFSET1 :	\
+	 (phys) + PAGE_OFFSET)
+
+#define __virt_to_phys(virt)						\
+	 ((virt) >= PAGE_OFFSET2 ? (virt) - PAGE_OFFSET2 + 0x80000000 :	\
+	  (virt) >= PAGE_OFFSET1 ? (virt) - PAGE_OFFSET1 + 0x20000000 :	\
+	  (virt) - PAGE_OFFSET)
+
+#endif	/* CONFIG_SPARSEMEM */
+
 #endif
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 5d09d8b..ec39488 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -304,6 +304,26 @@ static struct sys_timer realview_pbx_timer = {
 	.init		= realview_pbx_timer_init,
 };
 
+static void realview_pbx_fixup(struct machine_desc *mdesc, struct tag *tags,
+			       char **from, struct meminfo *meminfo)
+{
+#ifdef CONFIG_SPARSEMEM
+	/*
+	 * Memory configuration with SPARSEMEM enabled on RealView PBX (see
+	 * asm/mach/memory.h for more information).
+	 */
+	meminfo->bank[0].start = 0;
+	meminfo->bank[0].size = SZ_256M;
+	meminfo->bank[1].start = 0x20000000;
+	meminfo->bank[1].size = SZ_512M;
+	meminfo->bank[2].start = 0x80000000;
+	meminfo->bank[2].size = SZ_256M;
+	meminfo->nr_banks = 3;
+#else
+	realview_fixup(mdesc, tags, from, meminfo);
+#endif
+}
+
 static void __init realview_pbx_init(void)
 {
 	int i;
@@ -345,7 +365,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.phys_io	= REALVIEW_PBX_UART0_BASE,
 	.io_pg_offst	= (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
 	.boot_params	= PHYS_OFFSET + 0x00000100,
-	.fixup		= realview_fixup,
+	.fixup		= realview_pbx_fixup,
 	.map_io		= realview_pbx_map_io,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,


-- 
Catalin

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-11-09  9:51     ` Catalin Marinas
@ 2009-11-09 10:18       ` Russell King - ARM Linux
  2009-11-09 10:34         ` Catalin Marinas
  0 siblings, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-11-09 10:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 09, 2009 at 09:51:40AM +0000, Catalin Marinas wrote:
> On Sun, 2009-11-08 at 17:45 +0000, Russell King - ARM Linux wrote:
> > On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> > > +config ARCH_FLATMEM_ENABLE
> > > +	bool
> > > +	default y if ARCH_SPARSEMEM_ENABLE
> > > +
> > 
> > I seem to have missed this.  Why do we want to enable flatmem support for
> > _everything_ which enables sparsemem?
> 
> Just to have the option of selecting either flatmem or sparsemem with
> PBX (though I don't have a strong opinion about this). This can also be
> done transparently via REALVIEW_HIGH_PHYS_OFFSET.

If you want to do this, put ARCH_FLATMEM_ENABLE into arch/arm/Kconfig,
and arrange for the platform(s) where this is optional _and_ not the
default to select this symbol, in precisely the same way that
ARCH_SPARSEMEM_ENABLE is handled today.

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-11-09 10:18       ` Russell King - ARM Linux
@ 2009-11-09 10:34         ` Catalin Marinas
  2009-11-09 10:39           ` Russell King - ARM Linux
  0 siblings, 1 reply; 16+ messages in thread
From: Catalin Marinas @ 2009-11-09 10:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2009-11-09 at 10:18 +0000, Russell King - ARM Linux wrote:
> On Mon, Nov 09, 2009 at 09:51:40AM +0000, Catalin Marinas wrote:
> > On Sun, 2009-11-08 at 17:45 +0000, Russell King - ARM Linux wrote:
> > > On Thu, Oct 15, 2009 at 01:22:09PM +0100, Catalin Marinas wrote:
> > > > +config ARCH_FLATMEM_ENABLE
> > > > +	bool
> > > > +	default y if ARCH_SPARSEMEM_ENABLE
> > > > +
> > > 
> > > I seem to have missed this.  Why do we want to enable flatmem support for
> > > _everything_ which enables sparsemem?
> > 
> > Just to have the option of selecting either flatmem or sparsemem with
> > PBX (though I don't have a strong opinion about this). This can also be
> > done transparently via REALVIEW_HIGH_PHYS_OFFSET.
> 
> If you want to do this, put ARCH_FLATMEM_ENABLE into arch/arm/Kconfig,
> and arrange for the platform(s) where this is optional _and_ not the
> default to select this symbol, in precisely the same way that
> ARCH_SPARSEMEM_ENABLE is handled today.

I don't think it's worth the hassle anyway. If you have
REALVIEW_HIGH_PHYS_OFFSET disabled and FLATMEM, you end up with only
256MB of RAM available, I don't really see a point in this
configuration. With the new patch, if you don't like SPARSEMEM (maybe
for benchmarking reasons), just enable REALVIEW_HIGH_PHYS_OFFSET.

So, are you OK with the latest patch?

-- 
Catalin

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-11-09 10:34         ` Catalin Marinas
@ 2009-11-09 10:39           ` Russell King - ARM Linux
  2009-11-09 10:53             ` Catalin Marinas
  0 siblings, 1 reply; 16+ messages in thread
From: Russell King - ARM Linux @ 2009-11-09 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 09, 2009 at 10:34:06AM +0000, Catalin Marinas wrote:
> I don't think it's worth the hassle anyway. If you have
> REALVIEW_HIGH_PHYS_OFFSET disabled and FLATMEM, you end up with only
> 256MB of RAM available, I don't really see a point in this
> configuration. With the new patch, if you don't like SPARSEMEM (maybe
> for benchmarking reasons), just enable REALVIEW_HIGH_PHYS_OFFSET.
> 
> So, are you OK with the latest patch?

In that case, yes.

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

* [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform
  2009-11-09 10:39           ` Russell King - ARM Linux
@ 2009-11-09 10:53             ` Catalin Marinas
  0 siblings, 0 replies; 16+ messages in thread
From: Catalin Marinas @ 2009-11-09 10:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2009-11-09 at 10:39 +0000, Russell King - ARM Linux wrote:
> On Mon, Nov 09, 2009 at 10:34:06AM +0000, Catalin Marinas wrote:
> > I don't think it's worth the hassle anyway. If you have
> > REALVIEW_HIGH_PHYS_OFFSET disabled and FLATMEM, you end up with only
> > 256MB of RAM available, I don't really see a point in this
> > configuration. With the new patch, if you don't like SPARSEMEM (maybe
> > for benchmarking reasons), just enable REALVIEW_HIGH_PHYS_OFFSET.
> > 
> > So, are you OK with the latest patch?
> 
> In that case, yes.

OK, I updated the for-rmk branch.

Thanks.

-- 
Catalin

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

end of thread, other threads:[~2009-11-09 10:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15 12:21 [PATCH 0/4] RealView patches for 2.6.33 Catalin Marinas
2009-10-15 12:21 ` [PATCH 1/4] RealView: Add default memory configuration Catalin Marinas
2009-10-15 12:21 ` [PATCH 2/4] RealView: Remove duplicated #define REALVIEW_SYS_FLAGS* statements Catalin Marinas
2009-10-15 12:22 ` [PATCH 3/4] Revert 75f4aa1 (unconditionally define __virt_to_phys and __phys_to_virt) Catalin Marinas
2009-10-19 15:34   ` Russell King - ARM Linux
2009-10-19 15:46     ` Catalin Marinas
2009-10-19 15:54       ` Russell King - ARM Linux
2009-10-15 12:22 ` [PATCH 4/4] RealView: Add sparsemem support for the RealView PBX platform Catalin Marinas
2009-10-19 15:46   ` Russell King - ARM Linux
2009-10-19 16:03     ` Catalin Marinas
2009-11-08 17:45   ` Russell King - ARM Linux
2009-11-09  9:51     ` Catalin Marinas
2009-11-09 10:18       ` Russell King - ARM Linux
2009-11-09 10:34         ` Catalin Marinas
2009-11-09 10:39           ` Russell King - ARM Linux
2009-11-09 10:53             ` Catalin Marinas

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.