From patchwork Mon Jan 7 16:10:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10750757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A56BC6C5 for ; Mon, 7 Jan 2019 16:11:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94BEA287D3 for ; Mon, 7 Jan 2019 16:11:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88E9C2880C; Mon, 7 Jan 2019 16:11:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3FDC0287CE for ; Mon, 7 Jan 2019 16:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Z5J6yWGQnZPdIy0XF+nxopA92zaV1oFkHPs/J8OOiXs=; b=q8Ygp6cXvUjAYvhiKP9x4p0xpr dDPIFmhudDeVpD/M1OxJO1YYBshOi2YuXzD1Vgoi/hizbjHHVGdSLNYdnmKZNVEHwin2R2UdAEKAq Hr5poaKFpwr3VhweeWh4Q6JyT6/pFSHDlkCOGagoBY/OVivNhNmCkY5wV4VRXf2LcO8fLNez9ULNy HLrga4mTjx7wp0cxt+V0JhJOP77ShmLh7kHhl5KzWqWeUrcxEzGIJjd6TVEd+ycs1XE7EURKKwMrk fruhydLht57sGFway0gTqHC+PRC8X0kYMVHaV9f35Sybj6vO35gKpVtNGgbJtNmkbUvI1BYAdvVIV Ip0yjEjA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUj-00056Q-Im; Mon, 07 Jan 2019 16:11:17 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUg-00054P-I1 for linux-riscv@lists.infradead.org; Mon, 07 Jan 2019 16:11:16 +0000 Received: by mail-pl1-x641.google.com with SMTP id b5so360879plr.4 for ; Mon, 07 Jan 2019 08:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZaKrDnHRaJTR4IomjvSGKZD1Tygses0EL569fMSHM94=; b=Zgngd4Gp1H53m2Qe2zWQk2wO398PgVsT+ZHTKDh2XRITX1i06Er7yGFYAiP+zpw5FU Q/Kh0e6hxjZoyhW2SaLvccSWEkEcqSvbtNgL5kAOkOLiDZJJzqjrCoMwisjTvCo/SEkg FdXFLX0HKo2GPFosJVUGacQgbw1M77h9a5nj8L7OJlt0g7+oz++zZM8Z8XU4EIOx4jVB dP6sCPCe2aaGQOw8o2TeT4ckoUeG4rRDT/hHO4vfyfLW7VbtpxhIYm3tN6bHymNdufd7 XIxAUFy3gI9QLnGPsHGmZAcp0qtdGaayFfgv9f66X1htuvACphEbwLW89litgLS9Rzuy /kWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZaKrDnHRaJTR4IomjvSGKZD1Tygses0EL569fMSHM94=; b=Y9s1N08Eb9Hpsql7e1zcfjdOli7zpGcQBTs8AiLSW6BhRXhj4nCVhWVawmh6vWeU6p Y4nDtWU6KkFh+5lz84rBlSBSQ2WPikQqNoAOFNBZ4jKLVzXaB85uY6itQZ7MnwyMxSS9 zgfbCN/ekompsXCTKlLI6LpRJ/nyr0QyVdlkHq4uMkhoStSw36tDnRqLz2Cf1cxFjZMQ 8F4azQ8Z0HcJGvBDVg6E+kvXwb8nHFNK7iVyqIko9BXkphM9yM1MPiQPUFUC60E7wxWt 0tg3+Z0t3Yr2Gz4tbiNvgV5uNVZkziQGGKKrUB/U+QhxQj5jgHQEQ3rAqHZblliVT5Bm tlaA== X-Gm-Message-State: AJcUukeVI22rPoGDGf++FHhklTSkdDrMZClBu7IhB1/Vr2CWoTf/34Y8 h/EDQ6BgKHpKOaVYjfVS5PgIOw== X-Google-Smtp-Source: ALg8bN6j4G8Z+93Wuqw2y7pZioxENiinBLcR0tTRLcPEkAa/SDw2F7eM50llrZ7maSEFpoYcWvt3ZQ== X-Received: by 2002:a17:902:6bc7:: with SMTP id m7mr62838655plt.106.1546877473820; Mon, 07 Jan 2019 08:11:13 -0800 (PST) Received: from localhost.localdomain ([49.207.48.214]) by smtp.gmail.com with ESMTPSA id a10sm93243512pfi.138.2019.01.07.08.11.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:11:13 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH 1/5] RISC-V: Move free_initrd_mem() to kernel/setup.c Date: Mon, 7 Jan 2019 21:40:43 +0530 Message-Id: <20190107161047.10516-2-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107161047.10516-1-anup@brainfault.org> References: <20190107161047.10516-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_081114_767527_4FA3C397 X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-kernel@vger.kernel.org, Christoph Hellwig , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel We move free_initrd_mem() to kernel/setup.c so that all initrd related functions are in one place. Signed-off-by: Anup Patel Reviewed-by: Christoph Hellwig --- arch/riscv/kernel/setup.c | 4 ++++ arch/riscv/mm/init.c | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index fc8006a042eb..64646d0b4d53 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -96,6 +96,10 @@ static void __init setup_initrd(void) initrd_start = 0; initrd_end = 0; } + +void free_initrd_mem(unsigned long start, unsigned long end) +{ +} #endif /* CONFIG_BLK_DEV_INITRD */ pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 1d9bfaff60bc..f354486f9b78 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -63,9 +62,3 @@ void free_initmem(void) { free_initmem_default(0); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ From patchwork Mon Jan 7 16:10:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10750759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 807626C5 for ; Mon, 7 Jan 2019 16:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D85328812 for ; Mon, 7 Jan 2019 16:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6201B287D3; Mon, 7 Jan 2019 16:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED872287F4 for ; Mon, 7 Jan 2019 16:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Q1og1eJmqkgryQSbeuDgn9XEXZrv/QVjL4eeDb8xyV8=; b=Hvjga2WL3geaXZSvWEIhEak1JX kYQ54ae5zxab1+TQcHNDyKllAEF+WPDlbaphASYdo0vXaCP8NuI7xKf6botbCMigeIslHYGZV35VI rF027veoukhORHEl0cecwguOI7XNB38D0o2c9MREPTQ65vevwDomPUkkuBo3mdgdTsT5jPK8hIPBe 9fcIX7BaHRAYOvHredL5ex2k94i5uxf3TJT54LWqitdEEJXiCoP52YpzjMPIGXxe/So7AfbNMayMD RSfUfyIG0FRqI2tvNKJGaBAq1F+H/tbVEZleQFPrbT2Yqr0pE3euVJ+c3/Murrgr2HL6MSwRFXRhY DriFaiyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUo-00059c-5G; Mon, 07 Jan 2019 16:11:22 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUl-00057M-2a for linux-riscv@lists.infradead.org; Mon, 07 Jan 2019 16:11:20 +0000 Received: by mail-pl1-x643.google.com with SMTP id e11so343547plt.11 for ; Mon, 07 Jan 2019 08:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V8xgFTF0trh6SGkurGKzpWNhAcRz6eK6HX/JkCyedrQ=; b=C2NFECgvWtYo2Ag+3cL5Wmnikf66jtfVuNcqQHM3c5GN2Yy0fqZqMDp8v0an/H9uhh Pqm0J1k5WdvFs/d5UfppZjGE7g2ePu2sDg3nj6CEIGoP+Bm590MPcq602qu0bqGvSa5F /xT6sxCDQvIGKfSqYmXjs97AyLOdaP9VLsImipt4FHIAnDshZFOhAZv4YndfJtDiHAqQ qNxOSHdNNUitjC3zwXw8crz67+jh9GLs1f0I8d5MCdxAB4sm9Iay2jX10iW2NW2JHbNT GweghlwVn1HEqMH64x1gwVJdSQzYL9+aDqFC08HvFb6nituWnjaiW4U1T+utnM/5xXZR vFsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V8xgFTF0trh6SGkurGKzpWNhAcRz6eK6HX/JkCyedrQ=; b=HJnPkTKPFHGr+9R8+6879TkifpWgH8dTwSsHe/N9tpMxioFxFLJ5PGfdk6l0QyKnx7 P3KWHON108/clLp3xVIXwzhi6Ioc+gtxSX3oprlFpHQa0uAqfI+c6dbe3XcEIqVXi3bl 5sAD1qJUadtr7XTUT+/kGu7YR+z2dymuucdfwdiTkrRZMzbfwUnmF8SbaMrn0yQAMPJ2 UnwK4k2kDd4jBJFj3ad94+hdcOvStF75hBvL9ApEW6Nfpvod62WaR5ZPQH/TfGFhLDO/ IThUGHvNp6e0f/warOOM221wYBQ1r8B+HoZEvlsKiVOdpbB8fQjSlMWQ2HHMkMXRApoo RZ+g== X-Gm-Message-State: AJcUukd8EL2obmNzroEtY1U2euhdik5h5aBWBCf9VocYqzsAD5UijBZA iN1ENfVLyQrhcPqJzPalxV4e4wqfUAM= X-Google-Smtp-Source: ALg8bN6NOdOb4IsHwjeBH1UbimT0TibP73NfLcbOyU6fCVQavsFWayomdqq5olLc6MzG2fwwgelkmw== X-Received: by 2002:a17:902:9006:: with SMTP id a6mr61033475plp.334.1546877478097; Mon, 07 Jan 2019 08:11:18 -0800 (PST) Received: from localhost.localdomain ([49.207.48.214]) by smtp.gmail.com with ESMTPSA id a10sm93243512pfi.138.2019.01.07.08.11.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:11:17 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH 2/5] RISC-V: Setup init_mm before parse_early_param() Date: Mon, 7 Jan 2019 21:40:44 +0530 Message-Id: <20190107161047.10516-3-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107161047.10516-1-anup@brainfault.org> References: <20190107161047.10516-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_081119_119787_90E6B389 X-CRM114-Status: GOOD ( 10.71 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-kernel@vger.kernel.org, Christoph Hellwig , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel We should setup init_mm before doing parse_early_param() in setup_arch() to be consistent with setup_arch() of other architectures such as x86, ARM, and ARM64. Signed-off-by: Anup Patel --- arch/riscv/kernel/setup.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 64646d0b4d53..f7132547b8b3 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -201,15 +201,15 @@ static void __init setup_bootmem(void) void __init setup_arch(char **cmdline_p) { - *cmdline_p = boot_command_line; - - parse_early_param(); - init_mm.start_code = (unsigned long) _stext; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; init_mm.brk = (unsigned long) _end; + *cmdline_p = boot_command_line; + + parse_early_param(); + setup_bootmem(); paging_init(); unflatten_device_tree(); @@ -228,4 +228,3 @@ void __init setup_arch(char **cmdline_p) riscv_fill_hwcap(); } - From patchwork Mon Jan 7 16:10:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10750761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EBCE746 for ; Mon, 7 Jan 2019 16:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BC95287FA for ; Mon, 7 Jan 2019 16:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A790287D3; Mon, 7 Jan 2019 16:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF27F287FA for ; Mon, 7 Jan 2019 16:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Tgh+QoIFO6N2dwwhK0zl7sWeBnZBacQQY9q7ChNTKi4=; b=bCcpQH9sWW87kYrHwJBgRWIbig EfI8fHWtiOZygBWEQRwzZZ7nCENdakvWQjx+3DhPXODWbsu9/p7AmYvjSVNX4b6LJ0gfw7hNj000e +gzM4SMLav1kWfjZyVw0Ky16mDIHnfHoZ9lvJRq/ZRfVUjyNM/MkFeykcTz0mLwLKWGXRrVy++NUX 290pqvgQpSoQ4tpU+RXdTPw1M0cZAjPiPAWDBqWCdpI5GK45c1UqRD9BLUZzcB7EpZKYOT4cFAuNf eUfyNsPCPDLTEvNLmdMTG+8IfKC9DOLWCtSGR8+tb/1U5/hfSEwkkezPBFPmetsXZ7n4Lptzz8thI lJFkAhfA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUt-0005DX-3E; Mon, 07 Jan 2019 16:11:27 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUp-0005Ap-Jk for linux-riscv@lists.infradead.org; Mon, 07 Jan 2019 16:11:25 +0000 Received: by mail-pg1-x541.google.com with SMTP id w6so335346pgl.6 for ; Mon, 07 Jan 2019 08:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CSYWd6VeFZK8P72VO6QNWHyKLKv+RHglMAIawF/x8uk=; b=iheGcVmBnGNRZU3bCLq2c45+BKRGm2ge/n6wBqlJo88S5ApAC2vyibvQG/BZ+uKJau 7MZECl+8mdL7EfUkhZbf+l061G3Rez+3xIM6q4a7uudhIiV2gMhB4LvYEkyBlymkxDz+ YFWVJx07s/+MT1XD4yX0rsCwzOl3JWzGlr/v1WKkjCgzHjGesRZng/VUkSikdIJV5t1L r7zJe+AnWwNz7AJwd1KkkkW27OjnbolOm2tK2qj1GnFIZaqT2Ynm9MfvqErrXpKy5OHB gEHzX3r7Jaosj3Fd1BACYFHZtjUVb1QJeIadRAXDWZDY9WOyXSXiOtiwIJgmBN/2ou0i GvGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CSYWd6VeFZK8P72VO6QNWHyKLKv+RHglMAIawF/x8uk=; b=BmGpvijG9zdq5whkLUBfMta8+AP3aB2sDLN315t0NdCkp/bnUb5as9D+cmE4duGr6p pmdYSesyMXkdFFMhP6RJtHkhYp8LtzVrGsjH/o8aByIkJEVWa2iL5IFqzfjp//S+hZbs QyCwgAXontBoNZiOptlDPit2xtNDl1M8jiN9ZY+wTGquq1SZxjLGYZoH23cIbKLpwOSO CVqElmabiRLwR9bumPGT+gylq9WMY4aqGWX3o1SpnTkRjtM0THfjaxM5sg3p08R3Us2m ccN81aiKN1vLpjJPMoluvcUJhPUEzS5wE/Im4N46KPPgwuynKjin822HgCdRmHKqDAlo dgUg== X-Gm-Message-State: AJcUukdVwXvs8qxlmxWHO1A+xn64AMEKC5eaUBqK3Yxs5eOhsfKOvvzG M7vp0X/8oiT+ECC5o13SLrIsUw== X-Google-Smtp-Source: ALg8bN6RTmQpLYFPorPual2M7RwPK9lJ3CXTe3NMKljh56xYmRBUArCfZKtTyXAkpSEOpSVRoHMrPg== X-Received: by 2002:a63:cc4e:: with SMTP id q14mr11301316pgi.291.1546877482641; Mon, 07 Jan 2019 08:11:22 -0800 (PST) Received: from localhost.localdomain ([49.207.48.214]) by smtp.gmail.com with ESMTPSA id a10sm93243512pfi.138.2019.01.07.08.11.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:11:22 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH 3/5] RISC-V: Move setup_bootmem() to mm/init.c Date: Mon, 7 Jan 2019 21:40:45 +0530 Message-Id: <20190107161047.10516-4-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107161047.10516-1-anup@brainfault.org> References: <20190107161047.10516-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_081123_648276_9C038DE2 X-CRM114-Status: GOOD ( 16.19 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-kernel@vger.kernel.org, Christoph Hellwig , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel The setup_bootmem() mainly populates memblocks and does early memory reservations. The right location for this function is mm/init.c. Signed-off-by: Anup Patel Reviewed-by: Christoph Hellwig --- arch/riscv/include/asm/pgtable.h | 1 + arch/riscv/kernel/setup.c | 48 ++++---------------------------- arch/riscv/mm/init.c | 40 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 16301966d65b..35893810cba3 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -404,6 +404,7 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, #define kern_addr_valid(addr) (1) /* FIXME */ #endif +extern void setup_bootmem(void); extern void paging_init(void); static inline void pgtable_cache_init(void) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index f7132547b8b3..49a13b98e13f 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -156,49 +156,6 @@ void __init parse_dtb(unsigned int hartid, void *dtb) early_init_dt_scan(__va(dtb)); } -static void __init setup_bootmem(void) -{ - struct memblock_region *reg; - phys_addr_t mem_size = 0; - - /* Find the memory region containing the kernel */ - for_each_memblock(memory, reg) { - phys_addr_t vmlinux_end = __pa(_end); - phys_addr_t end = reg->base + reg->size; - - if (reg->base <= vmlinux_end && vmlinux_end <= end) { - /* - * Reserve from the start of the region to the end of - * the kernel - */ - memblock_reserve(reg->base, vmlinux_end - reg->base); - mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); - } - } - BUG_ON(mem_size == 0); - - set_max_mapnr(PFN_DOWN(mem_size)); - max_low_pfn = memblock_end_of_DRAM(); - -#ifdef CONFIG_BLK_DEV_INITRD - setup_initrd(); -#endif /* CONFIG_BLK_DEV_INITRD */ - - early_init_fdt_reserve_self(); - early_init_fdt_scan_reserved_mem(); - memblock_allow_resize(); - memblock_dump_all(); - - for_each_memblock(memory, reg) { - unsigned long start_pfn = memblock_region_memory_base_pfn(reg); - unsigned long end_pfn = memblock_region_memory_end_pfn(reg); - - memblock_set_node(PFN_PHYS(start_pfn), - PFN_PHYS(end_pfn - start_pfn), - &memblock.memory, 0); - } -} - void __init setup_arch(char **cmdline_p) { init_mm.start_code = (unsigned long) _stext; @@ -211,6 +168,11 @@ void __init setup_arch(char **cmdline_p) parse_early_param(); setup_bootmem(); + +#ifdef CONFIG_BLK_DEV_INITRD + setup_initrd(); +#endif /* CONFIG_BLK_DEV_INITRD */ + paging_init(); unflatten_device_tree(); diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index f354486f9b78..d0965979ee70 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -62,3 +63,42 @@ void free_initmem(void) { free_initmem_default(0); } + +void __init setup_bootmem(void) +{ + struct memblock_region *reg; + phys_addr_t mem_size = 0; + + /* Find the memory region containing the kernel */ + for_each_memblock(memory, reg) { + phys_addr_t vmlinux_end = __pa(_end); + phys_addr_t end = reg->base + reg->size; + + if (reg->base <= vmlinux_end && vmlinux_end <= end) { + /* + * Reserve from the start of the region to the end of + * the kernel + */ + memblock_reserve(reg->base, vmlinux_end - reg->base); + mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); + } + } + BUG_ON(mem_size == 0); + + set_max_mapnr(PFN_DOWN(mem_size)); + max_low_pfn = memblock_end_of_DRAM(); + + early_init_fdt_reserve_self(); + early_init_fdt_scan_reserved_mem(); + memblock_allow_resize(); + memblock_dump_all(); + + for_each_memblock(memory, reg) { + unsigned long start_pfn = memblock_region_memory_base_pfn(reg); + unsigned long end_pfn = memblock_region_memory_end_pfn(reg); + + memblock_set_node(PFN_PHYS(start_pfn), + PFN_PHYS(end_pfn - start_pfn), + &memblock.memory, 0); + } +} From patchwork Mon Jan 7 16:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10750763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F2AD746 for ; Mon, 7 Jan 2019 16:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E0EE287D3 for ; Mon, 7 Jan 2019 16:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 518D728812; Mon, 7 Jan 2019 16:11:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D4D5B2880A for ; Mon, 7 Jan 2019 16:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jRjsx89mtr7wUeIcz/gnDiB+bB5QPl4NbO590BCpxug=; b=YJeMa9RBVajLQi2MwSdGxgUQec ma7sigVDgdfEFUHE5MuirwkYydkquU5iIOicMZExCOWEq6c4efiFy+uno6z7PfkLg7irPsFR+eVmn +q6aZnYWkSw4scBh/xcVHbbQ8+SJMPBbqnRBlbnmt/3elVGQwEQzTSl+w6sbl7PtJKxTJrzk3hebp GK/HpGlnyaETwCUXSAx2jOK03A8EeftLZJs9edsxEwASHFC797pcaSjktCobuu7ZuxgazXPMoDkq1 KdGL8Td905WxYHX5uoEyfqZkr6AVkx5ebDVBgalkmjfV292KdsjQxUhhs5BlY+v4Bcw0NDyJfMVMB YtCLrK5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUy-0005IJ-Ak; Mon, 07 Jan 2019 16:11:32 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUt-0005E6-Rk for linux-riscv@lists.infradead.org; Mon, 07 Jan 2019 16:11:29 +0000 Received: by mail-pl1-x642.google.com with SMTP id e5so357216plb.5 for ; Mon, 07 Jan 2019 08:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t2eEqpoIDFvDG2gAO/fqfzYdvBoxxIkAd2CWhpFMFaE=; b=K1q9rjXHYg/XE/gYjtrKRPXFj2vv+NgpkDNWFCPt0FYOROE3IN/vc/V38JtDYXDryO wUZuCo7mRDTty67q70n29YIzOsbnZgN1Jmfxh5DtiXFGTBakfxzPFk55n5RZ15K29ZNd x/VlMl4MvFbnilVcC7enJyqpEcMhwlIZfUVqVB+YZ6V6oeX/dgDpip15PFYSBJSWI3rY v+9goMMgNuwpiDiLP8g4Hl8jioFVAZc84j5P8CcWM4dhvOw5QzDbFghNjqnL4Bb2oFEM 79GR4MytTX4Ce6nWixQ+cXmQn3OalLIgx/ix0ov2x8lj5MHjqiSgMVXlKmjY4qoI8pyL rDqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t2eEqpoIDFvDG2gAO/fqfzYdvBoxxIkAd2CWhpFMFaE=; b=TlFjPRyzGnUIaE3wxLFpRq7Kf5TTFpVtHHPmrreikr2x+hoDS8jX+V10gH11Haug9y KZlj+hUSud4g0s4kvwoxLW5i+xvT+8Zhnya/aGzqK6HXIYavbdy1Mx/kN1CarK71pwKj R/tHVsX8E0SYIJ8o5C6Ni0nGKH3trYjQywkW02qsb6JmEBaF5+Z0SaLqtq74PS2r86KM arerkIA4XjslUa64TzMUeKpXK9hYFYAlkiA6gFJUV6jVwIFc4FAoA1q12fjBZo5+ixsr G+xPeR0bZG7C5kXDuoTkQpuunLl76gsF9kkST0Qp6qU+pzdFnlRIlcuFCV+CqaEEmXy0 U3Bw== X-Gm-Message-State: AJcUukcMcFCh8JqMClABqJ5vti/g63SSbwNjcllaTlgkG4DyGtIFmED3 JbdgGBqzXirr1nzf2HaTn9y696gbvis= X-Google-Smtp-Source: ALg8bN4rv79GPRCMZZRRUYzTPZUTJRiPCBKRvB+SoPWGOw9W/9hS/LCTjOsk5w2dK8fNTCDnM6Wk7Q== X-Received: by 2002:a17:902:b093:: with SMTP id p19mr61640077plr.135.1546877487094; Mon, 07 Jan 2019 08:11:27 -0800 (PST) Received: from localhost.localdomain ([49.207.48.214]) by smtp.gmail.com with ESMTPSA id a10sm93243512pfi.138.2019.01.07.08.11.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:11:26 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH 4/5] RISC-V: Move setup_vm() to mm/init.c Date: Mon, 7 Jan 2019 21:40:46 +0530 Message-Id: <20190107161047.10516-5-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107161047.10516-1-anup@brainfault.org> References: <20190107161047.10516-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_081128_050821_6AC3A735 X-CRM114-Status: GOOD ( 13.07 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-kernel@vger.kernel.org, Christoph Hellwig , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel The setup_vm() is responsible for setting up initial page table hence should be placed in mm/init.c. Signed-off-by: Anup Patel Reviewed-by: Christoph Hellwig --- arch/riscv/kernel/setup.c | 49 -------------------------------------- arch/riscv/mm/init.c | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 49a13b98e13f..e9c7f1a6db5a 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -102,55 +102,6 @@ void free_initrd_mem(unsigned long start, unsigned long end) } #endif /* CONFIG_BLK_DEV_INITRD */ -pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); - -#ifndef __PAGETABLE_PMD_FOLDED -#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT) -pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss; -pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); -#endif - -asmlinkage void __init setup_vm(void) -{ - extern char _start; - uintptr_t i; - uintptr_t pa = (uintptr_t) &_start; - pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); - - va_pa_offset = PAGE_OFFSET - pa; - pfn_base = PFN_DOWN(pa); - - /* Sanity check alignment and size */ - BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); - BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0); - -#ifndef __PAGETABLE_PMD_FOLDED - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = - pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), - __pgprot(_PAGE_TABLE)); - trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot); - - for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] = - pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, - __pgprot(_PAGE_TABLE)); - } - for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++) - swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); -#else - trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = - pfn_pgd(PFN_DOWN(pa), prot); - - for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { - size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; - swapper_pg_dir[o] = - pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); - } -#endif -} - void __init parse_dtb(unsigned int hartid, void *dtb) { early_init_dt_scan(__va(dtb)); diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index d0965979ee70..b487f76d6060 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -102,3 +102,53 @@ void __init setup_bootmem(void) &memblock.memory, 0); } } + +pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); + +#ifndef __PAGETABLE_PMD_FOLDED +#define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT) +pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss; +pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); +#endif + +asmlinkage void __init setup_vm(void) +{ + extern char _start; + size_t o; + uintptr_t i; + uintptr_t pa = (uintptr_t) &_start; + pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); + + va_pa_offset = PAGE_OFFSET - pa; + pfn_base = PFN_DOWN(pa); + + /* Sanity check alignment and size */ + BUG_ON((PAGE_OFFSET % PGDIR_SIZE) != 0); + BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0); + +#ifndef __PAGETABLE_PMD_FOLDED + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd), + __pgprot(_PAGE_TABLE)); + trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot); + + for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] = + pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i, + __pgprot(_PAGE_TABLE)); + } + for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++) + swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); +#else + trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN(pa), prot); + + for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) { + o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i; + swapper_pg_dir[o] = + pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); + } +#endif +} From patchwork Mon Jan 7 16:10:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10750765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83419746 for ; Mon, 7 Jan 2019 16:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71A5D28783 for ; Mon, 7 Jan 2019 16:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65896287F5; Mon, 7 Jan 2019 16:11:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BD0A9287F4 for ; Mon, 7 Jan 2019 16:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hZ6K6doHEoBKghJBWYfVX6qcgCDecsKPNQzivp7qJKY=; b=dFFb876/F4+SRoge9360Wjf1dR N7Qx6JCbNT0sfya+0hIfaHUvKlDtIUuCQItcwlHImwQtNaZG286ZvZgaIe6qebFebaxQem3Up6Eiu al0+RfdV+Y4uanuakOfIC6teQUhP21MRCwwSR4eaetNS/al8+ktRs01bowq5hfizEqb6mbajWAPKl ljWh9JeBRH3OU8PGqGLvk3gi4dDAQ5C/mDn/YNyRtlJlmqF68W8luIrcfsiybCg7ngU1xQYVkBiMw q1mv25gbMYidAz+ewKQKD5RjUkC/YsZYvpFykKE7zXtOUuRLz1y83Tn2ZQSTW22hZ7F5ziYyVpoYb TO67xOVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXV2-0005LT-3U; Mon, 07 Jan 2019 16:11:36 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggXUy-0005ID-Iw for linux-riscv@lists.infradead.org; Mon, 07 Jan 2019 16:11:34 +0000 Received: by mail-pf1-x444.google.com with SMTP id 64so369557pfr.9 for ; Mon, 07 Jan 2019 08:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v6aM0hklZsFoaklZaSb50j46kecgBnQrkaeqJhZzzu0=; b=CRS69RQFENjNlNHF3xKRq9jrAWmuSsg45oCuH+alD6J9nO4XMkDK3JhaHp1la/Rgs5 Kv4hG84jkN7dVl9XqK4GU/N3L4m/PDo5y3TJR8p17BhzsOiuz14TeFo5m4ub1wUjE5K+ BbzvDHgmSvw/6TnoG8MUtcH8JyoHVmBYLys25erXg0chDK60FtivqvDU2BjJwyMl9sNu nmWHc1bMK2xG27/mYRTVZsP9KrXI8Gla+Wqpa2JPegYexlUYFTlCa+2vcLBPrgDHqb// raKpEDvp9NaO8EdHByv3BAM93ZjGYiUVTO18Jh1mgkwTaOh6c21bpAGepP6twy8vE5GU f5zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v6aM0hklZsFoaklZaSb50j46kecgBnQrkaeqJhZzzu0=; b=eUKR698ZGZ0c0vbup4aen1Js/1qJN1x8pWnFdlFsFHhlUMtqqO9KbvquiyCs6cYHfi UK6Mu6t7Zmw/jbW7yBKf5qTuYoOkOD5Gd2/eP3knlz9IvtJSXBFgxX64JT4MejgJEk6X sv3QIkkuB9aKXDsWk22bXD5onHWO5MtmKeghRfVVBgWcLn3R+XSUD7g9CmLxaPBM1pOf ukJbe0RGM/uUza9YfvVJLRh9dGX4L2A7jCc/vRyZloBrROMnTbRR+PS2uSGx/+vP4gxt 2zAW+yd7FUe/OS9BZkmzJxvUcvSQ684GBKthONlTaX/t7GAGiJqdvbIkMNFWIzUar0AW 5HiQ== X-Gm-Message-State: AA+aEWY8ubq60DoYHRijQpHlXnpvXr1+cXmsGtDCcfjJ10owUvmY8lz5 9U6tmACyTML04YES6GgPT8miGA== X-Google-Smtp-Source: AFSGD/V8as21mLKX4g9nDe++baxp9D7028k8deFV1gH3K4lE4zBPzT/Rjqm2ER2SUS5pNECYt74Hng== X-Received: by 2002:a62:7042:: with SMTP id l63mr66271895pfc.89.1546877491533; Mon, 07 Jan 2019 08:11:31 -0800 (PST) Received: from localhost.localdomain ([49.207.48.214]) by smtp.gmail.com with ESMTPSA id a10sm93243512pfi.138.2019.01.07.08.11.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:11:30 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH 5/5] RISC-V: Implement compile-time fixed mappings Date: Mon, 7 Jan 2019 21:40:47 +0530 Message-Id: <20190107161047.10516-6-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107161047.10516-1-anup@brainfault.org> References: <20190107161047.10516-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190107_081132_792496_578BCBDB X-CRM114-Status: GOOD ( 17.18 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , linux-kernel@vger.kernel.org, Christoph Hellwig , Atish Patra , Paul Walmsley , linux-riscv@lists.infradead.org MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Anup Patel This patch implements compile-time virtual to physical mappings. These compile-time fixed mappings can be used by earlycon, ACPI, and early ioremap for creating fixed mappings when FIX_EARLYCON_MEM=y. To start with, we have enabled compile-time fixed mappings for earlycon. Signed-off-by: Anup Patel --- arch/riscv/Kconfig | 3 ++ arch/riscv/include/asm/fixmap.h | 52 +++++++++++++++++++++++++++++++++ arch/riscv/mm/init.c | 32 ++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 arch/riscv/include/asm/fixmap.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index e0d7d61779a6..66094aba9a59 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -86,6 +86,9 @@ config GENERIC_CSUM config GENERIC_HWEIGHT def_bool y +config FIX_EARLYCON_MEM + def_bool y + config PGTABLE_LEVELS int default 3 if 64BIT diff --git a/arch/riscv/include/asm/fixmap.h b/arch/riscv/include/asm/fixmap.h new file mode 100644 index 000000000000..88e99f506ab9 --- /dev/null +++ b/arch/riscv/include/asm/fixmap.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 Western Digital Corporation or its affiliates. + * + * fixmap.h: compile-time virtual memory allocation + */ + +#ifndef _ASM_RISCV_FIXMAP_H +#define _ASM_RISCV_FIXMAP_H + +#ifndef __ASSEMBLY__ + +#include +#include +#include +#include + +/* + * Here we define all the compile-time 'special' virtual + * addresses. The point is to have a constant address at + * compile time, but to set the physical address only + * in the boot process. + * + * These 'compile-time allocated' memory buffers are + * page-sized. Use set_fixmap(idx,phys) to associate + * physical memory with fixmap indices. + */ +enum fixed_addresses { + FIX_HOLE, + FIX_EARLYCON_MEM_BASE, + __end_of_fixed_addresses +}; + +#define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE) +#define FIXADDR_TOP (PAGE_OFFSET) +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) + +#define FIXMAP_PAGE_IO PAGE_KERNEL + +#define __early_set_fixmap __set_fixmap + +#define __late_set_fixmap __set_fixmap +#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR) + +extern void __set_fixmap(enum fixed_addresses idx, + phys_addr_t phys, pgprot_t prot); + +#include + +#endif /* !__ASSEMBLY__ */ + +#endif /* _ASM_RISCV_FIXMAP_H */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index b487f76d6060..b10f1423c352 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -110,8 +111,28 @@ pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); #define NUM_SWAPPER_PMDS ((uintptr_t)-PAGE_OFFSET >> PGDIR_SHIFT) pmd_t swapper_pmd[PTRS_PER_PMD*((-PAGE_OFFSET)/PGDIR_SIZE)] __page_aligned_bss; pmd_t trampoline_pmd[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE); +pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; #endif +pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; + +void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot) +{ + unsigned long addr = __fix_to_virt(idx); + pte_t *ptep; + + BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses); + + ptep = &fixmap_pte[pte_index(addr)]; + + if (pgprot_val(prot)) { + set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot)); + } else { + pte_clear(&init_mm, addr, ptep); + local_flush_tlb_page(addr); + } +} + asmlinkage void __init setup_vm(void) { extern char _start; @@ -141,6 +162,13 @@ asmlinkage void __init setup_vm(void) } for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++) swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot); + + swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pmd), + __pgprot(_PAGE_TABLE)); + fixmap_pmd[(FIXADDR_START >> PMD_SHIFT) % PTRS_PER_PMD] = + pfn_pmd(PFN_DOWN((uintptr_t)fixmap_pte), + __pgprot(_PAGE_TABLE)); #else trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] = pfn_pgd(PFN_DOWN(pa), prot); @@ -150,5 +178,9 @@ asmlinkage void __init setup_vm(void) swapper_pg_dir[o] = pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot); } + + swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] = + pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pte), + __pgprot(_PAGE_TABLE)); #endif }