[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 355 } 356 356 #endif 357 357 358 - memory_present(0, first_usable_pfn, max_low_pfn); 359 - 360 358 /* Initialize the boot-time allocator with low memory only. */ 361 359 bootmap_size = init_bootmem(first_usable_pfn, max_low_pfn); 362 360 ··· 408 410 409 411 /* Register lowmem ranges */ 410 412 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); 413 + memory_present(0, curr_pfn, curr_pfn + size - 1); 411 414 } 412 415 413 416 /* Reserve the bootmap memory. */
+1 -1
arch/mips/mm/init.c
··· 227 227 for (tmp = 0; tmp < max_low_pfn; tmp++) 228 228 if (page_is_ram(tmp)) { 229 229 ram++; 230 - if (PageReserved(mem_map+tmp)) 230 + if (PageReserved(pfn_to_page(tmp))) 231 231 reservedpages++; 232 232 } 233 233
+2
include/asm-mips/page.h
··· 139 139 140 140 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 141 141 142 + #ifndef CONFIG_SPARSEMEM 142 143 #ifndef CONFIG_NEED_MULTIPLE_NODES 143 144 #define pfn_valid(pfn) ((pfn) < max_mapnr) 145 + #endif 144 146 #endif 145 147 146 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 +