[RFC PATCH 3/8] mm: memblock: Add a means to add to memblock.reserved

Jonathan Cameron Jonathan.Cameron at huawei.com
Wed May 29 10:12:31 PDT 2024


For CXL CFMWS regions, need to add memblocks that may not be
in the system memory map so that their nid can be queried later.
Add a function to make this easy to do.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron at huawei.com>
---
 include/linux/memblock.h |  2 ++
 mm/memblock.c            | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index c7d518a54359..9ac1ed8c3293 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -113,6 +113,8 @@ static inline void memblock_discard(void) {}
 void memblock_allow_resize(void);
 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid,
 		      enum memblock_flags flags);
+int memblock_add_reserved_node(phys_addr_t base, phys_addr_t size, int nid,
+		      enum memblock_flags flags);
 int memblock_add(phys_addr_t base, phys_addr_t size);
 int memblock_remove(phys_addr_t base, phys_addr_t size);
 int memblock_phys_free(phys_addr_t base, phys_addr_t size);
diff --git a/mm/memblock.c b/mm/memblock.c
index 5498d5ea70b4..8d02f75ec186 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -714,6 +714,17 @@ int __init_memblock memblock_add_node(phys_addr_t base, phys_addr_t size,
 	return memblock_add_range(&memblock.memory, base, size, nid, flags);
 }
 
+int __init_memblock memblock_add_reserved_node(phys_addr_t base, phys_addr_t size,
+				      int nid, enum memblock_flags flags)
+{
+	phys_addr_t end = base + size - 1;
+
+	memblock_dbg("%s: [%pa-%pa] nid=%d flags=%x %pS\n", __func__,
+		     &base, &end, nid, flags, (void *)_RET_IP_);
+
+	return memblock_add_range(&memblock.reserved, base, size, nid, flags);
+}
+
 /**
  * memblock_add - add new memblock region
  * @base: base address of the new region
-- 
2.39.2




More information about the linux-arm-kernel mailing list