public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations
@ 2026-01-07 13:04 Gregory CLEMENT
  2026-01-07 13:04 ` [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation Gregory CLEMENT
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-07 13:04 UTC (permalink / raw)
  To: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd, Gregory CLEMENT

Hello,

While working on adding reserved RAM support to the MTD physmap
driver, I encountered a limitation in the kernel's reserved memory
support: although the Device Tree specification allows multiple reg
entries for a memory-region node, the kernel only processed the first
one. This limitation prevented proper support for reserved RAM regions
in MTD.

This series addresses both issues:

First, the reserved memory support is extended to fully support
multiple reg entries per memory-region node, ensuring compliance with
the Device Tree specification.

Then, with this foundation in place, the series updates the MTD
physmap driver to support reserved RAM regions. The DT bindings are
extended to allow memory-region for RAM access, and the physmap driver
is modified to use these regions.

Gregory

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
Changes in v3:

- Fix the placement of the __free() annotation in patch 4, and also
  address the same issue in the current codebase with patch 1.
- Add MTD properties directly into /reserved-memory nodes, as
  suggested by Rob.
- Rebase on v6.19-rc1
- Link to v2: https://lore.kernel.org/r/20251121-mtd-memregion-v2-0-c5535fdcebe4@bootlin.com

Changes in v2:

- Properly managed cases where register entries used by the memory
  region are out of order, particularly when one or more register
  entries are mixed with memory region entries in an other node.
- Used "memlog" as the node name instead of "sram," which was misleading.
- Link to v1: https://lore.kernel.org/r/20251117-mtd-memregion-v1-0-7b35611c79a6@bootlin.com

---
Gregory CLEMENT (4):
      of: reserved_mem: Fix placement of __free() annotation
      of: reserved_mem: Support multiple 'reg' entries for memory-region
      dt-bindings: mtd: physmap: Allow using memory-region to access memory resources
      mtd: physmap: Add support for RAM reserved memory regions

 .../devicetree/bindings/mtd/mtd-physmap.yaml       |  69 +++++++---
 drivers/mtd/maps/physmap-core.c                    |  73 ++++++++--
 drivers/of/of_reserved_mem.c                       | 150 ++++++++++++++++++---
 drivers/of/platform.c                              |   2 +
 include/linux/of_reserved_mem.h                    |   4 +
 5 files changed, 252 insertions(+), 46 deletions(-)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251117-mtd-memregion-8830c1dd70ce

Best regards,
-- 
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation
  2026-01-07 13:04 [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations Gregory CLEMENT
@ 2026-01-07 13:04 ` Gregory CLEMENT
  2026-01-21  2:30   ` Rob Herring (Arm)
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-07 13:04 UTC (permalink / raw)
  To: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd, Gregory CLEMENT

The __free() annotation was incorrectly placed before the variable
name instead of after it, which resulted in the following checkpatch
errors:

ERROR: need consistent spacing around '*' (ctx:WxV)
+       struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx);
                                               ^
WARNING: function definition argument 'idx' should also have an identifier name
+       struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx);

As part of this cleanup, also remove the useless return statement
flagged by checkpatch.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 drivers/of/of_reserved_mem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 5619ec9178587..1ab8f4153600b 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -127,7 +127,6 @@ static void __init fdt_reserved_mem_save_node(unsigned long node, const char *un
 	fdt_init_reserved_mem_node(rmem);
 
 	reserved_mem_count++;
-	return;
 }
 
 static int __init early_init_dt_reserve_memory(phys_addr_t base,
@@ -747,7 +746,7 @@ int of_reserved_mem_region_to_resource(const struct device_node *np,
 	if (!np)
 		return -EINVAL;
 
-	struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx);
+	struct device_node *target __free(device_node) = of_parse_phandle(np, "memory-region", idx);
 	if (!target || !of_device_is_available(target))
 		return -ENODEV;
 

-- 
2.51.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations Gregory CLEMENT
  2026-01-07 13:04 ` [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation Gregory CLEMENT
@ 2026-01-07 13:04 ` Gregory CLEMENT
  2026-01-08 20:17   ` kernel test robot
                     ` (4 more replies)
  2026-01-07 13:04 ` [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources Gregory CLEMENT
  2026-01-07 13:04 ` [PATCH v3 4/4] mtd: physmap: Add support for RAM reserved memory regions Gregory CLEMENT
  3 siblings, 5 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-07 13:04 UTC (permalink / raw)
  To: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd, Gregory CLEMENT

The Device Tree specification allows a "memory-region" node to have
multiple 'reg' entries, but the current kernel implementation only
processes the first entry. This can lead to drivers not being able to
access all the reserved memory regions specified in the Device Tree.

This patch extends the reserved memory handling to support multiple
'reg' entries for a single "memory-region" node. The existing exported
functions remain unchanged for backward compatibility, but new APIs
are introduced to allow drivers to access all reserved memory regions.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 drivers/of/of_reserved_mem.c    | 147 ++++++++++++++++++++++++++++++++++++----
 include/linux/of_reserved_mem.h |   4 ++
 2 files changed, 137 insertions(+), 14 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 1ab8f4153600b..c9cef279260e7 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -157,6 +157,7 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
 	int i, len;
 	const __be32 *prop;
 	bool nomap;
+	int count = 0;
 
 	prop = of_flat_dt_get_addr_size_prop(node, "reg", &len);
 	if (!prop)
@@ -179,12 +180,13 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
 				dma_contiguous_early_fixup(base, size);
 			pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
 				uname, &base, (unsigned long)(size / SZ_1M));
+			count++;
 		} else {
 			pr_err("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n",
 			       uname, &base, (unsigned long)(size / SZ_1M));
 		}
 	}
-	return 0;
+	return count;
 }
 
 /*
@@ -247,20 +249,24 @@ void __init fdt_scan_reserved_mem_reg_nodes(void)
 
 	fdt_for_each_subnode(child, fdt, node) {
 		const char *uname;
+		const __be32 *reg;
 		u64 b, s;
+		int i, l;
 
 		if (!of_fdt_device_is_available(fdt, child))
 			continue;
-
-		if (!of_flat_dt_get_addr_size(child, "reg", &b, &s))
+		reg = of_flat_dt_get_addr_size_prop(child, "reg", &l);
+		if (!reg)
 			continue;
-
-		base = b;
-		size = s;
-
-		if (size) {
-			uname = fdt_get_name(fdt, child, NULL);
-			fdt_reserved_mem_save_node(child, uname, base, size);
+		for (i = 0; i < l; i++) {
+			of_flat_dt_read_addr_size(reg, i, &b, &s);
+			base = b;
+			size = s;
+
+			if (size) {
+				uname = fdt_get_name(fdt, child, NULL);
+				fdt_reserved_mem_save_node(child, uname, base, size);
+			}
 		}
 	}
 
@@ -291,16 +297,16 @@ int __init fdt_scan_reserved_mem(void)
 
 	fdt_for_each_subnode(child, fdt, node) {
 		const char *uname;
-		int err;
+		int err, ret;
 
 		if (!of_fdt_device_is_available(fdt, child))
 			continue;
 
 		uname = fdt_get_name(fdt, child, NULL);
 
-		err = __reserved_mem_reserve_reg(child, uname);
-		if (!err)
-			count++;
+		ret = __reserved_mem_reserve_reg(child, uname);
+		if (ret > 0)
+			count += ret;
 		/*
 		 * Save the nodes for the dynamically-placed regions
 		 * into an array which will be used for allocation right
@@ -726,6 +732,35 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np)
 }
 EXPORT_SYMBOL_GPL(of_reserved_mem_lookup);
 
+/**
+ * of_reserved_mem_array_lookup() - acquire reserved_mem array from a device node
+ * @np:		node pointer of the desired reserved-memory region
+ * @rmrm:	pointer to the first elemennt of the reserved_mem struct of the memory region
+ *
+ * This function allows drivers to acquire a reference to the array of the
+ *  reserved_mem struct based on a device node handle.
+ *
+ * Returns the number reserved_mem elements
+ */
+int of_reserved_mem_array_lookup(struct device_node *np,
+				 struct reserved_mem **rmem)
+{
+	const char *name;
+	int i, count = 0;
+
+	if (!np->full_name)
+		return 0;
+
+	name = kbasename(np->full_name);
+
+	for (i = 0; i < reserved_mem_count; i++)
+		if (!strcmp(reserved_mem[i].name, name))
+			rmem[count++] = &reserved_mem[i];
+
+	return count;
+}
+EXPORT_SYMBOL_GPL(of_reserved_mem_array_lookup);
+
 /**
  * of_reserved_mem_region_to_resource() - Get a reserved memory region as a resource
  * @np:		node containing 'memory-region' property
@@ -761,6 +796,49 @@ int of_reserved_mem_region_to_resource(const struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_reserved_mem_region_to_resource);
 
+/**
+ * of_reserved_mem_region_to_resource_array() - Get a reserved memory region as a resources
+ * @dev:	device associated to the node
+ * @np:		node containing 'memory-region' property
+ * @idx:	index of 'memory-region' property to lookup
+ * @res:	Pointer to an array of struct resource pointers to fill in with reserved regions
+ *
+ * This function allows drivers to lookup a node's 'memory-region' property
+ * entries by index and fill an array of struct resource pointers for the entries.
+ *
+ * Returns the number of resources filled in @res on success.
+ * Returns -ENODEV if 'memory-region' is missing or unavailable,
+ * -EINVAL for any other error.
+ */
+int of_reserved_mem_region_to_resource_array(struct device *dev, const struct device_node *np,
+					     unsigned int idx, struct resource **res)
+{
+	struct reserved_mem *rmem[MAX_RESERVED_REGIONS];
+	int count, i;
+	struct resource *r;
+
+	if (!np)
+		return -EINVAL;
+
+	struct device_node *target __free(device_node) = of_parse_phandle(np, "memory-region", idx);
+	if (!target || !of_device_is_available(target))
+		return -ENODEV;
+
+	count = of_reserved_mem_array_lookup(target, rmem);
+	if (count <= 0)
+		return -EINVAL;
+
+	*res = devm_kzalloc(dev, count * sizeof(struct resource), GFP_KERNEL);
+	r = res[0];
+	for (i = 0; i < count; i++) {
+		resource_set_range(&r[i], rmem[i]->base, rmem[i]->size);
+		r[i].flags = IORESOURCE_MEM;
+		r[i].name = rmem[i]->name;
+	}
+	return count;
+}
+EXPORT_SYMBOL_GPL(of_reserved_mem_region_to_resource_array);
+
 /**
  * of_reserved_mem_region_to_resource_byname() - Get a reserved memory region as a resource
  * @np:		node containing 'memory-region' property
@@ -805,3 +883,44 @@ int of_reserved_mem_region_count(const struct device_node *np)
 	return of_count_phandle_with_args(np, "memory-region", NULL);
 }
 EXPORT_SYMBOL_GPL(of_reserved_mem_region_count);
+
+/**
+ * of_reserved_mem_region_count() - Return the total number of reserved memory regions
+ * @np:		node containing 'memory-region' property
+ *
+ * This function counts the total number of reserved memory regions referenced
+ * by a node's 'memory-region' property. It iterates over each phandle and sums
+ * the number of regions found in each referenced reserved memory node.
+ *
+ * Returns the total number of reserved memory regions on success.
+ * This function allows drivers to retrieve the number of entries for a node's
+ * 'memory-region' property.
+ *
+ * Returns total number of reserved memory regions on success, or negative error
+ * code on a malformed property.
+ */
+int of_reserved_mem_region_total_count(const struct device_node *np)
+{
+	int nregion = of_count_phandle_with_args(np, "memory-region", NULL);
+	struct device_node *target;
+	int i, nregs = 0;
+
+	for (i = 0; i < nregion; i++) {
+		struct reserved_mem *rmem;
+
+		target = of_parse_phandle(np, "memory-region", i);
+		if (!target)
+			return -ENODEV;
+
+		if (!of_device_is_available(target)) {
+			of_node_put(target);
+			return 0;
+		}
+
+		nregs += of_reserved_mem_array_lookup(target, &rmem);
+
+		of_node_put(target);
+	};
+	return nregs;
+}
+EXPORT_SYMBOL_GPL(of_reserved_mem_region_total_count);
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index f573423359f48..1e0c6afddd812 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -40,11 +40,15 @@ int of_reserved_mem_device_init_by_name(struct device *dev,
 void of_reserved_mem_device_release(struct device *dev);
 
 struct reserved_mem *of_reserved_mem_lookup(struct device_node *np);
+int of_reserved_mem_array_lookup(struct device_node *np, struct reserved_mem **rmem);
 int of_reserved_mem_region_to_resource(const struct device_node *np,
 				       unsigned int idx, struct resource *res);
+int of_reserved_mem_region_to_resource_array(struct device *dev, const struct device_node *np,
+					     unsigned int idx, struct resource **res);
 int of_reserved_mem_region_to_resource_byname(const struct device_node *np,
 					      const char *name, struct resource *res);
 int of_reserved_mem_region_count(const struct device_node *np);
+int of_reserved_mem_region_total_count(const struct device_node *np);
 
 #else
 

-- 
2.51.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources
  2026-01-07 13:04 [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations Gregory CLEMENT
  2026-01-07 13:04 ` [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation Gregory CLEMENT
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
@ 2026-01-07 13:04 ` Gregory CLEMENT
  2026-01-09  9:52   ` Linus Walleij
  2026-01-07 13:04 ` [PATCH v3 4/4] mtd: physmap: Add support for RAM reserved memory regions Gregory CLEMENT
  3 siblings, 1 reply; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-07 13:04 UTC (permalink / raw)
  To: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd, Gregory CLEMENT

Enable access to memory resources not only via I/O address using reg,
but also through a portion of main memory using memory-region. To
achieve this, new compatible strings have been introduced: mtd-mem and
mtd-memro.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 .../devicetree/bindings/mtd/mtd-physmap.yaml       | 69 ++++++++++++++++------
 1 file changed, 52 insertions(+), 17 deletions(-)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
index a9ec3ca002c7d..98d45982d8eb9 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
@@ -13,10 +13,6 @@ description: |
   Flash chips (Memory Technology Devices) are often used for solid state
   file systems on embedded devices.
 
-allOf:
-  - $ref: mtd.yaml#
-  - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
-
 properties:
   compatible:
     oneOf:
@@ -61,6 +57,8 @@ properties:
           - jedec-flash
           - mtd-ram
           - mtd-rom
+          - mtd-mem
+          - mtd-memro
 
   reg:
     description: |
@@ -141,19 +139,37 @@ required:
   - compatible
   - reg
 
-if:
-  properties:
-    compatible:
-      contains:
-        const: cortina,gemini-flash
-then:
-  properties:
-    syscon:
-      $ref: /schemas/types.yaml#/definitions/phandle
-      description:
-        Phandle to the syscon controller
-  required:
-    - syscon
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: cortina,gemini-flash
+    then:
+      properties:
+        syscon:
+          $ref: /schemas/types.yaml#/definitions/phandle
+          description:
+            Phandle to the syscon controller
+          required:
+            - syscon
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - mtd-mem
+              - mtd-memro
+    then:
+      $ref: /schemas/reserved-memory/reserved-memory.yaml
+      required:
+        - no-map
+      properties:
+        addr-gpios: false
+    else:
+      allOf:
+        - $ref: /schemas/mtd/mtd.yaml
+        - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
 
 unevaluatedProperties: false
 
@@ -233,4 +249,23 @@ examples:
             reg = <0 0x04000000>;
         };
     };
+
+  - |
+    /* An example using mtd-mem/mtd-memro */
+    reserved-memory {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        bm_logs_reserved: bm_logs_reserved@10000800 {
+            compatible = "mtd-mem";
+            reg = <0x1 0x0000800 0x0 0x0010000>;
+            no-map;
+        };
+
+        sys_logs_reserved: sys_logs_reserved@100120000  {
+            compatible = "mtd-memro";
+            reg = <0x1 0x00120000 0x0 0x0010000>;
+            no-map;
+        };
+    };
 ...

-- 
2.51.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 4/4] mtd: physmap: Add support for RAM reserved memory regions
  2026-01-07 13:04 [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations Gregory CLEMENT
                   ` (2 preceding siblings ...)
  2026-01-07 13:04 ` [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources Gregory CLEMENT
@ 2026-01-07 13:04 ` Gregory CLEMENT
  3 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-07 13:04 UTC (permalink / raw)
  To: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd, Gregory CLEMENT

MTD fixed-partitions can now be exposed for reserved RAM regions, not
just ROM reg regions. This is achieved by using the new compatible
property (mtd-mem or mtd-memro) previously introduced in the reserved
memory region node.

Based on the work of Muhammad Musa <muhammad.musa@intel.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 drivers/mtd/maps/physmap-core.c | 73 +++++++++++++++++++++++++++++++++--------
 drivers/of/platform.c           |  2 ++
 2 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index 2bd7a1af898c9..cc7d08a413c78 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -39,6 +39,7 @@
 #include <linux/mtd/cfi_endian.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_reserved_mem.h>
 #include <linux/pm_runtime.h>
 #include <linux/gpio/consumer.h>
 
@@ -263,6 +264,14 @@ static const struct of_device_id of_flash_match[] = {
 		.type = "rom",
 		.compatible = "direct-mapped"
 	},
+	{
+		.compatible = "mtd-mem",
+		.data = "map_ram",
+	},
+	{
+		.compatible = "mtd-memro",
+		.data = "map_rom",
+	},
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, of_flash_match);
@@ -348,10 +357,19 @@ static int physmap_flash_of_init(struct platform_device *dev)
 
 	map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access");
 
-	err = of_property_read_u32(dp, "bank-width", &bankwidth);
-	if (err) {
-		dev_err(&dev->dev, "Can't get bank width from device tree\n");
-		return err;
+	if ((of_device_is_compatible(dp, "mtd-mem")) ||
+	    (of_device_is_compatible(dp, "mtd-memro"))) {
+		/*
+		 * When using reserved memory region from DRAM we use
+		 * the defaullt 32 bits acces
+		 */
+		bankwidth = 4;
+	} else {
+		err = of_property_read_u32(dp, "bank-width", &bankwidth);
+		if (err) {
+			dev_err(&dev->dev, "Can't get bank width from device tree\n");
+			return err;
+		}
 	}
 
 	if (of_property_read_bool(dp, "big-endian"))
@@ -446,8 +464,9 @@ static int physmap_flash_pdata_init(struct platform_device *dev)
 static int physmap_flash_probe(struct platform_device *dev)
 {
 	struct physmap_flash_info *info;
-	int err = 0;
-	int i;
+	struct resource *res_array;
+	int err = 0, is_rsvd_mem = 0, nreg = 0;
+	int i, curr_reg;
 
 	if (!dev->dev.of_node && !dev_get_platdata(&dev->dev))
 		return -EINVAL;
@@ -459,9 +478,13 @@ static int physmap_flash_probe(struct platform_device *dev)
 	while (platform_get_resource(dev, IORESOURCE_MEM, info->nmaps))
 		info->nmaps++;
 
-	if (!info->nmaps)
-		return -ENODEV;
-
+	if (!info->nmaps) {
+		info->nmaps = of_reserved_mem_region_total_count(dev->dev.of_node);
+		if (info->nmaps > 0)
+			is_rsvd_mem = 1;
+		else
+			return -ENODEV;
+	}
 	info->maps = devm_kzalloc(&dev->dev,
 				  sizeof(*info->maps) * info->nmaps,
 				  GFP_KERNEL);
@@ -503,7 +526,23 @@ static int physmap_flash_probe(struct platform_device *dev)
 	for (i = 0; i < info->nmaps; i++) {
 		struct resource *res;
 
-		info->maps[i].virt = devm_platform_get_and_ioremap_resource(dev, i, &res);
+		if (is_rsvd_mem) {
+			if (nreg <= i) {
+				int cnt = of_reserved_mem_region_to_resource_array(&dev->dev,
+							   dev->dev.of_node, i, &res_array);
+				if (cnt < 0) {
+					err = cnt;
+					goto err_out;
+				}
+				nreg += cnt;
+				curr_reg = 0;
+			}
+			res = &res_array[curr_reg++];
+			info->maps[i].virt = devm_ioremap_resource(&dev->dev, res);
+		} else {
+			info->maps[i].virt = devm_platform_get_and_ioremap_resource(dev, i, &res);
+		}
+
 		if (IS_ERR(info->maps[i].virt)) {
 			err = PTR_ERR(info->maps[i].virt);
 			goto err_out;
@@ -519,9 +558,17 @@ static int physmap_flash_probe(struct platform_device *dev)
 			info->maps[i].phys = res->start;
 
 		info->win_order = fls64(resource_size(res)) - 1;
-		info->maps[i].size = BIT(info->win_order +
-					 (info->gpios ?
-					  info->gpios->ndescs : 0));
+		/* When using a memory region, the size is not necessarily a
+		 * power of 2, so win_order is not applicable. Since GPIOs are
+		 * unavailable in this context, directly using the region's size
+		 * is safe.
+		 */
+		if (is_rsvd_mem)
+			info->maps[i].size = resource_size(res);
+		else
+			info->maps[i].size = BIT(info->win_order +
+						 (info->gpios ?
+						  info->gpios->ndescs : 0));
 
 		info->maps[i].map_priv_1 = (unsigned long)dev;
 
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index f77cb19973a5d..23ea5a723aa7f 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -496,6 +496,8 @@ static const struct of_device_id reserved_mem_matches[] = {
 	{ .compatible = "ramoops" },
 	{ .compatible = "nvmem-rmem" },
 	{ .compatible = "google,open-dice" },
+	{ .compatible = "mtd-memro" },
+	{ .compatible = "mtd-mem" },
 	{}
 };
 

-- 
2.51.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
@ 2026-01-08 20:17   ` kernel test robot
  2026-01-09 16:12     ` Gregory CLEMENT
  2026-01-08 23:06   ` kernel test robot
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: kernel test robot @ 2026-01-08 20:17 UTC (permalink / raw)
  To: Gregory CLEMENT, Rob Herring, Linus Walleij, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Conor Dooley
  Cc: oe-kbuild-all, Thomas Petazzoni, Vladimir Kondratiev,
	Benoît Monin, Théo Lebrun, devicetree, linux-kernel,
	linux-arm-kernel, linux-mtd, Gregory CLEMENT

Hi Gregory,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-CLEMENT/of-reserved_mem-Fix-placement-of-__free-annotation/20260107-211455
base:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
patch link:    https://lore.kernel.org/r/20260107-mtd-memregion-v3-2-f9fc9107b992%40bootlin.com
patch subject: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
config: x86_64-rhel-9.4-kunit (https://download.01.org/0day-ci/archive/20260108/202601082105.TThX0916-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260108/202601082105.TThX0916-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601082105.TThX0916-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem' not described in 'of_reserved_mem_array_lookup'
>> Warning: drivers/of/of_reserved_mem.c:902 expecting prototype for of_reserved_mem_region_count(). Prototype was for of_reserved_mem_region_total_count() instead
>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem' not described in 'of_reserved_mem_array_lookup'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
  2026-01-08 20:17   ` kernel test robot
@ 2026-01-08 23:06   ` kernel test robot
  2026-01-13  2:59   ` kernel test robot
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2026-01-08 23:06 UTC (permalink / raw)
  To: Gregory CLEMENT, Rob Herring, Linus Walleij, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Conor Dooley
  Cc: oe-kbuild-all, Thomas Petazzoni, Vladimir Kondratiev,
	Benoît Monin, Théo Lebrun, devicetree, linux-kernel,
	linux-arm-kernel, linux-mtd, Gregory CLEMENT

Hi Gregory,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-CLEMENT/of-reserved_mem-Fix-placement-of-__free-annotation/20260107-211455
base:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
patch link:    https://lore.kernel.org/r/20260107-mtd-memregion-v3-2-f9fc9107b992%40bootlin.com
patch subject: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
config: arm64-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260109/202601090005.f0WEJEKH-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project f43d6834093b19baf79beda8c0337ab020ac5f17)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260109/202601090005.f0WEJEKH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601090005.f0WEJEKH-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/of/of_reserved_mem.c:317:7: warning: variable 'err' is uninitialized when used here [-Wuninitialized]
     317 |                 if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) {
         |                     ^~~
   drivers/of/of_reserved_mem.c:300:10: note: initialize the variable 'err' to silence this warning
     300 |                 int err, ret;
         |                        ^
         |                         = 0
   1 warning generated.


vim +/err +317 drivers/of/of_reserved_mem.c

8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  278  
54c180e73ffa3e Rob Herring        2024-03-11  279  /*
54c180e73ffa3e Rob Herring        2024-03-11  280   * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory
54c180e73ffa3e Rob Herring        2024-03-11  281   */
54c180e73ffa3e Rob Herring        2024-03-11  282  int __init fdt_scan_reserved_mem(void)
54c180e73ffa3e Rob Herring        2024-03-11  283  {
54c180e73ffa3e Rob Herring        2024-03-11  284  	int node, child;
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  285  	int dynamic_nodes_cnt = 0, count = 0;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  286  	int dynamic_nodes[MAX_RESERVED_REGIONS];
54c180e73ffa3e Rob Herring        2024-03-11  287  	const void *fdt = initial_boot_params;
54c180e73ffa3e Rob Herring        2024-03-11  288  
54c180e73ffa3e Rob Herring        2024-03-11  289  	node = fdt_path_offset(fdt, "/reserved-memory");
54c180e73ffa3e Rob Herring        2024-03-11  290  	if (node < 0)
54c180e73ffa3e Rob Herring        2024-03-11  291  		return -ENODEV;
54c180e73ffa3e Rob Herring        2024-03-11  292  
54c180e73ffa3e Rob Herring        2024-03-11  293  	if (__reserved_mem_check_root(node) != 0) {
54c180e73ffa3e Rob Herring        2024-03-11  294  		pr_err("Reserved memory: unsupported node format, ignoring\n");
54c180e73ffa3e Rob Herring        2024-03-11  295  		return -EINVAL;
54c180e73ffa3e Rob Herring        2024-03-11  296  	}
54c180e73ffa3e Rob Herring        2024-03-11  297  
54c180e73ffa3e Rob Herring        2024-03-11  298  	fdt_for_each_subnode(child, fdt, node) {
54c180e73ffa3e Rob Herring        2024-03-11  299  		const char *uname;
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  300  		int err, ret;
54c180e73ffa3e Rob Herring        2024-03-11  301  
54c180e73ffa3e Rob Herring        2024-03-11  302  		if (!of_fdt_device_is_available(fdt, child))
54c180e73ffa3e Rob Herring        2024-03-11  303  			continue;
54c180e73ffa3e Rob Herring        2024-03-11  304  
54c180e73ffa3e Rob Herring        2024-03-11  305  		uname = fdt_get_name(fdt, child, NULL);
54c180e73ffa3e Rob Herring        2024-03-11  306  
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  307  		ret = __reserved_mem_reserve_reg(child, uname);
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  308  		if (ret > 0)
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  309  			count += ret;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  310  		/*
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  311  		 * Save the nodes for the dynamically-placed regions
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  312  		 * into an array which will be used for allocation right
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  313  		 * after all the statically-placed regions are reserved
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  314  		 * or marked as no-map. This is done to avoid dynamically
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  315  		 * allocating from one of the statically-placed regions.
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  316  		 */
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08 @317  		if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) {
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  318  			dynamic_nodes[dynamic_nodes_cnt] = child;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  319  			dynamic_nodes_cnt++;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  320  		}
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  321  	}
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  322  	for (int i = 0; i < dynamic_nodes_cnt; i++) {
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  323  		const char *uname;
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  324  		int err;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  325  
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  326  		child = dynamic_nodes[i];
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  327  		uname = fdt_get_name(fdt, child, NULL);
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  328  		err = __reserved_mem_alloc_size(child, uname);
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  329  		if (!err)
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  330  			count++;
54c180e73ffa3e Rob Herring        2024-03-11  331  	}
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  332  	total_reserved_mem_cnt = count;
54c180e73ffa3e Rob Herring        2024-03-11  333  	return 0;
54c180e73ffa3e Rob Herring        2024-03-11  334  }
54c180e73ffa3e Rob Herring        2024-03-11  335  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources
  2026-01-07 13:04 ` [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources Gregory CLEMENT
@ 2026-01-09  9:52   ` Linus Walleij
  0 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2026-01-09  9:52 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Rob Herring, Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley,
	Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd

Hi Gregory,

thanks for your patch!

On Wed, Jan 7, 2026 at 2:05 PM Gregory CLEMENT
<gregory.clement@bootlin.com> wrote:

> Enable access to memory resources not only via I/O address using reg,
> but also through a portion of main memory using memory-region. To
> achieve this, new compatible strings have been introduced: mtd-mem and
> mtd-memro.
>
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>

I have two issues with this patch:

1. It needs a description: telling us when to use this and why, and
what makes it necessary to use these new bindings instead of existing
bindings, like the following:

2. To me this looks suspiciously similar to reserved RAM, "reserved-memory".
Documentation/devicetree/bindings/reserved-memory/phram.yaml
Documentation/devicetree/bindings/nvmem/rmem.yaml
Documentation/devicetree/bindings/reserved-memory/ramoops.yaml

Also see the dtschema reserved-memory:
https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/reserved-memory/reserved-memory.yaml

Why is this using "mtd,*" compatibles? What makes is a
"memory technology device", which is admittedly a loose term but
usually means some kind of persistent memory such as flash. This does
not look persistent at all.

To me it seems more related to specific Linux-lingo around the MTD
subsystem and just happens to be handled inside that subsystem in
Linux. Which means it has nothing to do inside a (OS-neutral) DT binding.

So I'm a bit concerned, but maybe I misunderstood something!

Yours,
Linus Walleij

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-08 20:17   ` kernel test robot
@ 2026-01-09 16:12     ` Gregory CLEMENT
  0 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2026-01-09 16:12 UTC (permalink / raw)
  To: kernel test robot, Rob Herring, Linus Walleij, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Conor Dooley
  Cc: oe-kbuild-all, Thomas Petazzoni, Vladimir Kondratiev,
	Benoît Monin, Théo Lebrun, devicetree, linux-kernel,
	linux-arm-kernel, linux-mtd

kernel test robot <lkp@intel.com> writes:

> Hi Gregory,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-CLEMENT/of-reserved_mem-Fix-placement-of-__free-annotation/20260107-211455
> base:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
> patch link:    https://lore.kernel.org/r/20260107-mtd-memregion-v3-2-f9fc9107b992%40bootlin.com
> patch subject: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
> config: x86_64-rhel-9.4-kunit (https://download.01.org/0day-ci/archive/20260108/202601082105.TThX0916-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260108/202601082105.TThX0916-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202601082105.TThX0916-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
>>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem' not described in 'of_reserved_mem_array_lookup'
>>> Warning: drivers/of/of_reserved_mem.c:902 expecting prototype for of_reserved_mem_region_count(). Prototype was for of_reserved_mem_region_total_count() instead
>>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem'
>not described in 'of_reserved_mem_array_lookup'

It was a stupid typo in the description!

I will fix it.

Gregory

>
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

-- 
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
  2026-01-08 20:17   ` kernel test robot
  2026-01-08 23:06   ` kernel test robot
@ 2026-01-13  2:59   ` kernel test robot
  2026-01-13  3:41   ` kernel test robot
  2026-01-14 22:31   ` Rob Herring
  4 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2026-01-13  2:59 UTC (permalink / raw)
  To: Gregory CLEMENT, Rob Herring, Linus Walleij, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Conor Dooley
  Cc: oe-kbuild-all, Thomas Petazzoni, Vladimir Kondratiev,
	Benoît Monin, Théo Lebrun, devicetree, linux-kernel,
	linux-arm-kernel, linux-mtd, Gregory CLEMENT

Hi Gregory,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-CLEMENT/of-reserved_mem-Fix-placement-of-__free-annotation/20260107-211455
base:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
patch link:    https://lore.kernel.org/r/20260107-mtd-memregion-v3-2-f9fc9107b992%40bootlin.com
patch subject: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
config: arc-allnoconfig (https://download.01.org/0day-ci/archive/20260113/202601131045.DOJtnS0c-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260113/202601131045.DOJtnS0c-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601131045.DOJtnS0c-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem' not described in 'of_reserved_mem_array_lookup'
>> Warning: drivers/of/of_reserved_mem.c:902 expecting prototype for of_reserved_mem_region_count(). Prototype was for of_reserved_mem_region_total_count() instead
>> Warning: drivers/of/of_reserved_mem.c:746 function parameter 'rmem' not described in 'of_reserved_mem_array_lookup'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
                     ` (2 preceding siblings ...)
  2026-01-13  2:59   ` kernel test robot
@ 2026-01-13  3:41   ` kernel test robot
  2026-01-14 22:31   ` Rob Herring
  4 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2026-01-13  3:41 UTC (permalink / raw)
  To: Gregory CLEMENT, Rob Herring, Linus Walleij, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, Krzysztof Kozlowski,
	Conor Dooley
  Cc: llvm, oe-kbuild-all, Thomas Petazzoni, Vladimir Kondratiev,
	Benoît Monin, Théo Lebrun, devicetree, linux-kernel,
	linux-arm-kernel, linux-mtd, Gregory CLEMENT

Hi Gregory,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8f0b4cce4481fb22653697cced8d0d04027cb1e8]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-CLEMENT/of-reserved_mem-Fix-placement-of-__free-annotation/20260107-211455
base:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
patch link:    https://lore.kernel.org/r/20260107-mtd-memregion-v3-2-f9fc9107b992%40bootlin.com
patch subject: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20260113/202601131101.q65jw7p0-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260113/202601131101.q65jw7p0-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601131101.q65jw7p0-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/of/of_reserved_mem.c:317:7: warning: variable 'err' is uninitialized when used here [-Wuninitialized]
     317 |                 if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) {
         |                     ^~~
   drivers/of/of_reserved_mem.c:300:10: note: initialize the variable 'err' to silence this warning
     300 |                 int err, ret;
         |                        ^
         |                         = 0
   1 warning generated.


vim +/err +317 drivers/of/of_reserved_mem.c

8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  278  
54c180e73ffa3e Rob Herring        2024-03-11  279  /*
54c180e73ffa3e Rob Herring        2024-03-11  280   * fdt_scan_reserved_mem() - scan a single FDT node for reserved memory
54c180e73ffa3e Rob Herring        2024-03-11  281   */
54c180e73ffa3e Rob Herring        2024-03-11  282  int __init fdt_scan_reserved_mem(void)
54c180e73ffa3e Rob Herring        2024-03-11  283  {
54c180e73ffa3e Rob Herring        2024-03-11  284  	int node, child;
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  285  	int dynamic_nodes_cnt = 0, count = 0;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  286  	int dynamic_nodes[MAX_RESERVED_REGIONS];
54c180e73ffa3e Rob Herring        2024-03-11  287  	const void *fdt = initial_boot_params;
54c180e73ffa3e Rob Herring        2024-03-11  288  
54c180e73ffa3e Rob Herring        2024-03-11  289  	node = fdt_path_offset(fdt, "/reserved-memory");
54c180e73ffa3e Rob Herring        2024-03-11  290  	if (node < 0)
54c180e73ffa3e Rob Herring        2024-03-11  291  		return -ENODEV;
54c180e73ffa3e Rob Herring        2024-03-11  292  
54c180e73ffa3e Rob Herring        2024-03-11  293  	if (__reserved_mem_check_root(node) != 0) {
54c180e73ffa3e Rob Herring        2024-03-11  294  		pr_err("Reserved memory: unsupported node format, ignoring\n");
54c180e73ffa3e Rob Herring        2024-03-11  295  		return -EINVAL;
54c180e73ffa3e Rob Herring        2024-03-11  296  	}
54c180e73ffa3e Rob Herring        2024-03-11  297  
54c180e73ffa3e Rob Herring        2024-03-11  298  	fdt_for_each_subnode(child, fdt, node) {
54c180e73ffa3e Rob Herring        2024-03-11  299  		const char *uname;
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  300  		int err, ret;
54c180e73ffa3e Rob Herring        2024-03-11  301  
54c180e73ffa3e Rob Herring        2024-03-11  302  		if (!of_fdt_device_is_available(fdt, child))
54c180e73ffa3e Rob Herring        2024-03-11  303  			continue;
54c180e73ffa3e Rob Herring        2024-03-11  304  
54c180e73ffa3e Rob Herring        2024-03-11  305  		uname = fdt_get_name(fdt, child, NULL);
54c180e73ffa3e Rob Herring        2024-03-11  306  
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  307  		ret = __reserved_mem_reserve_reg(child, uname);
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  308  		if (ret > 0)
8be14ac8dccc70 Gregory CLEMENT    2026-01-07  309  			count += ret;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  310  		/*
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  311  		 * Save the nodes for the dynamically-placed regions
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  312  		 * into an array which will be used for allocation right
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  313  		 * after all the statically-placed regions are reserved
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  314  		 * or marked as no-map. This is done to avoid dynamically
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  315  		 * allocating from one of the statically-placed regions.
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  316  		 */
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08 @317  		if (err == -ENOENT && of_get_flat_dt_prop(child, "size", NULL)) {
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  318  			dynamic_nodes[dynamic_nodes_cnt] = child;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  319  			dynamic_nodes_cnt++;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  320  		}
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  321  	}
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  322  	for (int i = 0; i < dynamic_nodes_cnt; i++) {
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  323  		const char *uname;
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  324  		int err;
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  325  
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  326  		child = dynamic_nodes[i];
8a6e02d0c00e7b Oreoluwa Babatunde 2024-10-08  327  		uname = fdt_get_name(fdt, child, NULL);
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  328  		err = __reserved_mem_alloc_size(child, uname);
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  329  		if (!err)
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  330  			count++;
54c180e73ffa3e Rob Herring        2024-03-11  331  	}
00c9a452a235c6 Oreoluwa Babatunde 2024-10-08  332  	total_reserved_mem_cnt = count;
54c180e73ffa3e Rob Herring        2024-03-11  333  	return 0;
54c180e73ffa3e Rob Herring        2024-03-11  334  }
54c180e73ffa3e Rob Herring        2024-03-11  335  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region
  2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
                     ` (3 preceding siblings ...)
  2026-01-13  3:41   ` kernel test robot
@ 2026-01-14 22:31   ` Rob Herring
  4 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2026-01-14 22:31 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Linus Walleij, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Krzysztof Kozlowski, Conor Dooley,
	Thomas Petazzoni, Vladimir Kondratiev, Benoît Monin,
	Théo Lebrun, devicetree, linux-kernel, linux-arm-kernel,
	linux-mtd

On Wed, Jan 07, 2026 at 02:04:53PM +0100, Gregory CLEMENT wrote:
> The Device Tree specification allows a "memory-region" node to have
> multiple 'reg' entries, but the current kernel implementation only
> processes the first entry. This can lead to drivers not being able to
> access all the reserved memory regions specified in the Device Tree.

This may be a case of we change the spec. Or at least say, nodes 
referenced by memory-region can only have 1 region. Are there some 
existing users needing this functionality?

Rob

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation
  2026-01-07 13:04 ` [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation Gregory CLEMENT
@ 2026-01-21  2:30   ` Rob Herring (Arm)
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring (Arm) @ 2026-01-21  2:30 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Vignesh Raghavendra, linux-arm-kernel, Miquel Raynal,
	Richard Weinberger, linux-kernel, linux-mtd, devicetree,
	Krzysztof Kozlowski, Thomas Petazzoni, Théo Lebrun,
	Conor Dooley, Benoît Monin, Vladimir Kondratiev,
	Linus Walleij


On Wed, 07 Jan 2026 14:04:52 +0100, Gregory CLEMENT wrote:
> The __free() annotation was incorrectly placed before the variable
> name instead of after it, which resulted in the following checkpatch
> errors:
> 
> ERROR: need consistent spacing around '*' (ctx:WxV)
> +       struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx);
>                                                ^
> WARNING: function definition argument 'idx' should also have an identifier name
> +       struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx);
> 
> As part of this cleanup, also remove the useless return statement
> flagged by checkpatch.
> 
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
> ---
>  drivers/of/of_reserved_mem.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Applied, thanks!


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-01-21  2:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 13:04 [PATCH v3 0/4] MTD physmap: Adding reserved RAM support and fixing reserved_mem limitations Gregory CLEMENT
2026-01-07 13:04 ` [PATCH v3 1/4] of: reserved_mem: Fix placement of __free() annotation Gregory CLEMENT
2026-01-21  2:30   ` Rob Herring (Arm)
2026-01-07 13:04 ` [PATCH v3 2/4] of: reserved_mem: Support multiple 'reg' entries for memory-region Gregory CLEMENT
2026-01-08 20:17   ` kernel test robot
2026-01-09 16:12     ` Gregory CLEMENT
2026-01-08 23:06   ` kernel test robot
2026-01-13  2:59   ` kernel test robot
2026-01-13  3:41   ` kernel test robot
2026-01-14 22:31   ` Rob Herring
2026-01-07 13:04 ` [PATCH v3 3/4] dt-bindings: mtd: physmap: Allow using memory-region to access memory resources Gregory CLEMENT
2026-01-09  9:52   ` Linus Walleij
2026-01-07 13:04 ` [PATCH v3 4/4] mtd: physmap: Add support for RAM reserved memory regions Gregory CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox