[lkml]   [2021]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v3] of/fdt: Don't worry about non-memory region overlap for no-map
In commit 8a5a75e5e9e5 ("of/fdt: Make sure no-map does not remove
already reserved regions") we returned -EBUSY when trying to mark
regions as no-map when they're in the reserved memory node. This if
condition will still trigger though if the DT has a /memreserve/ that
completely subsumes the no-map memory carveouts in the reserved memory
node. Let's only consider this to be a problem if we're trying to mark a
region as no-map and it is actually memory. If it isn't memory,
presumably it was removed from the memory map via /memreserve/ and thus
can't be mapped anyway.

This silences a warning seen at boot on sc7180-trogdor.dtsi boards that
have /memreserve/ populated by the bootloader where those reserved
regions overlap with the reserved-memory carveouts that we have in DT
for other purposes like communicating with remote processors.

For example in sc7180.dtsi we have the following reserved-memory

smem_mem: memory@80900000 {
reg = <0x0 0x80900000 0x0 0x200000>;

and the memreserve injected by the bootloader is

/memreserve/ 0x80800000 0x400000;

so the reserved memory region overlaps with the no-map carveouts and we
get the following warning message printed at boot:

OF: fdt: Reserved memory: failed to reserve memory for node 'memory@80900000': base 0x0000000080900000, size 2 MiB

Everything keeps working, just the no-map property is being ignored in
__reserved_mem_reserve_reg() because the region we're trying to avoid
mapping has already been removed from the memory via the memreserve.

Cc: Mike Rapoport <>
Cc: Douglas Anderson <>
Cc: Nicolas Boichat <>
Cc: Quentin Perret <>
Cc: Jan Kiszka <>
Fixes: 8a5a75e5e9e5 ("of/fdt: Make sure no-map does not remove already reserved regions")
Signed-off-by: Stephen Boyd <>

Changes from v2 (
* More details in commit text

Changes from v1 (
* Use memblock_overlaps_region instead of memblock_is_region_memory()
* Add more details to commit text

drivers/of/fdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bdca35284ceb..c736e5bcc2f6 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -482,9 +482,11 @@ static int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
if (nomap) {
* If the memory is already reserved (by another region), we
- * should not allow it to be marked nomap.
+ * should not allow it to be marked nomap, but don't worry
+ * if the region isn't memory as it won't be mapped.
- if (memblock_is_region_reserved(base, size))
+ if (memblock_overlaps_region(&memblock.memory, base, size) &&
+ memblock_is_region_reserved(base, size))
return -EBUSY;

return memblock_mark_nomap(base, size);
base-commit: 136057256686de39cc3a07c2e39ef6bc43003ff6

 \ /
  Last update: 2021-12-15 20:55    [W:0.131 / U:1.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site