mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Cc: Stephen Bates <sbates@raithlin.com>,
	Palmer Dabbelt <palmer@sifive.com>,
	Christoph Hellwig <hch@lst.de>, Albert Ou <aou@eecs.berkeley.edu>,
	Logan Gunthorpe <logang@deltatee.com>,
	Mike Rapoport <rppt@linux.vnet.ibm.com>,
	Anup Patel <anup.patel@wdc.com>,
	Atish Patra <atish.patra@wdc.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Zong Li <zong@andestech.com>, Guo Ren <ren_guo@c-sky.com>
Subject: [PATCH 5/7] RISC-V: Implement memory hotplug
Date: Wed, 27 Mar 2019 15:36:41 -0600	[thread overview]
Message-ID: <20190327213643.23789-6-logang@deltatee.com> (raw)
In-Reply-To: <20190327213643.23789-1-logang@deltatee.com>

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(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index d21e6a12e8b6..9477214a00e7 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -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
 
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 315194557c3d..0a54c3adf0ac 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -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
-- 
2.20.1


  parent reply	other threads:[~2019-03-27 21:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 21:36 [PATCH 0/7] RISC-V: Sparsmem, Memory Hotplug and pte_devmap for P2P Logan Gunthorpe
2019-03-27 21:36 ` [PATCH 1/7] RISC-V: Implement sparsemem Logan Gunthorpe
2019-03-27 21:36 ` [PATCH 2/7] RISC-V: doc: Add file describing the virtual memory map Logan Gunthorpe
2019-03-28 11:49   ` Mike Rapoport
2019-03-28 15:51     ` Logan Gunthorpe
2019-03-27 21:36 ` [PATCH 3/7] RISC-V: Rework kernel's virtual address space mapping Logan Gunthorpe
2019-03-28  5:39   ` Palmer Dabbelt
2019-03-28  6:28     ` Anup Patel
2019-03-28 15:54       ` Logan Gunthorpe
2019-03-27 21:36 ` [PATCH 4/7] RISC-V: Update page tables to cover the whole linear mapping Logan Gunthorpe
2019-03-28 10:03   ` Anup Patel
2019-03-28 18:24     ` Logan Gunthorpe
2019-03-27 21:36 ` Logan Gunthorpe [this message]
2019-03-27 21:36 ` [PATCH 6/7] RISC-V: Implement memory hot remove Logan Gunthorpe
2019-03-27 21:36 ` [PATCH 7/7] RISC-V: Implement pte_devmap() Logan Gunthorpe
2019-04-24 23:23 ` [PATCH 0/7] RISC-V: Sparsmem, Memory Hotplug and pte_devmap for P2P Palmer Dabbelt
2019-04-26 16:37   ` Logan Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190327213643.23789-6-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=anup.patel@wdc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@wdc.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@sifive.com \
    --cc=paul.walmsley@sifive.com \
    --cc=ren_guo@c-sky.com \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=sbates@raithlin.com \
    --cc=zong@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®