From be370302742ff9948f2a42b15cb2ba174d97b930 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 7 May 2010 17:40:33 +0100 Subject: ARM: Remove DISCONTIGMEM support Everything should now be using sparsemem rather than discontigmem, so remove the code supporting discontigmem from ARM. Signed-off-by: Russell King --- arch/arm/mm/mm.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/arm/mm/mm.h') diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index 815d08eecbb0..7b19c90ab295 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h @@ -28,7 +28,5 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page #endif -struct pglist_data; - void __init bootmem_init(void); -void reserve_node_zero(struct pglist_data *pgdat); +void reserve_special_regions(void); -- cgit v1.2.3-59-g8ed1b From 98c672cf1fa2a56f6f43e3f48b1208b83845582c Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 22 May 2010 18:18:57 +0100 Subject: ARM: Move platform memory reservations out of generic code Move the platform specific bootmem memory reservations out of arch/arm/mm/mmu.c into their respective platform files. Signed-off-by: Russell King --- arch/arm/include/asm/mach/arch.h | 1 + arch/arm/mach-clps711x/edb7211-arch.c | 8 ++++ arch/arm/mach-integrator/common.h | 1 + arch/arm/mach-integrator/core.c | 12 ++++++ arch/arm/mach-integrator/integrator_ap.c | 3 ++ arch/arm/mach-integrator/integrator_cp.c | 3 ++ arch/arm/mach-pxa/palmt5.c | 7 ++++ arch/arm/mach-pxa/palmtreo.c | 9 +++++ arch/arm/mach-s3c2410/mach-h1940.c | 9 +++++ arch/arm/mach-s3c2440/mach-rx1950.c | 9 +++++ arch/arm/mach-s3c2440/mach-rx3715.c | 9 +++++ arch/arm/mach-u300/u300.c | 17 +++++++++ arch/arm/mm/init.c | 5 ++- arch/arm/mm/mm.h | 3 +- arch/arm/mm/mmu.c | 63 ++------------------------------ arch/arm/mm/nommu.c | 2 +- 16 files changed, 98 insertions(+), 63 deletions(-) create mode 100644 arch/arm/mach-integrator/common.h (limited to 'arch/arm/mm/mm.h') diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index c59842dc7cb8..d425f2b6efeb 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -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 */ diff --git a/arch/arm/mach-clps711x/edb7211-arch.c b/arch/arm/mach-clps711x/edb7211-arch.c index 41a4425617c1..077f4051a06a 100644 --- a/arch/arm/mach-clps711x/edb7211-arch.c +++ b/arch/arm/mach-clps711x/edb7211-arch.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include @@ -29,6 +30,12 @@ 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 index 000000000000..5f96e1518aa9 --- /dev/null +++ b/arch/arm/mach-integrator/common.h @@ -0,0 +1 @@ +void integrator_reserve(void); diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index b02cfc06e0ae..f815a1863f70 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include 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); +} diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 227cf4d05088..6ab5a03ab9d8 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -48,6 +48,8 @@ #include #include +#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, diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index cde57b2b83b5..05db40e3c4f7 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -43,6 +43,8 @@ #include +#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, diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c index 5305a3993e69..39fd788ab63b 100644 --- a/arch/arm/mach-pxa/palmt5.c +++ b/arch/arm/mach-pxa/palmt5.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c index d8b4469607a1..f5db4f7d7158 100644 --- a/arch/arm/mach-pxa/palmtreo.c +++ b/arch/arm/mach-pxa/palmtreo.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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, diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 779b45b3f80f..2407aab4d1b8 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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, diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c index 8603b577a24b..f26d5d60c13d 100644 --- a/arch/arm/mach-s3c2440/mach-rx1950.c +++ b/arch/arm/mach-s3c2440/mach-rx1950.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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, diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c index d2946de3f365..6ebdb7bcf085 100644 --- a/arch/arm/mach-s3c2440/mach-rx3715.c +++ b/arch/arm/mach-s3c2440/mach-rx3715.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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, diff --git a/arch/arm/mach-u300/u300.c b/arch/arm/mach-u300/u300.c index d2a0b8847a18..178dca4f9555 100644 --- a/arch/arm/mach-u300/u300.c +++ b/arch/arm/mach-u300/u300.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,21 @@ #include #include +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, diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 4d2720888c50..1a227eea64bd 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -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. */ diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index 7b19c90ab295..afafe4fc5431 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h @@ -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); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index ddb1bee6de73..1676d017a93a 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -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(); diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 25376d480b8e..ed58ddbbc5b3 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -46,7 +46,7 @@ void __init reserve_special_regions(void) */ void __init paging_init(struct machine_desc *mdesc) { - bootmem_init(); + bootmem_init(mdesc); } /* -- cgit v1.2.3-59-g8ed1b From 2778f62056ada442414392d7ccd41188bb631619 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 9 Jul 2010 16:27:52 +0100 Subject: ARM: initial LMB trial Acked-by: Tony Lindgren Signed-off-by: Russell King --- arch/arm/Kconfig | 1 + arch/arm/include/asm/memblock.h | 15 ++++ arch/arm/kernel/setup.c | 3 + arch/arm/mm/init.c | 164 +++++++++++----------------------------- arch/arm/mm/mm.h | 2 +- arch/arm/mm/mmu.c | 34 ++++----- arch/arm/mm/nommu.c | 19 +---- 7 files changed, 83 insertions(+), 155 deletions(-) create mode 100644 arch/arm/include/asm/memblock.h (limited to 'arch/arm/mm/mm.h') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 410edd65f117..36c8b5e12590 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -10,6 +10,7 @@ config ARM default y select HAVE_AOUT select HAVE_IDE + select HAVE_MEMBLOCK select RTC_LIB select SYS_SUPPORTS_APM_EMULATION select GENERIC_ATOMIC64 if (!CPU_32v6K) diff --git a/arch/arm/include/asm/memblock.h b/arch/arm/include/asm/memblock.h new file mode 100644 index 000000000000..3a1d58096f44 --- /dev/null +++ b/arch/arm/include/asm/memblock.h @@ -0,0 +1,15 @@ +#ifndef _ASM_ARM_MEMBLOCK_H +#define _ASM_ARM_MEMBLOCK_H + +#ifdef CONFIG_MMU +extern phys_addr_t lowmem_end_addr; +#define MEMBLOCK_REAL_LIMIT lowmem_end_addr +#else +#define MEMBLOCK_REAL_LIMIT 0 +#endif + +struct meminfo; + +extern void arm_memblock_init(struct meminfo *); + +#endif diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 387d2e9cb51f..dfd293477751 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -715,6 +716,8 @@ void __init setup_arch(char **cmdline_p) parse_early_param(); + arm_memblock_init(&meminfo); + paging_init(mdesc); request_standard_resources(&meminfo, mdesc); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 1a227eea64bd..4877e06308b7 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -146,95 +147,21 @@ static void __init find_limits(struct meminfo *mi, } } -/* - * FIXME: We really want to avoid allocating the bootmap bitmap - * over the top of the initrd. Hopefully, this is located towards - * the start of a bank, so if we allocate the bootmap bitmap at - * the end, we won't clash. - */ -static unsigned int __init -find_bootmap_pfn(struct meminfo *mi, unsigned int bootmap_pages) -{ - unsigned int start_pfn, i, bootmap_pfn; - - start_pfn = PAGE_ALIGN(__pa(_end)) >> PAGE_SHIFT; - bootmap_pfn = 0; - - for_each_bank(i, mi) { - struct membank *bank = &mi->bank[i]; - unsigned int start, end; - - start = bank_pfn_start(bank); - end = bank_pfn_end(bank); - - if (end < start_pfn) - continue; - - if (start < start_pfn) - start = start_pfn; - - if (end <= start) - continue; - - if (end - start >= bootmap_pages) { - bootmap_pfn = start; - break; - } - } - - if (bootmap_pfn == 0) - BUG(); - - return bootmap_pfn; -} - -static int __init check_initrd(struct meminfo *mi) -{ - int initrd = -2; -#ifdef CONFIG_BLK_DEV_INITRD - unsigned long end = phys_initrd_start + phys_initrd_size; - - /* - * Make sure that the initrd is within a valid area of - * memory. - */ - if (phys_initrd_size) { - unsigned int i; - - initrd = -1; - - for (i = 0; i < mi->nr_banks; i++) { - struct membank *bank = &mi->bank[i]; - if (bank_phys_start(bank) <= phys_initrd_start && - end <= bank_phys_end(bank)) - initrd = 0; - } - } - - if (initrd == -1) { - printk(KERN_ERR "INITRD: 0x%08lx+0x%08lx extends beyond " - "physical memory - disabling initrd\n", - phys_initrd_start, phys_initrd_size); - phys_initrd_start = phys_initrd_size = 0; - } -#endif - - return initrd; -} - static void __init arm_bootmem_init(struct meminfo *mi, unsigned long start_pfn, unsigned long end_pfn) { - unsigned long boot_pfn; unsigned int boot_pages; + phys_addr_t bitmap; pg_data_t *pgdat; int i; /* - * Allocate the bootmem bitmap page. + * Allocate the bootmem bitmap page. This must be in a region + * of memory which has already been mapped. */ boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn); - boot_pfn = find_bootmap_pfn(mi, boot_pages); + bitmap = memblock_alloc_base(boot_pages << PAGE_SHIFT, L1_CACHE_BYTES, + __pfn_to_phys(end_pfn)); /* * Initialise the bootmem allocator, handing the @@ -242,7 +169,7 @@ static void __init arm_bootmem_init(struct meminfo *mi, */ node_set_online(0); pgdat = NODE_DATA(0); - init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn); + init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn); for_each_bank(i, mi) { struct membank *bank = &mi->bank[i]; @@ -251,30 +178,16 @@ static void __init arm_bootmem_init(struct meminfo *mi, } /* - * Reserve the bootmem bitmap. + * Reserve the memblock reserved regions in bootmem. */ - reserve_bootmem(boot_pfn << PAGE_SHIFT, - boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT); -} - -static void __init bootmem_reserve_initrd(void) -{ -#ifdef CONFIG_BLK_DEV_INITRD - int res; - - res = reserve_bootmem(phys_initrd_start, - phys_initrd_size, BOOTMEM_EXCLUSIVE); - - if (res == 0) { - initrd_start = __phys_to_virt(phys_initrd_start); - initrd_end = initrd_start + phys_initrd_size; - } else { - printk(KERN_ERR - "INITRD: 0x%08lx+0x%08lx overlaps in-use " - "memory region - disabling initrd\n", - phys_initrd_start, phys_initrd_size); + for (i = 0; i < memblock.reserved.cnt; i++) { + phys_addr_t start = memblock_start_pfn(&memblock.reserved, i); + if (start >= start_pfn && + memblock_end_pfn(&memblock.reserved, i) <= end_pfn) + reserve_bootmem_node(pgdat, __pfn_to_phys(start), + memblock_size_bytes(&memblock.reserved, i), + BOOTMEM_DEFAULT); } -#endif } static void __init arm_bootmem_free(struct meminfo *mi) @@ -358,16 +271,40 @@ static void arm_memory_present(struct meminfo *mi) } #endif +void __init arm_memblock_init(struct meminfo *mi) +{ + int i; + + memblock_init(); + for (i = 0; i < mi->nr_banks; i++) + memblock_add(mi->bank[i].start, mi->bank[i].size); + + /* Register the kernel text, kernel data and initrd with memblock. */ +#ifdef CONFIG_XIP_KERNEL + memblock_reserve(__pa(_data), _end - _data); +#else + memblock_reserve(__pa(_stext), _end - _stext); +#endif +#ifdef CONFIG_BLK_DEV_INITRD + if (phys_initrd_size) { + memblock_reserve(phys_initrd_start, phys_initrd_size); + + /* Now convert initrd to virtual addresses */ + initrd_start = __phys_to_virt(phys_initrd_start); + initrd_end = initrd_start + phys_initrd_size; + } +#endif + + arm_mm_memblock_reserve(); + + memblock_analyze(); + memblock_dump_all(); +} + void __init bootmem_init(struct machine_desc *mdesc) { struct meminfo *mi = &meminfo; unsigned long min, max_low, max_high; - int initrd; - - /* - * Locate the ramdisk image, if any. - */ - initrd = check_initrd(mi); max_low = max_high = 0; @@ -375,20 +312,9 @@ void __init bootmem_init(struct machine_desc *mdesc) arm_bootmem_init(mi, min, max_low); - /* - * Reserve any special regions. - */ - reserve_special_regions(); - if (mdesc->reserve) mdesc->reserve(); - /* - * If the initrd is present, reserve its memory. - */ - if (initrd == 0) - bootmem_reserve_initrd(); - /* * Sparsemem tries to allocate bootmem in memory_present(), * so must be done after the fixed reservations diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index afafe4fc5431..fcfffae69b49 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h @@ -30,4 +30,4 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page struct machine_desc; void __init bootmem_init(struct machine_desc *); -void reserve_special_regions(void); +void arm_mm_memblock_reserve(void); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 05dbb956175b..833a6c3f70c0 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -489,7 +489,9 @@ static void __init build_mem_type_table(void) static void __init *early_alloc(unsigned long sz) { - return alloc_bootmem_low_pages(sz); + void *ptr = __va(memblock_alloc(sz, sz)); + memset(ptr, 0, sz); + return ptr; } static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot) @@ -705,10 +707,14 @@ static int __init early_vmalloc(char *arg) } early_param("vmalloc", early_vmalloc); +phys_addr_t lowmem_end_addr; + static void __init sanity_check_meminfo(void) { int i, j, highmem = 0; + lowmem_end_addr = __pa(vmalloc_min - 1) + 1; + for (i = 0, j = 0; i < meminfo.nr_banks; i++) { struct membank *bank = &meminfo.bank[j]; *bank = meminfo.bank[i]; @@ -834,34 +840,22 @@ static inline void prepare_page_table(void) } /* - * Reserve the various regions + * Reserve the special regions of memory */ -void __init reserve_special_regions(void) +void __init arm_mm_memblock_reserve(void) { - /* - * Register the kernel text and data with bootmem. - * Note that this can only be in node 0. - */ -#ifdef CONFIG_XIP_KERNEL - reserve_bootmem(__pa(_data), _end - _data, BOOTMEM_DEFAULT); -#else - reserve_bootmem(__pa(_stext), _end - _stext, BOOTMEM_DEFAULT); -#endif - /* * Reserve the page tables. These are already in use, * and can only be in node 0. */ - reserve_bootmem(__pa(swapper_pg_dir), - PTRS_PER_PGD * sizeof(pgd_t), BOOTMEM_DEFAULT); + memblock_reserve(__pa(swapper_pg_dir), PTRS_PER_PGD * sizeof(pgd_t)); #ifdef CONFIG_SA1111 /* * Because of the SA1111 DMA bug, we want to preserve our * precious DMA-able memory... */ - reserve_bootmem(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET, - BOOTMEM_DEFAULT); + memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET); #endif } @@ -1004,7 +998,6 @@ void __init paging_init(struct machine_desc *mdesc) sanity_check_meminfo(); prepare_page_table(); map_lowmem(); - bootmem_init(mdesc); devicemaps_init(mdesc); kmap_init(); @@ -1012,6 +1005,9 @@ void __init paging_init(struct machine_desc *mdesc) /* allocate the zero page. */ zero_page = early_alloc(PAGE_SIZE); + + bootmem_init(mdesc); + empty_zero_page = virt_to_page(zero_page); __flush_dcache_page(NULL, empty_zero_page); } diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index ed58ddbbc5b3..40e38fcccc7a 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include #include #include @@ -17,27 +17,14 @@ #include "mm.h" -/* - * Reserve the various regions - */ -void __init reserve_special_regions(void) +void __init arm_mm_memblock_reserve(void) { - /* - * Register the kernel text and data with bootmem. - * Note that this can only be in node 0. - */ -#ifdef CONFIG_XIP_KERNEL - reserve_bootmem(__pa(_data), _end - _data, BOOTMEM_DEFAULT); -#else - reserve_bootmem(__pa(_stext), _end - _stext, BOOTMEM_DEFAULT); -#endif - /* * Register the exception vector page. * some architectures which the DRAM is the exception vector to trap, * alloc_page breaks with error, although it is not NULL, but "0." */ - reserve_bootmem(CONFIG_VECTORS_BASE, PAGE_SIZE, BOOTMEM_DEFAULT); + memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE); } /* -- cgit v1.2.3-59-g8ed1b From 8d717a52d1b0959128be5134dd12608e8e4f2115 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 22 May 2010 19:47:18 +0100 Subject: ARM: Convert platform reservations to use LMB rather than bootmem Signed-off-by: Russell King --- arch/arm/include/asm/memblock.h | 3 ++- arch/arm/kernel/setup.c | 2 +- arch/arm/mach-clps711x/edb7211-arch.c | 4 ++-- arch/arm/mach-integrator/core.c | 4 ++-- arch/arm/mach-pxa/palmt5.c | 4 ++-- arch/arm/mach-pxa/palmtreo.c | 6 +++--- arch/arm/mach-s3c2410/mach-h1940.c | 6 +++--- arch/arm/mach-s3c2440/mach-rx1950.c | 6 +++--- arch/arm/mach-s3c2440/mach-rx3715.c | 6 +++--- arch/arm/mach-u300/u300.c | 4 ++-- arch/arm/mm/init.c | 11 ++++++----- arch/arm/mm/mm.h | 3 +-- arch/arm/mm/mmu.c | 2 +- arch/arm/mm/nommu.c | 2 +- 14 files changed, 32 insertions(+), 31 deletions(-) (limited to 'arch/arm/mm/mm.h') diff --git a/arch/arm/include/asm/memblock.h b/arch/arm/include/asm/memblock.h index 3a1d58096f44..fdbc43b2e6c0 100644 --- a/arch/arm/include/asm/memblock.h +++ b/arch/arm/include/asm/memblock.h @@ -9,7 +9,8 @@ extern phys_addr_t lowmem_end_addr; #endif struct meminfo; +struct machine_desc; -extern void arm_memblock_init(struct meminfo *); +extern void arm_memblock_init(struct meminfo *, struct machine_desc *); #endif diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index dfd293477751..31b2643bb0c6 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -716,7 +716,7 @@ void __init setup_arch(char **cmdline_p) parse_early_param(); - arm_memblock_init(&meminfo); + arm_memblock_init(&meminfo, mdesc); paging_init(mdesc); request_standard_resources(&meminfo, mdesc); diff --git a/arch/arm/mach-clps711x/edb7211-arch.c b/arch/arm/mach-clps711x/edb7211-arch.c index 077f4051a06a..4a7a2322979a 100644 --- a/arch/arm/mach-clps711x/edb7211-arch.c +++ b/arch/arm/mach-clps711x/edb7211-arch.c @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -#include +#include #include #include @@ -33,7 +33,7 @@ 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); + memblock_reserve(PHYS_OFFSET, 0x00020000); } static void __init diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index f815a1863f70..bcb26f01b26c 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -225,5 +225,5 @@ EXPORT_SYMBOL(cm_control); */ void __init integrator_reserve(void) { - reserve_bootmem(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET, BOOTMEM_DEFAULT); + memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET); } diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c index 39fd788ab63b..5e92d84fe50d 100644 --- a/arch/arm/mach-pxa/palmt5.c +++ b/arch/arm/mach-pxa/palmt5.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -399,7 +399,7 @@ static void __init palmt5_udc_init(void) static void __init palmt5_reserve(void) { - reserve_bootmem(0xa0200000, 0x1000, BOOTMEM_EXCLUSIVE); + memblock_reserve(0xa0200000, 0x1000); } static void __init palmt5_init(void) diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c index f5db4f7d7158..3d0c9cc2a406 100644 --- a/arch/arm/mach-pxa/palmtreo.c +++ b/arch/arm/mach-pxa/palmtreo.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -636,8 +636,8 @@ static void __init treo_lcd_power_init(void) static void __init treo_reserve(void) { - reserve_bootmem(0xa0000000, 0x1000, BOOTMEM_EXCLUSIVE); - reserve_bootmem(0xa2000000, 0x1000, BOOTMEM_EXCLUSIVE); + memblock_reserve(0xa0000000, 0x1000); + memblock_reserve(0xa2000000, 0x1000); } static void __init treo_init(void) diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 2407aab4d1b8..3ba3bab139d0 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -308,8 +308,8 @@ static void __init h1940_map_io(void) /* 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); + memblock_reserve(0x30003000, 0x1000); + memblock_reserve(0x30081000, 0x1000); } static void __init h1940_init_irq(void) diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c index f26d5d60c13d..142d1f921176 100644 --- a/arch/arm/mach-s3c2440/mach-rx1950.c +++ b/arch/arm/mach-s3c2440/mach-rx1950.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -574,8 +574,8 @@ static void __init rx1950_init_machine(void) /* 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); + memblock_reserve(0x30003000, 0x1000); + memblock_reserve(0x30081000, 0x1000); } MACHINE_START(RX1950, "HP iPAQ RX1950") diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c index 6ebdb7bcf085..6bb44f75a9ce 100644 --- a/arch/arm/mach-s3c2440/mach-rx3715.c +++ b/arch/arm/mach-s3c2440/mach-rx3715.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -195,8 +195,8 @@ static void __init rx3715_map_io(void) /* 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); + memblock_reserve(0x30003000, 0x1000); + memblock_reserve(0x30081000, 0x1000); } static void __init rx3715_init_irq(void) diff --git a/arch/arm/mach-u300/u300.c b/arch/arm/mach-u300/u300.c index 178dca4f9555..bfcda9820888 100644 --- a/arch/arm/mach-u300/u300.c +++ b/arch/arm/mach-u300/u300.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ static void __init u300_reserve(void) #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); + memblock_reserve(PHYS_OFFSET, 0x00100000); #endif #endif } diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 4877e06308b7..99d6bc9b89bb 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -271,7 +271,7 @@ static void arm_memory_present(struct meminfo *mi) } #endif -void __init arm_memblock_init(struct meminfo *mi) +void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) { int i; @@ -297,11 +297,15 @@ void __init arm_memblock_init(struct meminfo *mi) arm_mm_memblock_reserve(); + /* reserve any platform specific memblock areas */ + if (mdesc->reserve) + mdesc->reserve(); + memblock_analyze(); memblock_dump_all(); } -void __init bootmem_init(struct machine_desc *mdesc) +void __init bootmem_init(void) { struct meminfo *mi = &meminfo; unsigned long min, max_low, max_high; @@ -312,9 +316,6 @@ void __init bootmem_init(struct machine_desc *mdesc) arm_bootmem_init(mi, min, max_low); - if (mdesc->reserve) - mdesc->reserve(); - /* * Sparsemem tries to allocate bootmem in memory_present(), * so must be done after the fixed reservations diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index fcfffae69b49..6630620380a4 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h @@ -28,6 +28,5 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page #endif -struct machine_desc; -void __init bootmem_init(struct machine_desc *); +void __init bootmem_init(void); void arm_mm_memblock_reserve(void); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 833a6c3f70c0..d5541adc3520 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1006,7 +1006,7 @@ void __init paging_init(struct machine_desc *mdesc) /* allocate the zero page. */ zero_page = early_alloc(PAGE_SIZE); - bootmem_init(mdesc); + bootmem_init(); empty_zero_page = virt_to_page(zero_page); __flush_dcache_page(NULL, empty_zero_page); diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 40e38fcccc7a..687d02319a41 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -33,7 +33,7 @@ void __init arm_mm_memblock_reserve(void) */ void __init paging_init(struct machine_desc *mdesc) { - bootmem_init(mdesc); + bootmem_init(); } /* -- cgit v1.2.3-59-g8ed1b