diff options
author | Robin Getz <robin.getz@analog.com> | 2009-06-26 08:52:46 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-09-16 21:28:54 -0400 |
commit | 2f812c0bd5ee1d9c145fb1c3523ecdf45e05f8ce (patch) | |
tree | 9c7150c628ec5db78ef6be5d940d48e2f5e58eaa /arch/blackfin | |
parent | a769094061289453e8c331d7746e0e26f5d1e38b (diff) |
Blackfin: clean up early memory setup code
Remove code duplication, and only print out memory warnings when they are
an actual problem.
Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/kernel/setup.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 6225edae488e..6dbf21930a91 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c | |||
@@ -511,6 +511,7 @@ static __init void memory_setup(void) | |||
511 | #ifdef CONFIG_MTD_UCLINUX | 511 | #ifdef CONFIG_MTD_UCLINUX |
512 | unsigned long mtd_phys = 0; | 512 | unsigned long mtd_phys = 0; |
513 | #endif | 513 | #endif |
514 | unsigned long max_mem; | ||
514 | 515 | ||
515 | _rambase = (unsigned long)_stext; | 516 | _rambase = (unsigned long)_stext; |
516 | _ramstart = (unsigned long)_end; | 517 | _ramstart = (unsigned long)_end; |
@@ -520,7 +521,22 @@ static __init void memory_setup(void) | |||
520 | panic("DMA region exceeds memory limit: %lu.", | 521 | panic("DMA region exceeds memory limit: %lu.", |
521 | _ramend - _ramstart); | 522 | _ramend - _ramstart); |
522 | } | 523 | } |
523 | memory_end = _ramend - DMA_UNCACHED_REGION; | 524 | max_mem = memory_end = _ramend - DMA_UNCACHED_REGION; |
525 | |||
526 | #if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263) | ||
527 | /* Due to a Hardware Anomaly we need to limit the size of usable | ||
528 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on | ||
529 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception | ||
530 | */ | ||
531 | # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) | ||
532 | if (max_mem >= 56 * 1024 * 1024) | ||
533 | max_mem = 56 * 1024 * 1024; | ||
534 | # else | ||
535 | if (max_mem >= 60 * 1024 * 1024) | ||
536 | max_mem = 60 * 1024 * 1024; | ||
537 | # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ | ||
538 | #endif /* ANOMALY_05000263 */ | ||
539 | |||
524 | 540 | ||
525 | #ifdef CONFIG_MPU | 541 | #ifdef CONFIG_MPU |
526 | /* Round up to multiple of 4MB */ | 542 | /* Round up to multiple of 4MB */ |
@@ -549,22 +565,16 @@ static __init void memory_setup(void) | |||
549 | 565 | ||
550 | # if defined(CONFIG_ROMFS_FS) | 566 | # if defined(CONFIG_ROMFS_FS) |
551 | if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0 | 567 | if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0 |
552 | && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) | 568 | && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) { |
553 | mtd_size = | 569 | mtd_size = |
554 | PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2])); | 570 | PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2])); |
555 | # if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263) | 571 | |
556 | /* Due to a Hardware Anomaly we need to limit the size of usable | 572 | /* ROM_FS is XIP, so if we found it, we need to limit memory */ |
557 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on | 573 | if (memory_end > max_mem) { |
558 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception | 574 | pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n", max_mem >> 20); |
559 | */ | 575 | memory_end = max_mem; |
560 | # if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) | 576 | } |
561 | if (memory_end >= 56 * 1024 * 1024) | 577 | } |
562 | memory_end = 56 * 1024 * 1024; | ||
563 | # else | ||
564 | if (memory_end >= 60 * 1024 * 1024) | ||
565 | memory_end = 60 * 1024 * 1024; | ||
566 | # endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ | ||
567 | # endif /* ANOMALY_05000263 */ | ||
568 | # endif /* CONFIG_ROMFS_FS */ | 578 | # endif /* CONFIG_ROMFS_FS */ |
569 | 579 | ||
570 | /* Since the default MTD_UCLINUX has no magic number, we just blindly | 580 | /* Since the default MTD_UCLINUX has no magic number, we just blindly |
@@ -586,20 +596,14 @@ static __init void memory_setup(void) | |||
586 | } | 596 | } |
587 | #endif /* CONFIG_MTD_UCLINUX */ | 597 | #endif /* CONFIG_MTD_UCLINUX */ |
588 | 598 | ||
589 | #if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263) | 599 | /* We need lo limit memory, since everything could have a text section |
590 | /* Due to a Hardware Anomaly we need to limit the size of usable | 600 | * of userspace in it, and expose anomaly 05000263. If the anomaly |
591 | * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on | 601 | * doesn't exist, or we don't need to - then dont. |
592 | * 05000263 - Hardware loop corrupted when taking an ICPLB exception | ||
593 | */ | 602 | */ |
594 | #if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) | 603 | if (memory_end > max_mem) { |
595 | if (memory_end >= 56 * 1024 * 1024) | 604 | pr_info("Limiting kernel memory to %liMB due to anomaly 05000263\n", max_mem >> 20); |
596 | memory_end = 56 * 1024 * 1024; | 605 | memory_end = max_mem; |
597 | #else | 606 | } |
598 | if (memory_end >= 60 * 1024 * 1024) | ||
599 | memory_end = 60 * 1024 * 1024; | ||
600 | #endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ | ||
601 | printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20); | ||
602 | #endif /* ANOMALY_05000263 */ | ||
603 | 607 | ||
604 | #ifdef CONFIG_MPU | 608 | #ifdef CONFIG_MPU |
605 | page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32; | 609 | page_mask_nelts = ((_ramend >> PAGE_SHIFT) + 31) / 32; |