Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5749806img; Wed, 27 Mar 2019 14:37:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFWwETpWd0PQynIcLejO5jPStYqlz7kRRHn/txbDQPfQ4NwHVDtxn2TCASL+bg/xDOtiFG X-Received: by 2002:a62:29c5:: with SMTP id p188mr36530454pfp.203.1553722678853; Wed, 27 Mar 2019 14:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553722678; cv=none; d=google.com; s=arc-20160816; b=uOWrjpIVudzJ3TbzmQRuaGfNeNXMakWz2m1UJStW7qMcJc6/FGux2WFMg4F0rYDqFB BBVqi+UbXJjvxPQeY6q0MDygMDOZqRx0urkHJGCoQa31LTJaFatfPAT43IyjXYZs5Aai H1hYaisNRZeIulRe8Y+iSloV4c62ne+zPQIWN0Yi/f3iGOizWuYgSUxBUxH2ulHOhQv1 5p48tFacEUQKbwD50tjkb4kxQUXxrsTgvQguRAcSwEgUlWMyvFwJODCh0XWpq4VefALp cwT5GmlJgDhYnoWudL2qUGEQtQx0oiDURUf9g/ar9JphiDnrdN/4OwnsfIJDp/xI69DK SLig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=C3UDW9i0T0YbdmrMRxLDbA5WH4J8pFs9TWszMNU3rO8=; b=CrceG/u3W2w9ijoNouGNPuDLeUr0vq33hv4/AhhVjKm+PLNT1KeYAC8JEYey7DNrgI Z35YVq++pke6t5beo1h8VBaeNm64kE0PcQF2e83u4UVZUyIyOK/eWj2nLAE95vgSKHic Km2c9GQXKW1qxoCPEkTgPSPlDslKk4xCUjfNsUsF8U41pqG3atkv6m0C9EjqmuEjf1hZ /klR6ubp6GpxW7OGqhI31EsAxKUvFhgvkFraJ+Y96tSEfrbsWMFnUUzLEGfm/ghUyPI9 a85mbXUocz/ns4GJzIxFu87FSTtpY92GsRU0T5A51dxWKvR2Hm3FuGVkVe8CpOhWAEKu TuLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si18977105pgq.506.2019.03.27.14.37.43; Wed, 27 Mar 2019 14:37:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729713AbfC0Vg5 (ORCPT + 99 others); Wed, 27 Mar 2019 17:36:57 -0400 Received: from ale.deltatee.com ([207.54.116.67]:58666 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728276AbfC0Vgu (ORCPT ); Wed, 27 Mar 2019 17:36:50 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h9GE4-0006DL-EI; Wed, 27 Mar 2019 15:36:49 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1h9GE2-0006Ck-Bm; Wed, 27 Mar 2019 15:36:46 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Stephen Bates , Palmer Dabbelt , Christoph Hellwig , Albert Ou , Logan Gunthorpe , Mike Rapoport , Anup Patel , Atish Patra , Paul Walmsley , Zong Li , Guo Ren Date: Wed, 27 Mar 2019 15:36:41 -0600 Message-Id: <20190327213643.23789-6-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190327213643.23789-1-logang@deltatee.com> References: <20190327213643.23789-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, sbates@raithlin.com, hch@lst.de, aou@eecs.berkeley.edu, logang@deltatee.com, rppt@linux.vnet.ibm.com, anup.patel@wdc.com, atish.patra@wdc.com, palmer@sifive.com, paul.walmsley@sifive.com, zong@andestech.com, ren_guo@c-sky.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.5 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_FREE,MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH 5/7] RISC-V: Implement memory hotplug X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Palmer Dabbelt Cc: Albert Ou Cc: Mike Rapoport Cc: Anup Patel Cc: Atish Patra Cc: Paul Walmsley Cc: Zong Li Cc: Guo Ren --- 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