aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/init.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-05-07 12:40:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-07-16 05:57:35 -0400
commitbe370302742ff9948f2a42b15cb2ba174d97b930 (patch)
tree977bfa71c1e1483c22a40d85dfd3b233e5ac5d06 /arch/arm/mm/init.c
parent7961239599de71130c852ecfa9a4140f3f60547b (diff)
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 <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r--arch/arm/mm/init.c266
1 files changed, 116 insertions, 150 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index f6a999465323..4011e524cb1d 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -79,38 +79,37 @@ struct meminfo meminfo;
79void show_mem(void) 79void show_mem(void)
80{ 80{
81 int free = 0, total = 0, reserved = 0; 81 int free = 0, total = 0, reserved = 0;
82 int shared = 0, cached = 0, slab = 0, node, i; 82 int shared = 0, cached = 0, slab = 0, i;
83 struct meminfo * mi = &meminfo; 83 struct meminfo * mi = &meminfo;
84 84
85 printk("Mem-info:\n"); 85 printk("Mem-info:\n");
86 show_free_areas(); 86 show_free_areas();
87 for_each_online_node(node) { 87
88 for_each_nodebank (i,mi,node) { 88 for_each_bank (i, mi) {
89 struct membank *bank = &mi->bank[i]; 89 struct membank *bank = &mi->bank[i];
90 unsigned int pfn1, pfn2; 90 unsigned int pfn1, pfn2;
91 struct page *page, *end; 91 struct page *page, *end;
92 92
93 pfn1 = bank_pfn_start(bank); 93 pfn1 = bank_pfn_start(bank);
94 pfn2 = bank_pfn_end(bank); 94 pfn2 = bank_pfn_end(bank);
95 95
96 page = pfn_to_page(pfn1); 96 page = pfn_to_page(pfn1);
97 end = pfn_to_page(pfn2 - 1) + 1; 97 end = pfn_to_page(pfn2 - 1) + 1;
98 98
99 do { 99 do {
100 total++; 100 total++;
101 if (PageReserved(page)) 101 if (PageReserved(page))
102 reserved++; 102 reserved++;
103 else if (PageSwapCache(page)) 103 else if (PageSwapCache(page))
104 cached++; 104 cached++;
105 else if (PageSlab(page)) 105 else if (PageSlab(page))
106 slab++; 106 slab++;
107 else if (!page_count(page)) 107 else if (!page_count(page))
108 free++; 108 free++;
109 else 109 else
110 shared += page_count(page) - 1; 110 shared += page_count(page) - 1;
111 page++; 111 page++;
112 } while (page < end); 112 } while (page < end);
113 }
114 } 113 }
115 114
116 printk("%d pages of RAM\n", total); 115 printk("%d pages of RAM\n", total);
@@ -121,7 +120,7 @@ void show_mem(void)
121 printk("%d pages swap cached\n", cached); 120 printk("%d pages swap cached\n", cached);
122} 121}
123 122
124static void __init find_node_limits(int node, struct meminfo *mi, 123static void __init find_limits(struct meminfo *mi,
125 unsigned long *min, unsigned long *max_low, unsigned long *max_high) 124 unsigned long *min, unsigned long *max_low, unsigned long *max_high)
126{ 125{
127 int i; 126 int i;
@@ -129,7 +128,7 @@ static void __init find_node_limits(int node, struct meminfo *mi,
129 *min = -1UL; 128 *min = -1UL;
130 *max_low = *max_high = 0; 129 *max_low = *max_high = 0;
131 130
132 for_each_nodebank(i, mi, node) { 131 for_each_bank (i, mi) {
133 struct membank *bank = &mi->bank[i]; 132 struct membank *bank = &mi->bank[i];
134 unsigned long start, end; 133 unsigned long start, end;
135 134
@@ -154,14 +153,14 @@ static void __init find_node_limits(int node, struct meminfo *mi,
154 * the end, we won't clash. 153 * the end, we won't clash.
155 */ 154 */
156static unsigned int __init 155static unsigned int __init
157find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages) 156find_bootmap_pfn(struct meminfo *mi, unsigned int bootmap_pages)
158{ 157{
159 unsigned int start_pfn, i, bootmap_pfn; 158 unsigned int start_pfn, i, bootmap_pfn;
160 159
161 start_pfn = PAGE_ALIGN(__pa(_end)) >> PAGE_SHIFT; 160 start_pfn = PAGE_ALIGN(__pa(_end)) >> PAGE_SHIFT;
162 bootmap_pfn = 0; 161 bootmap_pfn = 0;
163 162
164 for_each_nodebank(i, mi, node) { 163 for_each_bank(i, mi) {
165 struct membank *bank = &mi->bank[i]; 164 struct membank *bank = &mi->bank[i];
166 unsigned int start, end; 165 unsigned int start, end;
167 166
@@ -191,7 +190,7 @@ find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
191 190
192static int __init check_initrd(struct meminfo *mi) 191static int __init check_initrd(struct meminfo *mi)
193{ 192{
194 int initrd_node = -2; 193 int initrd = -2;
195#ifdef CONFIG_BLK_DEV_INITRD 194#ifdef CONFIG_BLK_DEV_INITRD
196 unsigned long end = phys_initrd_start + phys_initrd_size; 195 unsigned long end = phys_initrd_start + phys_initrd_size;
197 196
@@ -202,17 +201,17 @@ static int __init check_initrd(struct meminfo *mi)
202 if (phys_initrd_size) { 201 if (phys_initrd_size) {
203 unsigned int i; 202 unsigned int i;
204 203
205 initrd_node = -1; 204 initrd = -1;
206 205
207 for (i = 0; i < mi->nr_banks; i++) { 206 for (i = 0; i < mi->nr_banks; i++) {
208 struct membank *bank = &mi->bank[i]; 207 struct membank *bank = &mi->bank[i];
209 if (bank_phys_start(bank) <= phys_initrd_start && 208 if (bank_phys_start(bank) <= phys_initrd_start &&
210 end <= bank_phys_end(bank)) 209 end <= bank_phys_end(bank))
211 initrd_node = bank->node; 210 initrd = 0;
212 } 211 }
213 } 212 }
214 213
215 if (initrd_node == -1) { 214 if (initrd == -1) {
216 printk(KERN_ERR "INITRD: 0x%08lx+0x%08lx extends beyond " 215 printk(KERN_ERR "INITRD: 0x%08lx+0x%08lx extends beyond "
217 "physical memory - disabling initrd\n", 216 "physical memory - disabling initrd\n",
218 phys_initrd_start, phys_initrd_size); 217 phys_initrd_start, phys_initrd_size);
@@ -220,10 +219,10 @@ static int __init check_initrd(struct meminfo *mi)
220 } 219 }
221#endif 220#endif
222 221
223 return initrd_node; 222 return initrd;
224} 223}
225 224
226static void __init bootmem_init_node(int node, struct meminfo *mi, 225static void __init arm_bootmem_init(struct meminfo *mi,
227 unsigned long start_pfn, unsigned long end_pfn) 226 unsigned long start_pfn, unsigned long end_pfn)
228{ 227{
229 unsigned long boot_pfn; 228 unsigned long boot_pfn;
@@ -235,37 +234,36 @@ static void __init bootmem_init_node(int node, struct meminfo *mi,
235 * Allocate the bootmem bitmap page. 234 * Allocate the bootmem bitmap page.
236 */ 235 */
237 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn); 236 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
238 boot_pfn = find_bootmap_pfn(node, mi, boot_pages); 237 boot_pfn = find_bootmap_pfn(mi, boot_pages);
239 238
240 /* 239 /*
241 * Initialise the bootmem allocator for this node, handing the 240 * Initialise the bootmem allocator, handing the
242 * memory banks over to bootmem. 241 * memory banks over to bootmem.
243 */ 242 */
244 node_set_online(node); 243 node_set_online(0);
245 pgdat = NODE_DATA(node); 244 pgdat = NODE_DATA(0);
246 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn); 245 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn);
247 246
248 for_each_nodebank(i, mi, node) { 247 for_each_bank(i, mi) {
249 struct membank *bank = &mi->bank[i]; 248 struct membank *bank = &mi->bank[i];
250 if (!bank->highmem) 249 if (!bank->highmem)
251 free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank)); 250 free_bootmem(bank_phys_start(bank), bank_phys_size(bank));
252 } 251 }
253 252
254 /* 253 /*
255 * Reserve the bootmem bitmap for this node. 254 * Reserve the bootmem bitmap.
256 */ 255 */
257 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT, 256 reserve_bootmem(boot_pfn << PAGE_SHIFT,
258 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT); 257 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
259} 258}
260 259
261static void __init bootmem_reserve_initrd(int node) 260static void __init bootmem_reserve_initrd(void)
262{ 261{
263#ifdef CONFIG_BLK_DEV_INITRD 262#ifdef CONFIG_BLK_DEV_INITRD
264 pg_data_t *pgdat = NODE_DATA(node);
265 int res; 263 int res;
266 264
267 res = reserve_bootmem_node(pgdat, phys_initrd_start, 265 res = reserve_bootmem(phys_initrd_start,
268 phys_initrd_size, BOOTMEM_EXCLUSIVE); 266 phys_initrd_size, BOOTMEM_EXCLUSIVE);
269 267
270 if (res == 0) { 268 if (res == 0) {
271 initrd_start = __phys_to_virt(phys_initrd_start); 269 initrd_start = __phys_to_virt(phys_initrd_start);
@@ -279,23 +277,23 @@ static void __init bootmem_reserve_initrd(int node)
279#endif 277#endif
280} 278}
281 279
282static void __init bootmem_free_node(int node, struct meminfo *mi) 280static void __init arm_bootmem_free(struct meminfo *mi)
283{ 281{
284 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; 282 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
285 unsigned long min, max_low, max_high; 283 unsigned long min, max_low, max_high;
286 int i; 284 int i;
287 285
288 find_node_limits(node, mi, &min, &max_low, &max_high); 286 find_limits(mi, &min, &max_low, &max_high);
289 287
290 /* 288 /*
291 * initialise the zones within this node. 289 * initialise the zones.
292 */ 290 */
293 memset(zone_size, 0, sizeof(zone_size)); 291 memset(zone_size, 0, sizeof(zone_size));
294 292
295 /* 293 /*
296 * The size of this node has already been determined. If we need 294 * The memory size has already been determined. If we need
297 * to do anything fancy with the allocation of this memory to the 295 * to do anything fancy with the allocation of this memory
298 * zones, now is the time to do it. 296 * to the zones, now is the time to do it.
299 */ 297 */
300 zone_size[0] = max_low - min; 298 zone_size[0] = max_low - min;
301#ifdef CONFIG_HIGHMEM 299#ifdef CONFIG_HIGHMEM
@@ -303,11 +301,11 @@ static void __init bootmem_free_node(int node, struct meminfo *mi)
303#endif 301#endif
304 302
305 /* 303 /*
306 * For each bank in this node, calculate the size of the holes. 304 * Calculate the size of the holes.
307 * holes = node_size - sum(bank_sizes_in_node) 305 * holes = node_size - sum(bank_sizes)
308 */ 306 */
309 memcpy(zhole_size, zone_size, sizeof(zhole_size)); 307 memcpy(zhole_size, zone_size, sizeof(zhole_size));
310 for_each_nodebank(i, mi, node) { 308 for_each_bank(i, mi) {
311 int idx = 0; 309 int idx = 0;
312#ifdef CONFIG_HIGHMEM 310#ifdef CONFIG_HIGHMEM
313 if (mi->bank[i].highmem) 311 if (mi->bank[i].highmem)
@@ -320,9 +318,9 @@ static void __init bootmem_free_node(int node, struct meminfo *mi)
320 * Adjust the sizes according to any special requirements for 318 * Adjust the sizes according to any special requirements for
321 * this machine type. 319 * this machine type.
322 */ 320 */
323 arch_adjust_zones(node, zone_size, zhole_size); 321 arch_adjust_zones(0, zone_size, zhole_size);
324 322
325 free_area_init_node(node, zone_size, min, zhole_size); 323 free_area_init_node(0, zone_size, min, zhole_size);
326} 324}
327 325
328#ifndef CONFIG_SPARSEMEM 326#ifndef CONFIG_SPARSEMEM
@@ -346,16 +344,16 @@ int pfn_valid(unsigned long pfn)
346} 344}
347EXPORT_SYMBOL(pfn_valid); 345EXPORT_SYMBOL(pfn_valid);
348 346
349static void arm_memory_present(struct meminfo *mi, int node) 347static void arm_memory_present(struct meminfo *mi)
350{ 348{
351} 349}
352#else 350#else
353static void arm_memory_present(struct meminfo *mi, int node) 351static void arm_memory_present(struct meminfo *mi)
354{ 352{
355 int i; 353 int i;
356 for_each_nodebank(i, mi, node) { 354 for_each_bank(i, mi) {
357 struct membank *bank = &mi->bank[i]; 355 struct membank *bank = &mi->bank[i];
358 memory_present(node, bank_pfn_start(bank), bank_pfn_end(bank)); 356 memory_present(0, bank_pfn_start(bank), bank_pfn_end(bank));
359 } 357 }
360} 358}
361#endif 359#endif
@@ -364,55 +362,35 @@ void __init bootmem_init(void)
364{ 362{
365 struct meminfo *mi = &meminfo; 363 struct meminfo *mi = &meminfo;
366 unsigned long min, max_low, max_high; 364 unsigned long min, max_low, max_high;
367 int node, initrd_node; 365 int initrd;
368 366
369 /* 367 /*
370 * Locate which node contains the ramdisk image, if any. 368 * Locate the ramdisk image, if any.
371 */ 369 */
372 initrd_node = check_initrd(mi); 370 initrd = check_initrd(mi);
373 371
374 max_low = max_high = 0; 372 max_low = max_high = 0;
375 373
376 /* 374 find_limits(mi, &min, &max_low, &max_high);
377 * Run through each node initialising the bootmem allocator.
378 */
379 for_each_node(node) {
380 unsigned long node_low, node_high;
381
382 find_node_limits(node, mi, &min, &node_low, &node_high);
383 375
384 if (node_low > max_low) 376 arm_bootmem_init(mi, min, max_low);
385 max_low = node_low;
386 if (node_high > max_high)
387 max_high = node_high;
388 377
389 /* 378 /*
390 * If there is no memory in this node, ignore it. 379 * Reserve any special regions.
391 * (We can't have nodes which have no lowmem) 380 */
392 */ 381 reserve_special_regions();
393 if (node_low == 0)
394 continue;
395
396 bootmem_init_node(node, mi, min, node_low);
397
398 /*
399 * Reserve any special node zero regions.
400 */
401 if (node == 0)
402 reserve_node_zero(NODE_DATA(node));
403 382
404 /* 383 /*
405 * If the initrd is in this node, reserve its memory. 384 * If the initrd is present, reserve its memory.
406 */ 385 */
407 if (node == initrd_node) 386 if (initrd == 0)
408 bootmem_reserve_initrd(node); 387 bootmem_reserve_initrd();
409 388
410 /* 389 /*
411 * Sparsemem tries to allocate bootmem in memory_present(), 390 * Sparsemem tries to allocate bootmem in memory_present(),
412 * so must be done after the fixed reservations 391 * so must be done after the fixed reservations
413 */ 392 */
414 arm_memory_present(mi, node); 393 arm_memory_present(mi);
415 }
416 394
417 /* 395 /*
418 * sparse_init() needs the bootmem allocator up and running. 396 * sparse_init() needs the bootmem allocator up and running.
@@ -420,12 +398,11 @@ void __init bootmem_init(void)
420 sparse_init(); 398 sparse_init();
421 399
422 /* 400 /*
423 * Now free memory in each node - free_area_init_node needs 401 * Now free the memory - free_area_init_node needs
424 * the sparse mem_map arrays initialized by sparse_init() 402 * the sparse mem_map arrays initialized by sparse_init()
425 * for memmap_init_zone(), otherwise all PFNs are invalid. 403 * for memmap_init_zone(), otherwise all PFNs are invalid.
426 */ 404 */
427 for_each_node(node) 405 arm_bootmem_free(mi);
428 bootmem_free_node(node, mi);
429 406
430 high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1; 407 high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
431 408
@@ -460,7 +437,7 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s)
460} 437}
461 438
462static inline void 439static inline void
463free_memmap(int node, unsigned long start_pfn, unsigned long end_pfn) 440free_memmap(unsigned long start_pfn, unsigned long end_pfn)
464{ 441{
465 struct page *start_pg, *end_pg; 442 struct page *start_pg, *end_pg;
466 unsigned long pg, pgend; 443 unsigned long pg, pgend;
@@ -483,13 +460,13 @@ free_memmap(int node, unsigned long start_pfn, unsigned long end_pfn)
483 * free the section of the memmap array. 460 * free the section of the memmap array.
484 */ 461 */
485 if (pg < pgend) 462 if (pg < pgend)
486 free_bootmem_node(NODE_DATA(node), pg, pgend - pg); 463 free_bootmem(pg, pgend - pg);
487} 464}
488 465
489/* 466/*
490 * The mem_map array can get very big. Free the unused area of the memory map. 467 * The mem_map array can get very big. Free the unused area of the memory map.
491 */ 468 */
492static void __init free_unused_memmap_node(int node, struct meminfo *mi) 469static void __init free_unused_memmap(struct meminfo *mi)
493{ 470{
494 unsigned long bank_start, prev_bank_end = 0; 471 unsigned long bank_start, prev_bank_end = 0;
495 unsigned int i; 472 unsigned int i;
@@ -499,7 +476,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
499 * may not be the case, especially if the user has provided the 476 * may not be the case, especially if the user has provided the
500 * information on the command line. 477 * information on the command line.
501 */ 478 */
502 for_each_nodebank(i, mi, node) { 479 for_each_bank(i, mi) {
503 struct membank *bank = &mi->bank[i]; 480 struct membank *bank = &mi->bank[i];
504 481
505 bank_start = bank_pfn_start(bank); 482 bank_start = bank_pfn_start(bank);
@@ -514,7 +491,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
514 * between the current bank and the previous, free it. 491 * between the current bank and the previous, free it.
515 */ 492 */
516 if (prev_bank_end && prev_bank_end != bank_start) 493 if (prev_bank_end && prev_bank_end != bank_start)
517 free_memmap(node, prev_bank_end, bank_start); 494 free_memmap(prev_bank_end, bank_start);
518 495
519 prev_bank_end = bank_pfn_end(bank); 496 prev_bank_end = bank_pfn_end(bank);
520 } 497 }
@@ -528,21 +505,14 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
528void __init mem_init(void) 505void __init mem_init(void)
529{ 506{
530 unsigned long reserved_pages, free_pages; 507 unsigned long reserved_pages, free_pages;
531 int i, node; 508 int i;
532 509
533#ifndef CONFIG_DISCONTIGMEM
534 max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map; 510 max_mapnr = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
535#endif
536 511
537 /* this will put all unused low memory onto the freelists */ 512 /* this will put all unused low memory onto the freelists */
538 for_each_online_node(node) { 513 free_unused_memmap(&meminfo);
539 pg_data_t *pgdat = NODE_DATA(node);
540
541 free_unused_memmap_node(node, &meminfo);
542 514
543 if (pgdat->node_spanned_pages != 0) 515 totalram_pages += free_all_bootmem();
544 totalram_pages += free_all_bootmem_node(pgdat);
545 }
546 516
547#ifdef CONFIG_SA1111 517#ifdef CONFIG_SA1111
548 /* now that our DMA memory is actually so designated, we can free it */ 518 /* now that our DMA memory is actually so designated, we can free it */
@@ -552,39 +522,35 @@ void __init mem_init(void)
552 522
553#ifdef CONFIG_HIGHMEM 523#ifdef CONFIG_HIGHMEM
554 /* set highmem page free */ 524 /* set highmem page free */
555 for_each_online_node(node) { 525 for_each_bank (i, &meminfo) {
556 for_each_nodebank (i, &meminfo, node) { 526 unsigned long start = bank_pfn_start(&meminfo.bank[i]);
557 unsigned long start = bank_pfn_start(&meminfo.bank[i]); 527 unsigned long end = bank_pfn_end(&meminfo.bank[i]);
558 unsigned long end = bank_pfn_end(&meminfo.bank[i]); 528 if (start >= max_low_pfn + PHYS_PFN_OFFSET)
559 if (start >= max_low_pfn + PHYS_PFN_OFFSET) 529 totalhigh_pages += free_area(start, end, NULL);
560 totalhigh_pages += free_area(start, end, NULL);
561 }
562 } 530 }
563 totalram_pages += totalhigh_pages; 531 totalram_pages += totalhigh_pages;
564#endif 532#endif
565 533
566 reserved_pages = free_pages = 0; 534 reserved_pages = free_pages = 0;
567 535
568 for_each_online_node(node) { 536 for_each_bank(i, &meminfo) {
569 for_each_nodebank(i, &meminfo, node) { 537 struct membank *bank = &meminfo.bank[i];
570 struct membank *bank = &meminfo.bank[i]; 538 unsigned int pfn1, pfn2;
571 unsigned int pfn1, pfn2; 539 struct page *page, *end;
572 struct page *page, *end; 540
573 541 pfn1 = bank_pfn_start(bank);
574 pfn1 = bank_pfn_start(bank); 542 pfn2 = bank_pfn_end(bank);
575 pfn2 = bank_pfn_end(bank); 543
576 544 page = pfn_to_page(pfn1);
577 page = pfn_to_page(pfn1); 545 end = pfn_to_page(pfn2 - 1) + 1;
578 end = pfn_to_page(pfn2 - 1) + 1; 546
579 547 do {
580 do { 548 if (PageReserved(page))
581 if (PageReserved(page)) 549 reserved_pages++;
582 reserved_pages++; 550 else if (!page_count(page))
583 else if (!page_count(page)) 551 free_pages++;
584 free_pages++; 552 page++;
585 page++; 553 } while (page < end);
586 } while (page < end);
587 }
588 } 554 }
589 555
590 /* 556 /*