[MIPS] Fix sparsemem support. Move memory_present() in arch/mips/kernel/setup.c. When using sparsemem extreme, this function does an allocate for bootmem. This would always fail since init_bootmem hasn't been called yet. Move memory_present after free_bootmem. This only marks actual memory ranges as present instead of the entire address space. Signed-off-by: Chad Reese <creese@caviumnetworks.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by Chad Reese and committed by Ralf Baechle b1c231f5 ecf52d3c

+18 -3
+1 -2
arch/mips/kernel/setup.c
··· 355 } 356 #endif 357 358 - memory_present(0, first_usable_pfn, max_low_pfn); 359 - 360 /* Initialize the boot-time allocator with low memory only. */ 361 bootmap_size = init_bootmem(first_usable_pfn, max_low_pfn); 362 ··· 408 409 /* Register lowmem ranges */ 410 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); 411 } 412 413 /* Reserve the bootmap memory. */
··· 355 } 356 #endif 357 358 /* Initialize the boot-time allocator with low memory only. */ 359 bootmap_size = init_bootmem(first_usable_pfn, max_low_pfn); 360 ··· 410 411 /* Register lowmem ranges */ 412 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); 413 + memory_present(0, curr_pfn, curr_pfn + size - 1); 414 } 415 416 /* Reserve the bootmap memory. */
+1 -1
arch/mips/mm/init.c
··· 227 for (tmp = 0; tmp < max_low_pfn; tmp++) 228 if (page_is_ram(tmp)) { 229 ram++; 230 - if (PageReserved(mem_map+tmp)) 231 reservedpages++; 232 } 233
··· 227 for (tmp = 0; tmp < max_low_pfn; tmp++) 228 if (page_is_ram(tmp)) { 229 ram++; 230 + if (PageReserved(pfn_to_page(tmp))) 231 reservedpages++; 232 } 233
+2
include/asm-mips/page.h
··· 139 140 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 141 142 #ifndef CONFIG_NEED_MULTIPLE_NODES 143 #define pfn_valid(pfn) ((pfn) < max_mapnr) 144 #endif 145 146 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
··· 139 140 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 141 142 + #ifndef CONFIG_SPARSEMEM 143 #ifndef CONFIG_NEED_MULTIPLE_NODES 144 #define pfn_valid(pfn) ((pfn) < max_mapnr) 145 + #endif 146 #endif 147 148 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
+14
include/asm-mips/sparsemem.h
···
··· 1 + #ifndef _MIPS_SPARSEMEM_H 2 + #define _MIPS_SPARSEMEM_H 3 + #ifdef CONFIG_SPARSEMEM 4 + 5 + /* 6 + * SECTION_SIZE_BITS 2^N: how big each section will be 7 + * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space 8 + */ 9 + #define SECTION_SIZE_BITS 28 10 + #define MAX_PHYSMEM_BITS 35 11 + 12 + #endif /* CONFIG_SPARSEMEM */ 13 + #endif /* _MIPS_SPARSEMEM_H */ 14 +