[RFC/RFT PATCH v3 1/1] arc: add sparsemem support

From: Mike Rapoport
Date: Mon Aug 31 2020 - 02:47:29 EST


From: Mike Rapoport <rppt@xxxxxxxxxxxxx>

Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
---
arch/arc/Kconfig | 10 ++++++++++
arch/arc/include/asm/sparsemem.h | 13 +++++++++++++
arch/arc/mm/init.c | 6 +++++-
3 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 arch/arc/include/asm/sparsemem.h

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ba00c4e1e1c2..2e3c02e9b657 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -48,6 +48,7 @@ config ARC
select PCI_SYSCALL if PCI
select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING
select HAVE_ARCH_JUMP_LABEL if ISA_ARCV2 && !CPU_ENDIAN_BE32
+ select SPARSEMEM_STATIC if SPARSEMEM

config ARCH_HAS_CACHE_LINE_SIZE
def_bool y
@@ -67,8 +68,15 @@ config GENERIC_CSUM
config ARCH_DISCONTIGMEM_ENABLE
def_bool n

+config ARCH_SPARSEMEM_ENABLE
+ def_bool n
+
config ARCH_FLATMEM_ENABLE
def_bool y
+ depends on !HIGHMEM
+
+config ARCH_SELECT_MEMORY_MODEL
+ def_bool n

config MMU
def_bool y
@@ -508,6 +516,8 @@ config LINUX_RAM_BASE
config HIGHMEM
bool "High Memory Support"
select ARCH_DISCONTIGMEM_ENABLE
+ select ARCH_SPARSEMEM_ENABLE
+ select ARCH_SELECT_MEMORY_MODEL
help
With ARC 2G:2G address split, only upper 2G is directly addressable by
kernel. Enable this to potentially allow access to rest of 2G and PAE
diff --git a/arch/arc/include/asm/sparsemem.h b/arch/arc/include/asm/sparsemem.h
new file mode 100644
index 000000000000..1156b9934c74
--- /dev/null
+++ b/arch/arc/include/asm/sparsemem.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_ARC_SPARSEMEM_H
+#define _ASM_ARC_SPARSEMEM_H
+
+#ifdef CONFIG_ARC_HAS_PAE40
+#define MAX_PHYSMEM_BITS 40
+#define SECTION_SIZE_BITS 32
+#else
+#define MAX_PHYSMEM_BITS 32
+#define SECTION_SIZE_BITS 27
+#endif
+
+#endif /* _ASM_ARC_SPARSEMEM_H */
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 3a35b82a718e..60e3808a4e19 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -153,7 +153,11 @@ void __init setup_arch_memory(void)
* DISCONTIGMEM in turns requires multiple nodes. node 0 above is
* populated with normal memory zone while node 1 only has highmem
*/
+#ifdef CONFIG_DISCONTIGMEM
node_set_online(1);
+#elif defined(CONFIG_SPARSEMEM)
+ sparse_init();
+#endif

min_high_pfn = PFN_DOWN(high_mem_start);
max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
@@ -162,7 +166,7 @@ void __init setup_arch_memory(void)

high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
kmap_init();
-#endif
+#endif /* CONFIG_HIGHMEM */

free_area_init(max_zone_pfn);
}
--
2.26.2