[RFC/RFT PATCH 3/3] m68k/mm: switch from DISCONTIGMEM to SPARSEMEM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 16M.

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             |  8 +++++
 arch/m68k/include/asm/sparsemem.h |  8 +++++
 arch/m68k/mm/motorola.c           | 64 ++++++++++++++++++++++++++++++++-------
 3 files changed, 69 insertions(+), 11 deletions(-)
 create mode 100644 arch/m68k/include/asm/sparsemem.h

diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 6542e7a5997b..1b056d24c554 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"
@@ -381,8 +382,15 @@ config SINGLE_MEMORY_CHUNK
 	  some operations.  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/include/asm/sparsemem.h b/arch/m68k/include/asm/sparsemem.h
new file mode 100644
index 000000000000..6645a6420af9
--- /dev/null
+++ b/arch/m68k/include/asm/sparsemem.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_M68K_SPARSEMEM_H_
+#define _ASM_M68K_SPARSEMEM_H_
+
+#define MAX_PHYSMEM_BITS	32
+#define SECTION_SIZE_BITS	24
+
+#endif /* _ASM_M68K_SPARSEMEM_H_ */
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 356601bf96d9..87d09942be5c 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -207,13 +207,63 @@ static void __init map_node(int node)
 #endif
 }
 
+#ifdef CONFIG_SPARSEMEM
+static void m68k_free_area_init(unsigned long max_addr)
+{
+	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+	unsigned long zholes_size[MAX_NR_ZONES] = { 0, };
+	unsigned long holes_size;
+
+	m68k_setup_node(0);
+
+	/*
+	 * 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);
+
+	zones_size[ZONE_DMA] = max_addr >> PAGE_SHIFT;
+	if (m68k_num_memory > 1) {
+		holes_size = max_addr - memblock_phys_mem_size();
+		zholes_size[ZONE_DMA] = holes_size >> PAGE_SHIFT;
+	}
+
+	free_area_init_node(0, zones_size,
+			    m68k_memory[0].addr >> PAGE_SHIFT, zholes_size);
+
+	if (node_present_pages(0))
+		node_set_state(0, N_NORMAL_MEMORY);
+}
+
+#else
+static void m68k_free_area_init(unsigned long max_addr)
+{
+	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+	int i;
+
+	for (i = 0; i < m68k_num_memory; i++) {
+		m68k_setup_node(i);
+		zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
+		free_area_init_node(i, zones_size,
+				    m68k_memory[i].addr >> PAGE_SHIFT, NULL);
+		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.
  */
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
 	unsigned long min_addr, max_addr;
 	unsigned long addr;
 	int i;
@@ -272,10 +322,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();
 
@@ -296,12 +344,6 @@ void __init paging_init(void)
 #ifdef DEBUG
 	printk ("before free_area_init\n");
 #endif
-	for (i = 0; i < m68k_num_memory; i++) {
-		zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
-		free_area_init_node(i, zones_size,
-				    m68k_memory[i].addr >> PAGE_SHIFT, NULL);
-		if (node_present_pages(i))
-			node_set_state(i, N_NORMAL_MEMORY);
-	}
+	m68k_free_area_init(max_addr);
 }
 
-- 
2.7.4




[Index of Archives]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux