aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm/mmu.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2008-10-06 13:24:40 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-11-28 10:36:44 -0500
commit4b5f32cee0cce7b9783ced5cbeabd17aa53c51fb (patch)
tree95d3f2af07733cf70419ea5c3ae1100be2533197 /arch/arm/mm/mmu.c
parent43ae286b7d4d8c4983bc263ef2e3cccc10dedb2b (diff)
[ARM] rationalize memory configuration code some more
Currently there are two instances of struct meminfo: one in kernel/setup.c marked __initdata, and another in mm/init.c with permanent storage. Let's keep only the later to directly populate the permanent version from arm_add_memory(). Also move common validation tests between the MMU and non-MMU cases into arm_add_memory() to remove some duplication. Protection against overflowing the membank array is also moved in there in order to cover the kernel cmdline parsing path as well. Signed-off-by: Nicolas Pitre <nico@marvell.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/mmu.c')
-rw-r--r--arch/arm/mm/mmu.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 7f36c825718d..6870805c31dd 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -654,13 +654,6 @@ __early_param("vmalloc=", early_vmalloc);
654static int __init check_membank_valid(struct membank *mb) 654static int __init check_membank_valid(struct membank *mb)
655{ 655{
656 /* 656 /*
657 * Check whether this memory region has non-zero size or
658 * invalid node number.
659 */
660 if (mb->size == 0 || mb->node >= MAX_NUMNODES)
661 return 0;
662
663 /*
664 * Check whether this memory region would entirely overlap 657 * Check whether this memory region would entirely overlap
665 * the vmalloc area. 658 * the vmalloc area.
666 */ 659 */
@@ -689,18 +682,18 @@ static int __init check_membank_valid(struct membank *mb)
689 return 1; 682 return 1;
690} 683}
691 684
692static void __init sanity_check_meminfo(struct meminfo *mi) 685static void __init sanity_check_meminfo(void)
693{ 686{
694 int i, j; 687 int i, j;
695 688
696 for (i = 0, j = 0; i < mi->nr_banks; i++) { 689 for (i = 0, j = 0; i < meminfo.nr_banks; i++) {
697 if (check_membank_valid(&mi->bank[i])) 690 if (check_membank_valid(&meminfo.bank[i]))
698 mi->bank[j++] = mi->bank[i]; 691 meminfo.bank[j++] = meminfo.bank[i];
699 } 692 }
700 mi->nr_banks = j; 693 meminfo.nr_banks = j;
701} 694}
702 695
703static inline void prepare_page_table(struct meminfo *mi) 696static inline void prepare_page_table(void)
704{ 697{
705 unsigned long addr; 698 unsigned long addr;
706 699
@@ -721,7 +714,7 @@ static inline void prepare_page_table(struct meminfo *mi)
721 * Clear out all the kernel space mappings, except for the first 714 * Clear out all the kernel space mappings, except for the first
722 * memory bank, up to the end of the vmalloc region. 715 * memory bank, up to the end of the vmalloc region.
723 */ 716 */
724 for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size); 717 for (addr = __phys_to_virt(bank_phys_end(&meminfo.bank[0]));
725 addr < VMALLOC_END; addr += PGDIR_SIZE) 718 addr < VMALLOC_END; addr += PGDIR_SIZE)
726 pmd_clear(pmd_off_k(addr)); 719 pmd_clear(pmd_off_k(addr));
727} 720}
@@ -880,14 +873,14 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
880 * paging_init() sets up the page tables, initialises the zone memory 873 * paging_init() sets up the page tables, initialises the zone memory
881 * maps, and sets up the zero page, bad page and bad page tables. 874 * maps, and sets up the zero page, bad page and bad page tables.
882 */ 875 */
883void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc) 876void __init paging_init(struct machine_desc *mdesc)
884{ 877{
885 void *zero_page; 878 void *zero_page;
886 879
887 build_mem_type_table(); 880 build_mem_type_table();
888 sanity_check_meminfo(mi); 881 sanity_check_meminfo();
889 prepare_page_table(mi); 882 prepare_page_table();
890 bootmem_init(mi); 883 bootmem_init();
891 devicemaps_init(mdesc); 884 devicemaps_init(mdesc);
892 885
893 top_pmd = pmd_off_k(0xffff0000); 886 top_pmd = pmd_off_k(0xffff0000);