@@ -83,6 +83,9 @@ config ARCH_SPARSEMEM_ENABLE
config ARCH_SELECT_MEMORY_MODEL
def_bool ARCH_SPARSEMEM_ENABLE
+config ARCH_ENABLE_MEMORY_HOTPLUG
+ def_bool y
+
config STACKTRACE_SUPPORT
def_bool y
@@ -238,3 +238,30 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
return vmemmap_populate_basepages(start, end, node);
}
#endif
+
+#ifdef CONFIG_MEMORY_HOTPLUG
+void vmemmap_free(unsigned long start, unsigned long end,
+ struct vmem_altmap *altmap)
+{
+}
+
+int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
+ bool want_memblock)
+{
+ unsigned long start_pfn = start >> PAGE_SHIFT;
+ unsigned long nr_pages = size >> PAGE_SHIFT;
+ int ret;
+
+ if ((start + size) > -va_pa_offset) {
+ pr_err("Cannot hotplug memory from %08llx to %08llx as it doesn't fall within the linear mapping\n",
+ start, start + size);
+ return -EFAULT;
+ }
+
+ ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ WARN_ON_ONCE(ret);
+
+ return ret;
+}
+
+#endif
In order to define ARCH_ENABLE_MEMORY_HOTPLUG we need to implement arch_add_memory() and vmemmap_free(). arch_add_memory() is very similar to the x86 versions except we don't need to fuss with the mapping as we've already mapped the entire linear region in riscv. For now, vmemmap_free() is empty which is similar to other arches that don't implement hot remove. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Anup Patel <anup.patel@wdc.com> Cc: Atish Patra <atish.patra@wdc.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Zong Li <zong@andestech.com> Cc: Guo Ren <ren_guo@c-sky.com> --- arch/riscv/Kconfig | 3 +++ arch/riscv/mm/init.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)