devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: skseofh@gmail.com
To: robh+dt@kernel.org
Cc: devicetree@vger.kernel.org, frowand.list@gmail.com,
	linux-kernel@vger.kernel.org, skseofh@gmail.com
Subject: [PATCH] of: fdt: modify small size memory check
Date: Tue,  5 Mar 2024 00:02:26 +0900	[thread overview]
Message-ID: <20240304150227.166053-1-skseofh@gmail.com> (raw)
In-Reply-To: <CAL_JsqKNGjKq3vcUPFiPa9JNq-8=oP=uBSD=tyKaPMH3cvAkww@mail.gmail.com>


>>
>> From: Daero Lee <skseofh@gmail.com>
>>
>> After page aligning, the size may become zero. So I added exception
>> handling code for size 0.
>
>That may be true, but when would anyone only have memory regions of
>less than 2 pages. In any case memblock_add will just do nothing. What
>is the actual problem you are having?
>
>Rob

Ignore the previous mail.
I modified the patch to clear this size check routine. Please check

-------------------------------------------------------------------------
From 2135d37c37f8c369033f79102b17ddf5bb3ff838 Mon Sep 17 00:00:00 2001
From: Daero Lee <skseofh@gmail.com>
Date: Mon, 4 Mar 2024 23:21:14 +0900
Subject: [PATCH] of: fdt: modify small size memory check

Small size memory which is less than 1 PAGE_SIZE after page align
should not be added to memblock.

In this patch, the size check was modified to make it clear.

Signed-off-by: Daero Lee <skseofh@gmail.com>
---
 drivers/of/fdt.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bf502ba8da95..9cf844e664b0 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1220,18 +1220,16 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
 {
        const u64 phys_offset = MIN_MEMBLOCK_ADDR;
+       u64 abase = PAGE_ALIGN(base), aend = PAGE_ALIGN_DOWN(base + size);

-       if (size < PAGE_SIZE - (base & ~PAGE_MASK)) {
+       if((aend - abase) < PAGE_SIZE) {
                pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
                        base, base + size);
                return;
        }

-       if (!PAGE_ALIGNED(base)) {
-               size -= PAGE_SIZE - (base & ~PAGE_MASK);
-               base = PAGE_ALIGN(base);
-       }
-       size &= PAGE_MASK;
+       base = abase;
+       size = (aend - abase) & PAGE_MASK;

        if (base > MAX_MEMBLOCK_ADDR) {
                pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
--
2.25.1


  parent reply	other threads:[~2024-03-04 15:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02 14:03 [PATCH] of: fdt: add size 0 check after page align skseofh
2024-03-04 13:26 ` Rob Herring
2024-03-04 14:51   ` skseofh
2024-03-04 15:02   ` skseofh [this message]
2024-03-04 17:05     ` [PATCH] of: fdt: modify small size memory check Rob Herring
2024-03-04 22:38       ` skseofh

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=20240304150227.166053-1-skseofh@gmail.com \
    --to=skseofh@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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).