linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Anup Patel <anup@brainfault.org>
To: Atish Patra <atish.patra@wdc.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
	Anup Patel <anup.patel@wdc.com>,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Palmer Dabbelt <palmer@dabbelt.com>, Zong Li <zong.li@sifive.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	linux-riscv <linux-riscv@lists.infradead.org>
Subject: Re: [PATCH v3] RISC-V: Remove any memblock representing unusable memory area
Date: Fri, 2 Oct 2020 15:42:23 +0530	[thread overview]
Message-ID: <CAAhSdy2bw-htb5_3Yz571=_Z_JKYDGCaiVv3Dh7EPvFQZPKmOg@mail.gmail.com> (raw)
In-Reply-To: <20201001190557.2860741-1-atish.patra@wdc.com>

On Fri, Oct 2, 2020 at 12:36 AM Atish Patra <atish.patra@wdc.com> wrote:
>
> RISC-V limits the physical memory size by -PAGE_OFFSET. Any memory beyond
> that size from DRAM start is unusable. Just remove any memblock pointing
> to those memory region without worrying about computing the maximum size.
>
> Signed-off-by: Atish Patra <atish.patra@wdc.com>
> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
>
> ---
> Changes from v2->v3
> Updated comment as per Mike's suggestion.
> ---
>  arch/riscv/mm/init.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index ca03762a3733..564e0be677b7 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -146,8 +146,6 @@ static phys_addr_t dtb_early_pa __initdata;
>  void __init setup_bootmem(void)
>  {
>         struct memblock_region *reg;
> -       phys_addr_t mem_size = 0;
> -       phys_addr_t total_mem = 0;
>         phys_addr_t mem_start, end = 0;
>         phys_addr_t vmlinux_end = __pa_symbol(&_end);
>         phys_addr_t vmlinux_start = __pa_symbol(&_start);
> @@ -155,21 +153,18 @@ void __init setup_bootmem(void)
>         /* Find the memory region containing the kernel */
>         for_each_memblock(memory, reg) {
>                 end = reg->base + reg->size;
> -               if (!total_mem)
> +               if (!mem_start)
>                         mem_start = reg->base;
>                 if (reg->base <= vmlinux_start && vmlinux_end <= end)
>                         BUG_ON(reg->size == 0);
> -               total_mem = total_mem + reg->size;
>         }
>
>         /*
> -        * Remove memblock from the end of usable area to the
> -        * end of region
> +        * The maximal physical memory size is -PAGE_OFFSET.
> +        * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed
> +        * as it is unusable by kernel.
>          */
> -       mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET);
> -       if (mem_start + mem_size < end)
> -               memblock_remove(mem_start + mem_size,
> -                               end - mem_start - mem_size);
> +       memblock_enforce_memory_limit(mem_start - PAGE_OFFSET);
>
>         /* Reserve from the start of the kernel to the end of the kernel */
>         memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
> --
> 2.25.1
>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2020-10-02 10:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 19:05 [PATCH v3] RISC-V: Remove any memblock representing unusable memory area Atish Patra
2020-10-02 10:12 ` Anup Patel [this message]
2020-10-04 23:22 ` Palmer Dabbelt

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='CAAhSdy2bw-htb5_3Yz571=_Z_JKYDGCaiVv3Dh7EPvFQZPKmOg@mail.gmail.com' \
    --to=anup@brainfault.org \
    --cc=anup.patel@wdc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@wdc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rppt@linux.ibm.com \
    --cc=zong.li@sifive.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).