linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
@ 2020-02-19  7:27 peng.fan
  2020-02-19  7:27 ` [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema peng.fan
                   ` (10 more replies)
  0 siblings, 11 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

-- 
2.16.4


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

* [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19 14:09   ` Rob Herring
  2020-02-19  7:27 ` [PATCH 2/9] dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP] peng.fan
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 .../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

diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
deleted file mode 100644
index fbcefd965dc4..000000000000
--- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
+++ /dev/null
@@ -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>;
-	};
diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml b/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
new file mode 100644
index 000000000000..12a5f3de38fb
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/remoteproc/imx-rproc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: NXP iMX6SX/iMX7D Co-Processor Bindings
+
+description:
+  This binding provides support for ARM Cortex M4 Co-processor found on
+  some NXP iMX SoCs.
+
+maintainers:
+  - Oleksij Rempel <o.rempel@pengutronix.de>
+  - Peng Fan <peng.fan@nxp.com>
+
+properties:
+  compatible:
+      enum:
+        - "fsl,imx7d-cm4"
+        - "fsl,imx6sx-cm4"
+
+  clocks:
+    items:
+      Clock for co-processor (See: ../clock/clock-bindings.txt)
+
+  syscon:
+     description:
+       Phandle to syscon block which provide access to System Reset Controller
+     allOf:
+       - $ref: "/schemas/types.yaml#/definitions/phandle"
+
+  memory-region:
+    description:
+      List of phandles to the reserved memory regions.
+      (see ../reserved-memory/reserved-memory.txt)
+
+required:
+  - compatible
+  - clocks
+  - syscon
+
+examples:
+  - |
+    #include <dt-bindings/clock/imx7d-clock.h>
+    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>;
+    };
+
+...
-- 
2.16.4


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

* [PATCH 2/9] dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP]
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
  2020-02-19  7:27 ` [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19  7:27 ` [PATCH 3/9] remoteproc: add support to skip firmware load when recovery peng.fan
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 .../devicetree/bindings/remoteproc/imx-rproc.yaml  | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml b/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
index 12a5f3de38fb..be708130d5c0 100644
--- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/imx-rproc.yaml
@@ -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
-- 
2.16.4


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

* [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
  2020-02-19  7:27 ` [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema peng.fan
  2020-02-19  7:27 ` [PATCH 2/9] dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP] peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19 14:39   ` Arnaud POULIQUEN
  2020-02-21 18:42   ` Mathieu Poirier
  2020-02-19  7:27 ` [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor peng.fan
                   ` (7 subsequent siblings)
  10 siblings, 2 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
 include/linux/remoteproc.h           |  1 +
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 876b5420a32b..ca310e3582bf 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -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);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 4fd5bedab4fa..fe6ee253b385 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -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


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

* [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (2 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 3/9] remoteproc: add support to skip firmware load when recovery peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-21 21:16   ` Mathieu Poirier
  2020-02-19  7:27 ` [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property peng.fan
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 240 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 220 insertions(+), 20 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 3e72b6f38d4b..b9fabe269fd2 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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);
 
-- 
2.16.4


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

* [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (3 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-21 21:56   ` Mathieu Poirier
  2020-02-19  7:27 ` [PATCH 6/9] remoteproc: imx_proc: enable virtio/mailbox peng.fan
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index b9fabe269fd2..e31ea1090cf3 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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,
-- 
2.16.4


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

* [PATCH 6/9] remoteproc: imx_proc: enable virtio/mailbox
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (4 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19  7:27 ` [PATCH 7/9] remoteproc: imx_rproc: add i.MX8QM/QXP peng.fan
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 106 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 102 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index e31ea1090cf3..36dec1ce4f50 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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);
 
-- 
2.16.4


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

* [PATCH 7/9] remoteproc: imx_rproc: add i.MX8QM/QXP
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (5 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 6/9] remoteproc: imx_proc: enable virtio/mailbox peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19  7:27 ` [PATCH 8/9] remoteproc: imx_rproc: support i.MX7ULP peng.fan
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 84 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 36dec1ce4f50..003f9e5c2b0c 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -1,10 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
+ * Copyright 2020 NXP, Peng Fan <peng.fan@nxp.com>
  */
 
 #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);
-- 
2.16.4


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

* [PATCH 8/9] remoteproc: imx_rproc: support i.MX7ULP
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (6 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 7/9] remoteproc: imx_rproc: add i.MX8QM/QXP peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19  7:27 ` [PATCH 9/9] remoteproc: imx_rproc: add i.MX8MM support peng.fan
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 003f9e5c2b0c..fc2a504bc350 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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 },
-- 
2.16.4


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

* [PATCH 9/9] remoteproc: imx_rproc: add i.MX8MM support
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (7 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 8/9] remoteproc: imx_rproc: support i.MX7ULP peng.fan
@ 2020-02-19  7:27 ` peng.fan
  2020-02-19 18:24 ` [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP Mathieu Poirier
  2020-02-21  6:51 ` Oleksij Rempel
  10 siblings, 0 replies; 30+ messages in thread
From: peng.fan @ 2020-02-19  7:27 UTC (permalink / raw)
  To: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index fc2a504bc350..d00c3cbcd87c 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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);
-- 
2.16.4


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

* Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema
  2020-02-19  7:27 ` [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema peng.fan
@ 2020-02-19 14:09   ` Rob Herring
  2020-02-19 14:34     ` Peng Fan
  0 siblings, 1 reply; 30+ messages in thread
From: Rob Herring @ 2020-02-19 14:09 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel, Peng Fan

On Wed, 19 Feb 2020 15:27:37 +0800, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Convert the i.MX remoteproc binding to DT schema format
> using json-schema
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  .../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.

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

* RE: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema
  2020-02-19 14:09   ` Rob Herring
@ 2020-02-19 14:34     ` Peng Fan
  2020-02-20  0:37       ` Rob Herring
  0 siblings, 1 reply; 30+ messages in thread
From: Peng Fan @ 2020-02-19 14:34 UTC (permalink / raw)
  To: Rob Herring
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, dl-linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

Hi Rob,

> Subject: Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to
> json-schema
> 
> On Wed, 19 Feb 2020 15:27:37 +0800, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Convert the i.MX remoteproc binding to DT schema format using
> > json-schema
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  .../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:

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

> 
> 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'
> 
> 
> 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.

> 
> 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.

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

* Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-19  7:27 ` [PATCH 3/9] remoteproc: add support to skip firmware load when recovery peng.fan
@ 2020-02-19 14:39   ` Arnaud POULIQUEN
  2020-02-19 15:40     ` Peng Fan
  2020-02-21 18:42   ` Mathieu Poirier
  1 sibling, 1 reply; 30+ messages in thread
From: Arnaud POULIQUEN @ 2020-02-19 14:39 UTC (permalink / raw)
  To: peng.fan, ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer,
	kernel, festevam
  Cc: linux-imx, linux-remoteproc, devicetree, linux-arm-kernel, linux-kernel

Hi,

On 2/19/20 8:27 AM, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
>  include/linux/remoteproc.h           |  1 +
>  2 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 876b5420a32b..ca310e3582bf 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -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;
> +		}

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

>  	}
>  
>  	/* 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);
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 4fd5bedab4fa..fe6ee253b385 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -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;
>  };
> 

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

* RE: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-19 14:39   ` Arnaud POULIQUEN
@ 2020-02-19 15:40     ` Peng Fan
  2020-02-20  8:49       ` Arnaud POULIQUEN
  0 siblings, 1 reply; 30+ messages in thread
From: Peng Fan @ 2020-02-19 15:40 UTC (permalink / raw)
  To: Arnaud POULIQUEN, ohad, bjorn.andersson, robh+dt, shawnguo,
	s.hauer, kernel, festevam
  Cc: dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel


> Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when
> recovery
> 
> Hi,
> 
> On 2/19/20 8:27 AM, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
> >  include/linux/remoteproc.h           |  1 +
> >  2 files changed, 12 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/remoteproc/remoteproc_core.c
> > b/drivers/remoteproc/remoteproc_core.c
> > index 876b5420a32b..ca310e3582bf 100644
> > --- a/drivers/remoteproc/remoteproc_core.c
> > +++ b/drivers/remoteproc/remoteproc_core.c
> > @@ -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;
> > +		}
> 
> 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. 

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



> 
> Regards
> Arnaud
> 
> >  	}
> >
> >  	/* 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);
> > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> > index 4fd5bedab4fa..fe6ee253b385 100644
> > --- a/include/linux/remoteproc.h
> > +++ b/include/linux/remoteproc.h
> > @@ -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;
> >  };
> >

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

* Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (8 preceding siblings ...)
  2020-02-19  7:27 ` [PATCH 9/9] remoteproc: imx_rproc: add i.MX8MM support peng.fan
@ 2020-02-19 18:24 ` Mathieu Poirier
  2020-02-20  1:36   ` Peng Fan
  2020-02-21  6:51 ` Oleksij Rempel
  10 siblings, 1 reply; 30+ messages in thread
From: Mathieu Poirier @ 2020-02-19 18:24 UTC (permalink / raw)
  To: peng.fan
  Cc: Ohad Ben-Cohen, Bjorn Andersson, Rob Herring, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-remoteproc, devicetree, linux-arm-kernel,
	Linux Kernel Mailing List

Hi Peng,

On Wed, 19 Feb 2020 at 00:33, <peng.fan@nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> 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.

>
> 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

>
> 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
>
> --
> 2.16.4
>

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

* Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema
  2020-02-19 14:34     ` Peng Fan
@ 2020-02-20  0:37       ` Rob Herring
  0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2020-02-20  0:37 UTC (permalink / raw)
  To: Peng Fan
  Cc: ohad, bjorn.andersson, shawnguo, s.hauer, kernel, festevam,
	dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Feb 19, 2020 at 8:34 AM Peng Fan <peng.fan@nxp.com> wrote:
>
> Hi Rob,
>
> > Subject: Re: [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to
> > json-schema
> >
> > On Wed, 19 Feb 2020 15:27:37 +0800, peng.fan@nxp.com wrote:
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > Convert the i.MX remoteproc binding to DT schema format using
> > > json-schema
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > >  .../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:
>
> 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

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

Rob

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

* RE: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-19 18:24 ` [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP Mathieu Poirier
@ 2020-02-20  1:36   ` Peng Fan
  2020-02-20 21:25     ` Mathieu Poirier
  0 siblings, 1 reply; 30+ messages in thread
From: Peng Fan @ 2020-02-20  1:36 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Ohad Ben-Cohen, Bjorn Andersson, Rob Herring, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	Linux Kernel Mailing List

Hi Mathieu,

> Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
> 
> Hi Peng,
> 
> On Wed, 19 Feb 2020 at 00:33, <peng.fan@nxp.com> wrote:
> >
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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.

> 
> >
> > This patchset is tested with Loic PALLARDY's patch
> > "remoteproc: add support for co-processor loaded and booted before
> kernel"
> > 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
> >
> xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9
> 2cd99c5c
> >
> 301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba
> YT%2BDZDk0
> > 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
> 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.

> 
> Thanks,
> Mathieu
> 
> >
> > 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
> >
> > --
> > 2.16.4
> >

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

* Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-19 15:40     ` Peng Fan
@ 2020-02-20  8:49       ` Arnaud POULIQUEN
  0 siblings, 0 replies; 30+ messages in thread
From: Arnaud POULIQUEN @ 2020-02-20  8:49 UTC (permalink / raw)
  To: Peng Fan, ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer,
	kernel, festevam
  Cc: dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	linux-kernel



On 2/19/20 4:40 PM, Peng Fan wrote:
> 
>> Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when
>> recovery
>>
>> Hi,
>>
>> On 2/19/20 8:27 AM, peng.fan@nxp.com wrote:
>>> From: Peng Fan <peng.fan@nxp.com>
>>>
>>> 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.
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>> ---
>>>  drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
>>>  include/linux/remoteproc.h           |  1 +
>>>  2 files changed, 12 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/remoteproc/remoteproc_core.c
>>> b/drivers/remoteproc/remoteproc_core.c
>>> index 876b5420a32b..ca310e3582bf 100644
>>> --- a/drivers/remoteproc/remoteproc_core.c
>>> +++ b/drivers/remoteproc/remoteproc_core.c
>>> @@ -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;
>>> +		}
>>
>> 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.

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

 
> 
> Regards,
> Peng. 
> 
>> FYI i'm reworking the Loic's patch and i plan to implement the recovery part
>> using skip_fw_load...
> 
> 
> 
>>
>> Regards
>> Arnaud
>>
>>>  	}
>>>
>>>  	/* 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);
>>> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
>>> index 4fd5bedab4fa..fe6ee253b385 100644
>>> --- a/include/linux/remoteproc.h
>>> +++ b/include/linux/remoteproc.h
>>> @@ -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;
>>>  };
>>>

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

* Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-20  1:36   ` Peng Fan
@ 2020-02-20 21:25     ` Mathieu Poirier
  2020-02-21  1:35       ` Peng Fan
  0 siblings, 1 reply; 30+ messages in thread
From: Mathieu Poirier @ 2020-02-20 21:25 UTC (permalink / raw)
  To: Peng Fan
  Cc: Ohad Ben-Cohen, Bjorn Andersson, Rob Herring, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	Linux Kernel Mailing List

On Wed, 19 Feb 2020 at 18:36, Peng Fan <peng.fan@nxp.com> wrote:
>
> Hi Mathieu,
>
> > Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
> >
> > Hi Peng,
> >
> > On Wed, 19 Feb 2020 at 00:33, <peng.fan@nxp.com> wrote:
> > >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > 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.
>
> >
> > >
> > > This patchset is tested with Loic PALLARDY's patch
> > > "remoteproc: add support for co-processor loaded and booted before
> > kernel"
> > > 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
> > >
> > xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9
> > 2cd99c5c
> > >
> > 301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba
> > YT%2BDZDk0
> > > 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.

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

>
>  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.
>
> 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.
>
> >
> > Thanks,
> > Mathieu
> >
> > >
> > > 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
> > >
> > > --
> > > 2.16.4
> > >

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

* RE: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-20 21:25     ` Mathieu Poirier
@ 2020-02-21  1:35       ` Peng Fan
  0 siblings, 0 replies; 30+ messages in thread
From: Peng Fan @ 2020-02-21  1:35 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Ohad Ben-Cohen, Bjorn Andersson, Rob Herring, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	dl-linux-imx, linux-remoteproc, devicetree, linux-arm-kernel,
	Linux Kernel Mailing List

> Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
> 
> On Wed, 19 Feb 2020 at 18:36, Peng Fan <peng.fan@nxp.com> wrote:
> >
> > Hi Mathieu,
> >
> > > Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support
> > > i.MX8/8M/7ULP
> > >
> > > Hi Peng,
> > >
> > > On Wed, 19 Feb 2020 at 00:33, <peng.fan@nxp.com> wrote:
> > > >
> > > > From: Peng Fan <peng.fan@nxp.com>
> > > >
> > > > 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.
> >
> > >
> > > >
> > > > This patchset is tested with Loic PALLARDY's patch
> > > > "remoteproc: add support for co-processor loaded and booted before
> > > kernel"
> > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2F
> > > > patc
> > > >
> > >
> hwork.kernel.org%2Fpatch%2F11265869%2F&amp;data=02%7C01%7Cpeng.f
> > > an%40n
> > > >
> > >
> xp.com%7Ce1cb19e535a14b63d0da08d7b568fd56%7C686ea1d3bc2b4c6fa9
> > > 2cd99c5c
> > > >
> > >
> 301635%7C0%7C0%7C637177334839497832&amp;sdata=aKQ%2Bulco63ba
> > > YT%2BDZDk0
> > > > 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.
> 
> 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
> conversation with Arnaud with it in mind.  I also invite you to join that
> conversation.

Appreciate.

Thanks,
Peng.

> 
> Regards,
> Mathieu
> 
> >
> >  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.
> >
> > 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.
> >
> > >
> > > Thanks,
> > > Mathieu
> > >
> > > >
> > > > 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
> > > >
> > > > --
> > > > 2.16.4
> > > >

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

* Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
                   ` (9 preceding siblings ...)
  2020-02-19 18:24 ` [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP Mathieu Poirier
@ 2020-02-21  6:51 ` Oleksij Rempel
  2020-02-21  6:56   ` Peng Fan
  10 siblings, 1 reply; 30+ messages in thread
From: Oleksij Rempel @ 2020-02-21  6:51 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, devicetree, linux-remoteproc, linux-kernel, linux-imx,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 4187 bytes --]

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.

On Wed, Feb 19, 2020 at 03:27:36PM +0800, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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
> 
> -- 
> 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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* RE: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-21  6:51 ` Oleksij Rempel
@ 2020-02-21  6:56   ` Peng Fan
  2020-02-21  7:03     ` Uwe Kleine-König
  0 siblings, 1 reply; 30+ messages in thread
From: Peng Fan @ 2020-02-21  6:56 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, devicetree, linux-remoteproc, linux-kernel,
	dl-linux-imx, linux-arm-kernel

Hi Oleksij,

> 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.

> 
> 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.

> 
> On Wed, Feb 19, 2020 at 03:27:36PM +0800, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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
> >
> > --
> > 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 |

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

* Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-21  6:56   ` Peng Fan
@ 2020-02-21  7:03     ` Uwe Kleine-König
  2020-02-21  7:08       ` Peng Fan
  0 siblings, 1 reply; 30+ messages in thread
From: Uwe Kleine-König @ 2020-02-21  7:03 UTC (permalink / raw)
  To: Peng Fan
  Cc: Oleksij Rempel, ohad, devicetree, festevam, s.hauer,
	linux-remoteproc, linux-kernel, bjorn.andersson, robh+dt,
	dl-linux-imx, kernel, shawnguo, linux-arm-kernel

Hello,

On Fri, Feb 21, 2020 at 06:56:02AM +0000, Peng Fan wrote:
> > 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

* RE: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
  2020-02-21  7:03     ` Uwe Kleine-König
@ 2020-02-21  7:08       ` Peng Fan
  0 siblings, 0 replies; 30+ messages in thread
From: Peng Fan @ 2020-02-21  7:08 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Oleksij Rempel, ohad, devicetree, festevam, s.hauer,
	linux-remoteproc, linux-kernel, bjorn.andersson, robh+dt,
	dl-linux-imx, kernel, shawnguo, linux-arm-kernel

> Subject: Re: [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP
> 
> Hello,
> 
> On Fri, Feb 21, 2020 at 06:56:02AM +0000, Peng Fan wrote:
> > > 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

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

Thanks,
Peng.

> 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 |

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

* Re: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-19  7:27 ` [PATCH 3/9] remoteproc: add support to skip firmware load when recovery peng.fan
  2020-02-19 14:39   ` Arnaud POULIQUEN
@ 2020-02-21 18:42   ` Mathieu Poirier
  2020-02-23  0:01     ` Peng Fan
  1 sibling, 1 reply; 30+ messages in thread
From: Mathieu Poirier @ 2020-02-21 18:42 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

Hi Peng,

On Wed, Feb 19, 2020 at 03:27:39PM +0800, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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

> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
>  include/linux/remoteproc.h           |  1 +
>  2 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 876b5420a32b..ca310e3582bf 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -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);
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 4fd5bedab4fa..fe6ee253b385 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -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
> 

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

* Re: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor
  2020-02-19  7:27 ` [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor peng.fan
@ 2020-02-21 21:16   ` Mathieu Poirier
  2020-02-23  0:05     ` Peng Fan
  0 siblings, 1 reply; 30+ messages in thread
From: Mathieu Poirier @ 2020-02-21 21:16 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

On Wed, Feb 19, 2020 at 03:27:40PM +0800, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 240 +++++++++++++++++++++++++++++++++++++----
>  1 file changed, 220 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 3e72b6f38d4b..b9fabe269fd2 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -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);

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?

> +
> +	/* 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);
>  
> -- 
> 2.16.4
> 

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

* Re: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property
  2020-02-19  7:27 ` [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property peng.fan
@ 2020-02-21 21:56   ` Mathieu Poirier
  2020-02-23  0:11     ` Peng Fan
  0 siblings, 1 reply; 30+ messages in thread
From: Mathieu Poirier @ 2020-02-21 21:56 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

On Wed, Feb 19, 2020 at 03:27:41PM +0800, peng.fan@nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> If early-property exists, there is no need to check syscon.
> Just mark early_boot as true.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index b9fabe269fd2..e31ea1090cf3 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -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. 

> +		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
> 

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

* RE: [PATCH 3/9] remoteproc: add support to skip firmware load when recovery
  2020-02-21 18:42   ` Mathieu Poirier
@ 2020-02-23  0:01     ` Peng Fan
  0 siblings, 0 replies; 30+ messages in thread
From: Peng Fan @ 2020-02-23  0:01 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, dl-linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

Hi Mathieu,

> Subject: Re: [PATCH 3/9] remoteproc: add support to skip firmware load when
> recovery
> 
> Hi Peng,
> 
> On Wed, Feb 19, 2020 at 03:27:39PM +0800, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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?

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

Regards,
Peng.

> 
> Thanks,
> Mathieu
> 
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/remoteproc/remoteproc_core.c | 19 +++++++++++--------
> >  include/linux/remoteproc.h           |  1 +
> >  2 files changed, 12 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/remoteproc/remoteproc_core.c
> > b/drivers/remoteproc/remoteproc_core.c
> > index 876b5420a32b..ca310e3582bf 100644
> > --- a/drivers/remoteproc/remoteproc_core.c
> > +++ b/drivers/remoteproc/remoteproc_core.c
> > @@ -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);
> > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> > index 4fd5bedab4fa..fe6ee253b385 100644
> > --- a/include/linux/remoteproc.h
> > +++ b/include/linux/remoteproc.h
> > @@ -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
> >

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

* RE: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor
  2020-02-21 21:16   ` Mathieu Poirier
@ 2020-02-23  0:05     ` Peng Fan
  0 siblings, 0 replies; 30+ messages in thread
From: Peng Fan @ 2020-02-23  0:05 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, dl-linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

> Subject: Re: [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote
> processor
> 
> On Wed, Feb 19, 2020 at 03:27:40PM +0800, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/remoteproc/imx_rproc.c | 240
> > +++++++++++++++++++++++++++++++++++++----
> >  1 file changed, 220 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index 3e72b6f38d4b..b9fabe269fd2
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -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);
> 
> 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.

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

> 
> 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.

> 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.

> 
> > +
> > +	/* 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);
> >
> > --
> > 2.16.4
> >

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

* RE: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property
  2020-02-21 21:56   ` Mathieu Poirier
@ 2020-02-23  0:11     ` Peng Fan
  0 siblings, 0 replies; 30+ messages in thread
From: Peng Fan @ 2020-02-23  0:11 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, bjorn.andersson, robh+dt, shawnguo, s.hauer, kernel,
	festevam, dl-linux-imx, linux-remoteproc, devicetree,
	linux-arm-kernel, linux-kernel

> Subject: Re: [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property
> 
> On Wed, Feb 19, 2020 at 03:27:41PM +0800, peng.fan@nxp.com wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > If early-property exists, there is no need to check syscon.
> > Just mark early_boot as true.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
> >  1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index b9fabe269fd2..e31ea1090cf3
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -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.

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.
> 
> > +		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
> >

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

end of thread, other threads:[~2020-02-23  0:11 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  7:27 [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP peng.fan
2020-02-19  7:27 ` [PATCH 1/9] dt-bindings: remoteproc: Convert imx-rproc to json-schema peng.fan
2020-02-19 14:09   ` Rob Herring
2020-02-19 14:34     ` Peng Fan
2020-02-20  0:37       ` Rob Herring
2020-02-19  7:27 ` [PATCH 2/9] dt-bindings: remoteproc: imx-rproc: support i.MX[8,8M,7ULP] peng.fan
2020-02-19  7:27 ` [PATCH 3/9] remoteproc: add support to skip firmware load when recovery peng.fan
2020-02-19 14:39   ` Arnaud POULIQUEN
2020-02-19 15:40     ` Peng Fan
2020-02-20  8:49       ` Arnaud POULIQUEN
2020-02-21 18:42   ` Mathieu Poirier
2020-02-23  0:01     ` Peng Fan
2020-02-19  7:27 ` [PATCH 4/9] remoteproc: imx_rproc: surport early booted remote processor peng.fan
2020-02-21 21:16   ` Mathieu Poirier
2020-02-23  0:05     ` Peng Fan
2020-02-19  7:27 ` [PATCH 5/9] remoteproc: imx_rproc: parse early-booted property peng.fan
2020-02-21 21:56   ` Mathieu Poirier
2020-02-23  0:11     ` Peng Fan
2020-02-19  7:27 ` [PATCH 6/9] remoteproc: imx_proc: enable virtio/mailbox peng.fan
2020-02-19  7:27 ` [PATCH 7/9] remoteproc: imx_rproc: add i.MX8QM/QXP peng.fan
2020-02-19  7:27 ` [PATCH 8/9] remoteproc: imx_rproc: support i.MX7ULP peng.fan
2020-02-19  7:27 ` [PATCH 9/9] remoteproc: imx_rproc: add i.MX8MM support peng.fan
2020-02-19 18:24 ` [PATCH 0/9] remoteproc: imx_rproc: support i.MX8/8M/7ULP Mathieu Poirier
2020-02-20  1:36   ` Peng Fan
2020-02-20 21:25     ` Mathieu Poirier
2020-02-21  1:35       ` Peng Fan
2020-02-21  6:51 ` Oleksij Rempel
2020-02-21  6:56   ` Peng Fan
2020-02-21  7:03     ` Uwe Kleine-König
2020-02-21  7:08       ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).