Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8025/1: Get rid of meminfo

memblock is now fully integrated into the kernel and is the prefered
method for tracking memory. Rather than reinvent the wheel with
meminfo, migrate to using memblock directly instead of meminfo as
an intermediate.

Acked-by: Jason Cooper <jason@lakedaemon.net>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Laura Abbott and committed by
Russell King
1c2f87c2 1c8c3cf0

+178 -332
-5
arch/arm/Kconfig
··· 1101 1101 1102 1102 source arch/arm/mm/Kconfig 1103 1103 1104 - config ARM_NR_BANKS 1105 - int 1106 - default 16 if ARCH_EP93XX 1107 - default 8 1108 - 1109 1104 config IWMMXT 1110 1105 bool "Enable iWMMXt support" if !CPU_PJ4 1111 1106 depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4
+2
arch/arm/boot/compressed/atags_to_fdt.c
··· 7 7 #define do_extend_cmdline 0 8 8 #endif 9 9 10 + #define NR_BANKS 16 11 + 10 12 static int node_offset(void *fdt, const char *node_path) 11 13 { 12 14 int offset = fdt_path_offset(fdt, node_path);
+1 -3
arch/arm/include/asm/mach/arch.h
··· 14 14 #include <linux/reboot.h> 15 15 16 16 struct tag; 17 - struct meminfo; 18 17 struct pt_regs; 19 18 struct smp_operations; 20 19 #ifdef CONFIG_SMP ··· 46 47 enum reboot_mode reboot_mode; /* default restart mode */ 47 48 struct smp_operations *smp; /* SMP operations */ 48 49 bool (*smp_init)(void); 49 - void (*fixup)(struct tag *, char **, 50 - struct meminfo *); 50 + void (*fixup)(struct tag *, char **); 51 51 void (*init_meminfo)(void); 52 52 void (*reserve)(void);/* reserve mem blocks */ 53 53 void (*map_io)(void);/* IO mapping function */
+1 -2
arch/arm/include/asm/memblock.h
··· 1 1 #ifndef _ASM_ARM_MEMBLOCK_H 2 2 #define _ASM_ARM_MEMBLOCK_H 3 3 4 - struct meminfo; 5 4 struct machine_desc; 6 5 7 - void arm_memblock_init(struct meminfo *, const struct machine_desc *); 6 + void arm_memblock_init(const struct machine_desc *); 8 7 phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align); 9 8 10 9 #endif
-28
arch/arm/include/asm/setup.h
··· 21 21 #define __tagtable(tag, fn) \ 22 22 static const struct tagtable __tagtable_##fn __tag = { tag, fn } 23 23 24 - /* 25 - * Memory map description 26 - */ 27 - #define NR_BANKS CONFIG_ARM_NR_BANKS 28 - 29 - struct membank { 30 - phys_addr_t start; 31 - phys_addr_t size; 32 - unsigned int highmem; 33 - }; 34 - 35 - struct meminfo { 36 - int nr_banks; 37 - struct membank bank[NR_BANKS]; 38 - }; 39 - 40 - extern struct meminfo meminfo; 41 - 42 - #define for_each_bank(iter,mi) \ 43 - for (iter = 0; iter < (mi)->nr_banks; iter++) 44 - 45 - #define bank_pfn_start(bank) __phys_to_pfn((bank)->start) 46 - #define bank_pfn_end(bank) __phys_to_pfn((bank)->start + (bank)->size) 47 - #define bank_pfn_size(bank) ((bank)->size >> PAGE_SHIFT) 48 - #define bank_phys_start(bank) (bank)->start 49 - #define bank_phys_end(bank) ((bank)->start + (bank)->size) 50 - #define bank_phys_size(bank) (bank)->size 51 - 52 24 extern int arm_add_memory(u64 start, u64 size); 53 25 extern void early_print(const char *str, ...); 54 26 extern void dump_machine_table(void);
+3 -2
arch/arm/kernel/atags_parse.c
··· 22 22 #include <linux/fs.h> 23 23 #include <linux/root_dev.h> 24 24 #include <linux/screen_info.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/setup.h> 27 28 #include <asm/system_info.h> ··· 223 222 } 224 223 225 224 if (mdesc->fixup) 226 - mdesc->fixup(tags, &from, &meminfo); 225 + mdesc->fixup(tags, &from); 227 226 228 227 if (tags->hdr.tag == ATAG_CORE) { 229 - if (meminfo.nr_banks != 0) 228 + if (memblock_phys_mem_size()) 230 229 squash_mem_tags(tags); 231 230 save_atags(tags); 232 231 parse_tags(tags);
-5
arch/arm/kernel/devtree.c
··· 27 27 #include <asm/mach/arch.h> 28 28 #include <asm/mach-types.h> 29 29 30 - void __init early_init_dt_add_memory_arch(u64 base, u64 size) 31 - { 32 - arm_add_memory(base, size); 33 - } 34 - 35 30 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 36 31 { 37 32 return memblock_virt_alloc(size, align);
+8 -22
arch/arm/kernel/setup.c
··· 628 628 629 629 int __init arm_add_memory(u64 start, u64 size) 630 630 { 631 - struct membank *bank = &meminfo.bank[meminfo.nr_banks]; 632 631 u64 aligned_start; 633 - 634 - if (meminfo.nr_banks >= NR_BANKS) { 635 - pr_crit("NR_BANKS too low, ignoring memory at 0x%08llx\n", 636 - (long long)start); 637 - return -EINVAL; 638 - } 639 632 640 633 /* 641 634 * Ensure that start/size are aligned to a page boundary. ··· 670 677 aligned_start = PHYS_OFFSET; 671 678 } 672 679 673 - bank->start = aligned_start; 674 - bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1); 680 + start = aligned_start; 681 + size = size & ~(phys_addr_t)(PAGE_SIZE - 1); 675 682 676 683 /* 677 684 * Check whether this memory region has non-zero size or 678 685 * invalid node number. 679 686 */ 680 - if (bank->size == 0) 687 + if (size == 0) 681 688 return -EINVAL; 682 689 683 - meminfo.nr_banks++; 690 + memblock_add(start, size); 684 691 return 0; 685 692 } 686 693 ··· 688 695 * Pick out the memory size. We look for mem=size@start, 689 696 * where start and size are "size[KkMm]" 690 697 */ 698 + 691 699 static int __init early_mem(char *p) 692 700 { 693 701 static int usermem __initdata = 0; ··· 703 709 */ 704 710 if (usermem == 0) { 705 711 usermem = 1; 706 - meminfo.nr_banks = 0; 712 + memblock_remove(memblock_start_of_DRAM(), 713 + memblock_end_of_DRAM() - memblock_start_of_DRAM()); 707 714 } 708 715 709 716 start = PHYS_OFFSET; ··· 849 854 static inline void reserve_crashkernel(void) {} 850 855 #endif /* CONFIG_KEXEC */ 851 856 852 - static int __init meminfo_cmp(const void *_a, const void *_b) 853 - { 854 - const struct membank *a = _a, *b = _b; 855 - long cmp = bank_pfn_start(a) - bank_pfn_start(b); 856 - return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; 857 - } 858 - 859 857 void __init hyp_mode_check(void) 860 858 { 861 859 #ifdef CONFIG_ARM_VIRT_EXT ··· 891 903 892 904 parse_early_param(); 893 905 894 - sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); 895 - 896 906 early_paging_init(mdesc, lookup_processor_type(read_cpuid_id())); 897 907 setup_dma_zone(mdesc); 898 908 sanity_check_meminfo(); 899 - arm_memblock_init(&meminfo, mdesc); 909 + arm_memblock_init(mdesc); 900 910 901 911 paging_init(mdesc); 902 912 request_standard_resources(mdesc);
+3 -4
arch/arm/mach-clps711x/board-clep7312.c
··· 18 18 #include <linux/init.h> 19 19 #include <linux/types.h> 20 20 #include <linux/string.h> 21 + #include <linux/memblock.h> 21 22 22 23 #include <asm/setup.h> 23 24 #include <asm/mach-types.h> ··· 27 26 #include "common.h" 28 27 29 28 static void __init 30 - fixup_clep7312(struct tag *tags, char **cmdline, struct meminfo *mi) 29 + fixup_clep7312(struct tag *tags, char **cmdline) 31 30 { 32 - mi->nr_banks=1; 33 - mi->bank[0].start = 0xc0000000; 34 - mi->bank[0].size = 0x01000000; 31 + memblock_add(0xc0000000, 0x01000000); 35 32 } 36 33 37 34 MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")
+4 -6
arch/arm/mach-clps711x/board-edb7211.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/backlight.h> 18 18 #include <linux/platform_device.h> 19 + #include <linux/memblock.h> 19 20 20 21 #include <linux/mtd/physmap.h> 21 22 #include <linux/mtd/partitions.h> ··· 134 133 } 135 134 136 135 static void __init 137 - fixup_edb7211(struct tag *tags, char **cmdline, struct meminfo *mi) 136 + fixup_edb7211(struct tag *tags, char **cmdline) 138 137 { 139 138 /* 140 139 * Bank start addresses are not present in the information ··· 144 143 * Banks sizes _are_ present in the param block, but we're 145 144 * not using that information yet. 146 145 */ 147 - mi->bank[0].start = 0xc0000000; 148 - mi->bank[0].size = SZ_8M; 149 - mi->bank[1].start = 0xc1000000; 150 - mi->bank[1].size = SZ_8M; 151 - mi->nr_banks = 2; 146 + memblock_add(0xc0000000, SZ_8M); 147 + memblock_add(0xc1000000, SZ_8M); 152 148 } 153 149 154 150 static void __init edb7211_init(void)
+1 -1
arch/arm/mach-clps711x/board-p720t.c
··· 295 295 }; 296 296 297 297 static void __init 298 - fixup_p720t(struct tag *tag, char **cmdline, struct meminfo *mi) 298 + fixup_p720t(struct tag *tag, char **cmdline) 299 299 { 300 300 /* 301 301 * Our bootloader doesn't setup any tags (yet).
+1 -1
arch/arm/mach-footbridge/cats-hw.c
··· 76 76 * hard reboots fail on early boards. 77 77 */ 78 78 static void __init 79 - fixup_cats(struct tag *tags, char **cmdline, struct meminfo *mi) 79 + fixup_cats(struct tag *tags, char **cmdline) 80 80 { 81 81 #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) 82 82 screen_info.orig_video_lines = 25;
+1 -1
arch/arm/mach-footbridge/netwinder-hw.c
··· 620 620 * the parameter page. 621 621 */ 622 622 static void __init 623 - fixup_netwinder(struct tag *tags, char **cmdline, struct meminfo *mi) 623 + fixup_netwinder(struct tag *tags, char **cmdline) 624 624 { 625 625 #ifdef CONFIG_ISAPNP 626 626 extern int isapnp_disable;
-6
arch/arm/mach-msm/board-halibut.c
··· 83 83 platform_add_devices(devices, ARRAY_SIZE(devices)); 84 84 } 85 85 86 - static void __init halibut_fixup(struct tag *tags, char **cmdline, 87 - struct meminfo *mi) 88 - { 89 - } 90 - 91 86 static void __init halibut_map_io(void) 92 87 { 93 88 msm_map_common_io(); ··· 95 100 96 101 MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)") 97 102 .atag_offset = 0x100, 98 - .fixup = halibut_fixup, 99 103 .map_io = halibut_map_io, 100 104 .init_early = halibut_init_early, 101 105 .init_irq = halibut_init_irq,
+4 -9
arch/arm/mach-msm/board-mahimahi.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/kernel.h> 24 24 #include <linux/platform_device.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/mach-types.h> 27 28 #include <asm/mach/arch.h> ··· 53 52 platform_add_devices(devices, ARRAY_SIZE(devices)); 54 53 } 55 54 56 - static void __init mahimahi_fixup(struct tag *tags, char **cmdline, 57 - struct meminfo *mi) 55 + static void __init mahimahi_fixup(struct tag *tags, char **cmdline) 58 56 { 59 - mi->nr_banks = 2; 60 - mi->bank[0].start = PHYS_OFFSET; 61 - mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET); 62 - mi->bank[0].size = (219*1024*1024); 63 - mi->bank[1].start = MSM_HIGHMEM_BASE; 64 - mi->bank[1].node = PHYS_TO_NID(MSM_HIGHMEM_BASE); 65 - mi->bank[1].size = MSM_HIGHMEM_SIZE; 57 + memblock_add(PHYS_OFFSET, 219*SZ_1M); 58 + memblock_add(MSM_HIGHMEM_BASE, MSM_HIGHMEM_SIZE); 66 59 } 67 60 68 61 static void __init mahimahi_map_io(void)
+1 -2
arch/arm/mach-msm/board-msm7x30.c
··· 40 40 #include "proc_comm.h" 41 41 #include "common.h" 42 42 43 - static void __init msm7x30_fixup(struct tag *tag, char **cmdline, 44 - struct meminfo *mi) 43 + static void __init msm7x30_fixup(struct tag *tag, char **cmdline) 45 44 { 46 45 for (; tag->hdr.size; tag = tag_next(tag)) 47 46 if (tag->hdr.tag == ATAG_MEM && tag->u.mem.start == 0x200000) {
+5 -8
arch/arm/mach-msm/board-sapphire.c
··· 35 35 36 36 #include <linux/mtd/nand.h> 37 37 #include <linux/mtd/partitions.h> 38 + #include <linux/memblock.h> 38 39 39 40 #include "gpio_chip.h" 40 41 #include "board-sapphire.h" ··· 75 74 } 76 75 }; 77 76 78 - static void __init sapphire_fixup(struct tag *tags, char **cmdline, 79 - struct meminfo *mi) 77 + static void __init sapphire_fixup(struct tag *tags, char **cmdline) 80 78 { 81 79 int smi_sz = parse_tag_smi((const struct tag *)tags); 82 80 83 - mi->nr_banks = 1; 84 - mi->bank[0].start = PHYS_OFFSET; 85 - mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET); 86 81 if (smi_sz == 32) { 87 - mi->bank[0].size = (84*1024*1024); 82 + memblock_add(PHYS_OFFSET, 84*SZ_1M); 88 83 } else if (smi_sz == 64) { 89 - mi->bank[0].size = (101*1024*1024); 84 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 90 85 } else { 86 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 91 87 /* Give a default value when not get smi size */ 92 88 smi_sz = 64; 93 - mi->bank[0].size = (101*1024*1024); 94 89 } 95 90 } 96 91
+3 -5
arch/arm/mach-msm/board-trout.c
··· 19 19 #include <linux/init.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/clkdev.h> 22 + #include <linux/memblock.h> 22 23 23 24 #include <asm/system_info.h> 24 25 #include <asm/mach-types.h> ··· 56 55 msm_init_irq(); 57 56 } 58 57 59 - static void __init trout_fixup(struct tag *tags, char **cmdline, 60 - struct meminfo *mi) 58 + static void __init trout_fixup(struct tag *tags, char **cmdline) 61 59 { 62 - mi->nr_banks = 1; 63 - mi->bank[0].start = PHYS_OFFSET; 64 - mi->bank[0].size = (101*1024*1024); 60 + memblock_add(PHYS_OFFSET, 101*SZ_1M); 65 61 } 66 62 67 63 static void __init trout_init(void)
+1 -2
arch/arm/mach-orion5x/common.c
··· 365 365 * Many orion-based systems have buggy bootloader implementations. 366 366 * This is a common fixup for bogus memory tags. 367 367 */ 368 - void __init tag_fixup_mem32(struct tag *t, char **from, 369 - struct meminfo *meminfo) 368 + void __init tag_fixup_mem32(struct tag *t, char **from) 370 369 { 371 370 for (; t->hdr.size; t = tag_next(t)) 372 371 if (t->hdr.tag == ATAG_MEM &&
+1 -2
arch/arm/mach-orion5x/common.h
··· 71 71 static inline void edmini_v2_init(void) {}; 72 72 #endif 73 73 74 - struct meminfo; 75 74 struct tag; 76 - extern void __init tag_fixup_mem32(struct tag *, char **, struct meminfo *); 75 + extern void __init tag_fixup_mem32(struct tag *, char **); 77 76 78 77 /***************************************************************************** 79 78 * Helpers to access Orion registers
+1 -2
arch/arm/mach-pxa/cm-x300.c
··· 837 837 cm_x300_init_bl(); 838 838 } 839 839 840 - static void __init cm_x300_fixup(struct tag *tags, char **cmdline, 841 - struct meminfo *mi) 840 + static void __init cm_x300_fixup(struct tag *tags, char **cmdline) 842 841 { 843 842 /* Make sure that mi->bank[0].start = PHYS_ADDR */ 844 843 for (; tags->hdr.size; tags = tag_next(tags))
+4 -6
arch/arm/mach-pxa/corgi.c
··· 34 34 #include <linux/input/matrix_keypad.h> 35 35 #include <linux/gpio_keys.h> 36 36 #include <linux/module.h> 37 + #include <linux/memblock.h> 37 38 #include <video/w100fb.h> 38 39 39 40 #include <asm/setup.h> ··· 754 753 platform_add_devices(devices, ARRAY_SIZE(devices)); 755 754 } 756 755 757 - static void __init fixup_corgi(struct tag *tags, char **cmdline, 758 - struct meminfo *mi) 756 + static void __init fixup_corgi(struct tag *tags, char **cmdline) 759 757 { 760 758 sharpsl_save_param(); 761 - mi->nr_banks=1; 762 - mi->bank[0].start = 0xa0000000; 763 759 if (machine_is_corgi()) 764 - mi->bank[0].size = (32*1024*1024); 760 + memblock_add(0xa0000000, SZ_32M); 765 761 else 766 - mi->bank[0].size = (64*1024*1024); 762 + memblock_add(0xa0000000, SZ_64M); 767 763 } 768 764 769 765 #ifdef CONFIG_MACH_CORGI
+4 -5
arch/arm/mach-pxa/eseries.c
··· 21 21 #include <linux/mtd/nand.h> 22 22 #include <linux/mtd/partitions.h> 23 23 #include <linux/usb/gpio_vbus.h> 24 + #include <linux/memblock.h> 24 25 25 26 #include <video/w100fb.h> 26 27 ··· 42 41 #include "clock.h" 43 42 44 43 /* Only e800 has 128MB RAM */ 45 - void __init eseries_fixup(struct tag *tags, char **cmdline, struct meminfo *mi) 44 + void __init eseries_fixup(struct tag *tags, char **cmdline) 46 45 { 47 - mi->nr_banks=1; 48 - mi->bank[0].start = 0xa0000000; 49 46 if (machine_is_e800()) 50 - mi->bank[0].size = (128*1024*1024); 47 + memblock_add(0xa0000000, SZ_128M); 51 48 else 52 - mi->bank[0].size = (64*1024*1024); 49 + memblock_add(0xa0000000, SZ_64M); 53 50 } 54 51 55 52 struct gpio_vbus_mach_info e7xx_udc_info = {
+3 -5
arch/arm/mach-pxa/poodle.c
··· 29 29 #include <linux/spi/ads7846.h> 30 30 #include <linux/spi/pxa2xx_spi.h> 31 31 #include <linux/mtd/sharpsl.h> 32 + #include <linux/memblock.h> 32 33 33 34 #include <mach/hardware.h> 34 35 #include <asm/mach-types.h> ··· 457 456 poodle_init_spi(); 458 457 } 459 458 460 - static void __init fixup_poodle(struct tag *tags, char **cmdline, 461 - struct meminfo *mi) 459 + static void __init fixup_poodle(struct tag *tags, char **cmdline) 462 460 { 463 461 sharpsl_save_param(); 464 - mi->nr_banks=1; 465 - mi->bank[0].start = 0xa0000000; 466 - mi->bank[0].size = (32*1024*1024); 462 + memblock_add(0xa0000000, SZ_32M); 467 463 } 468 464 469 465 MACHINE_START(POODLE, "SHARP Poodle")
+3 -5
arch/arm/mach-pxa/spitz.c
··· 32 32 #include <linux/io.h> 33 33 #include <linux/module.h> 34 34 #include <linux/reboot.h> 35 + #include <linux/memblock.h> 35 36 36 37 #include <asm/setup.h> 37 38 #include <asm/mach-types.h> ··· 972 971 spitz_i2c_init(); 973 972 } 974 973 975 - static void __init spitz_fixup(struct tag *tags, char **cmdline, 976 - struct meminfo *mi) 974 + static void __init spitz_fixup(struct tag *tags, char **cmdline) 977 975 { 978 976 sharpsl_save_param(); 979 - mi->nr_banks = 1; 980 - mi->bank[0].start = 0xa0000000; 981 - mi->bank[0].size = (64*1024*1024); 977 + memblock_add(0xa0000000, SZ_64M); 982 978 } 983 979 984 980 #ifdef CONFIG_MACH_SPITZ
+3 -5
arch/arm/mach-pxa/tosa.c
··· 37 37 #include <linux/i2c/pxa-i2c.h> 38 38 #include <linux/usb/gpio_vbus.h> 39 39 #include <linux/reboot.h> 40 + #include <linux/memblock.h> 40 41 41 42 #include <asm/setup.h> 42 43 #include <asm/mach-types.h> ··· 961 960 platform_add_devices(devices, ARRAY_SIZE(devices)); 962 961 } 963 962 964 - static void __init fixup_tosa(struct tag *tags, char **cmdline, 965 - struct meminfo *mi) 963 + static void __init fixup_tosa(struct tag *tags, char **cmdline) 966 964 { 967 965 sharpsl_save_param(); 968 - mi->nr_banks=1; 969 - mi->bank[0].start = 0xa0000000; 970 - mi->bank[0].size = (64*1024*1024); 966 + memblock_add(0xa0000000, SZ_64M); 971 967 } 972 968 973 969 MACHINE_START(TOSA, "SHARP Tosa")
+4 -7
arch/arm/mach-realview/core.c
··· 31 31 #include <linux/amba/mmci.h> 32 32 #include <linux/gfp.h> 33 33 #include <linux/mtd/physmap.h> 34 + #include <linux/memblock.h> 34 35 35 36 #include <mach/hardware.h> 36 37 #include <asm/irq.h> ··· 371 370 /* 372 371 * Setup the memory banks. 373 372 */ 374 - void realview_fixup(struct tag *tags, char **from, struct meminfo *meminfo) 373 + void realview_fixup(struct tag *tags, char **from) 375 374 { 376 375 /* 377 376 * Most RealView platforms have 512MB contiguous RAM at 0x70000000. 378 377 * Half of this is mirrored at 0. 379 378 */ 380 379 #ifdef CONFIG_REALVIEW_HIGH_PHYS_OFFSET 381 - meminfo->bank[0].start = 0x70000000; 382 - meminfo->bank[0].size = SZ_512M; 383 - meminfo->nr_banks = 1; 380 + memblock_add(0x70000000, SZ_512M); 384 381 #else 385 - meminfo->bank[0].start = 0; 386 - meminfo->bank[0].size = SZ_256M; 387 - meminfo->nr_banks = 1; 382 + memblock_add(0, SZ_256M); 388 383 #endif 389 384 }
+1 -2
arch/arm/mach-realview/core.h
··· 51 51 extern int realview_eth_register(const char *name, struct resource *res); 52 52 extern int realview_usb_register(struct resource *res); 53 53 extern void realview_init_early(void); 54 - extern void realview_fixup(struct tag *tags, char **from, 55 - struct meminfo *meminfo); 54 + extern void realview_fixup(struct tag *tags, char **from); 56 55 57 56 extern struct smp_operations realview_smp_ops; 58 57 extern void realview_cpu_die(unsigned int cpu);
+3 -5
arch/arm/mach-realview/realview_pb1176.c
··· 32 32 #include <linux/irqchip/arm-gic.h> 33 33 #include <linux/platform_data/clk-realview.h> 34 34 #include <linux/reboot.h> 35 + #include <linux/memblock.h> 35 36 36 37 #include <mach/hardware.h> 37 38 #include <asm/irq.h> ··· 340 339 dsb(); 341 340 } 342 341 343 - static void realview_pb1176_fixup(struct tag *tags, char **from, 344 - struct meminfo *meminfo) 342 + static void realview_pb1176_fixup(struct tag *tags, char **from) 345 343 { 346 344 /* 347 345 * RealView PB1176 only has 128MB of RAM mapped at 0. 348 346 */ 349 - meminfo->bank[0].start = 0; 350 - meminfo->bank[0].size = SZ_128M; 351 - meminfo->nr_banks = 1; 347 + memblock_add(0, SZ_128M); 352 348 } 353 349 354 350 static void __init realview_pb1176_init(void)
+7 -10
arch/arm/mach-realview/realview_pbx.c
··· 29 29 #include <linux/irqchip/arm-gic.h> 30 30 #include <linux/platform_data/clk-realview.h> 31 31 #include <linux/reboot.h> 32 + #include <linux/memblock.h> 32 33 33 34 #include <asm/irq.h> 34 35 #include <asm/mach-types.h> ··· 326 325 realview_pbx_twd_init(); 327 326 } 328 327 329 - static void realview_pbx_fixup(struct tag *tags, char **from, 330 - struct meminfo *meminfo) 328 + static void realview_pbx_fixup(struct tag *tags, char **from) 331 329 { 332 330 #ifdef CONFIG_SPARSEMEM 333 331 /* 334 332 * Memory configuration with SPARSEMEM enabled on RealView PBX (see 335 333 * asm/mach/memory.h for more information). 336 334 */ 337 - meminfo->bank[0].start = 0; 338 - meminfo->bank[0].size = SZ_256M; 339 - meminfo->bank[1].start = 0x20000000; 340 - meminfo->bank[1].size = SZ_512M; 341 - meminfo->bank[2].start = 0x80000000; 342 - meminfo->bank[2].size = SZ_256M; 343 - meminfo->nr_banks = 3; 335 + 336 + memblock_add(0, SZ_256M); 337 + memblock_add(0x20000000, SZ_512M); 338 + memblock_add(0x80000000, SZ_256M); 344 339 #else 345 - realview_fixup(tags, from, meminfo); 340 + realview_fixup(tags, from); 346 341 #endif 347 342 } 348 343
+3 -5
arch/arm/mach-s3c24xx/mach-smdk2413.c
··· 22 22 #include <linux/serial_s3c.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/io.h> 25 + #include <linux/memblock.h> 25 26 26 27 #include <asm/mach/arch.h> 27 28 #include <asm/mach/map.h> ··· 94 93 &s3c2412_device_dma, 95 94 }; 96 95 97 - static void __init smdk2413_fixup(struct tag *tags, char **cmdline, 98 - struct meminfo *mi) 96 + static void __init smdk2413_fixup(struct tag *tags, char **cmdline) 99 97 { 100 98 if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { 101 - mi->nr_banks=1; 102 - mi->bank[0].start = 0x30000000; 103 - mi->bank[0].size = SZ_64M; 99 + memblock_add(0x30000000, SZ_64M); 104 100 } 105 101 } 106 102
+3 -5
arch/arm/mach-s3c24xx/mach-vstms.c
··· 23 23 #include <linux/mtd/nand.h> 24 24 #include <linux/mtd/nand_ecc.h> 25 25 #include <linux/mtd/partitions.h> 26 + #include <linux/memblock.h> 26 27 27 28 #include <asm/mach/arch.h> 28 29 #include <asm/mach/map.h> ··· 130 129 &s3c2412_device_dma, 131 130 }; 132 131 133 - static void __init vstms_fixup(struct tag *tags, char **cmdline, 134 - struct meminfo *mi) 132 + static void __init vstms_fixup(struct tag *tags, char **cmdline) 135 133 { 136 134 if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) { 137 - mi->nr_banks=1; 138 - mi->bank[0].start = 0x30000000; 139 - mi->bank[0].size = SZ_64M; 135 + memblock_add(0x30000000, SZ_64M); 140 136 } 141 137 } 142 138
+1 -1
arch/arm/mach-sa1100/assabet.c
··· 531 531 } 532 532 533 533 static void __init 534 - fixup_assabet(struct tag *tags, char **cmdline, struct meminfo *mi) 534 + fixup_assabet(struct tag *tags, char **cmdline) 535 535 { 536 536 /* This must be done before any call to machine_has_neponset() */ 537 537 map_sa1100_gpio_regs();
+28 -44
arch/arm/mm/init.c
··· 81 81 * initialization functions, as well as show_mem() for the skipping 82 82 * of holes in the memory map. It is populated by arm_add_memory(). 83 83 */ 84 - struct meminfo meminfo; 85 - 86 84 void show_mem(unsigned int filter) 87 85 { 88 86 int free = 0, total = 0, reserved = 0; 89 - int shared = 0, cached = 0, slab = 0, i; 90 - struct meminfo * mi = &meminfo; 87 + int shared = 0, cached = 0, slab = 0; 88 + struct memblock_region *reg; 91 89 92 90 printk("Mem-info:\n"); 93 91 show_free_areas(filter); 94 92 95 - for_each_bank (i, mi) { 96 - struct membank *bank = &mi->bank[i]; 93 + for_each_memblock (memory, reg) { 97 94 unsigned int pfn1, pfn2; 98 95 struct page *page, *end; 99 96 100 - pfn1 = bank_pfn_start(bank); 101 - pfn2 = bank_pfn_end(bank); 97 + pfn1 = memblock_region_memory_base_pfn(reg); 98 + pfn2 = memblock_region_memory_end_pfn(reg); 102 99 103 100 page = pfn_to_page(pfn1); 104 101 end = pfn_to_page(pfn2 - 1) + 1; ··· 112 115 free++; 113 116 else 114 117 shared += page_count(page) - 1; 115 - page++; 116 - } while (page < end); 118 + pfn1++; 119 + page = pfn_to_page(pfn1); 120 + } while (pfn1 < pfn2); 117 121 } 118 122 119 123 printk("%d pages of RAM\n", total); ··· 128 130 static void __init find_limits(unsigned long *min, unsigned long *max_low, 129 131 unsigned long *max_high) 130 132 { 131 - struct meminfo *mi = &meminfo; 132 - int i; 133 - 134 - /* This assumes the meminfo array is properly sorted */ 135 - *min = bank_pfn_start(&mi->bank[0]); 136 - for_each_bank (i, mi) 137 - if (mi->bank[i].highmem) 138 - break; 139 - *max_low = bank_pfn_end(&mi->bank[i - 1]); 140 - *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]); 133 + *max_low = PFN_DOWN(memblock_get_current_limit()); 134 + *min = PFN_UP(memblock_start_of_DRAM()); 135 + *max_high = PFN_DOWN(memblock_end_of_DRAM()); 141 136 } 142 137 143 138 #ifdef CONFIG_ZONE_DMA ··· 265 274 return phys; 266 275 } 267 276 268 - void __init arm_memblock_init(struct meminfo *mi, 269 - const struct machine_desc *mdesc) 277 + void __init arm_memblock_init(const struct machine_desc *mdesc) 270 278 { 271 - int i; 272 - 273 - for (i = 0; i < mi->nr_banks; i++) 274 - memblock_add(mi->bank[i].start, mi->bank[i].size); 275 - 276 279 /* Register the kernel text, kernel data and initrd with memblock. */ 277 280 #ifdef CONFIG_XIP_KERNEL 278 281 memblock_reserve(__pa(_sdata), _end - _sdata); ··· 398 413 /* 399 414 * The mem_map array can get very big. Free the unused area of the memory map. 400 415 */ 401 - static void __init free_unused_memmap(struct meminfo *mi) 416 + static void __init free_unused_memmap(void) 402 417 { 403 - unsigned long bank_start, prev_bank_end = 0; 404 - unsigned int i; 418 + unsigned long start, prev_end = 0; 419 + struct memblock_region *reg; 405 420 406 421 /* 407 422 * This relies on each bank being in address order. 408 423 * The banks are sorted previously in bootmem_init(). 409 424 */ 410 - for_each_bank(i, mi) { 411 - struct membank *bank = &mi->bank[i]; 412 - 413 - bank_start = bank_pfn_start(bank); 425 + for_each_memblock(memory, reg) { 426 + start = memblock_region_memory_base_pfn(reg); 414 427 415 428 #ifdef CONFIG_SPARSEMEM 416 429 /* 417 430 * Take care not to free memmap entries that don't exist 418 431 * due to SPARSEMEM sections which aren't present. 419 432 */ 420 - bank_start = min(bank_start, 421 - ALIGN(prev_bank_end, PAGES_PER_SECTION)); 433 + start = min(start, 434 + ALIGN(prev_end, PAGES_PER_SECTION)); 422 435 #else 423 436 /* 424 437 * Align down here since the VM subsystem insists that the 425 438 * memmap entries are valid from the bank start aligned to 426 439 * MAX_ORDER_NR_PAGES. 427 440 */ 428 - bank_start = round_down(bank_start, MAX_ORDER_NR_PAGES); 441 + start = round_down(start, MAX_ORDER_NR_PAGES); 429 442 #endif 430 443 /* 431 444 * If we had a previous bank, and there is a space 432 445 * between the current bank and the previous, free it. 433 446 */ 434 - if (prev_bank_end && prev_bank_end < bank_start) 435 - free_memmap(prev_bank_end, bank_start); 447 + if (prev_end && prev_end < start) 448 + free_memmap(prev_end, start); 436 449 437 450 /* 438 451 * Align up here since the VM subsystem insists that the 439 452 * memmap entries are valid from the bank end aligned to 440 453 * MAX_ORDER_NR_PAGES. 441 454 */ 442 - prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES); 455 + prev_end = ALIGN(memblock_region_memory_end_pfn(reg), 456 + MAX_ORDER_NR_PAGES); 443 457 } 444 458 445 459 #ifdef CONFIG_SPARSEMEM 446 - if (!IS_ALIGNED(prev_bank_end, PAGES_PER_SECTION)) 447 - free_memmap(prev_bank_end, 448 - ALIGN(prev_bank_end, PAGES_PER_SECTION)); 460 + if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION)) 461 + free_memmap(prev_end, 462 + ALIGN(prev_end, PAGES_PER_SECTION)); 449 463 #endif 450 464 } 451 465 ··· 520 536 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 521 537 522 538 /* this will put all unused low memory onto the freelists */ 523 - free_unused_memmap(&meminfo); 539 + free_unused_memmap(); 524 540 free_all_bootmem(); 525 541 526 542 #ifdef CONFIG_SA1111
+36 -83
arch/arm/mm/mmu.c
··· 1062 1062 void __init sanity_check_meminfo(void) 1063 1063 { 1064 1064 phys_addr_t memblock_limit = 0; 1065 - int i, j, highmem = 0; 1065 + int highmem = 0; 1066 1066 phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1; 1067 + struct memblock_region *reg; 1067 1068 1068 - for (i = 0, j = 0; i < meminfo.nr_banks; i++) { 1069 - struct membank *bank = &meminfo.bank[j]; 1070 - phys_addr_t size_limit; 1069 + for_each_memblock(memory, reg) { 1070 + phys_addr_t block_start = reg->base; 1071 + phys_addr_t block_end = reg->base + reg->size; 1072 + phys_addr_t size_limit = reg->size; 1071 1073 1072 - *bank = meminfo.bank[i]; 1073 - size_limit = bank->size; 1074 - 1075 - if (bank->start >= vmalloc_limit) 1074 + if (reg->base >= vmalloc_limit) 1076 1075 highmem = 1; 1077 1076 else 1078 - size_limit = vmalloc_limit - bank->start; 1077 + size_limit = vmalloc_limit - reg->base; 1079 1078 1080 - bank->highmem = highmem; 1081 1079 1082 - #ifdef CONFIG_HIGHMEM 1083 - /* 1084 - * Split those memory banks which are partially overlapping 1085 - * the vmalloc area greatly simplifying things later. 1086 - */ 1087 - if (!highmem && bank->size > size_limit) { 1088 - if (meminfo.nr_banks >= NR_BANKS) { 1089 - printk(KERN_CRIT "NR_BANKS too low, " 1090 - "ignoring high memory\n"); 1091 - } else { 1092 - memmove(bank + 1, bank, 1093 - (meminfo.nr_banks - i) * sizeof(*bank)); 1094 - meminfo.nr_banks++; 1095 - i++; 1096 - bank[1].size -= size_limit; 1097 - bank[1].start = vmalloc_limit; 1098 - bank[1].highmem = highmem = 1; 1099 - j++; 1080 + if (!IS_ENABLED(CONFIG_HIGHMEM) || cache_is_vipt_aliasing()) { 1081 + 1082 + if (highmem) { 1083 + pr_notice("Ignoring RAM at %pa-%pa (!CONFIG_HIGHMEM)\n", 1084 + &block_start, &block_end); 1085 + memblock_remove(reg->base, reg->size); 1086 + continue; 1100 1087 } 1101 - bank->size = size_limit; 1102 - } 1103 - #else 1104 - /* 1105 - * Highmem banks not allowed with !CONFIG_HIGHMEM. 1106 - */ 1107 - if (highmem) { 1108 - printk(KERN_NOTICE "Ignoring RAM at %.8llx-%.8llx " 1109 - "(!CONFIG_HIGHMEM).\n", 1110 - (unsigned long long)bank->start, 1111 - (unsigned long long)bank->start + bank->size - 1); 1112 - continue; 1088 + 1089 + if (reg->size > size_limit) { 1090 + phys_addr_t overlap_size = reg->size - size_limit; 1091 + 1092 + pr_notice("Truncating RAM at %pa-%pa to -%pa", 1093 + &block_start, &block_end, &vmalloc_limit); 1094 + memblock_remove(vmalloc_limit, overlap_size); 1095 + block_end = vmalloc_limit; 1096 + } 1113 1097 } 1114 1098 1115 - /* 1116 - * Check whether this memory bank would partially overlap 1117 - * the vmalloc area. 1118 - */ 1119 - if (bank->size > size_limit) { 1120 - printk(KERN_NOTICE "Truncating RAM at %.8llx-%.8llx " 1121 - "to -%.8llx (vmalloc region overlap).\n", 1122 - (unsigned long long)bank->start, 1123 - (unsigned long long)bank->start + bank->size - 1, 1124 - (unsigned long long)bank->start + size_limit - 1); 1125 - bank->size = size_limit; 1126 - } 1127 - #endif 1128 - if (!bank->highmem) { 1129 - phys_addr_t bank_end = bank->start + bank->size; 1130 - 1131 - if (bank_end > arm_lowmem_limit) 1132 - arm_lowmem_limit = bank_end; 1099 + if (!highmem) { 1100 + if (block_end > arm_lowmem_limit) { 1101 + if (reg->size > size_limit) 1102 + arm_lowmem_limit = vmalloc_limit; 1103 + else 1104 + arm_lowmem_limit = block_end; 1105 + } 1133 1106 1134 1107 /* 1135 1108 * Find the first non-section-aligned page, and point ··· 1118 1145 * occurs before any free memory is mapped. 1119 1146 */ 1120 1147 if (!memblock_limit) { 1121 - if (!IS_ALIGNED(bank->start, SECTION_SIZE)) 1122 - memblock_limit = bank->start; 1123 - else if (!IS_ALIGNED(bank_end, SECTION_SIZE)) 1124 - memblock_limit = bank_end; 1148 + if (!IS_ALIGNED(block_start, SECTION_SIZE)) 1149 + memblock_limit = block_start; 1150 + else if (!IS_ALIGNED(block_end, SECTION_SIZE)) 1151 + memblock_limit = arm_lowmem_limit; 1125 1152 } 1126 - } 1127 - j++; 1128 - } 1129 - #ifdef CONFIG_HIGHMEM 1130 - if (highmem) { 1131 - const char *reason = NULL; 1132 1153 1133 - if (cache_is_vipt_aliasing()) { 1134 - /* 1135 - * Interactions between kmap and other mappings 1136 - * make highmem support with aliasing VIPT caches 1137 - * rather difficult. 1138 - */ 1139 - reason = "with VIPT aliasing cache"; 1140 - } 1141 - if (reason) { 1142 - printk(KERN_CRIT "HIGHMEM is not supported %s, ignoring high memory\n", 1143 - reason); 1144 - while (j > 0 && meminfo.bank[j - 1].highmem) 1145 - j--; 1146 1154 } 1147 1155 } 1148 - #endif 1149 - meminfo.nr_banks = j; 1156 + 1150 1157 high_memory = __va(arm_lowmem_limit - 1) + 1; 1151 1158 1152 1159 /*
+34 -28
arch/arm/mm/nommu.c
··· 88 88 void __init sanity_check_meminfo_mpu(void) 89 89 { 90 90 int i; 91 - struct membank *bank = meminfo.bank; 92 91 phys_addr_t phys_offset = PHYS_OFFSET; 93 92 phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size; 93 + struct memblock_region *reg; 94 + bool first = true; 95 + phys_addr_t mem_start; 96 + phys_addr_t mem_end; 94 97 95 - /* Initially only use memory continuous from PHYS_OFFSET */ 96 - if (bank_phys_start(&bank[0]) != phys_offset) 97 - panic("First memory bank must be contiguous from PHYS_OFFSET"); 98 + for_each_memblock(memory, reg) { 99 + if (first) { 100 + /* 101 + * Initially only use memory continuous from 102 + * PHYS_OFFSET */ 103 + if (reg->base != phys_offset) 104 + panic("First memory bank must be contiguous from PHYS_OFFSET"); 98 105 99 - /* Banks have already been sorted by start address */ 100 - for (i = 1; i < meminfo.nr_banks; i++) { 101 - if (bank[i].start <= bank_phys_end(&bank[0]) && 102 - bank_phys_end(&bank[i]) > bank_phys_end(&bank[0])) { 103 - bank[0].size = bank_phys_end(&bank[i]) - bank[0].start; 106 + mem_start = reg->base; 107 + mem_end = reg->base + reg->size; 108 + specified_mem_size = reg->size; 109 + first = false; 104 110 } else { 105 - pr_notice("Ignoring RAM after 0x%.8lx. " 106 - "First non-contiguous (ignored) bank start: 0x%.8lx\n", 107 - (unsigned long)bank_phys_end(&bank[0]), 108 - (unsigned long)bank_phys_start(&bank[i])); 109 - break; 111 + /* 112 + * memblock auto merges contiguous blocks, remove 113 + * all blocks afterwards 114 + */ 115 + pr_notice("Ignoring RAM after %pa, memory at %pa ignored\n", 116 + &mem_start, &reg->base); 117 + memblock_remove(reg->base, reg->size); 110 118 } 111 119 } 112 - /* All contiguous banks are now merged in to the first bank */ 113 - meminfo.nr_banks = 1; 114 - specified_mem_size = bank[0].size; 115 120 116 121 /* 117 122 * MPU has curious alignment requirements: Size must be power of 2, and ··· 133 128 */ 134 129 aligned_region_size = (phys_offset - 1) ^ (phys_offset); 135 130 /* Find the max power-of-two sized region that fits inside our bank */ 136 - rounded_mem_size = (1 << __fls(bank[0].size)) - 1; 131 + rounded_mem_size = (1 << __fls(specified_mem_size)) - 1; 137 132 138 133 /* The actual region size is the smaller of the two */ 139 134 aligned_region_size = aligned_region_size < rounded_mem_size 140 135 ? aligned_region_size + 1 141 136 : rounded_mem_size + 1; 142 137 143 - if (aligned_region_size != specified_mem_size) 144 - pr_warn("Truncating memory from 0x%.8lx to 0x%.8lx (MPU region constraints)", 145 - (unsigned long)specified_mem_size, 146 - (unsigned long)aligned_region_size); 138 + if (aligned_region_size != specified_mem_size) { 139 + pr_warn("Truncating memory from %pa to %pa (MPU region constraints)", 140 + &specified_mem_size, &aligned_region_size); 141 + memblock_remove(mem_start + aligned_region_size, 142 + specified_mem_size - aligned_round_size); 147 143 148 - meminfo.bank[0].size = aligned_region_size; 149 - pr_debug("MPU Region from 0x%.8lx size 0x%.8lx (end 0x%.8lx))\n", 150 - (unsigned long)phys_offset, 151 - (unsigned long)aligned_region_size, 152 - (unsigned long)bank_phys_end(&bank[0])); 144 + mem_end = mem_start + aligned_region_size; 145 + } 146 + 147 + pr_debug("MPU Region from %pa size %pa (end %pa))\n", 148 + &phys_offset, &aligned_region_size, &mem_end); 153 149 154 150 } 155 151 ··· 298 292 { 299 293 phys_addr_t end; 300 294 sanity_check_meminfo_mpu(); 301 - end = bank_phys_end(&meminfo.bank[meminfo.nr_banks - 1]); 295 + end = memblock_end_of_DRAM(); 302 296 high_memory = __va(end - 1) + 1; 303 297 } 304 298