diff options
Diffstat (limited to 'arch/sparc64/mm/init.c')
-rw-r--r-- | arch/sparc64/mm/init.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index 4e821b3ecb03..a41df7bef035 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <asm/sstate.h> | 49 | #include <asm/sstate.h> |
50 | #include <asm/mdesc.h> | 50 | #include <asm/mdesc.h> |
51 | #include <asm/cpudata.h> | 51 | #include <asm/cpudata.h> |
52 | #include <asm/irq.h> | ||
52 | 53 | ||
53 | #define MAX_PHYS_ADDRESS (1UL << 42UL) | 54 | #define MAX_PHYS_ADDRESS (1UL << 42UL) |
54 | #define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) | 55 | #define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) |
@@ -795,6 +796,9 @@ static unsigned long nid_range(unsigned long start, unsigned long end, | |||
795 | start += PAGE_SIZE; | 796 | start += PAGE_SIZE; |
796 | } | 797 | } |
797 | 798 | ||
799 | if (start > end) | ||
800 | start = end; | ||
801 | |||
798 | return start; | 802 | return start; |
799 | } | 803 | } |
800 | #else | 804 | #else |
@@ -1722,8 +1726,7 @@ void __init paging_init(void) | |||
1722 | 1726 | ||
1723 | find_ramdisk(phys_base); | 1727 | find_ramdisk(phys_base); |
1724 | 1728 | ||
1725 | if (cmdline_memory_size) | 1729 | lmb_enforce_memory_limit(cmdline_memory_size); |
1726 | lmb_enforce_memory_limit(phys_base + cmdline_memory_size); | ||
1727 | 1730 | ||
1728 | lmb_analyze(); | 1731 | lmb_analyze(); |
1729 | lmb_dump_all(); | 1732 | lmb_dump_all(); |
@@ -1771,6 +1774,16 @@ void __init paging_init(void) | |||
1771 | if (tlb_type == hypervisor) | 1774 | if (tlb_type == hypervisor) |
1772 | sun4v_mdesc_init(); | 1775 | sun4v_mdesc_init(); |
1773 | 1776 | ||
1777 | /* Once the OF device tree and MDESC have been setup, we know | ||
1778 | * the list of possible cpus. Therefore we can allocate the | ||
1779 | * IRQ stacks. | ||
1780 | */ | ||
1781 | for_each_possible_cpu(i) { | ||
1782 | /* XXX Use node local allocations... XXX */ | ||
1783 | softirq_stack[i] = __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); | ||
1784 | hardirq_stack[i] = __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); | ||
1785 | } | ||
1786 | |||
1774 | /* Setup bootmem... */ | 1787 | /* Setup bootmem... */ |
1775 | last_valid_pfn = end_pfn = bootmem_init(phys_base); | 1788 | last_valid_pfn = end_pfn = bootmem_init(phys_base); |
1776 | 1789 | ||
@@ -1830,7 +1843,7 @@ static int pavail_rescan_ents __initdata; | |||
1830 | * memory list again, and make sure it provides at least as much | 1843 | * memory list again, and make sure it provides at least as much |
1831 | * memory as 'pavail' does. | 1844 | * memory as 'pavail' does. |
1832 | */ | 1845 | */ |
1833 | static void setup_valid_addr_bitmap_from_pavail(void) | 1846 | static void __init setup_valid_addr_bitmap_from_pavail(void) |
1834 | { | 1847 | { |
1835 | int i; | 1848 | int i; |
1836 | 1849 | ||
@@ -1950,6 +1963,15 @@ void __init mem_init(void) | |||
1950 | void free_initmem(void) | 1963 | void free_initmem(void) |
1951 | { | 1964 | { |
1952 | 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; | ||
1953 | 1975 | ||
1954 | /* | 1976 | /* |
1955 | * 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. |
@@ -1964,13 +1986,16 @@ void free_initmem(void) | |||
1964 | ((unsigned long) __va(kern_base)) - | 1986 | ((unsigned long) __va(kern_base)) - |
1965 | ((unsigned long) KERNBASE)); | 1987 | ((unsigned long) KERNBASE)); |
1966 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); | 1988 | memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE); |
1967 | p = virt_to_page(page); | ||
1968 | 1989 | ||
1969 | ClearPageReserved(p); | 1990 | if (do_free) { |
1970 | init_page_count(p); | 1991 | p = virt_to_page(page); |
1971 | __free_page(p); | 1992 | |
1972 | num_physpages++; | 1993 | ClearPageReserved(p); |
1973 | totalram_pages++; | 1994 | init_page_count(p); |
1995 | __free_page(p); | ||
1996 | num_physpages++; | ||
1997 | totalram_pages++; | ||
1998 | } | ||
1974 | } | 1999 | } |
1975 | } | 2000 | } |
1976 | 2001 | ||