mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jessica Clarke <jrtc27@jrtc27.com>
To: Anup Patel <anup@brainfault.org>
Cc: Guo Ren <guoren@kernel.org>, Palmer Dabbelt <palmer@dabbelt.com>,
	atishp@rivosinc.com,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Guo Ren <guoren@linux.alibaba.com>,
	Anup Patel <anup.patel@wdc.com>,
	Alexandre Ghiti <alexandre.ghiti@canonical.com>,
	Alexandre Ghiti <alex@ghiti.fr>
Subject: Re: [RFC PATCH 2/3] riscv: Add early_param to decrease firmware region
Date: Tue, 23 Nov 2021 11:53:48 +0000	[thread overview]
Message-ID: <07AD2CEA-3C9B-48FA-8E67-3B60448A08F0@jrtc27.com> (raw)
In-Reply-To: <CAAhSdy0LLu4o6uOB8t_Wv6jsOrrrSMx0pv1E1B5F679gan3i6g@mail.gmail.com>

On 23 Nov 2021, at 03:44, Anup Patel <anup@brainfault.org> wrote:
> 
> +Alex
> 
> On Tue, Nov 23, 2021 at 7:27 AM <guoren@kernel.org> wrote:
>> 
>> 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);
>> +
> 
> We have avoided any RISC-V specific kernel parameter till now
> and I don't think adding "riscv.fwsz" is the right approach.
> 
> OpenSBI adds a reserved memory node (mmode_resv@8000000)
> to mark the memory where it is running as reserved. In fact, all
> M-mode runtime firmware should be adding a reserved memory
> node just like OpenSBI.

BBL does not do this and, even if it’s modified today, older versions
will still need to be supported for quite a while longer.

In FreeBSD[1] we only reserve the first 2 MiB of DRAM (we don’t care
about RV32) if there is no reserved memory node covering the DRAM base
address, which avoids this issue. The only downside with that approach
is that if firmware occupies a different region than the beginning of
DRAM (or there is no firmware resident in the supervisor’s physical
address space, as is the case for a virtualised guest) then it
unnecessarily reserves that first 2 MiB, but that’s not a huge deal,
and can’t be avoided so long as BBL continues to exist (well, I guess
you could probe the SBI implementation ID if you really cared about
that, but I’ve yet to hear of a platform where the SBI implementation,
if it exists, isn’t at the start of DRAM, and if you’re virtualising
then you probably have enough DRAM that you don’t notice 2 MiB going
missing).

Jess

[1] https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/machdep.c#L554-L568


  reply	other threads:[~2021-11-23 11:53 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 ` [RFC PATCH 2/3] riscv: Add early_param to decrease firmware region guoren
2021-11-23  3:44   ` Anup Patel
2021-11-23 11:53     ` Jessica Clarke [this message]
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=07AD2CEA-3C9B-48FA-8E67-3B60448A08F0@jrtc27.com \
    --to=jrtc27@jrtc27.com \
    --cc=alex@ghiti.fr \
    --cc=alexandre.ghiti@canonical.com \
    --cc=anup.patel@wdc.com \
    --cc=anup@brainfault.org \
    --cc=atishp@rivosinc.com \
    --cc=guoren@kernel.org \
    --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

all inboxes | Powered by JetHome®