ARM: Move platform memory reservations out of generic code
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 22 May 2010 17:18:57 +0000 (18:18 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 16 Jul 2010 10:06:40 +0000 (11:06 +0100)
Move the platform specific bootmem memory reservations out of
arch/arm/mm/mmu.c into their respective platform files.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
16 files changed:
arch/arm/include/asm/mach/arch.h
arch/arm/mach-clps711x/edb7211-arch.c
arch/arm/mach-integrator/common.h [new file with mode: 0644]
arch/arm/mach-integrator/core.c
arch/arm/mach-integrator/integrator_ap.c
arch/arm/mach-integrator/integrator_cp.c
arch/arm/mach-pxa/palmt5.c
arch/arm/mach-pxa/palmtreo.c
arch/arm/mach-s3c2410/mach-h1940.c
arch/arm/mach-s3c2440/mach-rx1950.c
arch/arm/mach-s3c2440/mach-rx3715.c
arch/arm/mach-u300/u300.c
arch/arm/mm/init.c
arch/arm/mm/mm.h
arch/arm/mm/mmu.c
arch/arm/mm/nommu.c

index c59842dc7cb8d8f2b3a3e140d3a17d8da575efe0..d425f2b6efeb3600382e7a0687001c93e2b5bd18 100644 (file)
@@ -37,6 +37,7 @@ struct machine_desc {
        void                    (*fixup)(struct machine_desc *,
                                         struct tag *, char **,
                                         struct meminfo *);
+       void                    (*reserve)(void);/* reserve mem blocks  */
        void                    (*map_io)(void);/* IO mapping function  */
        void                    (*init_irq)(void);
        struct sys_timer        *timer;         /* system tick timer    */
index 41a4425617c1b6dcb06f623618955a8c5737da92..077f4051a06a6165437225d0f3bc049e1bdfb061 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <linux/init.h>
+#include <linux/bootmem.h>
 #include <linux/types.h>
 #include <linux/string.h>
 
 
 extern void edb7211_map_io(void);
 
+/* Reserve screen memory region at the start of main system memory. */
+static void __init edb7211_reserve(void)
+{
+       reserve_bootmem(PHYS_OFFSET, 0x00020000, BOOTMEM_DEFAULT);
+}
+
 static void __init
 fixup_edb7211(struct machine_desc *desc, struct tag *tags,
              char **cmdline, struct meminfo *mi)
@@ -55,6 +62,7 @@ MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
        .boot_params    = 0xc0020100,   /* 0xc0000000 - 0xc001ffff can be video RAM */
        .fixup          = fixup_edb7211,
        .map_io         = edb7211_map_io,
+       .reserve        = edb7211_reserve,
        .init_irq       = clps711x_init_irq,
        .timer          = &clps711x_timer,
 MACHINE_END
diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h
new file mode 100644 (file)
index 0000000..5f96e15
--- /dev/null
@@ -0,0 +1 @@
+void integrator_reserve(void);
index b02cfc06e0aeeff452a2c3813523fccd53f1edf2..f815a1863f709425006faa013bc5476a78266c9e 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/bootmem.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/termios.h>
@@ -30,6 +31,7 @@
 #include <asm/system.h>
 #include <asm/leds.h>
 #include <asm/mach/time.h>
+#include <asm/pgtable.h>
 
 static struct amba_pl010_data integrator_uart_data;
 
@@ -215,3 +217,13 @@ void cm_control(u32 mask, u32 set)
 }
 
 EXPORT_SYMBOL(cm_control);
+
+/*
+ * We need to stop things allocating the low memory; ideally we need a
+ * better implementation of GFP_DMA which does not assume that DMA-able
+ * memory starts at zero.
+ */
+void __init integrator_reserve(void)
+{
+       reserve_bootmem(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET, BOOTMEM_DEFAULT);
+}
index 227cf4d05088ec85bf870e1423b7044d0758d133..6ab5a03ab9d8b0a7f45311595b0ee1fa16474ef3 100644 (file)
@@ -48,6 +48,8 @@
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
+#include "common.h"
+
 /* 
  * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
  * is the (PA >> 12).
@@ -502,6 +504,7 @@ MACHINE_START(INTEGRATOR, "ARM-Integrator")
        .io_pg_offst    = ((0xf1600000) >> 18) & 0xfffc,
        .boot_params    = 0x00000100,
        .map_io         = ap_map_io,
+       .reserve        = integrator_reserve,
        .init_irq       = ap_init_irq,
        .timer          = &ap_timer,
        .init_machine   = ap_init,
index cde57b2b83b57a36288382ef5b57a39ae895d802..05db40e3c4f75a7fcf661718269cdcf330d7f9cc 100644 (file)
@@ -43,6 +43,8 @@
 
 #include <plat/timer-sp.h>
 
+#include "common.h"
+
 #define INTCP_PA_FLASH_BASE            0x24000000
 #define INTCP_FLASH_SIZE               SZ_32M
 
@@ -601,6 +603,7 @@ MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
        .io_pg_offst    = ((0xf1600000) >> 18) & 0xfffc,
        .boot_params    = 0x00000100,
        .map_io         = intcp_map_io,
+       .reserve        = integrator_reserve,
        .init_irq       = intcp_init_irq,
        .timer          = &cp_timer,
        .init_machine   = intcp_init,
index 5305a3993e694b77666920db5e1581a1abb503fc..39fd788ab63bc599cae672a43f123a2d245d4885 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/irq.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/bootmem.h>
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
@@ -396,6 +397,11 @@ static void __init palmt5_udc_init(void)
        }
 }
 
+static void __init palmt5_reserve(void)
+{
+       reserve_bootmem(0xa0200000, 0x1000, BOOTMEM_EXCLUSIVE);
+}
+
 static void __init palmt5_init(void)
 {
        pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
@@ -421,6 +427,7 @@ MACHINE_START(PALMT5, "Palm Tungsten|T5")
        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
        .boot_params    = 0xa0000100,
        .map_io         = pxa_map_io,
+       .reserve        = palmt5_reserve,
        .init_irq       = pxa27x_init_irq,
        .timer          = &pxa_timer,
        .init_machine   = palmt5_init
index d8b4469607a1e1794a1775238bddd8c478e99e4a..f5db4f7d7158cfc8a2f1aae320ac98d25b6ae587 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/irq.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/bootmem.h>
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
@@ -633,6 +634,12 @@ static void __init treo_lcd_power_init(void)
        treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
 }
 
+static void __init treo_reserve(void)
+{
+       reserve_bootmem(0xa0000000, 0x1000, BOOTMEM_EXCLUSIVE);
+       reserve_bootmem(0xa2000000, 0x1000, BOOTMEM_EXCLUSIVE);
+}
+
 static void __init treo_init(void)
 {
        pxa_set_ffuart_info(NULL);
@@ -668,6 +675,7 @@ MACHINE_START(TREO680, "Palm Treo 680")
        .io_pg_offst    = io_p2v(0x40000000),
        .boot_params    = 0xa0000100,
        .map_io         = pxa_map_io,
+       .reserve        = treo_reserve,
        .init_irq       = pxa27x_init_irq,
        .timer          = &pxa_timer,
        .init_machine   = treo680_init,
@@ -691,6 +699,7 @@ MACHINE_START(CENTRO, "Palm Centro 685")
        .io_pg_offst    = io_p2v(0x40000000),
        .boot_params    = 0xa0000100,
        .map_io         = pxa_map_io,
+       .reserve        = treo_reserve,
        .init_irq       = pxa27x_init_irq,
        .timer          = &pxa_timer,
        .init_machine   = centro_init,
index 779b45b3f80fdca1f6815782eef8b8dfa81b4841..2407aab4d1b803aef7a716640056f873297bafd0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/bootmem.h>
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/sysdev.h>
@@ -304,6 +305,13 @@ static void __init h1940_map_io(void)
        s3c_pm_init();
 }
 
+/* H1940 and RX3715 need to reserve this for suspend */
+static void __init h1940_reserve(void)
+{
+       reserve_bootmem(0x30003000, 0x1000, BOOTMEM_DEFAULT);
+       reserve_bootmem(0x30081000, 0x1000, BOOTMEM_DEFAULT);
+}
+
 static void __init h1940_init_irq(void)
 {
        s3c24xx_init_irq();
@@ -346,6 +354,7 @@ MACHINE_START(H1940, "IPAQ-H1940")
        .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
        .boot_params    = S3C2410_SDRAM_PA + 0x100,
        .map_io         = h1940_map_io,
+       .reserve        = h1940_reserve,
        .init_irq       = h1940_init_irq,
        .init_machine   = h1940_init,
        .timer          = &s3c24xx_timer,
index 8603b577a24b7673703db6992e2a4e3d7549e8c6..f26d5d60c13d7a6c40c8d9ae5529133c1b55d1c0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/bootmem.h>
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/init.h>
@@ -570,12 +571,20 @@ static void __init rx1950_init_machine(void)
        platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
 }
 
+/* H1940 and RX3715 need to reserve this for suspend */
+static void __init rx1950_reserve(void)
+{
+       reserve_bootmem(0x30003000, 0x1000, BOOTMEM_DEFAULT);
+       reserve_bootmem(0x30081000, 0x1000, BOOTMEM_DEFAULT);
+}
+
 MACHINE_START(RX1950, "HP iPAQ RX1950")
     /* Maintainers: Vasily Khoruzhick */
     .phys_io = S3C2410_PA_UART,
        .io_pg_offst = (((u32) S3C24XX_VA_UART) >> 18) & 0xfffc,
        .boot_params = S3C2410_SDRAM_PA + 0x100,
        .map_io = rx1950_map_io,
+       .reserve        = rx1950_reserve,
        .init_irq = s3c24xx_init_irq,
        .init_machine = rx1950_init_machine,
        .timer = &s3c24xx_timer,
index d2946de3f3659d3e2588cc980a727973b9716062..6ebdb7bcf0856939669e3639e37c12b90c0c23cf 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/bootmem.h>
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/tty.h>
@@ -191,6 +192,13 @@ static void __init rx3715_map_io(void)
        s3c24xx_init_uarts(rx3715_uartcfgs, ARRAY_SIZE(rx3715_uartcfgs));
 }
 
+/* H1940 and RX3715 need to reserve this for suspend */
+static void __init rx3715_reserve(void)
+{
+       reserve_bootmem(0x30003000, 0x1000, BOOTMEM_DEFAULT);
+       reserve_bootmem(0x30081000, 0x1000, BOOTMEM_DEFAULT);
+}
+
 static void __init rx3715_init_irq(void)
 {
        s3c24xx_init_irq();
@@ -214,6 +222,7 @@ MACHINE_START(RX3715, "IPAQ-RX3715")
        .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
        .boot_params    = S3C2410_SDRAM_PA + 0x100,
        .map_io         = rx3715_map_io,
+       .reserve        = rx3715_reserve,
        .init_irq       = rx3715_init_irq,
        .init_machine   = rx3715_init_machine,
        .timer          = &s3c24xx_timer,
index d2a0b8847a18061e36576f5dec89bc567745d473..178dca4f955581fa1519b9be11d181ab811eeee5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
+#include <linux/bootmem.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+static void __init u300_reserve(void)
+{
+       /*
+        * U300 - This platform family can share physical memory
+        * between two ARM cpus, one running Linux and the other
+        * running another OS.
+        */
+#ifdef CONFIG_MACH_U300_SINGLE_RAM
+#if ((CONFIG_MACH_U300_ACCESS_MEM_SIZE & 1) == 1) && \
+       CONFIG_MACH_U300_2MB_ALIGNMENT_FIX
+        reserve_bootmem(PHYS_OFFSET, 0x00100000, BOOTMEM_DEFAULT);
+#endif
+#endif
+}
+
 static void __init u300_init_machine(void)
 {
        u300_init_devices();
@@ -49,6 +65,7 @@ MACHINE_START(U300, MACH_U300_STRING)
        .io_pg_offst    = ((U300_AHB_PER_VIRT_BASE) >> 18) & 0xfffc,
        .boot_params    = BOOT_PARAMS_OFFSET,
        .map_io         = u300_map_io,
+       .reserve        = u300_reserve,
        .init_irq       = u300_init_irq,
        .timer          = &u300_timer,
        .init_machine   = u300_init_machine,
index 4d2720888c50f86aa42992529df1610f53d70a0e..1a227eea64bd9b735aad2e8a4758c51184d78d71 100644 (file)
@@ -358,7 +358,7 @@ static void arm_memory_present(struct meminfo *mi)
 }
 #endif
 
-void __init bootmem_init(void)
+void __init bootmem_init(struct machine_desc *mdesc)
 {
        struct meminfo *mi = &meminfo;
        unsigned long min, max_low, max_high;
@@ -380,6 +380,9 @@ void __init bootmem_init(void)
         */
        reserve_special_regions();
 
+       if (mdesc->reserve)
+               mdesc->reserve();
+
        /*
         * If the initrd is present, reserve its memory.
         */
index 7b19c90ab295e1baaf0ce44c723185802c4d2cfb..afafe4fc54318fcdc3ecaf950d07fcd2ed052d08 100644 (file)
@@ -28,5 +28,6 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page
 
 #endif
 
-void __init bootmem_init(void);
+struct machine_desc;
+void __init bootmem_init(struct machine_desc *);
 void reserve_special_regions(void);
index ddb1bee6de7331cc1617d744510c955f0caa9c4b..1676d017a93a7330271412d5aa0d05377d5a9be8 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/sort.h>
 
 #include <asm/cputype.h>
-#include <asm/mach-types.h>
 #include <asm/sections.h>
 #include <asm/cachetype.h>
 #include <asm/setup.h>
@@ -831,8 +830,6 @@ static inline void prepare_page_table(void)
  */
 void __init reserve_special_regions(void)
 {
-       unsigned long res_size = 0;
-
        /*
         * Register the kernel text and data with bootmem.
         * Note that this can only be in node 0.
@@ -850,68 +847,14 @@ void __init reserve_special_regions(void)
        reserve_bootmem(__pa(swapper_pg_dir),
                        PTRS_PER_PGD * sizeof(pgd_t), BOOTMEM_DEFAULT);
 
-       /*
-        * Hmm... This should go elsewhere, but we really really need to
-        * stop things allocating the low memory; ideally we need a better
-        * implementation of GFP_DMA which does not assume that DMA-able
-        * memory starts at zero.
-        */
-       if (machine_is_integrator() || machine_is_cintegrator())
-               res_size = __pa(swapper_pg_dir) - PHYS_OFFSET;
-
-       /*
-        * These should likewise go elsewhere.  They pre-reserve the
-        * screen memory region at the start of main system memory.
-        */
-       if (machine_is_edb7211())
-               res_size = 0x00020000;
-       if (machine_is_p720t())
-               res_size = 0x00014000;
-
-       /* H1940, RX3715 and RX1950 need to reserve this for suspend */
-
-       if (machine_is_h1940() || machine_is_rx3715()
-               || machine_is_rx1950()) {
-               reserve_bootmem(0x30003000, 0x1000, BOOTMEM_DEFAULT);
-               reserve_bootmem(0x30081000, 0x1000, BOOTMEM_DEFAULT);
-       }
-
-       if (machine_is_palmld() || machine_is_palmtx()) {
-               reserve_bootmem(0xa0000000, 0x1000, BOOTMEM_EXCLUSIVE);
-               reserve_bootmem(0xa0200000, 0x1000, BOOTMEM_EXCLUSIVE);
-       }
-
-       if (machine_is_treo680() || machine_is_centro()) {
-               reserve_bootmem(0xa0000000, 0x1000, BOOTMEM_EXCLUSIVE);
-               reserve_bootmem(0xa2000000, 0x1000, BOOTMEM_EXCLUSIVE);
-       }
-
-       if (machine_is_palmt5())
-               reserve_bootmem(0xa0200000, 0x1000, BOOTMEM_EXCLUSIVE);
-
-       /*
-        * U300 - This platform family can share physical memory
-        * between two ARM cpus, one running Linux and the other
-        * running another OS.
-        */
-       if (machine_is_u300()) {
-#ifdef CONFIG_MACH_U300_SINGLE_RAM
-#if ((CONFIG_MACH_U300_ACCESS_MEM_SIZE & 1) == 1) &&   \
-       CONFIG_MACH_U300_2MB_ALIGNMENT_FIX
-               res_size = 0x00100000;
-#endif
-#endif
-       }
-
 #ifdef CONFIG_SA1111
        /*
         * Because of the SA1111 DMA bug, we want to preserve our
         * precious DMA-able memory...
         */
-       res_size = __pa(swapper_pg_dir) - PHYS_OFFSET;
+       reserve_bootmem(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET,
+                       BOOTMEM_DEFAULT);
 #endif
-       if (res_size)
-               reserve_bootmem(PHYS_OFFSET, res_size, BOOTMEM_DEFAULT);
 }
 
 /*
@@ -1056,7 +999,7 @@ void __init paging_init(struct machine_desc *mdesc)
        sanity_check_meminfo();
        prepare_page_table();
        map_lowmem();
-       bootmem_init();
+       bootmem_init(mdesc);
        devicemaps_init(mdesc);
        kmap_init();
 
index 25376d480b8e712f5df6a2de507e7e5955738331..ed58ddbbc5b30cd4afaa990c98be33101509ba20 100644 (file)
@@ -46,7 +46,7 @@ void __init reserve_special_regions(void)
  */
 void __init paging_init(struct machine_desc *mdesc)
 {
-       bootmem_init();
+       bootmem_init(mdesc);
 }
 
 /*