Skip to contentSkip to conversation

Add RPROC support for the MX95-15x15-FRDM board

PATCH NAK Laurentiu Mihalcea 6 participants 17 messages Jul 30 – Aug 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Add RPROC support for the MX95-15x15-FRDM board

From: Laurentiu Mihalcea <[email protected]>

Hi folks,

As you can see from the title, this series attempts to introduce/enable RPROC support for the MX95-15x15-FRDM board.

For a while now, the imx_rproc driver has been using the reserved memory DT nodes as the carveout names, which would force DT writers to go against the DT specification's recommendation and use non-generic names (e.g. "vdev0vring0", "vdev0vring1", etc...). This series also tries to fix this issue by introducing the "memory-region-names" property and using it in the imx_rproc driver to figure out the carveout names. The driver will still allow the old way of doing things (i.e. no "memory-region-names" property) but a warning will now be printed since this should be discouraged.

---

Changes in v3:

* kept the DT binding patch because it fixes the ABI problem pointed out
by Frank. Modified the commit message to reflect this.
* link to v2: https://lore.kernel.org/lkml/[email protected]/

Changes in v2:

* change commit message of binding patch to describe why it's needed
* drop restrictions on the string names passed via "memory-region-names"
* drop patch moving the CM7 node to the SoC DTSI. CM7 node is now added in the RPMSG DT overlay
* rewrite commit message of patch removing some of the RMEM regions from the bord DTS - previous version was a stale version from first iterations of this series
* change "micfil" node status from "disabled" to "reserved"
* add check against rmem phandle count and string count mismatch
* include "of_reserved_mem.h" in "imx_rproc.h" to avoid having to rely on the consumers including it

---

Laurentiu Mihalcea (4):
dt-bindings: remoteproc: imx_rproc: document optional
"memory-region-names"
remoteproc: imx_rpoc: fix carveout name parsing
arm64: dts: freescale: imx95-15x15-frdm: remove some rmem regions
arm64: dts: freescale: add DT overlay for MX95-15x15-FRDM RPMSG usage

 .../bindings/remoteproc/fsl,imx-rproc.yaml    |  4 ++
 arch/arm64/boot/dts/freescale/Makefile        |  3 +
 .../dts/freescale/imx95-15x15-frdm-rpmsg.dtso | 67 +++++++++++++++++++
 .../boot/dts/freescale/imx95-15x15-frdm.dts   | 21 ------
 drivers/remoteproc/imx_rproc.c                | 13 +++-
 drivers/remoteproc/imx_rproc.h                | 21 ++++++
 6 files changed, 106 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso
Signature · 1 line
2.53.0
#1 lore raw

PATCH v3 1/4 dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to happen.

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to build the carveout region names without relying on the DT node names.

---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
index c18f71b64889..8e3e6676a95e 100644
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32
+
   power-domains:
     minItems: 2
     maxItems: 8
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

Quoted 8 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to happen.

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to build the carveout region names without relying on the DT node names.

"After update all existing DT tree, this will be required.

Quoted 3 lines

---

Additional information to help understand why it is important.

1. at thread wrong use vdevbuffer insteand vdev0buffer as node name
https://lore.kernel.org/imx/[email protected]/
2. similar case happen at
https://lore.kernel.org/imx/[email protected]/

Suppose these problem should be detected by dt binding check instead of sashkio ai.

Quoted 8 lines
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -0
index c18f71b64889..8e3e6676a95e 100644

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 68

Quoted 7 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32
+

Need restrict names

memory-region-names:
description:
Names for the memory-region phandles. Each entry must be one of the following recognized names. "vdev0buffer" is the shared buffer for virtio device 0, handled automatically by the rproc virtio framework. "vdev<n>ring<n>" (e.g. "vdev0vring0", "vdev0vring1") are the virtio vring buffers for device N, also managed by the virtio framework. "rsc-table" is the resource table region used to share the resource table between Linux and the remote processor when it is pre-loaded in memory. All other entries are treated as generic carveout regions that are mapped and made available to the remote processor.
minItems: 1
maxItems: 32
items:
anyOf:
- const: rsc-table
- pattern: "^vdev[0-9]+buffer$"
- pattern: "^vdev[0-9]+vring[0-9]+$"

Frank

Quoted 6 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -1
   power-domains:
     minItems: 2
     maxItems: 8
--

2.53.0

#3 lore raw

RE: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

Quoted 71 lines

Subject: Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc:
document optional "memory-region-names"

Quoted 4 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to

happen.

Quoted 3 lines

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to

build

Quoted 1 line

the carveout region names without relying on the DT node names.

"After update all existing DT tree, this will be required.

Quoted 3 lines

---

Additional information to help understand why it is important.

1. at thread wrong use vdevbuffer insteand vdev0buffer as node name
https://lore.kernel.org/imx/[email protected]
ernel.org/
2. similar case happen at
https://lore.kernel.org/imx/[email protected]
ernel.org/

Suppose these problem should be detected by dt binding check instead of sashkio ai.

Quoted 5 lines
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 2 lines

index c18f71b64889..8e3e6676a95e 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 68

Quoted 8 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32
+

Need restrict names

memory-region-names:
description:
Names for the memory-region phandles. Each entry must be one of
the
following recognized names. "vdev0buffer" is the shared buffer for virtio device 0, handled automatically by the rproc virtio framework. "vdev<n>ring<n>" (e.g. "vdev0vring0", "vdev0vring1") are the virtio vring buffers for device N, also managed by the virtio framework. "rsc-table" is the resource table region used to share the resource table between Linux and the remote processor when it is pre-
loaded in
memory. All other entries are treated as generic carveout regions
that

Quoted 8 lines

are mapped and made available to the remote processor.
minItems: 1
maxItems: 32
items:
anyOf:
- const: rsc-table
- pattern: "^vdev[0-9]+buffer$"
- pattern: "^vdev[0-9]+vring[0-9]+$"

There might be other entries such as m4_reserved or m7_reserved

Regards
Peng.

Quoted 9 lines

Frank

Quoted 6 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -1
   power-domains:
     minItems: 2
     maxItems: 8
--

2.53.0

#4 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

Quoted 80 lines · Peng Fan (OSS)
Quoted 71 lines

Subject: Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc:
document optional "memory-region-names"

Quoted 4 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to

happen.

Quoted 3 lines

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to

build

Quoted 1 line

the carveout region names without relying on the DT node names.

"After update all existing DT tree, this will be required.

Quoted 3 lines

---

Additional information to help understand why it is important.

1. at thread wrong use vdevbuffer insteand vdev0buffer as node name
https://lore.kernel.org/imx/[email protected]
ernel.org/
2. similar case happen at
https://lore.kernel.org/imx/[email protected]
ernel.org/

Suppose these problem should be detected by dt binding check instead of sashkio ai.

Quoted 5 lines
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 2 lines

index c18f71b64889..8e3e6676a95e 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 68

Quoted 8 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32
+

Need restrict names

memory-region-names:
description:
Names for the memory-region phandles. Each entry must be one of
the
following recognized names. "vdev0buffer" is the shared buffer for virtio device 0, handled automatically by the rproc virtio framework. "vdev<n>ring<n>" (e.g. "vdev0vring0", "vdev0vring1") are the virtio vring buffers for device N, also managed by the virtio framework. "rsc-table" is the resource table region used to share the resource table between Linux and the remote processor when it is pre-
loaded in
memory. All other entries are treated as generic carveout regions
that

Quoted 8 lines

are mapped and made available to the remote processor.
minItems: 1
maxItems: 32
items:
anyOf:
- const: rsc-table
- pattern: "^vdev[0-9]+buffer$"
- pattern: "^vdev[0-9]+vring[0-9]+$"

Quoted 1 line

There might be other entries such as m4_reserved or m7_reserved

You can add
- pattern: "^m(4|7)_reserved"

Frank

Quoted 13 lines

Regards
Peng.

Quoted 9 lines

Frank

Quoted 6 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -1
   power-domains:
     minItems: 2
     maxItems: 8
--

2.53.0

#5 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

In reply to Peng Fan (OSS)
Quoted 80 lines · Peng Fan (OSS)
Quoted 71 lines

Subject: Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc:
document optional "memory-region-names"

Quoted 4 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to

happen.

Quoted 3 lines

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to

build

Quoted 1 line

the carveout region names without relying on the DT node names.

"After update all existing DT tree, this will be required.

Quoted 3 lines

---

Additional information to help understand why it is important.

1. at thread wrong use vdevbuffer insteand vdev0buffer as node name
https://lore.kernel.org/imx/[email protected]
ernel.org/
2. similar case happen at
https://lore.kernel.org/imx/[email protected]
ernel.org/

Suppose these problem should be detected by dt binding check instead of sashkio ai.

Quoted 5 lines
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 2 lines

index c18f71b64889..8e3e6676a95e 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Quoted 1 line

+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-

rproc.yaml

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 68

Quoted 8 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32
+

Need restrict names

memory-region-names:
description:
Names for the memory-region phandles. Each entry must be one of
the
following recognized names. "vdev0buffer" is the shared buffer for virtio device 0, handled automatically by the rproc virtio framework. "vdev<n>ring<n>" (e.g. "vdev0vring0", "vdev0vring1") are the virtio vring buffers for device N, also managed by the virtio framework. "rsc-table" is the resource table region used to share the resource table between Linux and the remote processor when it is pre-
loaded in
memory. All other entries are treated as generic carveout regions
that

Quoted 8 lines

are mapped and made available to the remote processor.
minItems: 1
maxItems: 32
items:
anyOf:
- const: rsc-table
- pattern: "^vdev[0-9]+buffer$"
- pattern: "^vdev[0-9]+vring[0-9]+$"

Quoted 1 line

There might be other entries such as m4_reserved or m7_reserved

Then how about an additional pattern? Something like:

- pattern: "^remote-reserved[0-9]$"

I believe a board could, in theory, have more of these additional carveouts, depending on the range of firmware provided by the vendor's BSP (or the community) for that particular board.

Still need to put this in code and test it, though.

Peng Fan, Frank Li, would this work for the NXP platforms?

Franceso, could you please let me know if this'll work for the Toradex platforms?

#6 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

In reply to Laurentiu Mihalcea
Quoted 8 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to happen.

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to build the carveout region names without relying on the DT node names.

That's not the point of xxx-names property. It only serves as a helper to get the resource.

Quoted 11 lines
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -0
index c18f71b64889..8e3e6676a95e 100644

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 67

Quoted 6 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +3 -0
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
+  memory-region-names:
+    minItems: 1
+    maxItems: 32

This cannot be flexible and unspecific. Why "yellow submarine" would be a correct name?

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

Quoted 27 lines · Krzysztof Kozlowski
Quoted 8 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to happen.

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to build the carveout region names without relying on the DT node names.

That's not the point of xxx-names property. It only serves as a helper to get the resource.

Quoted 14 lines
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -0
index c18f71b64889..8e3e6676a95e 100644
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
Quoted 7 lines

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 67

Quoted 3 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +3 -0
+  memory-region-names:
+    minItems: 1
+    maxItems: 32

This cannot be flexible and unspecific. Why "yellow submarine" would be a correct name?

And I already SAID that at v2, so you just keep pushing this without implementing feedback.

NAK

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v3 1/4] dt-bindings: remoteproc: imx_rproc: document optional "memory-region-names"

Quoted 36 lines · Krzysztof Kozlowski
Quoted 27 lines · Krzysztof Kozlowski
Quoted 8 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The carveout region names are derived based on the DT node names. Because of this, the DT node names are ABI, which is not supposed to happen.

Fix this by documenting an additional, optional property:
"memory-region-names". This way, the software will have a way to build the carveout region names without relying on the DT node names.

That's not the point of xxx-names property. It only serves as a helper to get the resource.

Quoted 14 lines
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml         | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0 -0
index c18f71b64889..8e3e6676a95e 100644
@@ -62,6 +62,10 @@ properties:
     minItems: 1
     maxItems: 32
 
Quoted 7 lines

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 67

Quoted 3 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +3 -0
+  memory-region-names:
+    minItems: 1
+    maxItems: 32

This cannot be flexible and unspecific. Why "yellow submarine" would be a correct name?

Quoted 4 lines

And I already SAID that at v2, so you just keep pushing this without implementing feedback.

NAK

Thanks you review these patch and I already sent out suggestion, could you wait for me check it firstly to off load your work.

Frank

Quoted 4 lines

Best regards,
Krzysztof

#9 lore raw

PATCH v3 2/4 remoteproc: imx_rpoc: fix carveout name parsing

In reply to Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The imx remoteproc driver assumes that the names of the reserved memory regions reflect their usage (e.g. "vdevbuffer", "vdev0vring0", etc.). This conflicts with the devicetree specification's recommendation, which states that the names of the devicetree nodes should be generic.

Therefore, instead of relying on the node names, use the names passed via the "memory-region-names" property if present. Otherwise, keep the old behavior.

The definition of imx_rproc_rmem_to_resource() is added to a common place as imx_dsp_rproc.c can also use it given that it suffers from the same aforementioned problem.

---
 drivers/remoteproc/imx_rproc.c | 13 +++++++++++--
 drivers/remoteproc/imx_rproc.h | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +11 -2
index 745ce52cd822..ce9bdfc1fa98 100644
@@ -643,7 +643,7 @@ static int imx_rproc_prepare(struct rproc *rproc)
 		int err;
 		struct resource res;
 
-		err = of_reserved_mem_region_to_resource(np, i++, &res);
+		err = imx_rproc_rmem_to_resource(np, i++, &res);
 		if (err)
 			break;
 
@@ -818,11 +818,20 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 	if (nph <= 0)
 		return 0;
 
+	if (!of_property_present(np, "memory-region-names")) {
+		dev_warn(dev, "using node names for carveouts should be avoided\n");
+	} else {
+		if (nph != of_property_count_strings(np, "memory-region-names")) {
+			dev_err(dev, "invalid reserved memory name count\n");
+			return -EINVAL;
+		}
+	}
+
 	/* remap optional addresses */
 	for (a = 0; a < nph; a++) {
 		struct resource res;
 
-		err = of_reserved_mem_region_to_resource(np, a, &res);
+		err = imx_rproc_rmem_to_resource(np, a, &res);
 		if (err) {
 			dev_err(dev, "unable to resolve memory region\n");
 			return err;
drivers/remoteproc/imx_rproc.h +21 -0
index 0d7d48352a10..3632bc375c71 100644
@@ -7,6 +7,8 @@
 #ifndef _IMX_RPROC_H
 #define _IMX_RPROC_H
 
+#include <linux/of_reserved_mem.h>
+
 /* address translation table */
 struct imx_rproc_att {
 	u32 da;	/* device address (From Cortex M4 view)*/
@@ -45,4 +47,23 @@ struct imx_rproc_dcfg {
 	u32				reset_vector_mask;
 };
 
+static inline int imx_rproc_rmem_to_resource(struct device_node *np,
+					     int index,
+					     struct resource *res)
+{
+	int ret;
+
+	ret = of_reserved_mem_region_to_resource(np, index, res);
+	if (ret)
+		return ret;
+
+	/* "memory-region-names" is optional */
+	ret = of_property_read_string_index(np, "memory-region-names",
+					    index, &res->name);
+	if (ret == -EINVAL)
+		return 0;
+
+	return ret;
+}
+
 #endif /* _IMX_RPROC_H */
Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH v3 2/4] remoteproc: imx_rpoc: fix carveout name parsing

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] If rproc_mem_entry_init() fails, imx_rproc_prepare() returns an error without cleaning up carveouts and coredump segments added in previous loop iterations. --

--- Patch [2]: [PATCH v3 2/4] remoteproc: imx_rpoc: fix carveout name parsing --- commit 919463e3c08e2a14917d823b86fa8559b43af4fc
Author: Laurentiu Mihalcea <[email protected]>

remoteproc: imx_rpoc: fix carveout name parsing

The imx remoteproc driver is updated to use the "memory-region-names" property for reserved memory regions instead of relying on devicetree node names. This allows standardizing node names according to the devicetree specification.

drivers/remoteproc/imx_rproc.c static int imx_rproc_prepare(struct rproc *rproc) · line 677

Quoted 12 lines
drivers/remoteproc/imx_rproc.c +1 -1
index 7662ebd9d2f49..74719066905d6 100644
@@ -672,7 +672,7 @@ static int imx_rproc_prepare(struct rproc *rproc)
 		int err;
 		struct resource res;
 
-		err = of_reserved_mem_region_to_resource(np, i++, &res);
+		err = imx_rproc_rmem_to_resource(np, i++, &res);
 		if (err)
 			break;

[Severity: High]
This isn't a bug introduced by this patch, but looking at the loop in imx_rproc_prepare(), does the early return on rproc_mem_entry_init() failure leak resources?

If rproc_mem_entry_init() fails, it returns -ENOMEM without cleaning up the carveouts and coredump segments added in previous loop iterations:

drivers/remoteproc/imx_rproc.c:imx_rproc_prepare() {
	while (1) {
		...
		mem = rproc_mem_entry_init(...);
		if (!mem)
			return -ENOMEM;
		
		rproc_coredump_add_segment(rproc, da, resource_size(&res));
		rproc_add_carveout(rproc, mem);
	}
}

This error propagates back to rproc_fw_boot(), where the error handling path skips the clean_up_resources: label and jumps straight to disable_iommu:.

If a boot is retried by userspace (e.g., via sysfs), could this continually append duplicate entries to the lists and eventually exhaust vmalloc space when rproc_alloc_registered_carveouts() iterates over the duplicates and maps the same physical memory addresses multiple times?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#11 lore raw

Re: [PATCH v3 2/4] remoteproc: imx_rpoc: fix carveout name parsing

In reply to Laurentiu Mihalcea
Quoted 6 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The imx remoteproc driver assumes that the names of the reserved memory regions reflect their usage (e.g. "vdevbuffer", "vdev0vring0", etc.). This conflicts with the devicetree specification's recommendation, which states that the names of the devicetree nodes should be generic.

This relies on a hidden ABI by parsing the remote node's name, and also bypasses the DT binding check since there is no way to restrict the node name of a memory region.

Frank

Quoted 90 lines

Therefore, instead of relying on the node names, use the names passed via the "memory-region-names" property if present. Otherwise, keep the old behavior.

The definition of imx_rproc_rmem_to_resource() is added to a common place as imx_dsp_rproc.c can also use it given that it suffers from the same aforementioned problem.

---
 drivers/remoteproc/imx_rproc.c | 13 +++++++++++--
 drivers/remoteproc/imx_rproc.h | 21 +++++++++++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +11 -2
index 745ce52cd822..ce9bdfc1fa98 100644
@@ -643,7 +643,7 @@ static int imx_rproc_prepare(struct rproc *rproc)
 		int err;
 		struct resource res;
 
-		err = of_reserved_mem_region_to_resource(np, i++, &res);
+		err = imx_rproc_rmem_to_resource(np, i++, &res);
 		if (err)
 			break;
 
@@ -818,11 +818,20 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 	if (nph <= 0)
 		return 0;
 
+	if (!of_property_present(np, "memory-region-names")) {
+		dev_warn(dev, "using node names for carveouts should be avoided\n");
+	} else {
+		if (nph != of_property_count_strings(np, "memory-region-names")) {
+			dev_err(dev, "invalid reserved memory name count\n");
+			return -EINVAL;
+		}
+	}
+
 	/* remap optional addresses */
 	for (a = 0; a < nph; a++) {
 		struct resource res;
 
-		err = of_reserved_mem_region_to_resource(np, a, &res);
+		err = imx_rproc_rmem_to_resource(np, a, &res);
 		if (err) {
 			dev_err(dev, "unable to resolve memory region\n");
 			return err;
drivers/remoteproc/imx_rproc.h +21 -1
index 0d7d48352a10..3632bc375c71 100644
@@ -7,6 +7,8 @@
 #ifndef _IMX_RPROC_H
 #define _IMX_RPROC_H
 
+#include <linux/of_reserved_mem.h>
+
 /* address translation table */
 struct imx_rproc_att {
 	u32 da;	/* device address (From Cortex M4 view)*/
@@ -45,4 +47,23 @@ struct imx_rproc_dcfg {
 	u32				reset_vector_mask;
 };
 
+static inline int imx_rproc_rmem_to_resource(struct device_node *np,
+					     int index,
+					     struct resource *res)
+{
+	int ret;
+
+	ret = of_reserved_mem_region_to_resource(np, index, res);
+	if (ret)
+		return ret;
+
+	/* "memory-region-names" is optional */
+	ret = of_property_read_string_index(np, "memory-region-names",
+					    index, &res->name);
+	if (ret == -EINVAL)
+		return 0;
+
+	return ret;
+}
+
 #endif /* _IMX_RPROC_H */
--

2.53.0

#12 lore raw

Re: [PATCH v3 2/4] remoteproc: imx_rpoc: fix carveout name parsing

In reply to Laurentiu Mihalcea
Quoted 6 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The imx remoteproc driver assumes that the names of the reserved memory regions reflect their usage (e.g. "vdevbuffer", "vdev0vring0", etc.). This conflicts with the devicetree specification's recommendation, which states that the names of the devicetree nodes should be generic.

This is not true and I already told you that at v2.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v3 2/4] remoteproc: imx_rpoc: fix carveout name parsing

Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

The imx remoteproc driver assumes that the names of the reserved memory regions reflect their usage (e.g. "vdevbuffer", "vdev0vring0", etc.). This conflicts with the devicetree specification's recommendation, which states that the names of the devicetree nodes should be generic.

Quoted 5 lines

This is not true and I already told you that at v2.

Best regards,
Krzysztof

Unintentional. Forgot to update commit message. Sorry for the noise. Will update.

#14 lore raw

PATCH v3 3/4 arm64: dts: freescale: imx95-15x15-frdm: remove some rmem regions

In reply to Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

Remove some of the remoteproc reserved memory regions, which are currently not being used for anything. These will be added in the DT overlay enabling remoteproc support for this board.

---
 .../boot/dts/freescale/imx95-15x15-frdm.dts   | 21 -------------------
 1 file changed, 21 deletions(-)
arch/arm64/boot/dts/freescale/imx95-15x15-frdm.dts +0 -21
index 0f43e3be7058..f9b0e266754d 100644
@@ -188,16 +188,6 @@ linux_cma: linux,cma {
 			linux,cma-default;
 		};
 
-		vdev0vring0: memory@88000000 {
-			reg = <0 0x88000000 0 0x8000>;
-			no-map;
-		};
-
-		vdev0vring1: memory@88008000 {
-			reg = <0 0x88008000 0 0x8000>;
-			no-map;
-		};
-
 		vdev1vring0: memory@88010000 {
 			reg = <0 0x88010000 0 0x8000>;
 			no-map;
@@ -208,17 +198,6 @@ vdev1vring1: memory@88018000 {
 			no-map;
 		};
 
-		vdevbuffer: memory@88020000 {
-			compatible = "shared-dma-pool";
-			reg = <0 0x88020000 0 0x100000>;
-			no-map;
-		};
-
-		rsc_table: memory@88220000 {
-			reg = <0 0x88220000 0 0x1000>;
-			no-map;
-		};
-
 		vpu_boot: memory@a0000000 {
 			reg = <0 0xa0000000 0 0x100000>;
 			no-map;
Signature · 1 line
2.53.0
#15 lore raw

PATCH v3 4/4 arm64: dts: freescale: add DT overlay for MX95-15x15-FRDM RPMSG usage

In reply to Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

Add RPMSG DT overlay for the MX95-15x15-FRDM board. This overlay is meant to be used with the mx95evkrpmsg system manager configuration for remoteproc and audio over rpmsg-usecases.

---
 arch/arm64/boot/dts/freescale/Makefile        |  3 +
 .../dts/freescale/imx95-15x15-frdm-rpmsg.dtso | 67 +++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso
arch/arm64/boot/dts/freescale/Makefile +3 -0
index 95ae85ab4adf..3f98132f5a32 100644
@@ -707,6 +707,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx943-evk-sdwifi.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-ab2.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-frdm.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-frdm-rpmsg.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk-sof.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-frdm-pro.dtb
@@ -729,6 +730,8 @@ dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-mallow.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-yavia.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-zinnia.dtb
 
+imx95-15x15-frdm-rpmsg-dtbs = imx95-15x15-frdm.dtb imx95-15x15-frdm-rpmsg.dtbo
+
 imx95-15x15-evk-pcie-dtbs += imx95-15x15-evk.dtb imx-m2-pcie.dtbo
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-evk-pcie.dtb
 
arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.53.0
#16 lore raw

Re: [PATCH v3 4/4] arm64: dts: freescale: add DT overlay for MX95-15x15-FRDM RPMSG usage

Quoted 52 lines · Laurentiu Mihalcea

From: Laurentiu Mihalcea <[email protected]>

Add RPMSG DT overlay for the MX95-15x15-FRDM board. This overlay is meant to be used with the mx95evkrpmsg system manager configuration for remoteproc and audio over rpmsg-usecases.

---
 arch/arm64/boot/dts/freescale/Makefile        |  3 +
 .../dts/freescale/imx95-15x15-frdm-rpmsg.dtso | 67 +++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso
arch/arm64/boot/dts/freescale/Makefile +3 -0
index 95ae85ab4adf..3f98132f5a32 100644
@@ -707,6 +707,7 @@ dtb-$(CONFIG_ARCH_MXC) += imx943-evk-sdwifi.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-ab2.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-frdm.dtb
+dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-frdm-rpmsg.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-evk-sof.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-19x19-frdm-pro.dtb
@@ -729,6 +730,8 @@ dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-mallow.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-yavia.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx95-verdin-wifi-zinnia.dtb
 
+imx95-15x15-frdm-rpmsg-dtbs = imx95-15x15-frdm.dtb imx95-15x15-frdm-rpmsg.dtbo
+
 imx95-15x15-evk-pcie-dtbs += imx95-15x15-evk.dtb imx-m2-pcie.dtbo
 dtb-$(CONFIG_ARCH_MXC) += imx95-15x15-evk-pcie.dtb
 
arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso new file +11 -0
new file mode 100644
index 000000000000..bc02864c6f88
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2026 NXP
+ *
+ * This DT overlay is meant to be used alongside the mx95evkrpmsg SM
+ * configuration for remoteproc and audio over rpmsg.
+ */
+
+/dts-v1/;
+/plugin/;
+

arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso line 21

Quoted 10 lines
arch/arm64/boot/dts/freescale/imx95-15x15-frdm-rpmsg.dtso new file +10 -0
+&{/} {
+	remoteproc-cm7 {
+		compatible = "fsl,imx95-cm7";
+		mboxes = <&mu7 0 1>, <&mu7 1 1>, <&mu7 3 1>;
+		mbox-names = "tx", "rx", "rxdb";
+		memory-region = <&vdev0buffer>, <&vdev0vring0>,
+				<&vdev0vring1>, <&rsc_table>;
+		memory-region-names = "vdev0buffer", "vdev0vring0",
+				      "vdev0vring1", "rsc-table";
+	};

should we have a common dtsi, instead of having an overlay for each board? something like arch/arm64/boot/dts/ti/k3-am62-ti-ipc-firmware.dtsi ?

the goal would be to avoid duplication, and to have the functionality just working out of the box for all the boards that opt in for it.

Francesco