aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/init.c
diff options
context:
space:
mode:
authorLaura Abbott <lauraa@codeaurora.org>2014-04-13 17:54:58 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-05-31 20:17:12 -0400
commit1c2f87c22566cd057bc8cde10c37ae9da1a1bb76 (patch)
tree6c135a3b2b6af6be3b6593ac6329d6d4f353b7dd /arch/arm/mm/init.c
parent1c8c3cf0b5239388e712508a85821f4718f4d889 (diff)
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>
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r--arch/arm/mm/init.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 2a77ba8796ae..c8ab21dc2178 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -81,24 +81,21 @@ __tagtable(ATAG_INITRD2, parse_tag_initrd2);
81 * initialization functions, as well as show_mem() for the skipping 81 * initialization functions, as well as show_mem() for the skipping
82 * of holes in the memory map. It is populated by arm_add_memory(). 82 * of holes in the memory map. It is populated by arm_add_memory().
83 */ 83 */
84struct meminfo meminfo;
85
86void show_mem(unsigned int filter) 84void show_mem(unsigned int filter)
87{ 85{
88 int free = 0, total = 0, reserved = 0; 86 int free = 0, total = 0, reserved = 0;
89 int shared = 0, cached = 0, slab = 0, i; 87 int shared = 0, cached = 0, slab = 0;
90 struct meminfo * mi = &meminfo; 88 struct memblock_region *reg;
91 89
92 printk("Mem-info:\n"); 90 printk("Mem-info:\n");
93 show_free_areas(filter); 91 show_free_areas(filter);
94 92
95 for_each_bank (i, mi) { 93 for_each_memblock (memory, reg) {
96 struct membank *bank = &mi->bank[i];
97 unsigned int pfn1, pfn2; 94 unsigned int pfn1, pfn2;
98 struct page *page, *end; 95 struct page *page, *end;
99 96
100 pfn1 = bank_pfn_start(bank); 97 pfn1 = memblock_region_memory_base_pfn(reg);
101 pfn2 = bank_pfn_end(bank); 98 pfn2 = memblock_region_memory_end_pfn(reg);
102 99
103 page = pfn_to_page(pfn1); 100 page = pfn_to_page(pfn1);
104 end = pfn_to_page(pfn2 - 1) + 1; 101 end = pfn_to_page(pfn2 - 1) + 1;
@@ -115,8 +112,9 @@ void show_mem(unsigned int filter)
115 free++; 112 free++;
116 else 113 else
117 shared += page_count(page) - 1; 114 shared += page_count(page) - 1;
118 page++; 115 pfn1++;
119 } while (page < end); 116 page = pfn_to_page(pfn1);
117 } while (pfn1 < pfn2);
120 } 118 }
121 119
122 printk("%d pages of RAM\n", total); 120 printk("%d pages of RAM\n", total);
@@ -130,16 +128,9 @@ void show_mem(unsigned int filter)
130static void __init find_limits(unsigned long *min, unsigned long *max_low, 128static void __init find_limits(unsigned long *min, unsigned long *max_low,
131 unsigned long *max_high) 129 unsigned long *max_high)
132{ 130{
133 struct meminfo *mi = &meminfo; 131 *max_low = PFN_DOWN(memblock_get_current_limit());
134 int i; 132 *min = PFN_UP(memblock_start_of_DRAM());
135 133 *max_high = PFN_DOWN(memblock_end_of_DRAM());
136 /* This assumes the meminfo array is properly sorted */
137 *min = bank_pfn_start(&mi->bank[0]);
138 for_each_bank (i, mi)
139 if (mi->bank[i].highmem)
140 break;
141 *max_low = bank_pfn_end(&mi->bank[i - 1]);
142 *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]);
143} 134}
144 135
145#ifdef CONFIG_ZONE_DMA 136#ifdef CONFIG_ZONE_DMA
@@ -274,14 +265,8 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)
274 return phys; 265 return phys;
275} 266}
276 267
277void __init arm_memblock_init(struct meminfo *mi, 268void __init arm_memblock_init(const struct machine_desc *mdesc)
278 const struct machine_desc *mdesc)
279{ 269{
280 int i;
281
282 for (i = 0; i < mi->nr_banks; i++)
283 memblock_add(mi->bank[i].start, mi->bank[i].size);
284
285 /* Register the kernel text, kernel data and initrd with memblock. */ 270 /* Register the kernel text, kernel data and initrd with memblock. */
286#ifdef CONFIG_XIP_KERNEL 271#ifdef CONFIG_XIP_KERNEL
287 memblock_reserve(__pa(_sdata), _end - _sdata); 272 memblock_reserve(__pa(_sdata), _end - _sdata);
@@ -413,54 +398,53 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn)
413/* 398/*
414 * The mem_map array can get very big. Free the unused area of the memory map. 399 * The mem_map array can get very big. Free the unused area of the memory map.
415 */ 400 */
416static void __init free_unused_memmap(struct meminfo *mi) 401static void __init free_unused_memmap(void)
417{ 402{
418 unsigned long bank_start, prev_bank_end = 0; 403 unsigned long start, prev_end = 0;
419 unsigned int i; 404 struct memblock_region *reg;
420 405
421 /* 406 /*
422 * This relies on each bank being in address order. 407 * This relies on each bank being in address order.
423 * The banks are sorted previously in bootmem_init(). 408 * The banks are sorted previously in bootmem_init().
424 */ 409 */
425 for_each_bank(i, mi) { 410 for_each_memblock(memory, reg) {
426 struct membank *bank = &mi->bank[i]; 411 start = memblock_region_memory_base_pfn(reg);
427
428 bank_start = bank_pfn_start(bank);
429 412
430#ifdef CONFIG_SPARSEMEM 413#ifdef CONFIG_SPARSEMEM
431 /* 414 /*
432 * Take care not to free memmap entries that don't exist 415 * Take care not to free memmap entries that don't exist
433 * due to SPARSEMEM sections which aren't present. 416 * due to SPARSEMEM sections which aren't present.
434 */ 417 */
435 bank_start = min(bank_start, 418 start = min(start,
436 ALIGN(prev_bank_end, PAGES_PER_SECTION)); 419 ALIGN(prev_end, PAGES_PER_SECTION));
437#else 420#else
438 /* 421 /*
439 * Align down here since the VM subsystem insists that the 422 * Align down here since the VM subsystem insists that the
440 * memmap entries are valid from the bank start aligned to 423 * memmap entries are valid from the bank start aligned to
441 * MAX_ORDER_NR_PAGES. 424 * MAX_ORDER_NR_PAGES.
442 */ 425 */
443 bank_start = round_down(bank_start, MAX_ORDER_NR_PAGES); 426 start = round_down(start, MAX_ORDER_NR_PAGES);
444#endif 427#endif
445 /* 428 /*
446 * If we had a previous bank, and there is a space 429 * If we had a previous bank, and there is a space
447 * between the current bank and the previous, free it. 430 * between the current bank and the previous, free it.
448 */ 431 */
449 if (prev_bank_end && prev_bank_end < bank_start) 432 if (prev_end && prev_end < start)
450 free_memmap(prev_bank_end, bank_start); 433 free_memmap(prev_end, start);
451 434
452 /* 435 /*
453 * Align up here since the VM subsystem insists that the 436 * Align up here since the VM subsystem insists that the
454 * memmap entries are valid from the bank end aligned to 437 * memmap entries are valid from the bank end aligned to
455 * MAX_ORDER_NR_PAGES. 438 * MAX_ORDER_NR_PAGES.
456 */ 439 */
457 prev_bank_end = ALIGN(bank_pfn_end(bank), MAX_ORDER_NR_PAGES); 440 prev_end = ALIGN(memblock_region_memory_end_pfn(reg),
441 MAX_ORDER_NR_PAGES);
458 } 442 }
459 443
460#ifdef CONFIG_SPARSEMEM 444#ifdef CONFIG_SPARSEMEM
461 if (!IS_ALIGNED(prev_bank_end, PAGES_PER_SECTION)) 445 if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION))
462 free_memmap(prev_bank_end, 446 free_memmap(prev_end,
463 ALIGN(prev_bank_end, PAGES_PER_SECTION)); 447 ALIGN(prev_end, PAGES_PER_SECTION));
464#endif 448#endif
465} 449}
466 450
@@ -536,7 +520,7 @@ void __init mem_init(void)
536 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 520 set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
537 521
538 /* this will put all unused low memory onto the freelists */ 522 /* this will put all unused low memory onto the freelists */
539 free_unused_memmap(&meminfo); 523 free_unused_memmap();
540 free_all_bootmem(); 524 free_all_bootmem();
541 525
542#ifdef CONFIG_SA1111 526#ifdef CONFIG_SA1111