Skip to contentSkip to conversation

remoteproc: imx_rproc: support i.MX8/8M/7ULP

PATCH In review [email protected] 6 participants 30 messages Feb 19, 2020 – Feb 23, 2020

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

cover remoteproc: imx_rproc: support i.MX8/8M/7ULP

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before kernel"
https://patchwork.kernel.org/patch/11265869/,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

+
+ imx8x-cm4 {
+ compatible = "fsl,imx8qxp-cm4";
+ rsrc-table = <
+ 0x1 0x2 0x0 0x0 0x18 0x5c
+ 3
+ /*fw_rsc_vdev*/
+ 7 0 1 0 0 0x200
+ /*fw_rsc_vdev_vring*/
+ 0x90000000 4096 256 1 0
+ 0x90008000 4096 256 2 0
+ 3
+ /*fw_rsc_vdev*/
+ 7 1 1 0 0 0x200
+ /*fw_rsc_vdev_vring*/
+ 0x90010000 4096 256 1 0
+ 0x90018000 4096 256 2 0
+ >;
+ early-booted;
+ mbox-names = "tx", "rx", "rxdb";
+ mboxes = <&lsio_mu5 0 1
+ &lsio_mu5 1 1
+ &lsio_mu5 3 1>;
+ mub-partition = <3>;
+ memory-region = <&vdev0vring0>, <&vdev0vring1>, <&vdev0buffer>,
+ <&vdev1vring0>, <&vdev1vring1>, <&vdev0buffer>;
+ };
+
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+
+ vdev0vring0: vdev0vring0@90000000 {
+ compatible = "shared-dma-pool";
+ reg = <0 0x90000000 0 0x8000>;
+ no-map;
+ };
+
+ vdev0vring1: vdev0vring1@90008000 {
+ compatible = "shared-dma-pool";
+ reg = <0 0x90008000 0 0x8000>;
+ no-map;
+ };
+
+ vdev1vring0: vdev1vring0@90010000 {
+ compatible = "shared-dma-pool";
+ reg = <0 0x90010000 0 0x8000>;
+ no-map;
+ };
+
+ vdev1vring1: vdev1vring1@90018000 {
+ compatible = "shared-dma-pool";
+ reg = <0 0x90018000 0 0x8000>;
+ no-map;
+ };
+
+ vdev0buffer: vdev0buffer {
+ compatible = "shared-dma-pool";
+ reg = <0 0x90400000 0 0x100000>;
+ no-map;
+ };
+ };
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455 +++++++++++++++++++--
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
Signature · 1 line
2.16.4
#1 lore raw

PATCH 1/9 dt-bindings: remoteproc: Convert imx-rproc to json-schema

From: Peng Fan <[email protected]>

Convert the i.MX remoteproc binding to DT schema format using json-schema

---
 .../devicetree/bindings/remoteproc/imx-rproc.txt   | 33 ------------
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 61 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
Documentation/devicetree/bindings/remoteproc/imx-rproc.txt deleted +0 -33
deleted file mode 100644
index fbcefd965dc4..000000000000
@@ -1,33 +0,0 @@
-NXP iMX6SX/iMX7D Co-Processor Bindings
-----------------------------------------
-
-This binding provides support for ARM Cortex M4 Co-processor found on some
-NXP iMX SoCs.
-
-Required properties:
-- compatible		Should be one of:
-				"fsl,imx7d-cm4"
-				"fsl,imx6sx-cm4"
-- clocks		Clock for co-processor (See: ../clock/clock-bindings.txt)
-- syscon		Phandle to syscon block which provide access to
-			System Reset Controller
-
-Optional properties:
-- memory-region		list of phandels to the reserved memory regions.
-			(See: ../reserved-memory/reserved-memory.txt)
-
-Example:
-	m4_reserved_sysmem1: cm4@80000000 {
-		reg = <0x80000000 0x80000>;
-	};
-
-	m4_reserved_sysmem2: cm4@81000000 {
-		reg = <0x81000000 0x80000>;
-	};
-
-	imx7d-cm4 {
-		compatible	= "fsl,imx7d-cm4";
-		memory-region	= <&m4_reserved_sysmem1>, <&m4_reserved_sysmem2>;
-		syscon		= <&src>;
-		clocks		= <&clks IMX7D_ARM_M4_ROOT_CLK>;
-	};
Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.16.4
maintainer
#2 lore raw

Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema

Quoted 5 lines · On Wed, 19 Feb 2020 15:27:37 +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

Convert the i.MX remoteproc binding to DT schema format using json-schema

Quoted 8 lines
---
 .../devicetree/bindings/remoteproc/imx-rproc.txt   | 33 ------------
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 61 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

My bot found errors running 'make dt_binding_check' on your patch:

warning: no schema found in file: Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: ignoring, error in schema: properties: clocks: items Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not valid under any of the given schemas (Possible causes of the failure):
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks:items: Additional properties are not allowed ('Clock for co-processor (See' was unexpected)

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks: {'items': {'Clock for co-processor (See': '../clock/clock-bindings.txt)'}} is not valid under any of the given schemas (Possible causes of the failure):
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks: 'maxItems' is a required property /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not valid under any of the given schemas (Possible causes of the failure):
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not of type 'array'

Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2

See https://patchwork.ozlabs.org/patch/1240544
Please check and re-submit.

author
#3 lore raw

RE: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema

Hi Rob,

Quoted 20 lines

Subject: Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema

Quoted 6 lines · On Wed, 19 Feb 2020 15:27:37 +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

Convert the i.MX remoteproc binding to DT schema format using json-schema

Quoted 9 lines
---
 .../devicetree/bindings/remoteproc/imx-rproc.txt   | 33 ------------
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 61
++++++++++++++++++++++
 2 files changed, 61 insertions(+), 33 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

Quoted 1 line

My bot found errors running 'make dt_binding_check' on your patch:

My command:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

and output:

  CHKDT   Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
  SCHEMA  Documentation/devicetree/bindings/processed-schema.yaml
  DTC     Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dt.yaml
  CHECK   Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dt.yaml
Quoted 33 lines

warning: no schema found in file:
Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rem oteproc/imx-rproc.yaml: ignoring, error in schema: properties: clocks: items Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:
21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rem oteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not valid under any of the given schemas (Possible causes of the failure):
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/
remoteproc/imx-rproc.yaml: properties:clocks:items: Additional properties are not allowed ('Clock for co-processor (See' was unexpected)

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rem oteproc/imx-rproc.yaml: properties:clocks: {'items': {'Clock for co-processor (See': '../clock/clock-bindings.txt)'}} is not valid under any of the given schemas (Possible causes of the failure):
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/
remoteproc/imx-rproc.yaml: properties:clocks: 'maxItems' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/
remoteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not valid under any of the given schemas (Possible causes of the failure):

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/
remoteproc/imx-rproc.yaml: properties:clocks:items: {'Clock for co-processor (See': '../clock/clock-bindings.txt)'} is not of type 'array'

Quoted 8 lines

Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dts' failed
make[1]: *** [Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2

I'll check, and after get comments for other patches will send out v2.

Thanks,
Peng.

Quoted 8 lines

See
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatch
work.ozlabs.org%2Fpatch%2F1240544&amp;data=02%7C01%7Cpeng.fan%40 nxp.com%7C28b6280f1e8d4cd48fff08d7b5455348%7C686ea1d3bc2b4c6fa92 cd99c5c301635%7C0%7C0%7C637177181663776763&amp;sdata=XfOrYdrVi qB4jwZRjPFLM82Zz5BjTZQF7gNohDOcOCw%3D&amp;reserved=0 Please check and re-submit.

maintainer
#4 lore raw

Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema

Quoted 28 lines · Peng Fan

Hi Rob,

Quoted 20 lines

Subject: Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema

Quoted 6 lines · On Wed, 19 Feb 2020 15:27:37 +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

Convert the i.MX remoteproc binding to DT schema format using json-schema

Quoted 9 lines
---
 .../devicetree/bindings/remoteproc/imx-rproc.txt   | 33 ------------
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 61
++++++++++++++++++++++
 2 files changed, 61 insertions(+), 33 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

Quoted 1 line

My bot found errors running 'make dt_binding_check' on your patch:

My command:
make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

Quoted 6 lines

and output:

  CHKDT   Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
  SCHEMA  Documentation/devicetree/bindings/processed-schema.yaml
  DTC     Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dt.yaml
  CHECK   Documentation/devicetree/bindings/remoteproc/imx-rproc.example.dt.yaml

Make sure dtschema is up to date though I'm not sure this could have ever passed. 'items' value is clearly wrong.

Rob

#5 lore raw

PATCH 2/9 dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]

In reply to [email protected]

From: Peng Fan <[email protected]>

Support i.MX8/8M/7ULP:
- Introduce early-booted property for M4 booted before Linux
- Introduce mboxes for rpmsg/virtio to communicate with M4
- Introduce mub-partition for hardware partition supported by i.MX8
- Introduce rsrc-table which hold the resource table

---
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml +34 -0
index 12a5f3de38fb..be708130d5c0 100644
@@ -19,6 +19,12 @@ properties:
       enum:
         - "fsl,imx7d-cm4"
         - "fsl,imx6sx-cm4"
+        - "fsl,imx7ulp-cm4"
+        - "fsl,imx8mm-cm4"
+        - "fsl,imx8qm-cm4"
+        - "fsl,imx8qxp-cm4"
+
+  early-booted: true
 
   clocks:
     items:
@@ -30,11 +36,39 @@ properties:
      allOf:
        - $ref: "/schemas/types.yaml#/definitions/phandle"
 
+  mboxes:
+    description:
+      This property is required only if the rpmsg/virtio functionality is used.
+      List of <&phandle type channel> - 1 channel for TX, 1 channel for RX,
+      1 channel for RXDB.
+      (see mailbox/fsl,mu.txt)
+    maxItems: 3
+
+  mbox-names:
+    items:
+      - const: tx
+      - const: rx
+      - const: rxdb
+    maxItems: 3
+
   memory-region:
     description:
       List of phandles to the reserved memory regions.
       (see ../reserved-memory/reserved-memory.txt)
 
+  mub-partition:
+    description:
+      The remote Co-processor hardware partition which is only valid for
+      i.MX SoCs with hardware partition feature.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  rsrc-table:
+    description:
+      Resource table array is required only if the rpmsg/virtio
+      functionality is used.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32-array
+
 required:
   - compatible
   - clocks
Signature · 1 line
2.16.4
#6 lore raw

PATCH 3/9 remoteproc: add support to skip firmware load when recovery

In reply to [email protected]

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +11 -8
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
-	/* load firmware */
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -0
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
Signature · 1 line
2.16.4
#7 lore raw

Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Hi,

Quoted 30 lines · On 2/19/20 8:27 AM, [email protected] wrote:

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +3 -3
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
-	/* load firmware */

drivers/remoteproc/remoteproc_core.c int rproc_trigger_recovery(struct rproc *rproc) · line 1690

Quoted 10 lines
drivers/remoteproc/remoteproc_core.c +6 -4
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}

Any specific reason to not reuse skip_fw_load here?
FYI i'm reworking the Loic's patch and i plan to implement the recovery part using skip_fw_load...

Regards
Arnaud

Quoted 24 lines
drivers/remoteproc/remoteproc_core.c +2 -1
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -0
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
author
#8 lore raw

RE: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Quoted 37 lines

Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Hi,

Quoted 30 lines · On 2/19/20 8:27 AM, [email protected] wrote:

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +3 -2
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
Quoted 13 lines

drivers/remoteproc/remoteproc_core.c int rproc_trigger_recovery(struct rproc *rproc) · line 1690

Quoted 11 lines
drivers/remoteproc/remoteproc_core.c +6 -5
-	/* load firmware */
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}

Any specific reason to not reuse skip_fw_load here?

Just thought firmware needs to be loaded by Linux when remote processor crash, even if it initially booted ealy.

skip_fw_load just handles first boot which no need firmware. But if recovery boot needs firwarem, skip_fw_load will not handle.

So I add this new bool.

Actually to my platform, skip_fw_load could work when recovery, I just think other platforms might need firware load when recovery.

Regards,
Peng.

Quoted 33 lines

FYI i'm reworking the Loic's patch and i plan to implement the recovery part using skip_fw_load...

Regards
Arnaud

Quoted 24 lines
drivers/remoteproc/remoteproc_core.c +2 -1
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -0
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
#9 lore raw

Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Quoted 54 lines · Peng Fan
Quoted 37 lines

Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Hi,

Quoted 30 lines · On 2/19/20 8:27 AM, [email protected] wrote:

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +3 -2
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
Quoted 13 lines

drivers/remoteproc/remoteproc_core.c int rproc_trigger_recovery(struct rproc *rproc) · line 1690

Quoted 11 lines
drivers/remoteproc/remoteproc_core.c +6 -5
-	/* load firmware */
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}

Any specific reason to not reuse skip_fw_load here?

Just thought firmware needs to be loaded by Linux when remote processor crash, even if it initially booted ealy.

Quoted 7 lines

skip_fw_load just handles first boot which no need firmware. But if recovery boot needs firwarem, skip_fw_load will not handle.

So I add this new bool.

Actually to my platform, skip_fw_load could work when recovery, I just think other platforms might need firware load when recovery.

Thanks for the clarification. For the ST platform, we can have both usecase
By clearing skip_fw_load in case of crash we s should be able to handle this usecase.
Anyway as discussion is still on going for the preloaded firmware topic, we have at least to take into account your use case.

Thanks,
Arnaud

Quoted 37 lines

Regards,
Peng.

Quoted 33 lines

FYI i'm reworking the Loic's patch and i plan to implement the recovery part using skip_fw_load...

Regards
Arnaud

Quoted 24 lines
drivers/remoteproc/remoteproc_core.c +2 -1
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -0
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
maintainer
#10 lore raw

Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

In reply to [email protected]

Hi Peng,

Quoted 8 lines · On Wed, Feb 19, 2020 at 03:27:39PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

For now I will not comment on the code - I just need clarifications on the scenario.

In the specific case you are trying to address here, I understand that when the M4 crashes, the SCU will recognize that and reload the MCU firmware. Does the SCU also start the MCU or is that left to the remoteproc subsystem?

Thanks,
Mathieu

Quoted 58 lines
---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +11 -8
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
-	/* load firmware */
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -0
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
Signature · 1 line
2.16.4
author
#11 lore raw

RE: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Hi Mathieu,

Quoted 15 lines

Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery

Hi Peng,

Quoted 8 lines · On Wed, Feb 19, 2020 at 03:27:39PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

Remote processor such as M4 inside i.MX8QXP is not handled by Linux when it is configured to run inside its own hardware partition by system control unit(SCU). So even remote processor crash reset, it is handled by SCU, not linux. To such case, firmware load should be ignored, So introduce skip_fw_load_recovery and platform driver should set it if needed.

Quoted 6 lines

For now I will not comment on the code - I just need clarifications on the scenario.

In the specific case you are trying to address here, I understand that when the M4 crashes, the SCU will recognize that and reload the MCU firmware. Does the SCU also start the MCU or is that left to the remoteproc subsystem?

SCU starts M4. Linux has no permission to start/stop M4 from hardware perspective with hardware partition feature enabled.

Regards,
Peng.

Quoted 63 lines

Thanks,
Mathieu

Quoted 59 lines
---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)
drivers/remoteproc/remoteproc_core.c +11 -8
index 876b5420a32b..ca310e3582bf 100644
@@ -1678,20 +1678,23 @@ int rproc_trigger_recovery(struct rproc *rproc)
 	if (ret)
 		goto unlock_mutex;
 
-	/* generate coredump */
-	rproc_coredump(rproc);
+	if (!rproc->skip_fw_load_recovery) {
+		/* generate coredump */
+		rproc_coredump(rproc);
 
-	/* load firmware */
-	ret = request_firmware(&firmware_p, rproc->firmware, dev);
-	if (ret < 0) {
-		dev_err(dev, "request_firmware failed: %d\n", ret);
-		goto unlock_mutex;
+		/* load firmware */
+		ret = request_firmware(&firmware_p, rproc->firmware, dev);
+		if (ret < 0) {
+			dev_err(dev, "request_firmware failed: %d\n", ret);
+			goto unlock_mutex;
+		}
 	}
 
 	/* boot the remote processor up again */
 	ret = rproc_start(rproc, firmware_p);
 
-	release_firmware(firmware_p);
+	if (!rproc->skip_fw_load_recovery)
+		release_firmware(firmware_p);
 
 unlock_mutex:
 	mutex_unlock(&rproc->lock);
include/linux/remoteproc.h +1 -1
index 4fd5bedab4fa..fe6ee253b385 100644
@@ -514,6 +514,7 @@ struct rproc {
 	bool has_iommu;
 	bool auto_boot;
 	bool skip_fw_load;
+	bool skip_fw_load_recovery;
 	struct list_head dump_segments;
 	int nb_vdev;
 };
--

2.16.4

#12 lore raw

PATCH 4/9 remoteproc: imx_rproc: surport early booted remote processor

In reply to [email protected]

From: Peng Fan <[email protected]>

When remote processor is booted by bootloader, Linux need to ignore firmware loading, and ignore remote processor start/stop related hardware operations. what should do is to need to handle memory-regions and resource table.

Add a src_started entry to check whether Cortex-M4 is started for i.MX7D and i.MX6SX.

---
 drivers/remoteproc/imx_rproc.c | 240 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 220 insertions(+), 20 deletions(-)
drivers/remoteproc/imx_rproc.c +220 -20
index 3e72b6f38d4b..b9fabe269fd2 100644
@@ -74,6 +74,7 @@ struct imx_rproc_dcfg {
 	u32				src_mask;
 	u32				src_start;
 	u32				src_stop;
+	u32				src_started;
 	const struct imx_rproc_att	*att;
 	size_t				att_size;
 };
@@ -85,6 +86,7 @@ struct imx_rproc {
 	const struct imx_rproc_dcfg	*dcfg;
 	struct imx_rproc_mem		mem[IMX7D_RPROC_MEM_MAX];
 	struct clk			*clk;
+	bool				early_boot;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
@@ -142,6 +144,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
 	.src_mask	= IMX7D_M4_RST_MASK,
 	.src_start	= IMX7D_M4_START,
 	.src_stop	= IMX7D_M4_STOP,
+	.src_started	= IMX7D_ENABLE_M4,
 	.att		= imx_rproc_att_imx7d,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx7d),
 };
@@ -151,6 +154,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
 	.src_mask	= IMX6SX_M4_RST_MASK,
 	.src_start	= IMX6SX_M4_START,
 	.src_stop	= IMX6SX_M4_STOP,
+	.src_started	= IMX6SX_ENABLE_M4,
 	.att		= imx_rproc_att_imx6sx,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
 };
@@ -162,6 +166,9 @@ static int imx_rproc_start(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_start);
 	if (ret)
@@ -177,6 +184,9 @@ static int imx_rproc_stop(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_stop);
 	if (ret)
@@ -240,10 +250,167 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len)
 	return va;
 }
 
+static int imx_rproc_elf_load_segments(struct rproc *rproc,
+				       const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_segments(rproc, fw);
+
+	return 0;
+}
+
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+			       struct rproc_mem_entry *mem)
+{
+	struct device *dev = rproc->dev.parent;
+	void *va;
+
+	dev_dbg(dev, "map memory: %p+%x\n", &mem->dma, mem->len);
+	va = ioremap_wc(mem->dma, mem->len);
+	if (IS_ERR_OR_NULL(va)) {
+		dev_err(dev, "Unable to map memory region: %p+%x\n",
+			&mem->dma, mem->len);
+		return -ENOMEM;
+	}
+
+	/* Update memory entry va */
+	mem->va = va;
+
+	return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+				 struct rproc_mem_entry *mem)
+{
+	dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma);
+	iounmap(mem->va);
+
+	return 0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+	struct resource_table *resource_table;
+	struct device_node *np = priv->dev->of_node;
+	struct of_phandle_iterator it;
+	struct rproc_mem_entry *mem;
+	struct reserved_mem *rmem;
+	int index = 0;
+	int elems;
+	int ret;
+	u64 da;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_rsc_table(rproc, fw);
+
+	/* Register associated reserved memory regions */
+	of_phandle_iterator_init(&it, np, "memory-region", NULL, 0);
+	while (of_phandle_iterator_next(&it) == 0) {
+		rmem = of_reserved_mem_lookup(it.node);
+		if (!rmem) {
+			dev_err(priv->dev, "unable to acquire memory-region\n");
+			return -EINVAL;
+		}
+
+		/* No need to translate pa to da */
+		da = rmem->base;
+
+		if (strcmp(it.node->name, "vdev0buffer")) {
+			/* Register memory region */
+			mem = rproc_mem_entry_init(priv->dev, NULL,
+						   (dma_addr_t)rmem->base,
+						   rmem->size, da,
+						   imx_rproc_mem_alloc,
+						   imx_rproc_mem_release,
+						   it.node->name);
+
+			if (mem)
+				rproc_coredump_add_segment(rproc, da,
+							   rmem->size);
+		} else {
+			/* Register reserved memory for vdev buffer alloc */
+			mem = rproc_of_resm_mem_entry_init(priv->dev, index,
+							   rmem->size,
+							   rmem->base,
+							   it.node->name);
+		}
+
+		if (!mem)
+			return -ENOMEM;
+
+		rproc_add_carveout(rproc, mem);
+		index++;
+	}
+
+	/*Parse device tree to get resource table */
+	elems = of_property_count_u32_elems(np, "rsrc-table");
+	if (elems < 0) {
+		dev_err(&rproc->dev, "no rsrc-table\n");
+		return elems;
+	}
+
+	resource_table = kzalloc(elems * sizeof(u32), GFP_KERNEL);
+	if (!resource_table)
+		return PTR_ERR(resource_table);
+
+	ret = of_property_read_u32_array(np, "rsrc-table",
+					 (u32 *)resource_table, elems);
+	if (ret)
+		return ret;
+
+	rproc->cached_table = resource_table;
+	rproc->table_ptr = resource_table;
+	rproc->table_sz = elems * sizeof(u32);
+
+	return 0;
+}
+
+static struct resource_table *
+imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc,
+				    const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_find_loaded_rsc_table(rproc, fw);
+
+	return NULL;
+}
+
+static int imx_rproc_elf_sanity_check(struct rproc *rproc,
+				      const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_sanity_check(rproc, fw);
+
+	return 0;
+}
+
+static u32 imx_rproc_elf_get_boot_addr(struct rproc *rproc,
+				       const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_get_boot_addr(rproc, fw);
+
+	return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
 	.da_to_va       = imx_rproc_da_to_va,
+	.load		= imx_rproc_elf_load_segments,
+	.parse_fw	= imx_rproc_parse_fw,
+	.find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table,
+	.sanity_check	= imx_rproc_elf_sanity_check,
+	.get_boot_addr	= imx_rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv,
@@ -309,6 +476,31 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 	return 0;
 }
 
+static int imx_rproc_configure_mode(struct imx_rproc *priv)
+{
+	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+	struct device *dev = priv->dev;
+	int ret;
+	u32 val;
+
+	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+		priv->early_boot = true;
+	} else {
+		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
+		if (ret) {
+			dev_err(dev, "Failed to read src\n");
+			return ret;
+		}
+
+		priv->early_boot = !!(val & dcfg->src_started);
+	}
+
+	if (priv->early_boot)
+		priv->rproc->skip_fw_load = true;
+
+	return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -347,27 +539,33 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(dev, rproc);
 
-	ret = imx_rproc_addr_init(priv, pdev);
-	if (ret) {
-		dev_err(dev, "failed on imx_rproc_addr_init\n");
+	ret = imx_rproc_configure_mode(priv);
+	if (ret)
 		goto err_put_rproc;
-	}
 
-	priv->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "Failed to get clock\n");
-		ret = PTR_ERR(priv->clk);
-		goto err_put_rproc;
-	}
+	if (!priv->early_boot) {
+		ret = imx_rproc_addr_init(priv, pdev);
+		if (ret) {
+			dev_err(dev, "failed on imx_rproc_addr_init\n");
+			goto err_put_rproc;
+		}
 
-	/*
-	 * clk for M4 block including memory. Should be
-	 * enabled before .start for FW transfer.
-	 */
-	ret = clk_prepare_enable(priv->clk);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed to enable clock\n");
-		goto err_put_rproc;
+		priv->clk = devm_clk_get(dev, NULL);
+		if (IS_ERR(priv->clk)) {
+			dev_err(dev, "Failed to get clock\n");
+			ret = PTR_ERR(priv->clk);
+			goto err_put_rproc;
+		}
+
+		/*
+		 * clk for M4 block including memory. Should be
+		 * enabled before .start for FW transfer.
+		 */
+		ret = clk_prepare_enable(priv->clk);
+		if (ret) {
+			dev_err(&rproc->dev, "Failed to enable clock\n");
+			goto err_put_rproc;
+		}
 	}
 
 	ret = rproc_add(rproc);
@@ -379,7 +577,8 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	return 0;
 
 err_put_clk:
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 err_put_rproc:
 	rproc_free(rproc);
 
@@ -391,7 +590,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 	struct rproc *rproc = platform_get_drvdata(pdev);
 	struct imx_rproc *priv = rproc->priv;
 
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 	rproc_del(rproc);
 	rproc_free(rproc);
 
Signature · 1 line
2.16.4
maintainer
#13 lore raw

Re: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor

Quoted 120 lines · On Wed, Feb 19, 2020 at 03:27:40PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

When remote processor is booted by bootloader, Linux need to ignore firmware loading, and ignore remote processor start/stop related hardware operations. what should do is to need to handle memory-regions and resource table.

Add a src_started entry to check whether Cortex-M4 is started for i.MX7D and i.MX6SX.

---
 drivers/remoteproc/imx_rproc.c | 240 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 220 insertions(+), 20 deletions(-)
drivers/remoteproc/imx_rproc.c +55 -0
index 3e72b6f38d4b..b9fabe269fd2 100644
@@ -74,6 +74,7 @@ struct imx_rproc_dcfg {
 	u32				src_mask;
 	u32				src_start;
 	u32				src_stop;
+	u32				src_started;
 	const struct imx_rproc_att	*att;
 	size_t				att_size;
 };
@@ -85,6 +86,7 @@ struct imx_rproc {
 	const struct imx_rproc_dcfg	*dcfg;
 	struct imx_rproc_mem		mem[IMX7D_RPROC_MEM_MAX];
 	struct clk			*clk;
+	bool				early_boot;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
@@ -142,6 +144,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
 	.src_mask	= IMX7D_M4_RST_MASK,
 	.src_start	= IMX7D_M4_START,
 	.src_stop	= IMX7D_M4_STOP,
+	.src_started	= IMX7D_ENABLE_M4,
 	.att		= imx_rproc_att_imx7d,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx7d),
 };
@@ -151,6 +154,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
 	.src_mask	= IMX6SX_M4_RST_MASK,
 	.src_start	= IMX6SX_M4_START,
 	.src_stop	= IMX6SX_M4_STOP,
+	.src_started	= IMX6SX_ENABLE_M4,
 	.att		= imx_rproc_att_imx6sx,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
 };
@@ -162,6 +166,9 @@ static int imx_rproc_start(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_start);
 	if (ret)
@@ -177,6 +184,9 @@ static int imx_rproc_stop(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_stop);
 	if (ret)
@@ -240,10 +250,167 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len)
 	return va;
 }
 
+static int imx_rproc_elf_load_segments(struct rproc *rproc,
+				       const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_segments(rproc, fw);
+
+	return 0;
+}
+
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+			       struct rproc_mem_entry *mem)
+{
+	struct device *dev = rproc->dev.parent;
+	void *va;
+
+	dev_dbg(dev, "map memory: %p+%x\n", &mem->dma, mem->len);
+	va = ioremap_wc(mem->dma, mem->len);
+	if (IS_ERR_OR_NULL(va)) {
+		dev_err(dev, "Unable to map memory region: %p+%x\n",
+			&mem->dma, mem->len);
+		return -ENOMEM;
+	}
+
+	/* Update memory entry va */
+	mem->va = va;
+
+	return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+				 struct rproc_mem_entry *mem)
+{
+	dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma);
+	iounmap(mem->va);
+
+	return 0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+	struct resource_table *resource_table;
+	struct device_node *np = priv->dev->of_node;

drivers/remoteproc/imx_rproc.c static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) · line 307

Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10 -0
+	struct of_phandle_iterator it;
+	struct rproc_mem_entry *mem;
+	struct reserved_mem *rmem;
+	int index = 0;
+	int elems;
+	int ret;
+	u64 da;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_rsc_table(rproc, fw);

Once again I will concentrate on the scenario rather than making comments on the code.

If I understand correctly if the AP is responsible for loading the firmware and starting the MCU, the ELF image contains a resource table that describes all the memory areas and vdev needed.

Otherwise the MCU firmware that is preloaded by the boot loader or the SCU does _not_ have a resource table and as such specifics need to be coming from the DT.

Is my assesment correct?

Quoted 216 lines
drivers/remoteproc/imx_rproc.c +155 -20
+
+	/* Register associated reserved memory regions */
+	of_phandle_iterator_init(&it, np, "memory-region", NULL, 0);
+	while (of_phandle_iterator_next(&it) == 0) {
+		rmem = of_reserved_mem_lookup(it.node);
+		if (!rmem) {
+			dev_err(priv->dev, "unable to acquire memory-region\n");
+			return -EINVAL;
+		}
+
+		/* No need to translate pa to da */
+		da = rmem->base;
+
+		if (strcmp(it.node->name, "vdev0buffer")) {
+			/* Register memory region */
+			mem = rproc_mem_entry_init(priv->dev, NULL,
+						   (dma_addr_t)rmem->base,
+						   rmem->size, da,
+						   imx_rproc_mem_alloc,
+						   imx_rproc_mem_release,
+						   it.node->name);
+
+			if (mem)
+				rproc_coredump_add_segment(rproc, da,
+							   rmem->size);
+		} else {
+			/* Register reserved memory for vdev buffer alloc */
+			mem = rproc_of_resm_mem_entry_init(priv->dev, index,
+							   rmem->size,
+							   rmem->base,
+							   it.node->name);
+		}
+
+		if (!mem)
+			return -ENOMEM;
+
+		rproc_add_carveout(rproc, mem);
+		index++;
+	}
+
+	/*Parse device tree to get resource table */
+	elems = of_property_count_u32_elems(np, "rsrc-table");
+	if (elems < 0) {
+		dev_err(&rproc->dev, "no rsrc-table\n");
+		return elems;
+	}
+
+	resource_table = kzalloc(elems * sizeof(u32), GFP_KERNEL);
+	if (!resource_table)
+		return PTR_ERR(resource_table);
+
+	ret = of_property_read_u32_array(np, "rsrc-table",
+					 (u32 *)resource_table, elems);
+	if (ret)
+		return ret;
+
+	rproc->cached_table = resource_table;
+	rproc->table_ptr = resource_table;
+	rproc->table_sz = elems * sizeof(u32);
+
+	return 0;
+}
+
+static struct resource_table *
+imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc,
+				    const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_find_loaded_rsc_table(rproc, fw);
+
+	return NULL;
+}
+
+static int imx_rproc_elf_sanity_check(struct rproc *rproc,
+				      const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_sanity_check(rproc, fw);
+
+	return 0;
+}
+
+static u32 imx_rproc_elf_get_boot_addr(struct rproc *rproc,
+				       const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_get_boot_addr(rproc, fw);
+
+	return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
 	.da_to_va       = imx_rproc_da_to_va,
+	.load		= imx_rproc_elf_load_segments,
+	.parse_fw	= imx_rproc_parse_fw,
+	.find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table,
+	.sanity_check	= imx_rproc_elf_sanity_check,
+	.get_boot_addr	= imx_rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv,
@@ -309,6 +476,31 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 	return 0;
 }
 
+static int imx_rproc_configure_mode(struct imx_rproc *priv)
+{
+	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+	struct device *dev = priv->dev;
+	int ret;
+	u32 val;
+
+	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+		priv->early_boot = true;
+	} else {
+		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
+		if (ret) {
+			dev_err(dev, "Failed to read src\n");
+			return ret;
+		}
+
+		priv->early_boot = !!(val & dcfg->src_started);
+	}
+
+	if (priv->early_boot)
+		priv->rproc->skip_fw_load = true;
+
+	return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -347,27 +539,33 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(dev, rproc);
 
-	ret = imx_rproc_addr_init(priv, pdev);
-	if (ret) {
-		dev_err(dev, "failed on imx_rproc_addr_init\n");
+	ret = imx_rproc_configure_mode(priv);
+	if (ret)
 		goto err_put_rproc;
-	}
 
-	priv->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "Failed to get clock\n");
-		ret = PTR_ERR(priv->clk);
-		goto err_put_rproc;
-	}
+	if (!priv->early_boot) {
+		ret = imx_rproc_addr_init(priv, pdev);
+		if (ret) {
+			dev_err(dev, "failed on imx_rproc_addr_init\n");
+			goto err_put_rproc;
+		}
 
-	/*
-	 * clk for M4 block including memory. Should be
-	 * enabled before .start for FW transfer.
-	 */
-	ret = clk_prepare_enable(priv->clk);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed to enable clock\n");
-		goto err_put_rproc;
+		priv->clk = devm_clk_get(dev, NULL);
+		if (IS_ERR(priv->clk)) {
+			dev_err(dev, "Failed to get clock\n");
+			ret = PTR_ERR(priv->clk);
+			goto err_put_rproc;
+		}
+
+		/*
+		 * clk for M4 block including memory. Should be
+		 * enabled before .start for FW transfer.
+		 */
+		ret = clk_prepare_enable(priv->clk);
+		if (ret) {
+			dev_err(&rproc->dev, "Failed to enable clock\n");
+			goto err_put_rproc;
+		}
 	}
 
 	ret = rproc_add(rproc);
@@ -379,7 +577,8 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	return 0;
 
 err_put_clk:
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 err_put_rproc:
 	rproc_free(rproc);
 
@@ -391,7 +590,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 	struct rproc *rproc = platform_get_drvdata(pdev);
 	struct imx_rproc *priv = rproc->priv;
 
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 	rproc_del(rproc);
 	rproc_free(rproc);
 
Signature · 1 line
2.16.4
author
#14 lore raw

RE: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor

Quoted 140 lines

Subject: Re: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor

drivers/remoteproc/imx_rproc.c static const struct imx_rproc_dcfg

Quoted 46 lines · On Wed, Feb 19, 2020 at 03:27:40PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

When remote processor is booted by bootloader, Linux need to ignore firmware loading, and ignore remote processor start/stop related hardware operations. what should do is to need to handle memory-regions and resource table.

Add a src_started entry to check whether Cortex-M4 is started for i.MX7D and i.MX6SX.

---
 drivers/remoteproc/imx_rproc.c | 240
+++++++++++++++++++++++++++++++++++++----
 1 file changed, 220 insertions(+), 20 deletions(-)
(quoted diff) +0 -0

b/drivers/remoteproc/imx_rproc.c index 3e72b6f38d4b..b9fabe269fd2 100644

drivers/remoteproc/imx_rproc.c +4 -0
@@ -74,6 +74,7 @@ struct imx_rproc_dcfg {
 	u32				src_mask;
 	u32				src_start;
 	u32				src_stop;
+	u32				src_started;
 	const struct imx_rproc_att	*att;
 	size_t				att_size;
 };
@@ -85,6 +86,7 @@ struct imx_rproc {
 	const struct imx_rproc_dcfg	*dcfg;
 	struct imx_rproc_mem		mem[IMX7D_RPROC_MEM_MAX];
 	struct clk			*clk;
+	bool				early_boot;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = { @@ -142,6
+144,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
 	.src_mask	= IMX7D_M4_RST_MASK,
 	.src_start	= IMX7D_M4_START,
 	.src_stop	= IMX7D_M4_STOP,
+	.src_started	= IMX7D_ENABLE_M4,
 	.att		= imx_rproc_att_imx7d,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx7d),
 };
@@ -151,6 +154,7 @@ static const struct imx_rproc_dcfg

imx_rproc_cfg_imx6sx = {

drivers/remoteproc/imx_rproc.c static void *imx_rproc_da_to_va(struct rproc

Quoted 28 lines
drivers/remoteproc/imx_rproc.c +7 -0
 	.src_mask	= IMX6SX_M4_RST_MASK,
 	.src_start	= IMX6SX_M4_START,
 	.src_stop	= IMX6SX_M4_STOP,
+	.src_started	= IMX6SX_ENABLE_M4,
 	.att		= imx_rproc_att_imx6sx,
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
 };
@@ -162,6 +166,9 @@ static int imx_rproc_start(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_start);
 	if (ret)
@@ -177,6 +184,9 @@ static int imx_rproc_stop(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (priv->early_boot)
+		return 0;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_stop);
 	if (ret)
@@ -240,10 +250,167 @@ static void *imx_rproc_da_to_va(struct rproc

*rproc, u64 da, int len)

Quoted 46 lines
drivers/remoteproc/imx_rproc.c +43 -0
 	return va;
 }
 
+static int imx_rproc_elf_load_segments(struct rproc *rproc,
+				       const struct firmware *fw) {
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_segments(rproc, fw);
+
+	return 0;
+}
+
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+			       struct rproc_mem_entry *mem) {
+	struct device *dev = rproc->dev.parent;
+	void *va;
+
+	dev_dbg(dev, "map memory: %p+%x\n", &mem->dma, mem->len);
+	va = ioremap_wc(mem->dma, mem->len);
+	if (IS_ERR_OR_NULL(va)) {
+		dev_err(dev, "Unable to map memory region: %p+%x\n",
+			&mem->dma, mem->len);
+		return -ENOMEM;
+	}
+
+	/* Update memory entry va */
+	mem->va = va;
+
+	return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+				 struct rproc_mem_entry *mem)
+{
+	dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma);
+	iounmap(mem->va);
+
+	return 0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct
+firmware *fw) {
+	struct imx_rproc *priv = rproc->priv;
+	struct resource_table *resource_table;
+	struct device_node *np = priv->dev->of_node;

drivers/remoteproc/imx_rproc.c static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) · line 307

Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10 -0
+	struct of_phandle_iterator it;
+	struct rproc_mem_entry *mem;
+	struct reserved_mem *rmem;
+	int index = 0;
+	int elems;
+	int ret;
+	u64 da;
+
+	if (!priv->early_boot)
+		return rproc_elf_load_rsc_table(rproc, fw);

Once again I will concentrate on the scenario rather than making comments on the code.

Quoted 3 lines

If I understand correctly if the AP is responsible for loading the firmware and starting the MCU, the ELF image contains a resource table that describes all the memory areas and vdev needed.

This is just make sure the original code to support i.MX6SX/i.MX7D work which added by Pengutronix.

Quoted 2 lines

Otherwise the MCU firmware that is preloaded by the boot loader or the SCU

NXP released firmware will be preloaded and booted by bootloader or SCU in different SoCs depends on hardware design.

Quoted 4 lines

does _not_ have a resource table and as such specifics need to be coming from the DT.

Is my assesment correct?

Yes. Correct.

Regards,
Peng.

Quoted 217 lines

drivers/remoteproc/imx_rproc.c static int imx_rproc_probe(struct platform_device

Quoted 193 lines
drivers/remoteproc/imx_rproc.c +150 -18
+
+	/* Register associated reserved memory regions */
+	of_phandle_iterator_init(&it, np, "memory-region", NULL, 0);
+	while (of_phandle_iterator_next(&it) == 0) {
+		rmem = of_reserved_mem_lookup(it.node);
+		if (!rmem) {
+			dev_err(priv->dev, "unable to acquire memory-region\n");
+			return -EINVAL;
+		}
+
+		/* No need to translate pa to da */
+		da = rmem->base;
+
+		if (strcmp(it.node->name, "vdev0buffer")) {
+			/* Register memory region */
+			mem = rproc_mem_entry_init(priv->dev, NULL,
+						   (dma_addr_t)rmem->base,
+						   rmem->size, da,
+						   imx_rproc_mem_alloc,
+						   imx_rproc_mem_release,
+						   it.node->name);
+
+			if (mem)
+				rproc_coredump_add_segment(rproc, da,
+							   rmem->size);
+		} else {
+			/* Register reserved memory for vdev buffer alloc */
+			mem = rproc_of_resm_mem_entry_init(priv->dev, index,
+							   rmem->size,
+							   rmem->base,
+							   it.node->name);
+		}
+
+		if (!mem)
+			return -ENOMEM;
+
+		rproc_add_carveout(rproc, mem);
+		index++;
+	}
+
+	/*Parse device tree to get resource table */
+	elems = of_property_count_u32_elems(np, "rsrc-table");
+	if (elems < 0) {
+		dev_err(&rproc->dev, "no rsrc-table\n");
+		return elems;
+	}
+
+	resource_table = kzalloc(elems * sizeof(u32), GFP_KERNEL);
+	if (!resource_table)
+		return PTR_ERR(resource_table);
+
+	ret = of_property_read_u32_array(np, "rsrc-table",
+					 (u32 *)resource_table, elems);
+	if (ret)
+		return ret;
+
+	rproc->cached_table = resource_table;
+	rproc->table_ptr = resource_table;
+	rproc->table_sz = elems * sizeof(u32);
+
+	return 0;
+}
+
+static struct resource_table *
+imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc,
+				    const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_find_loaded_rsc_table(rproc, fw);
+
+	return NULL;
+}
+
+static int imx_rproc_elf_sanity_check(struct rproc *rproc,
+				      const struct firmware *fw)
+{
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_sanity_check(rproc, fw);
+
+	return 0;
+}
+
+static u32 imx_rproc_elf_get_boot_addr(struct rproc *rproc,
+				       const struct firmware *fw) {
+	struct imx_rproc *priv = rproc->priv;
+
+	if (!priv->early_boot)
+		return rproc_elf_get_boot_addr(rproc, fw);
+
+	return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
 	.da_to_va       = imx_rproc_da_to_va,
+	.load		= imx_rproc_elf_load_segments,
+	.parse_fw	= imx_rproc_parse_fw,
+	.find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table,
+	.sanity_check	= imx_rproc_elf_sanity_check,
+	.get_boot_addr	= imx_rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv, @@ -309,6
+476,31 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 	return 0;
 }
 
+static int imx_rproc_configure_mode(struct imx_rproc *priv) {
+	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+	struct device *dev = priv->dev;
+	int ret;
+	u32 val;
+
+	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+		priv->early_boot = true;
+	} else {
+		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
+		if (ret) {
+			dev_err(dev, "Failed to read src\n");
+			return ret;
+		}
+
+		priv->early_boot = !!(val & dcfg->src_started);
+	}
+
+	if (priv->early_boot)
+		priv->rproc->skip_fw_load = true;
+
+	return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)  {
 	struct device *dev = &pdev->dev;
@@ -347,27 +539,33 @@ static int imx_rproc_probe(struct
 platform_device *pdev)
 
 	dev_set_drvdata(dev, rproc);
 
-	ret = imx_rproc_addr_init(priv, pdev);
-	if (ret) {
-		dev_err(dev, "failed on imx_rproc_addr_init\n");
+	ret = imx_rproc_configure_mode(priv);
+	if (ret)
 		goto err_put_rproc;
-	}
 
-	priv->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "Failed to get clock\n");
-		ret = PTR_ERR(priv->clk);
-		goto err_put_rproc;
-	}
+	if (!priv->early_boot) {
+		ret = imx_rproc_addr_init(priv, pdev);
+		if (ret) {
+			dev_err(dev, "failed on imx_rproc_addr_init\n");
+			goto err_put_rproc;
+		}
 
-	/*
-	 * clk for M4 block including memory. Should be
-	 * enabled before .start for FW transfer.
-	 */
-	ret = clk_prepare_enable(priv->clk);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed to enable clock\n");
-		goto err_put_rproc;
+		priv->clk = devm_clk_get(dev, NULL);
+		if (IS_ERR(priv->clk)) {
+			dev_err(dev, "Failed to get clock\n");
+			ret = PTR_ERR(priv->clk);
+			goto err_put_rproc;
+		}
+
+		/*
+		 * clk for M4 block including memory. Should be
+		 * enabled before .start for FW transfer.
+		 */
+		ret = clk_prepare_enable(priv->clk);
+		if (ret) {
+			dev_err(&rproc->dev, "Failed to enable clock\n");
+			goto err_put_rproc;
+		}
 	}
 
drivers/remoteproc/imx_rproc.c +0 -0
 	ret = rproc_add(rproc);
@@ -379,7 +577,8 @@ static int imx_rproc_probe(struct platform_device

*pdev)

drivers/remoteproc/imx_rproc.c static int imx_rproc_remove(struct platform_device

Quoted 10 lines
drivers/remoteproc/imx_rproc.c +2 -1
 	return 0;
 
 err_put_clk:
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 err_put_rproc:
 	rproc_free(rproc);
 
@@ -391,7 +590,8 @@ static int imx_rproc_remove(struct platform_device

*pdev)

Quoted 12 lines
drivers/remoteproc/imx_rproc.c +2 -2
 	struct rproc *rproc = platform_get_drvdata(pdev);
 	struct imx_rproc *priv = rproc->priv;
 
-	clk_disable_unprepare(priv->clk);
+	if (!priv->early_boot)
+		clk_disable_unprepare(priv->clk);
 	rproc_del(rproc);
 	rproc_free(rproc);
 
--

2.16.4

#15 lore raw

PATCH 5/9 remoteproc: imx_rproc: parse early-booted property

In reply to [email protected]

From: Peng Fan <[email protected]>

If early-property exists, there is no need to check syscon. Just mark early_boot as true.

---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/remoteproc/imx_rproc.c +11 -7
index b9fabe269fd2..e31ea1090cf3 100644
@@ -483,7 +483,9 @@ static int imx_rproc_configure_mode(struct imx_rproc *priv)
 	int ret;
 	u32 val;
 
-	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+	if (dcfg->variants == IMX7ULP) {
+		priv->early_boot = true;
+	} else if (of_get_property(dev->of_node, "early-booted", NULL)) {
 		priv->early_boot = true;
 	} else {
 		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
@@ -509,15 +511,17 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	struct rproc *rproc;
 	struct regmap_config config = { .name = "imx-rproc" };
 	const struct imx_rproc_dcfg *dcfg;
-	struct regmap *regmap;
+	struct regmap *regmap = NULL;
 	int ret;
 
-	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-	if (IS_ERR(regmap)) {
-		dev_err(dev, "failed to find syscon\n");
-		return PTR_ERR(regmap);
+	if (!of_get_property(np, "early-booted", NULL)) {
+		regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+		if (IS_ERR(regmap)) {
+			dev_err(dev, "failed to find syscon\n");
+			return PTR_ERR(regmap);
+		}
+		regmap_attach_dev(dev, regmap, &config);
 	}
-	regmap_attach_dev(dev, regmap, &config);
 
 	/* set some other name then imx */
 	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
Signature · 1 line
2.16.4
maintainer
#16 lore raw

Re: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property

Quoted 15 lines · On Wed, Feb 19, 2020 at 03:27:41PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

If early-property exists, there is no need to check syscon. Just mark early_boot as true.

---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/remoteproc/imx_rproc.c +0 -0
index b9fabe269fd2..e31ea1090cf3 100644

drivers/remoteproc/imx_rproc.c static int imx_rproc_configure_mode(struct imx_rproc *priv) · line 486

Quoted 5 lines
drivers/remoteproc/imx_rproc.c +1 -1
@@ -483,7 +483,9 @@ static int imx_rproc_configure_mode(struct imx_rproc *priv)
 	int ret;
 	u32 val;
 
-	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+	if (dcfg->variants == IMX7ULP) {

Where does dcfg->variants comes from?

This patch doesn't compile, nor does the one before it. I will not review another patchset like that.

Quoted 32 lines
drivers/remoteproc/imx_rproc.c +10 -6
+		priv->early_boot = true;
+	} else if (of_get_property(dev->of_node, "early-booted", NULL)) {
 		priv->early_boot = true;
 	} else {
 		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
@@ -509,15 +511,17 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	struct rproc *rproc;
 	struct regmap_config config = { .name = "imx-rproc" };
 	const struct imx_rproc_dcfg *dcfg;
-	struct regmap *regmap;
+	struct regmap *regmap = NULL;
 	int ret;
 
-	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-	if (IS_ERR(regmap)) {
-		dev_err(dev, "failed to find syscon\n");
-		return PTR_ERR(regmap);
+	if (!of_get_property(np, "early-booted", NULL)) {
+		regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+		if (IS_ERR(regmap)) {
+			dev_err(dev, "failed to find syscon\n");
+			return PTR_ERR(regmap);
+		}
+		regmap_attach_dev(dev, regmap, &config);
 	}
-	regmap_attach_dev(dev, regmap, &config);
 
 	/* set some other name then imx */
 	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
Signature · 1 line
2.16.4
author
#17 lore raw

RE: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property

Quoted 23 lines

Subject: Re: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property

drivers/remoteproc/imx_rproc.c static int imx_rproc_configure_mode(struct

Quoted 16 lines · On Wed, Feb 19, 2020 at 03:27:41PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

If early-property exists, there is no need to check syscon. Just mark early_boot as true.

---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/remoteproc/imx_rproc.c index b9fabe269fd2..e31ea1090cf3 100644

drivers/remoteproc/imx_rproc.c +0 -0
@@ -483,7 +483,9 @@ static int imx_rproc_configure_mode(struct

imx_rproc *priv)

Quoted 3 lines
drivers/remoteproc/imx_rproc.c +0 -0
 	int ret;
 	u32 val;
 
Quoted 7 lines

drivers/remoteproc/imx_rproc.c static int imx_rproc_configure_mode(struct imx_rproc *priv) · line 486

Quoted 2 lines
drivers/remoteproc/imx_rproc.c +1 -1
-	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+	if (dcfg->variants == IMX7ULP) {

Where does dcfg->variants comes from?

This patch doesn't compile, nor does the one before it. I will not review another patchset like that.

Ah. Weird. variants should be variant.
See https://patchwork.kernel.org/patch/11390559/

I need wait early boot related functions in
remoteproc-core.c ready, then post v2.

Thanks,
Peng.

Quoted 33 lines
Quoted 33 lines
drivers/remoteproc/imx_rproc.c +11 -7
+		priv->early_boot = true;
+	} else if (of_get_property(dev->of_node, "early-booted", NULL)) {
 		priv->early_boot = true;
 	} else {
 		ret = regmap_read(priv->regmap, dcfg->src_reg, &val); @@ -509,15
+511,17 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	struct rproc *rproc;
 	struct regmap_config config = { .name = "imx-rproc" };
 	const struct imx_rproc_dcfg *dcfg;
-	struct regmap *regmap;
+	struct regmap *regmap = NULL;
 	int ret;
 
-	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-	if (IS_ERR(regmap)) {
-		dev_err(dev, "failed to find syscon\n");
-		return PTR_ERR(regmap);
+	if (!of_get_property(np, "early-booted", NULL)) {
+		regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+		if (IS_ERR(regmap)) {
+			dev_err(dev, "failed to find syscon\n");
+			return PTR_ERR(regmap);
+		}
+		regmap_attach_dev(dev, regmap, &config);
 	}
-	regmap_attach_dev(dev, regmap, &config);
 
 	/* set some other name then imx */
 	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
--

2.16.4

#18 lore raw

PATCH 6/9 remoteproc: imx_proc: enable virtio/mailbox

In reply to [email protected]

From: Peng Fan <[email protected]>

Use virtio/mailbox to build connection between Remote Proccessors and Linux. Add delayed work to handle incoming messages.

---
 drivers/remoteproc/imx_rproc.c | 106 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 102 insertions(+), 4 deletions(-)
drivers/remoteproc/imx_rproc.c +102 -4
index e31ea1090cf3..36dec1ce4f50 100644
@@ -7,14 +7,18 @@
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mailbox_client.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/remoteproc.h>
 
+#include "remoteproc_internal.h"
+
 #define IMX7D_SRC_SCR			0x0C
 #define IMX7D_ENABLE_M4			BIT(3)
 #define IMX7D_SW_M4P_RST		BIT(2)
@@ -87,6 +91,10 @@ struct imx_rproc {
 	struct imx_rproc_mem		mem[IMX7D_RPROC_MEM_MAX];
 	struct clk			*clk;
 	bool				early_boot;
+	struct mbox_client		cl;
+	struct mbox_chan		*tx_ch;
+	struct mbox_chan		*rx_ch;
+	struct delayed_work		rproc_work;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
@@ -402,9 +410,25 @@ static u32 imx_rproc_elf_get_boot_addr(struct rproc *rproc,
 	return 0;
 }
 
+static void imx_rproc_kick(struct rproc *rproc, int vqid)
+{
+	struct imx_rproc *priv = rproc->priv;
+	int err;
+	__u32 mmsg;
+
+	mmsg = vqid << 16;
+
+	priv->cl.tx_tout = 20;
+	err = mbox_send_message(priv->tx_ch, (void *)&mmsg);
+	if (err < 0)
+		dev_err(priv->dev, "%s: failed (%d, err:%d)\n",
+			__func__, vqid, err);
+}
+
 static const struct rproc_ops imx_rproc_ops = {
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
+	.kick		= imx_rproc_kick,
 	.da_to_va       = imx_rproc_da_to_va,
 	.load		= imx_rproc_elf_load_segments,
 	.parse_fw	= imx_rproc_parse_fw,
@@ -503,6 +527,67 @@ static int imx_rproc_configure_mode(struct imx_rproc *priv)
 	return 0;
 }
 
+static void imx_rproc_vq_work(struct work_struct *work)
+{
+	struct delayed_work *dwork = to_delayed_work(work);
+	struct imx_rproc *priv = container_of(dwork, struct imx_rproc,
+					      rproc_work);
+
+	rproc_vq_interrupt(priv->rproc, 0);
+	rproc_vq_interrupt(priv->rproc, 1);
+}
+
+static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
+{
+	struct rproc *rproc = dev_get_drvdata(cl->dev);
+	struct imx_rproc *priv = rproc->priv;
+
+	schedule_delayed_work(&(priv->rproc_work), 0);
+}
+
+static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
+{
+	struct imx_rproc *priv = rproc->priv;
+	struct device *dev = priv->dev;
+	struct mbox_client *cl;
+	int ret = 0;
+
+	cl = &priv->cl;
+	cl->dev = dev;
+	cl->tx_block = true;
+	cl->tx_tout = 20;
+	cl->knows_txdone = false;
+	cl->rx_callback = imx_rproc_rx_callback;
+
+	priv->tx_ch = mbox_request_channel_byname(cl, "tx");
+	if (IS_ERR(priv->tx_ch)) {
+		if (PTR_ERR(priv->tx_ch) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		ret = PTR_ERR(priv->tx_ch);
+		dev_dbg(cl->dev, "failed to request mbox tx chan, ret %d\n",
+			ret);
+		goto err_out;
+	}
+
+	priv->rx_ch = mbox_request_channel_byname(cl, "rx");
+	if (IS_ERR(priv->rx_ch)) {
+		ret = PTR_ERR(priv->rx_ch);
+		dev_dbg(cl->dev, "failed to request mbox rx chan, ret %d\n",
+			ret);
+		goto err_out;
+	}
+
+	return ret;
+
+err_out:
+	if (!IS_ERR(priv->tx_ch))
+		mbox_free_channel(priv->tx_ch);
+	if (!IS_ERR(priv->rx_ch))
+		mbox_free_channel(priv->rx_ch);
+
+	return ret;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -543,22 +628,28 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
 	dev_set_drvdata(dev, rproc);
 
+	ret = imx_rproc_xtr_mbox_init(rproc);
+	if (ret) {
+		if (ret == -EPROBE_DEFER)
+			goto err_put_rproc;
+	}
+
 	ret = imx_rproc_configure_mode(priv);
 	if (ret)
-		goto err_put_rproc;
+		goto err_put_mbox;
 
 	if (!priv->early_boot) {
 		ret = imx_rproc_addr_init(priv, pdev);
 		if (ret) {
 			dev_err(dev, "failed on imx_rproc_addr_init\n");
-			goto err_put_rproc;
+			goto err_put_mbox;
 		}
 
 		priv->clk = devm_clk_get(dev, NULL);
 		if (IS_ERR(priv->clk)) {
 			dev_err(dev, "Failed to get clock\n");
 			ret = PTR_ERR(priv->clk);
-			goto err_put_rproc;
+			goto err_put_mbox;
 		}
 
 		/*
@@ -568,10 +659,12 @@ static int imx_rproc_probe(struct platform_device *pdev)
 		ret = clk_prepare_enable(priv->clk);
 		if (ret) {
 			dev_err(&rproc->dev, "Failed to enable clock\n");
-			goto err_put_rproc;
+			goto err_put_mbox;
 		}
 	}
 
+	INIT_DELAYED_WORK(&(priv->rproc_work), imx_rproc_vq_work);
+
 	ret = rproc_add(rproc);
 	if (ret) {
 		dev_err(dev, "rproc_add failed\n");
@@ -583,6 +676,11 @@ static int imx_rproc_probe(struct platform_device *pdev)
 err_put_clk:
 	if (!priv->early_boot)
 		clk_disable_unprepare(priv->clk);
+err_put_mbox:
+	if (!IS_ERR(priv->tx_ch))
+		mbox_free_channel(priv->tx_ch);
+	if (!IS_ERR(priv->rx_ch))
+		mbox_free_channel(priv->rx_ch);
 err_put_rproc:
 	rproc_free(rproc);
 
Signature · 1 line
2.16.4
#19 lore raw

PATCH 7/9 remoteproc: imx_rproc: add i.MX8QM/QXP

In reply to [email protected]

From: Peng Fan <[email protected]>

i.MX8QM and i.MX8QXP support hardware partition feature, the M4 could be controlled by System Control Unit(SCU). The M4 is out of control of Linux with hardware partition used which is the normal case for production in automotive space.

When M4 reboot, SCU will issue interrupt to Linux side, and Linux side will recovery the connection. To use related functions, guard code with CONFIG_IMX_SCU which is enabled for all i.MX SoCs with SCU inside.

---
 drivers/remoteproc/imx_rproc.c | 84 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 4 deletions(-)
drivers/remoteproc/imx_rproc.c +80 -4
index 36dec1ce4f50..003f9e5c2b0c 100644
@@ -1,10 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017 Pengutronix, Oleksij Rempel <[email protected]>
+ * Copyright 2020 NXP, Peng Fan <[email protected]>
  */
 
 #include <linux/clk.h>
 #include <linux/err.h>
+#ifdef CONFIG_IMX_SCU
+#include <linux/firmware/imx/sci.h>
+#endif
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/mailbox_client.h>
@@ -49,6 +53,13 @@
 
 #define IMX7D_RPROC_MEM_MAX		8
 
+enum imx_rproc_variants {
+	IMX8QM,
+	IMX8QXP,
+	IMX7D,
+	IMX6SX,
+};
+
 /**
  * struct imx_rproc_mem - slim internal memory structure
  * @cpu_addr: MPU virtual address of the memory region
@@ -81,6 +92,7 @@ struct imx_rproc_dcfg {
 	u32				src_started;
 	const struct imx_rproc_att	*att;
 	size_t				att_size;
+	enum imx_rproc_variants		variant;
 };
 
 struct imx_rproc {
@@ -95,6 +107,8 @@ struct imx_rproc {
 	struct mbox_chan		*tx_ch;
 	struct mbox_chan		*rx_ch;
 	struct delayed_work		rproc_work;
+	u32				mub_partition;
+	struct notifier_block		proc_nb;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
@@ -167,6 +181,14 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = {
+	.variant	= IMX8QXP,
+};
+
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = {
+	.variant	= IMX8QM,
+};
+
 static int imx_rproc_start(struct rproc *rproc)
 {
 	struct imx_rproc *priv = rproc->priv;
@@ -507,9 +529,7 @@ static int imx_rproc_configure_mode(struct imx_rproc *priv)
 	int ret;
 	u32 val;
 
-	if (dcfg->variants == IMX7ULP) {
-		priv->early_boot = true;
-	} else if (of_get_property(dev->of_node, "early-booted", NULL)) {
+	if (of_get_property(dev->of_node, "early-booted", NULL)) {
 		priv->early_boot = true;
 	} else {
 		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
@@ -588,6 +608,25 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
 	return ret;
 }
 
+#ifdef CONFIG_IMX_SCU
+static int imx_rproc_partition_notify(struct notifier_block *nb,
+				      unsigned long event, void *group)
+{
+	struct imx_rproc *priv = container_of(nb, struct imx_rproc, proc_nb);
+
+	/* Ignore other irqs */
+	if (!((event & BIT(priv->mub_partition)) &&
+	    (*(u8 *)group == 5)))
+		return 0;
+
+	rproc_report_crash(priv->rproc, RPROC_WATCHDOG);
+
+	pr_info("Patition%d reset!\n", priv->mub_partition);
+
+	return 0;
+}
+#endif
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -665,15 +704,50 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
 	INIT_DELAYED_WORK(&(priv->rproc_work), imx_rproc_vq_work);
 
+#ifdef CONFIG_IMX_SCU
+	priv->proc_nb.notifier_call = imx_rproc_partition_notify;
+
+	if (dcfg->variant == IMX8QXP || dcfg->variant == IMX8QM) {
+		/*
+		 * Get muB partition id and enable irq in SCFW
+		 * default partition 3
+		 */
+		if (of_property_read_u32(np, "mub-partition",
+					 &priv->mub_partition))
+			priv->mub_partition = 3;
+
+		ret = imx_scu_irq_group_enable(5, BIT(priv->mub_partition),
+					       true);
+		if (ret) {
+			dev_warn(dev, "Enable irq failed.\n");
+			goto err_put_clk;
+		}
+
+		ret = imx_scu_irq_register_notifier(&priv->proc_nb);
+		if (ret) {
+			imx_scu_irq_group_enable(5, BIT(priv->mub_partition),
+						 false);
+			dev_warn(dev, "reqister scu notifier failed.\n");
+			goto err_put_clk;
+		}
+
+		priv->rproc->skip_fw_load_recovery = true;
+	}
+#endif
+
 	ret = rproc_add(rproc);
 	if (ret) {
 		dev_err(dev, "rproc_add failed\n");
-		goto err_put_clk;
+		goto err_put_scu;
 	}
 
 	return 0;
 
+err_put_scu:
+#ifdef CONFIG_IMX_SCU
+	imx_scu_irq_group_enable(5, BIT(priv->mub_partition), false);
 err_put_clk:
+#endif
 	if (!priv->early_boot)
 		clk_disable_unprepare(priv->clk);
 err_put_mbox:
@@ -703,6 +777,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 static const struct of_device_id imx_rproc_of_match[] = {
 	{ .compatible = "fsl,imx7d-cm4", .data = &imx_rproc_cfg_imx7d },
 	{ .compatible = "fsl,imx6sx-cm4", .data = &imx_rproc_cfg_imx6sx },
+	{ .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp },
+	{ .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm },
 	{},
 };
 MODULE_DEVICE_TABLE(of, imx_rproc_of_match);
Signature · 1 line
2.16.4
#20 lore raw

PATCH 8/9 remoteproc: imx_rproc: support i.MX7ULP

In reply to [email protected]

From: Peng Fan <[email protected]>

To i.MX7ULP, M4 is booted before Linux and it's in charge of the whole system. So M4 is surely have early_boot set.

---
 drivers/remoteproc/imx_rproc.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/remoteproc/imx_rproc.c +17 -8
index 003f9e5c2b0c..fc2a504bc350 100644
@@ -56,6 +56,7 @@
 enum imx_rproc_variants {
 	IMX8QM,
 	IMX8QXP,
+	IMX7ULP,
 	IMX7D,
 	IMX6SX,
 };
@@ -181,6 +182,10 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
 	.att_size	= ARRAY_SIZE(imx_rproc_att_imx6sx),
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = {
+	.variant	= IMX7ULP,
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = {
 	.variant	= IMX8QXP,
 };
@@ -529,7 +534,9 @@ static int imx_rproc_configure_mode(struct imx_rproc *priv)
 	int ret;
 	u32 val;
 
-	if (of_get_property(dev->of_node, "early-booted", NULL)) {
+	if (dcfg->variant == IMX7ULP) {
+		priv->early_boot = true;
+	} else if (of_get_property(dev->of_node, "early-booted", NULL)) {
 		priv->early_boot = true;
 	} else {
 		ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
@@ -638,7 +645,14 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	struct regmap *regmap = NULL;
 	int ret;
 
-	if (!of_get_property(np, "early-booted", NULL)) {
+	dcfg = of_device_get_match_data(dev);
+	if (!dcfg) {
+		ret = -EINVAL;
+		return ret;
+	}
+
+	if (!of_get_property(np, "early-booted", NULL) &&
+	    !(dcfg->variant == IMX7ULP)) {
 		regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
 		if (IS_ERR(regmap)) {
 			dev_err(dev, "failed to find syscon\n");
@@ -653,12 +667,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
 	if (!rproc)
 		return -ENOMEM;
 
-	dcfg = of_device_get_match_data(dev);
-	if (!dcfg) {
-		ret = -EINVAL;
-		goto err_put_rproc;
-	}
-
 	priv = rproc->priv;
 	priv->rproc = rproc;
 	priv->regmap = regmap;
@@ -775,6 +783,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id imx_rproc_of_match[] = {
+	{ .compatible = "fsl,imx7ulp-cm4", .data = &imx_rproc_cfg_imx7ulp },
 	{ .compatible = "fsl,imx7d-cm4", .data = &imx_rproc_cfg_imx7d },
 	{ .compatible = "fsl,imx6sx-cm4", .data = &imx_rproc_cfg_imx6sx },
 	{ .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp },
Signature · 1 line
2.16.4
#21 lore raw

PATCH 9/9 remoteproc: imx_rproc: add i.MX8MM support

In reply to [email protected]

From: Peng Fan <[email protected]>

Add i.MX8MM support. Remote processor is under control of Cortex-A processor. Currently only early boot is supported.

---
 drivers/remoteproc/imx_rproc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/remoteproc/imx_rproc.c +6 -0
index fc2a504bc350..d00c3cbcd87c 100644
@@ -56,6 +56,7 @@
 enum imx_rproc_variants {
 	IMX8QM,
 	IMX8QXP,
+	IMX8MM,
 	IMX7ULP,
 	IMX7D,
 	IMX6SX,
@@ -194,6 +195,10 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = {
 	.variant	= IMX8QM,
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mm = {
+	.variant	= IMX8MM,
+};
+
 static int imx_rproc_start(struct rproc *rproc)
 {
 	struct imx_rproc *priv = rproc->priv;
@@ -788,6 +793,7 @@ static const struct of_device_id imx_rproc_of_match[] = {
 	{ .compatible = "fsl,imx6sx-cm4", .data = &imx_rproc_cfg_imx6sx },
 	{ .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp },
 	{ .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm },
+	{ .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mm },
 	{},
 };
 MODULE_DEVICE_TABLE(of, imx_rproc_of_match);
Signature · 1 line
2.16.4
maintainer
#22 lore raw
In reply to [email protected]

Hi Peng,

Quoted 4 lines · On Wed, 19 Feb 2020 at 00:33, <[email protected]> wrote:

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

You mean remoteproc/imx_rproc.c ? Upstream rpmsg/imx_rpmsg.c doesn't exist.

Quoted 6 lines

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before kernel"
https://patchwork.kernel.org/patch/11265869/,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Did you base your work on top of Loic's because your MCU firmware is always loaded by the bootloader? If not please send another revision of your work without early boot support. When we have a clear view on how to proceed with the early boot support you can send another set to enable that.

Thanks,
Mathieu

Quoted 100 lines

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +64 -0
+
+       imx8x-cm4 {
+               compatible = "fsl,imx8qxp-cm4";
+               rsrc-table = <
+                       0x1 0x2 0x0 0x0 0x18 0x5c
+                       3
+                       /*fw_rsc_vdev*/
+                       7 0 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90000000 4096 256 1 0
+                       0x90008000 4096 256 2 0
+                       3
+                       /*fw_rsc_vdev*/
+                       7 1 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90010000 4096 256 1 0
+                       0x90018000 4096 256 2 0
+               >;
+               early-booted;
+               mbox-names = "tx", "rx", "rxdb";
+               mboxes = <&lsio_mu5 0 1
+                         &lsio_mu5 1 1
+                         &lsio_mu5 3 1>;
+               mub-partition = <3>;
+               memory-region = <&vdev0vring0>, <&vdev0vring1>, <&vdev0buffer>,
+                               <&vdev1vring0>, <&vdev1vring1>, <&vdev0buffer>;
+       };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90000000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90008000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90010000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90018000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90400000 0 0x100000>;
+                       no-map;
+               };
+       };
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455 +++++++++++++++++++--
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

--
2.16.4

author
#23 lore raw

Hi Mathieu,

Quoted 4 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Hi Peng,

Quoted 8 lines
Quoted 4 lines · On Wed, 19 Feb 2020 at 00:33, <[email protected]> wrote:

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

You mean remoteproc/imx_rproc.c ? Upstream rpmsg/imx_rpmsg.c doesn't exist.

imx_rpmsg.c only in NXP vendor tree. This pachset is to use imx_rproc.c for rpmsg/virtio functions for i.MX SoC.

Quoted 13 lines
Quoted 4 lines

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before

kernel"

Quoted 2 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc

hwork.kernel.org%2Fpatch%2F11265869%2F&amp;data=02%7C01%7Cpeng.f an%40n

Quoted 1 line

xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9 2cd99c5c

Quoted 1 line
Quoted 8 lines

301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba YT%2BDZDk0

Quoted 3 lines

VLt1NpkNuhrY3ssxiRCOcrM%3D&amp;reserved=0,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Did you base your work on top of Loic's because your MCU firmware is always loaded by the bootloader?

I only took Loic's early-boot patch as base and apply my patchset.

The mcu firmware currently only loaded by bootloader or system controller firmware. NXP released mcu firmware not support being loaded by Linux remoteproc.

If not please send another revision of your work

Quoted 2 lines

without early boot support. When we have a clear view on how to proceed with the early boot support you can send another set to enable that.

I'll wait your new patch for early boot in remoteproc-core. Then I'll rebase and send a new version. Since I introduce big changes to imx_rproc.c, so I'll see whether any comments there.

Thanks,
Peng.

Quoted 108 lines

Thanks,
Mathieu

Quoted 27 lines

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +15 -0
+
+       imx8x-cm4 {
+               compatible = "fsl,imx8qxp-cm4";
+               rsrc-table = <
+                       0x1 0x2 0x0 0x0 0x18 0x5c
+                       3
+                       /*fw_rsc_vdev*/
+                       7 0 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90000000 4096 256 1 0
+                       0x90008000 4096 256 2 0
+                       3
+                       /*fw_rsc_vdev*/
+                       7 1 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/

Review

Quoted 10 lines
(quoted diff) +10 -0
+                       0x90010000 4096 256 1 0
+                       0x90018000 4096 256 2 0
+               >;
+               early-booted;
+               mbox-names = "tx", "rx", "rxdb";
+               mboxes = <&lsio_mu5 0 1
+                         &lsio_mu5 1 1
+                         &lsio_mu5 3 1>;
+               mub-partition = <3>;
+               memory-region = <&vdev0vring0>, <&vdev0vring1>,

<&vdev0buffer>,

Quoted 1 line

+ <&vdev1vring0>, <&vdev1vring1>,

<&vdev0buffer>;

Quoted 50 lines
(quoted diff) +38 -0
+       };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90000000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90008000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90010000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90018000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90400000 0 0x100000>;
+                       no-map;
+               };
+       };
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

Quoted 3 lines
 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455

+++++++++++++++++++--

Quoted 10 lines
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

--
2.16.4

maintainer
#24 lore raw
Quoted 38 lines · Peng Fan

Hi Mathieu,

Quoted 4 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Hi Peng,

Quoted 8 lines
Quoted 4 lines · On Wed, 19 Feb 2020 at 00:33, <[email protected]> wrote:

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

You mean remoteproc/imx_rproc.c ? Upstream rpmsg/imx_rpmsg.c doesn't exist.

imx_rpmsg.c only in NXP vendor tree. This pachset is to use imx_rproc.c for rpmsg/virtio functions for i.MX SoC.

Quoted 19 lines
Quoted 4 lines

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before

kernel"

Quoted 2 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc

hwork.kernel.org%2Fpatch%2F11265869%2F&amp;data=02%7C01%7Cpeng.f an%40n

Quoted 1 line

xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9 2cd99c5c

Quoted 1 line

301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba YT%2BDZDk0

Quoted 3 lines

VLt1NpkNuhrY3ssxiRCOcrM%3D&amp;reserved=0,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Quoted 7 lines
Quoted 2 lines

Did you base your work on top of Loic's because your MCU firmware is always loaded by the bootloader?

I only took Loic's early-boot patch as base and apply my patchset.

The mcu firmware currently only loaded by bootloader or system controller firmware. NXP released mcu firmware not support being loaded by Linux remoteproc.

Thanks for bringing this use case to the front. I suspected such a scenario existed but didn't spend too much time thinking about it since none had been brought to our attention. I will review your patchset and continue the conversation with Arnaud with it in mind. I also invite you to join that conversation.

Regards,
Mathieu

Quoted 120 lines

If not please send another revision of your work

Quoted 2 lines

without early boot support. When we have a clear view on how to proceed with the early boot support you can send another set to enable that.

I'll wait your new patch for early boot in remoteproc-core. Then I'll rebase and send a new version. Since I introduce big changes to imx_rproc.c, so I'll see whether any comments there.

Thanks,
Peng.

Quoted 108 lines

Thanks,
Mathieu

Quoted 27 lines

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +15 -0
+
+       imx8x-cm4 {
+               compatible = "fsl,imx8qxp-cm4";
+               rsrc-table = <
+                       0x1 0x2 0x0 0x0 0x18 0x5c
+                       3
+                       /*fw_rsc_vdev*/
+                       7 0 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90000000 4096 256 1 0
+                       0x90008000 4096 256 2 0
+                       3
+                       /*fw_rsc_vdev*/
+                       7 1 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/

Review

Quoted 10 lines
(quoted diff) +10 -0
+                       0x90010000 4096 256 1 0
+                       0x90018000 4096 256 2 0
+               >;
+               early-booted;
+               mbox-names = "tx", "rx", "rxdb";
+               mboxes = <&lsio_mu5 0 1
+                         &lsio_mu5 1 1
+                         &lsio_mu5 3 1>;
+               mub-partition = <3>;
+               memory-region = <&vdev0vring0>, <&vdev0vring1>,

<&vdev0buffer>,

Quoted 1 line

+ <&vdev1vring0>, <&vdev1vring1>,

<&vdev0buffer>;

Quoted 50 lines
(quoted diff) +38 -0
+       };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90000000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90008000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90010000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90018000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90400000 0 0x100000>;
+                       no-map;
+               };
+       };
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

Quoted 3 lines
 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455

+++++++++++++++++++--

Quoted 10 lines
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

--
2.16.4

author
#25 lore raw
Quoted 52 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Quoted 12 lines · Peng Fan

Hi Mathieu,

Quoted 9 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Hi Peng,

Quoted 3 lines · On Wed, 19 Feb 2020 at 00:33, <[email protected]> wrote:

From: Peng Fan <[email protected]>

Quoted 17 lines
Quoted 4 lines
Quoted 1 line

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

You mean remoteproc/imx_rproc.c ? Upstream rpmsg/imx_rpmsg.c doesn't exist.

imx_rpmsg.c only in NXP vendor tree. This pachset is to use imx_rproc.c for rpmsg/virtio functions for i.MX SoC.

Quoted 9 lines
Quoted 4 lines

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before

kernel"

Quoted 3 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
patc

hwork.kernel.org%2Fpatch%2F11265869%2F&amp;data=02%7C01%7Cpeng.f

Quoted 3 lines
Quoted 3 lines

an%40n

Quoted 1 line

xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9

Quoted 3 lines
Quoted 3 lines

2cd99c5c

Quoted 1 line

301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba

Quoted 11 lines
Quoted 8 lines

YT%2BDZDk0

Quoted 4 lines

VLt1NpkNuhrY3ssxiRCOcrM%3D&amp;reserved=0,
and inspried from st's remoteproc early boot support. Since Loic's patch is still under review, just expect your comments :)

Did you base your work on top of Loic's because your MCU firmware is always loaded by the bootloader?

I only took Loic's early-boot patch as base and apply my patchset.

Quoted 7 lines
Quoted 1 line

The mcu firmware currently only loaded by bootloader or system controller

firmware.

Quoted 1 line

NXP released mcu firmware not support being loaded by Linux remoteproc.

Thanks for bringing this use case to the front. I suspected such a scenario existed but didn't spend too much time thinking about it since none had been brought to our attention.

Actually to i.MX7ULP, M4 is booted first from hardware design and it controls every things, A7 is under control of M4

To i.MX8/8X, M4 is booted by system control unit firmware for quick boot for automotive CAN and Linux is booted later. Linux could only IPC to M4, and nothing else.

To i.MX8M, M4 is booted by bootloader, but it could also be booted by Linux, It is just NXP only support bootloader case.

I will review your patchset and continue the

Quoted 2 lines

conversation with Arnaud with it in mind. I also invite you to join that conversation.

Appreciate.

Thanks,
Peng.

Quoted 128 lines

Regards,
Mathieu

Quoted 4 lines

If not please send another revision of your work

Quoted 2 lines

without early boot support. When we have a clear view on how to proceed with the early boot support you can send another set to enable

that.

Quoted 20 lines

I'll wait your new patch for early boot in remoteproc-core. Then I'll rebase and send a new version. Since I introduce big changes to imx_rproc.c, so I'll see whether any comments there.

Thanks,
Peng.

Quoted 12 lines

Thanks,
Mathieu

Quoted 8 lines

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch
3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add

resource

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +25 -0
+
+       imx8x-cm4 {
+               compatible = "fsl,imx8qxp-cm4";
+               rsrc-table = <
+                       0x1 0x2 0x0 0x0 0x18 0x5c
+                       3
+                       /*fw_rsc_vdev*/
+                       7 0 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90000000 4096 256 1 0
+                       0x90008000 4096 256 2 0
+                       3
+                       /*fw_rsc_vdev*/
+                       7 1 1 0 0 0x200
+                       /*fw_rsc_vdev_vring*/
+                       0x90010000 4096 256 1 0
+                       0x90018000 4096 256 2 0
+               >;
+               early-booted;
+               mbox-names = "tx", "rx", "rxdb";
+               mboxes = <&lsio_mu5 0 1
+                         &lsio_mu5 1 1
+                         &lsio_mu5 3 1>;
+               mub-partition = <3>;
+               memory-region = <&vdev0vring0>, <&vdev0vring1>,
Quoted 2 lines
Quoted 2 lines

<&vdev0buffer>,

Quoted 1 line

+ <&vdev1vring0>,

<&vdev1vring1>,

Quoted 65 lines
Quoted 65 lines

<&vdev0buffer>;

Quoted 50 lines
(quoted diff) +38 -0
+       };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90000000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90008000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90010000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90018000 0 0x8000>;
+                       no-map;
+               };
+
+               vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+                       reg = <0 0x90400000 0 0x100000>;
+                       no-map;
+               };
+       };
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

Quoted 3 lines
 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455

+++++++++++++++++++--

Quoted 10 lines
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

--
2.16.4

#26 lore raw
In reply to [email protected]

Hi Peng,

i can't apply your patches on kernel master HEAD. Do I need some extras?

Please add me to CC for this driver next time.

Quoted 111 lines · On Wed, Feb 19, 2020 at 03:27:36PM +0800, [email protected] wrote:

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before kernel"
https://patchwork.kernel.org/patch/11265869/,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +64 -0
+
+	imx8x-cm4 {
+		compatible = "fsl,imx8qxp-cm4";
+		rsrc-table = <
+			0x1 0x2 0x0 0x0 0x18 0x5c
+			3
+			/*fw_rsc_vdev*/
+			7 0 1 0 0 0x200
+			/*fw_rsc_vdev_vring*/
+			0x90000000 4096 256 1 0
+			0x90008000 4096 256 2 0
+			3
+			/*fw_rsc_vdev*/
+			7 1 1 0 0 0x200
+			/*fw_rsc_vdev_vring*/
+			0x90010000 4096 256 1 0
+			0x90018000 4096 256 2 0
+		>;
+		early-booted;
+		mbox-names = "tx", "rx", "rxdb";
+		mboxes = <&lsio_mu5 0 1
+			  &lsio_mu5 1 1
+			  &lsio_mu5 3 1>;
+		mub-partition = <3>;
+		memory-region = <&vdev0vring0>, <&vdev0vring1>, <&vdev0buffer>,
+				<&vdev1vring0>, <&vdev1vring1>, <&vdev0buffer>;
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90000000 0 0x8000>;
+			no-map;
+		};
+
+		vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90008000 0 0x8000>;
+			no-map;
+		};
+
+		vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90010000 0 0x8000>;
+			no-map;
+		};
+
+		vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90018000 0 0x8000>;
+			no-map;
+		};
+
+		vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90400000 0 0x100000>;
+			no-map;
+		};
+	};
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455 +++++++++++++++++++--
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
Signature · 1 line
2.16.4
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#27 lore raw

Hi Oleksij,

Quoted 5 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Hi Peng,

i can't apply your patches on kernel master HEAD. Do I need some extras?

The patchset is based on Shawn's for-next branch. With Loic' V4 patch applied as showed in cover-letter.

Quoted 2 lines

Please add me to CC for this driver next time.

I used get_maintainer.pl to get the to/cc list. Will add you in v2, but may delay for a while, sine early boot stuff not settle down until now.

Thanks,
Peng.

Quoted 127 lines · On Wed, Feb 19, 2020 at 03:27:36PM +0800, [email protected] wrote:
Quoted 6 lines

From: Peng Fan <[email protected]>

This patchset aim to replace NXP vendor imx_rpmsg.c driver.

This patchset is tested with Loic PALLARDY's patch "remoteproc: add support for co-processor loaded and booted before

kernel"

Quoted 30 lines

https://patchwork.kernel.org/patch/11265869/,
and inspried from st's remoteproc early boot support.
Since Loic's patch is still under review, just expect your comments :)

Patch [1,2]/9: dt-bindings convert to json and new SoC support Patch 3/9: skip firmware load when recovery. To i.MX8, firmware is not
handled by Linux.

Patch [4-9]/9: i.MX specific part to support rpmsg/virtio with mbox.
because NXP release image not have resoure table, so add resource table in dts

My test dts diff for i.MX8QXP MEK, but I have tested this patchset for i.MX8QXP MEK, i.MX8MM EVK, i.MX7ULP EVK:

(quoted diff) +15 -0
+
+	imx8x-cm4 {
+		compatible = "fsl,imx8qxp-cm4";
+		rsrc-table = <
+			0x1 0x2 0x0 0x0 0x18 0x5c
+			3
+			/*fw_rsc_vdev*/
+			7 0 1 0 0 0x200
+			/*fw_rsc_vdev_vring*/
+			0x90000000 4096 256 1 0
+			0x90008000 4096 256 2 0
+			3
+			/*fw_rsc_vdev*/
+			7 1 1 0 0 0x200
+			/*fw_rsc_vdev_vring*/

Review

Quoted 10 lines
(quoted diff) +10 -0
+			0x90010000 4096 256 1 0
+			0x90018000 4096 256 2 0
+		>;
+		early-booted;
+		mbox-names = "tx", "rx", "rxdb";
+		mboxes = <&lsio_mu5 0 1
+			  &lsio_mu5 1 1
+			  &lsio_mu5 3 1>;
+		mub-partition = <3>;
+		memory-region = <&vdev0vring0>, <&vdev0vring1>,

<&vdev0buffer>,

Quoted 51 lines
(quoted diff) +39 -0
+				<&vdev1vring0>, <&vdev1vring1>, <&vdev0buffer>;
+	};
+
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		vdev0vring0: vdev0vring0@90000000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90000000 0 0x8000>;
+			no-map;
+		};
+
+		vdev0vring1: vdev0vring1@90008000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90008000 0 0x8000>;
+			no-map;
+		};
+
+		vdev1vring0: vdev1vring0@90010000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90010000 0 0x8000>;
+			no-map;
+		};
+
+		vdev1vring1: vdev1vring1@90018000 {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90018000 0 0x8000>;
+			no-map;
+		};
+
+		vdev0buffer: vdev0buffer {
+                       compatible = "shared-dma-pool";
+			reg = <0 0x90400000 0 0x100000>;
+			no-map;
+		};
+	};
+

Peng Fan (9):
dt-bindings: remoteproc: Convert imx-rproc to json-schema
dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
remoteproc: add support to skip firmware load when recovery
remoteproc: imx_rproc: surport early booted remote processor
remoteproc: imx_rproc: parse early-booted property
remoteproc: imx_proc: enable virtio/mailbox
remoteproc: imx_rproc: add i.MX8QM/QXP
remoteproc: imx_rproc: support i.MX7ULP
remoteproc: imx_rproc: add i.MX8MM support

Quoted 3 lines
 .../devicetree/bindings/remoteproc/imx-rproc.txt   |  33 --
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  |  95 +++++
 drivers/remoteproc/imx_rproc.c                     | 455

+++++++++++++++++++--

Quoted 5 lines
 drivers/remoteproc/remoteproc_core.c               |  19 +-
 include/linux/remoteproc.h                         |   1 +
 5 files changed, 531 insertions(+), 72 deletions(-)  delete mode
100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
 create mode 100644
Quoted 7 lines

Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml

--
2.16.4

--
Pengutronix e.K. |
|
Steuerwalder Str. 21 |
http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone:
+49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |

#28 lore raw

Hello,

Quoted 5 lines · Peng Fan
Quoted 2 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP i can't apply your patches on kernel master HEAD. Do I need some extras?

The patchset is based on Shawn's for-next branch. With Loic' V4 patch applied as showed in cover-letter.

BTW, the generic approach to formalize that is using --base to git-format-patch (or git-send-email). See
https://people.kernel.org/monsieuricon/all-patches-must-include-base-commit-info

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K�nig            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
author
#29 lore raw
Quoted 7 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP

Hello,

Quoted 2 lines · Peng Fan
Quoted 2 lines

Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP i can't apply your patches on kernel master HEAD. Do I

Quoted 7 lines

need some extras?

Quoted 3 lines

The patchset is based on Shawn's for-next branch. With Loic' V4 patch applied as showed in cover-letter.

BTW, the generic approach to formalize that is using --base to git-format-patch (or git-send-email). See

Thanks for tips. I'll follow when do new patches.

Thanks,
Peng.

Quoted 19 lines

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpeople
.kernel.org%2Fmonsieuricon%2Fall-patches-must-include-base-commit-info& amp;data=02%7C01%7Cpeng.fan%40nxp.com%7C9cd4c63fe8974353439408 d7b69c1b2f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63717 8653890207488&amp;sdata=6fvjPjemWlSzZVcDMqWPtjuyEFdOBOttGcO7bS uxsyY%3D&amp;reserved=0

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König
|
Industrial Linux Solutions |
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
pengutronix.de%2F&amp;data=02%7C01%7Cpeng.fan%40nxp.com%7C9cd4c 63fe8974353439408d7b69c1b2f%7C686ea1d3bc2b4c6fa92cd99c5c301635% 7C0%7C0%7C637178653890207488&amp;sdata=1XRpT97ML%2FLpYjdbZb% 2BTdp6DfW6FSMq0Jnxv%2B7%2BX59Y%3D&amp;reserved=0 |