linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: guoren@kernel.org
To: guoren@kernel.org, anup@brainfault.org, palmer@dabbelt.com,
	atishp@rivosinc.com
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-doc@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>,
	Anup Patel <anup.patel@wdc.com>
Subject: [RFC PATCH 2/3] riscv: Add early_param to decrease firmware region
Date: Tue, 23 Nov 2021 09:57:16 +0800	[thread overview]
Message-ID: <20211123015717.542631-3-guoren@kernel.org> (raw)
In-Reply-To: <20211123015717.542631-1-guoren@kernel.org>

From: Guo Ren <guoren@linux.alibaba.com>

Using riscv.fw_size in cmdline to tell the kernel what the
firmware (opensbi) size is. Then reserve the proper size of
firmware to save memory instead of the whole 2MB. It's helpful
to satisfy a small memory system (D1s/F133 from Allwinner).

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Anup Patel <anup.patel@wdc.com>
Cc: Atish Patra <atishp@rivosinc.com>
---
 arch/riscv/mm/init.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 920e78f8c3e4..f7db6d40213d 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -159,6 +159,15 @@ static int __init early_mem(char *p)
 }
 early_param("mem", early_mem);
 
+static phys_addr_t firmware_size __initdata;
+static int __init early_get_firmware_size(char *arg)
+{
+	firmware_size = memparse(arg, &arg);
+
+	return 0;
+}
+early_param("riscv.fwsz", early_get_firmware_size);
+
 static void __init setup_bootmem(void)
 {
 	phys_addr_t vmlinux_end = __pa_symbol(&_end);
@@ -224,7 +233,10 @@ static void __init setup_bootmem(void)
 	/*
 	 * Reserve OpenSBI region and depends on PMP to deny accesses.
 	 */
-	memblock_reserve(__pa(PAGE_OFFSET), LOAD_OFFSET);
+	if (firmware_size > PAGE_SIZE)
+		memblock_reserve(__pa(PAGE_OFFSET), firmware_size);
+	else
+		memblock_reserve(__pa(PAGE_OFFSET), LOAD_OFFSET);
 
 	early_init_fdt_scan_reserved_mem();
 	dma_contiguous_reserve(dma32_phys_limit);
-- 
2.25.1


  parent reply	other threads:[~2021-11-23  1:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23  1:57 [RFC PATCH 0/3] riscv: Add riscv.fwsz kernel parameter to save memory guoren
2021-11-23  1:57 ` [RFC PATCH 1/3] riscv: Remove 2MB offset in the mm layout guoren
2021-11-23  3:56   ` Anup Patel
2021-11-23  6:18     ` Guo Ren
2021-11-23 13:37     ` Alexandre Ghiti
2021-11-24 11:58       ` Guo Ren
2021-11-24 15:09         ` Alexandre ghiti
2021-11-23  1:57 ` guoren [this message]
2021-11-23  3:44   ` [RFC PATCH 2/3] riscv: Add early_param to decrease firmware region Anup Patel
2021-11-23 11:53     ` Jessica Clarke
2021-11-23 13:37       ` Alexandre Ghiti
2021-11-23  1:57 ` [RFC PATCH 3/3] riscv: Add riscv.fwsz kernel parameter guoren
2021-11-23  2:34   ` Randy Dunlap
2021-11-23  3:21     ` Guo Ren
2021-11-23  3:45   ` Anup Patel
2021-11-23 19:33 ` [RFC PATCH 0/3] riscv: Add riscv.fwsz kernel parameter to save memory Heiko Stübner
2021-11-23 20:01   ` Atish Patra
2021-11-23 21:50     ` Heiko Stübner
2021-11-24  6:49     ` Guo Ren
2021-11-24 12:13       ` Heiko Stübner
2021-11-24 14:25         ` Guo Ren
2021-11-24  6:42   ` Guo Ren
2021-11-24 12:16     ` Heiko Stübner

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=20211123015717.542631-3-guoren@kernel.org \
    --to=guoren@kernel.org \
    --cc=anup.patel@wdc.com \
    --cc=anup@brainfault.org \
    --cc=atishp@rivosinc.com \
    --cc=guoren@linux.alibaba.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.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;
as well as URLs for NNTP newsgroup(s).