Commit 1de481de authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  lmb: Fix reserved region handling in lmb_enforce_memory_limit().
  sparc64: Fix cmdline_memory_size handling bugs.
  sparc64: Fix overshoot in nid_range().
parents abcf4241 ebb1951d
...@@ -796,6 +796,9 @@ static unsigned long nid_range(unsigned long start, unsigned long end, ...@@ -796,6 +796,9 @@ static unsigned long nid_range(unsigned long start, unsigned long end,
start += PAGE_SIZE; start += PAGE_SIZE;
} }
if (start > end)
start = end;
return start; return start;
} }
#else #else
...@@ -1723,8 +1726,7 @@ void __init paging_init(void) ...@@ -1723,8 +1726,7 @@ void __init paging_init(void)
find_ramdisk(phys_base); find_ramdisk(phys_base);
if (cmdline_memory_size) lmb_enforce_memory_limit(cmdline_memory_size);
lmb_enforce_memory_limit(phys_base + cmdline_memory_size);
lmb_analyze(); lmb_analyze();
lmb_dump_all(); lmb_dump_all();
...@@ -1961,6 +1963,15 @@ void __init mem_init(void) ...@@ -1961,6 +1963,15 @@ void __init mem_init(void)
void free_initmem(void) void free_initmem(void)
{ {
unsigned long addr, initend; unsigned long addr, initend;
int do_free = 1;
/* If the physical memory maps were trimmed by kernel command
* line options, don't even try freeing this initmem stuff up.
* The kernel image could have been in the trimmed out region
* and if so the freeing below will free invalid page structs.
*/
if (cmdline_memory_size)
do_free = 0;
/* /*
* The init section is aligned to 8k in vmlinux.lds. Page align for >8k pagesizes. * The init section is aligned to 8k in vmlinux.lds. Page align for >8k pagesizes.
...@@ -1975,13 +1986,16 @@ void free_initmem(void) ...@@ -1975,13 +1986,16 @@ void free_initmem(void)
((unsigned long) __va(kern_base)) - ((unsigned long) __va(kern_base)) -
((unsigned long) KERNBASE)); ((unsigned long) KERNBASE));
memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
p = virt_to_page(page);
ClearPageReserved(p); if (do_free) {
init_page_count(p); p = virt_to_page(page);
__free_page(p);
num_physpages++; ClearPageReserved(p);
totalram_pages++; init_page_count(p);
__free_page(p);
num_physpages++;
totalram_pages++;
}
} }
} }
......
...@@ -462,6 +462,8 @@ void __init lmb_enforce_memory_limit(u64 memory_limit) ...@@ -462,6 +462,8 @@ void __init lmb_enforce_memory_limit(u64 memory_limit)
if (lmb.memory.region[0].size < lmb.rmo_size) if (lmb.memory.region[0].size < lmb.rmo_size)
lmb.rmo_size = lmb.memory.region[0].size; lmb.rmo_size = lmb.memory.region[0].size;
memory_limit = lmb_end_of_DRAM();
/* And truncate any reserves above the limit also. */ /* And truncate any reserves above the limit also. */
for (i = 0; i < lmb.reserved.cnt; i++) { for (i = 0; i < lmb.reserved.cnt; i++) {
p = &lmb.reserved.region[i]; p = &lmb.reserved.region[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment