diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-18 15:03:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-18 15:03:23 -0400 |
commit | 1de481ded98d1d48e2a4102a5aa549e3c4d18ee3 (patch) | |
tree | defeccfeac5a86c349f4cac61a8689f3597d3201 | |
parent | abcf42419d24416175ea8bc9a502d833f64955d1 (diff) | |
parent | ebb1951d3624c2f961abe676645c13e5a1145569 (diff) |
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().
-rw-r--r-- | arch/sparc64/mm/init.c | 30 | ||||
-rw-r--r-- | lib/lmb.c | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index 217de3ea29e8..b4aeb0f696dc 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
@@ -796,6 +796,9 @@ static unsigned long nid_range(unsigned long start, unsigned long end, | |||
796 | start += PAGE_SIZE; | 796 | start += PAGE_SIZE; |
797 | } | 797 | } |
798 | 798 | ||
799 | if (start > end) | ||
800 | start = end; | ||
801 | |||
799 | return start; | 802 | return start; |
800 | } | 803 | } |
801 | #else | 804 | #else |
@@ -1723,8 +1726,7 @@ void __init paging_init(void) | |||
1723 | 1726 | ||
1724 | find_ramdisk(phys_base); | 1727 | find_ramdisk(phys_base); |
1725 | 1728 | ||
1726 | if (cmdline_memory_size) | 1729 | lmb_enforce_memory_limit(cmdline_memory_size); |
1727 | lmb_enforce_memory_limit(phys_base + cmdline_memory_size); | ||
1728 | 1730 | ||
1729 | lmb_analyze(); | 1731 | lmb_analyze(); |
1730 | lmb_dump_all(); | 1732 | lmb_dump_all(); |
@@ -1961,6 +1963,15 @@ void __init mem_init(void) | |||
1961 | void free_initmem(void) | 1963 | void free_initmem(void) |
1962 | { | 1964 | { |
1963 | unsigned long addr, initend; | 1965 | unsigned long addr, initend; |
1966 | int do_free = 1; | ||
1967 | |||
1968 | /* If the physical memory maps were trimmed by kernel command | ||
1969 | * line options, don't even try freeing this initmem stuff up. | ||
1970 | * The kernel image could have been in the trimmed out region | ||
1971 | * and if so the freeing below will free invalid page structs. | ||
1972 | */ | ||
1973 | if (cmdline_memory_size) | ||
1974 | do_free = 0; | ||
1964 | 1975 | ||
1965 | /* | 1976 | /* |
1966 | * The init section is aligned to 8k in vmlinux.lds. Page align for >8k pagesizes. | 1977 | * The init section is aligned to 8k in vmlinux.lds. Page align for >8k pagesizes. |
@@ -1975,13 +1986,16 @@ void free_initmem(void) | |||
1975 | ((unsigned long) __va(kern_base)) - | 1986 | ((unsigned long) __va(kern_base)) - |
1976 | ((unsigned long) KERNBASE)); | 1987 | ((unsigned long) KERNBASE)); |
1977 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | 1988 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); |
1978 | p = virt_to_page(page); | ||
1979 | 1989 | ||
1980 | ClearPageReserved(p); | 1990 | if (do_free) { |
1981 | init_page_count(p); | 1991 | p = virt_to_page(page); |
1982 | __free_page(p); | 1992 | |
1983 | num_physpages++; | 1993 | ClearPageReserved(p); |
1984 | totalram_pages++; | 1994 | init_page_count(p); |
1995 | __free_page(p); | ||
1996 | num_physpages++; | ||
1997 | totalram_pages++; | ||
1998 | } | ||
1985 | } | 1999 | } |
1986 | } | 2000 | } |
1987 | 2001 | ||
@@ -462,6 +462,8 @@ void __init lmb_enforce_memory_limit(u64 memory_limit) | |||
462 | if (lmb.memory.region[0].size < lmb.rmo_size) | 462 | if (lmb.memory.region[0].size < lmb.rmo_size) |
463 | lmb.rmo_size = lmb.memory.region[0].size; | 463 | lmb.rmo_size = lmb.memory.region[0].size; |
464 | 464 | ||
465 | memory_limit = lmb_end_of_DRAM(); | ||
466 | |||
465 | /* And truncate any reserves above the limit also. */ | 467 | /* And truncate any reserves above the limit also. */ |
466 | for (i = 0; i < lmb.reserved.cnt; i++) { | 468 | for (i = 0; i < lmb.reserved.cnt; i++) { |
467 | p = &lmb.reserved.region[i]; | 469 | p = &lmb.reserved.region[i]; |