From: Mike Rapoport <rppt@linux.vnet.ibm.com>
To: Ley Foon Tan <lftan@altera.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Michal Hocko <mhocko@kernel.org>,
nios2-dev@lists.rocketboards.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: [PATCH 1/3] of: ignore sub-page memory regions
Date: Wed, 4 Jul 2018 16:18:13 +0300 [thread overview]
Message-ID: <1530710295-10774-2-git-send-email-rppt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1530710295-10774-1-git-send-email-rppt@linux.vnet.ibm.com>
Memory region size is rounded down to page boundary and with sub-page
region it becomes 0 and there is no point to add an empty region.
Moreover, when the base is less than PAGE_SIZE we get a bogus size as
(base + size - 1) evaluates to -1.
The commit 8cccffc52694 ("of: check for size < 0 after rounding in
early_init_dt_add_memory_arch") introduced a test for wrap around for the
case when base is not page aligned, the same test can be used to ignore
sub-page region sizes.
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
drivers/of/fdt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 6da20b9..e866745 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1134,12 +1134,13 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
{
const u64 phys_offset = MIN_MEMBLOCK_ADDR;
+ if (size < PAGE_SIZE - (base & ~PAGE_MASK)) {
+ pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
+ base, base + size);
+ return;
+ }
+
if (!PAGE_ALIGNED(base)) {
- if (size < PAGE_SIZE - (base & ~PAGE_MASK)) {
- pr_warn("Ignoring memory block 0x%llx - 0x%llx\n",
- base, base + size);
- return;
- }
size -= PAGE_SIZE - (base & ~PAGE_MASK);
base = PAGE_ALIGN(base);
}
--
2.7.4
next prev parent reply other threads:[~2018-07-04 13:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 13:18 [PATCH 0/3] nios2: switch to NO_BOOTMEM Mike Rapoport
2018-07-04 13:18 ` Mike Rapoport [this message]
2018-07-04 13:18 ` [PATCH 2/3] nios2: use generic early_init_dt_add_memory_arch Mike Rapoport
2018-08-02 7:06 ` Ley Foon Tan
2018-07-04 13:18 ` [PATCH 3/3] nios2: switch to NO_BOOTMEM Mike Rapoport
2018-08-02 7:05 ` Ley Foon Tan
2018-07-30 6:14 ` [PATCH 0/3] " Mike Rapoport
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=1530710295-10774-2-git-send-email-rppt@linux.vnet.ibm.com \
--to=rppt@linux.vnet.ibm.com \
--cc=frowand.list@gmail.com \
--cc=lftan@altera.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=nios2-dev@lists.rocketboards.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).