From: Mike Rapoport <rppt@xxxxxxxxxxxxx> Enable SPARSEMEM support for systems with !SINGLE_MEMORY_CHUNK. With SPARSEMEM there is a single node for the entire physical memory and to cope with holes in the physical address space it is divided to sections of up to 4M or 16M, depending on CONFIG_MEMORY_LIMIT_1G. Each section has it's own memory map which size depends on actual populated memory. The DISCONTIGMEM is marked BROKEN and will be removed in a couple of releases. Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx> --- arch/m68k/Kconfig.cpu | 17 +++++++++++++++++ arch/m68k/mm/motorola.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu index 3af0fca03803..4e8a124741d6 100644 --- a/arch/m68k/Kconfig.cpu +++ b/arch/m68k/Kconfig.cpu @@ -21,6 +21,7 @@ choice config M68KCLASSIC bool "Classic M68K CPU family support" select NEED_MULTIPLE_NODES if DISCONTIGMEM + select SPARSEMEM_STATIC if SPARSEMEM config COLDFIRE bool "Coldfire CPU family support" @@ -380,9 +381,25 @@ config SINGLE_MEMORY_CHUNK purposes. This will save a few bytes kernel size and may speed up some operations. Say N if not sure. +config MEMORY_LIMIT_1G + bool "Limit maximal physical memory to 1G" + depends on MMU && !SINGLE_MEMORY_CHUNK + help + Limit the physical memory addressable by the kernel to 1G. + On systems that have several chunks of physical memory and the + hole between these chunks is less than 16M this will prevent + wasting memory on empty memory map. Say N if not sure. + config ARCH_DISCONTIGMEM_ENABLE + def_bool no + depends on BROKEN && MMU && !SINGLE_MEMORY_CHUNK + +config ARCH_SPARSEMEM_ENABLE def_bool MMU && !SINGLE_MEMORY_CHUNK +config HAVE_ARCH_PFN_VALID + def_bool SPARSEMEM + config 060_WRITETHROUGH bool "Use write-through caching for 68060 supervisor accesses" depends on ADVANCED && M68060 diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index 2bb006bdc31c..6a513b9c919d 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -384,6 +384,39 @@ static void __init map_node(int node) #endif } +#ifdef CONFIG_SPARSEMEM +static void mem_model_init(void) +{ + m68k_setup_node(0); + node_set_state(0, N_NORMAL_MEMORY); + + /* + * Make sure the memory map is allocated from top of the + * memory. + * Otherwise for systems with both ST-RAM and FastRam, ST-RAM + * gets filled with the memory map leaving no space for + * framebuffer + */ + memblock_set_bottom_up(false); + memblocks_present(); + sparse_init(); + memblock_set_bottom_up(true); +} +#else +static void mem_model_init(void) +{ + unsigned long zones_size[MAX_NR_ZONES] = { 0, }; + int i; + + for (i = 0; i < m68k_num_memory; i++) { + m68k_setup_node(i); + if (node_present_pages(i)) + node_set_state(i, N_NORMAL_MEMORY); + } +} +#endif + + /* * paging_init() continues the virtual memory environment setup which * was begun by the code in arch/head.S. @@ -449,10 +482,8 @@ void __init paging_init(void) */ memblock_set_bottom_up(true); - for (i = 0; i < m68k_num_memory; i++) { - m68k_setup_node(i); + for (i = 0; i < m68k_num_memory; i++) map_node(i); - } flush_tlb_all(); @@ -477,6 +508,8 @@ void __init paging_init(void) if (node_present_pages(i)) node_set_state(i, N_NORMAL_MEMORY); + mem_model_init(); + max_zone_pfn[ZONE_DMA] = memblock_end_of_DRAM(); free_area_init(max_zone_pfn); } -- 2.26.2