remoteproc: imx_rproc: use imx specific hook for find_loaded_rsc_table
PATCH v2 1/1 remoteproc: imx_rproc: use imx specific hook for find_loaded_rsc_table
From: Peng Fan <[email protected]>
If there is a resource table device tree node, use the address as the resource table address, otherwise use the address(where .resource_table section loaded) inside the Cortex-M elf file.
And there is an update in NXP SDK that Resource Domain Control(RDC) enabled to protect TCM, linux not able to write the TCM space when updating resource table status and cause kernel dump. So use the address from device tree could avoid kernel dump.
Note: NXP M4 SDK not check resource table update, so it does not matter use whether resource table address specified in elf file or in device tree. But to reflect the fact that if people specific resource table address in device tree, it means people are aware and going to use it, not the address specified in elf file.
---
V2:
Update commit message
drivers/remoteproc/imx_rproc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/remoteproc/imx_rproc.c +12 -1
@@ -499,6 +499,17 @@ static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc *rprocreturn (struct resource_table *)priv->rsc_table; } +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->rsc_table) +return (struct resource_table *)priv->rsc_table; + +return rproc_elf_find_loaded_rsc_table (rproc, fw); +} +static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach,
@@ -508,7 +519,7 @@ static const struct rproc_ops imx_rproc_ops = { .da_to_va = imx_rproc_da_to_va, .load = rproc_elf_load_segments, .parse_fw = imx_rproc_parse_fw, - .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table, .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr,
Signature · 1 line
2.25.1
PATCH 1/1 remoteproc: imx_rproc: validate resource table
From: Peng Fan <[email protected]>
Currently NXP use one device tree to support all NXP released Cortex-M demos. There is one simple demo that not need to communicate with Linux, thus it will not update the resource table. So there maybe garbage data in it. In such case, Linux should directly ignore it.
It is hard to decide what data is garbage data, NXP released SDK use ver(1), reserved(0) in a valid resource table. But in case others use different value, so here use 0xff as a max value for ver and num.
--- drivers/remoteproc/imx_rproc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/remoteproc/imx_rproc.c +8 -0
@@ -490,11 +490,19 @@ static int imx_rproc_attach(struct rproc *rproc)static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) {struct imx_rproc *priv = rproc->priv; +struct resource_table *table;/* The resource table has already been mapped in imx_rproc_addr_init */ if (!priv->rsc_table)return NULL ; + table = priv->rsc_table; +/* Gabage data check */ +if (table->ver >=0xff || table->num >=0xff || table->reserved[0 ] || table->reserved[1 ]) { +dev_err (priv->dev,"Ignore invalid rsc table\n" ); +return NULL ; + } + *table_sz =SZ_1K ;return (struct resource_table *)priv->rsc_table; }
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH] remoteproc: imx_rproc: validate resource table
Good morning,
Quoted 27 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Currently NXP use one device tree to support all NXP released Cortex-M demos. There is one simple demo that not need to communicate with Linux, thus it will not update the resource table. So there maybe garbage data in it. In such case, Linux should directly ignore it.
It is hard to decide what data is garbage data, NXP released SDK use ver(1), reserved(0) in a valid resource table. But in case others use different value, so here use
0xffas a max value for ver and num.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/remoteproc/imx_rproc.c +1
-0@@ -490,11 +490,19 @@ static int imx_rproc_attach(struct rproc *rproc)static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) {struct imx_rproc *priv = rproc->priv; +struct resource_table *table;/* The resource table has already been mapped in imx_rproc_addr_init */
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc) · line 505
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +7
-0if (!priv->rsc_table)return NULL ; + table = priv->rsc_table; +/* Gabage data check */ +if (table->ver >=0xff || table->num >=0xff || table->reserved[0 ] || table->reserved[1 ]) { +dev_err (priv->dev,"Ignore invalid rsc table\n" ); +return NULL ; + } +
This seems like the wrong fix to me. Either use different DTs or update the resource table for all demos - efficiency should not be a problem since they are demos. With the above it is only a matter of time before the pattern associated with valid resource tables changes, leading to more hacks that will be impossible to maintain over time.
Thanks,
Mathieu
Quoted 6 lines
drivers/remoteproc/imx_rproc.c +0
-0*table_sz =SZ_1K ;return (struct resource_table *)priv->rsc_table; }Signature · 1 line
2.25.1
RE: [PATCH] remoteproc: imx_rproc: validate resource table
Quoted 41 lines
Subject: Re: [PATCH] remoteproc:
imx_rproc: validate resource tableGood morning,
Quoted 24 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Currently NXP use one device tree to support all NXP released Cortex-M demos. There is one simple demo that not need to communicate with Linux, thus it will not update the resource table. So there maybe garbage data in it. In such case, Linux should directly ignore it.
It is hard to decide what data is garbage data, NXP released SDK use ver(1), reserved(0) in a valid resource table. But in case others use different value, so here use
0xffas a max value for ver and num.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 8 ++++++++ 1 file changed, 8 insertions(+)(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex0bd24c937a73..75fde16f80a4100644drivers/remoteproc/imx_rproc.c +0
-0@@ -490,11 +490,19 @@ static int imx_rproc_attach(struct rproc *rproc)static struct
resource_table*imx_rproc_get_loaded_rsc_table(struct rproc *rproc,size_t*table_sz) {drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc)
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +1
-0struct imx_rproc *priv = rproc->priv; +struct resource_table *table;/* The resource table has already been mapped in imx_rproc_addr_init */
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc)
Quoted 6 lines
drivers/remoteproc/imx_rproc.c +3
-0if (!priv->rsc_table)return NULL ; + table = priv->rsc_table; +/* Gabage data check */ + if (table->ver >= 0xff || table->num >= 0xff || table->reserved[0] ||table->reserved[1]) {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc) · line 505
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +4
-0+dev_err (priv->dev,"Ignore invalid rsc table\n" ); +return NULL ; + } +This seems like the wrong fix to me. Either use different DTs or update the resource table for all demos - efficiency should not be a problem since they are demos. With the above it is only a matter of time before the pattern associated with valid resource tables changes, leading to more hacks that will be impossible to maintain over time.
I see, drop this patch :)
Thanks,
Peng.
Quoted 9 lines
Thanks,
MathieuQuoted 5 lines
drivers/remoteproc/imx_rproc.c +0
-1*table_sz =SZ_1K ;return (struct resource_table *)priv->rsc_table; } --2.25.1
cover remoteproc: imx_rproc: support i.MX8QXP/QM and self recovery
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
This patchset is to add i.MX8QM/QXP support.
i.MX8QM/QXP general purpose M4 core has self recovery capability if M4 is configured not in the same hardware partition. patch 3 is to support self recovery case, when doing self recovery, only do detach and attach, not using stop/start.
This patchset depends on: https://lkml.org/lkml/2022/1/10/1577
Peng Fan (9):
dt-bindings: remoteproc: imx_rproc: support i.MX8QXP
dt-bindings: remoteproc: imx_rproc: support i.MX8QM
remoteproc: support self recovery after rproc crash
remoteproc: imx_rproc: ignore create mem entry for resource table
remoteproc: imx_rproc: make clk optional
remoteproc: imx_rproc: support attaching to i.MX8QXP M4
remoteproc: imx_rproc: support kicking Mcore from Linux for i.MX8QXP
remoteproc: imx_rproc: support i.MX8QM
remoteproc: imx_rproc: request mbox channel later
.../bindings/remoteproc/fsl,imx-rproc.yaml | 14 + drivers/remoteproc/imx_rproc.c | 245 +++++++++++++++++- drivers/remoteproc/remoteproc_core.c | 66 +++-- include/linux/remoteproc.h | 2 + 4 files changed, 296 insertions(+), 31 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/9 dt-bindings: remoteproc: imx_rproc: support i.MX8QXP
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Add i.MX8QXP compatible
Add a new property rsrc-id for SoC which supports SCFW. This rsrc-id is used to check whether remote process is under control of Linux or not.
To i.MX8QM/QXP, when M4 is in the same hardware partition with Cortex-A cores, need power up M4 through SCFW, then M4 could start. So introduce power-domains property
--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +10 -0
@@ -19,6 +19,7 @@ properties: - fsl,imx8mm-cm4 - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 + - fsl,imx8qxp-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4
@@ -59,6 +60,15 @@ properties: Indicate whether need to load the default firmware and start the remote processor automatically. + power-domains: + maxItems: 8 + + rsrc-id: + description: + This property is to specify the resource id of the remote processor in SoC + which supports SCFW + maxItems: 1 + required: - compatible
Signature · 1 line
2.25.1
RE: [PATCH 1/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QXP
Quoted 1 line
Subject: [PATCH 1/9] dt-bindings: remoteproc:
imx_rproc: support i.MX8QXP
+Rob
Quoted 51 lines
From: Peng Fan <[email protected]>
Add i.MX8QXP compatible
Add a new property rsrc-id for SoC which supports SCFW. This rsrc-id is used to check whether remote process is under control of Linux or not.
To i.MX8QM/QXP, when M4 is in the same hardware partition with Cortex-A cores, need power up M4 through SCFW, then M4 could start. So introduce power-domains property
Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git
a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlb/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlindexfc16d903353e..ed1bcb3046a9100644Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +1
-0@@ -19,6 +19,7 @@ properties: - fsl,imx8mm-cm4 - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 + - fsl,imx8qxp-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4@@ -59,6 +60,15 @@ properties: Indicate whether need to load the default firmware and start theremote
processor automatically.Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +6
-0+ power-domains: + maxItems: 8 + + rsrc-id: + description: + This property is to specify the resource id of the remote processor inSoC
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +3
-1+ which supports SCFW + maxItems: 1 + required: - compatible --2.25.1
Mathieu Poirier
maintainerRe: [PATCH 1/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QXP
In reply to Peng Fan (OSS)Quoted 5 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Add i.MX8QXP compatible
Add a new property rsrc-id for SoC which supports SCFW. This rsrc-id
You are introducing an acronym that doesn't have a definition - I have to grep the kernel tree to have an idea of what SCFW is. That consumes time that I don't have to review your code or someone else's.
Quoted 1 line
is used to check whether remote process is under control of Linux or
s/process/processor
Quoted 42 lines
not.
To i.MX8QM/QXP, when M4 is in the same hardware partition with Cortex-A cores, need power up M4 through SCFW, then M4 could start. So introduce power-domains property
Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +10
-0@@ -19,6 +19,7 @@ properties: - fsl,imx8mm-cm4 - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 + - fsl,imx8qxp-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4@@ -59,6 +60,15 @@ properties: Indicate whether need to load the default firmware and start the remote processor automatically. + power-domains: + maxItems: 8 + + rsrc-id: + description: + This property is to specify the resource id of the remote processor in SoC + which supports SCFW + maxItems: 1 + required: - compatibleSignature · 1 line
2.25.1
RE: [PATCH 1/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QXP
Quoted 6 lines
Subject: Re: [PATCH 1/9] dt-bindings: remoteproc:
imx_rproc: support i.MX8QXPQuoted 2 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Quoted 7 lines
Quoted 3 lines
Add i.MX8QXP compatible
Add a new property rsrc-id for SoC which supports SCFW. This rsrc-id
You are introducing an acronym that doesn't have a definition - I have to grep the kernel tree to have an idea of what SCFW is. That consumes time that I don't have to review your code or someone else's.
Sorry. SCFW(System controller Unit Firmware).
Quoted 4 lines
Quoted 2 lines
is used to check whether remote process is under control of Linux or
s/process/processor
Fix in v2.
Thanks,
Peng.
Quoted 48 lines
Quoted 28 lines
not.
To i.MX8QM/QXP, when M4 is in the same hardware partition with Cortex-A cores, need power up M4 through SCFW, then M4 could start. So introduce power-domains property
Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git
a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlb/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlindexfc16d903353e..ed1bcb3046a9100644Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +1
-0@@ -19,6 +19,7 @@ properties: - fsl,imx8mm-cm4 - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 + - fsl,imx8qxp-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties: · line 60
Quoted 1 line
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +0
-0@@ -59,6 +60,15 @@ properties: Indicate whether need to load the default firmware and start theremote
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml properties:
Quoted 8 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +6
-0processor automatically. + power-domains: + maxItems: 8 + + rsrc-id: + description: + This property is to specify the resource id of the remote processorin SoC
Quoted 9 lines
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +3
-1+ which supports SCFW + maxItems: 1 + required: - compatible --2.25.1
PATCH 2/9 dt-bindings: remoteproc: imx_rproc: support i.MX8QM
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Add i.MX8QM compatible
There are two general purpose M4, so add reg property to indicate the id.
--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4 -0
@@ -20,6 +20,7 @@ properties: - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 - fsl,imx8qxp-cm4 + - fsl,imx8qm-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4
@@ -63,6 +64,9 @@ properties: power-domains: maxItems: 8 + reg: + maxItems: 1 + rsrc-id: description: This property is to specify the resource id of the remote processor in SoC
Signature · 1 line
2.25.1
RE: [PATCH 2/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QM
Quoted 1 line
Subject: [PATCH 2/9] dt-bindings: remoteproc:
imx_rproc: support i.MX8QM
+Rob
Quoted 39 lines
From: Peng Fan <[email protected]>
Add i.MX8QM compatible
There are two general purpose M4, so add reg property to indicate the id.
Signed-off-by Peng Fan <[email protected]>--- .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 4 ++++ 1 file changed, 4 insertions(+)diff --git
a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlb/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yamlindexed1bcb3046a9..cd9dcb63b176100644Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml +4
-0@@ -20,6 +20,7 @@ properties: - fsl,imx8mn-cm7 - fsl,imx8mp-cm7 - fsl,imx8qxp-cm4 + - fsl,imx8qm-cm4 - fsl,imx8ulp-cm33 - fsl,imx7d-cm4 - fsl,imx7ulp-cm4@@ -63,6 +64,9 @@ properties: power-domains: maxItems: 8 + reg: + maxItems: 1 + rsrc-id: description: This property is to specify the resource id of the remote processor inSoC
--
2.25.1
PATCH 3/9 remoteproc: support self recovery after rproc crash
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Current logic only support main processor to stop/start the remote processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the remote processor could do self recovery after crash and trigger watchdog reboot. It does not need main processor to load image, stop/start M4 core.
This patch add a new flag to indicate whether the SoC has self recovery capability. And introduce two functions: rproc_self_recovery, rproc_assisted_recovery for the two cases. Assisted recovery is as before, let main processor to help recovery, while self recovery is recover itself withou help. To self recovery, we only do detach and attach.
--- drivers/remoteproc/remoteproc_core.c | 66 ++++++++++++++++++++-------- include/linux/remoteproc.h | 2 + 2 files changed, 49 insertions(+), 19 deletions(-)
drivers/remoteproc/remoteproc_core.c +47 -19
@@ -1887,6 +1887,49 @@ static int __rproc_detach(struct rproc *rproc)return 0 ; } +static int rproc_self_recovery (struct rproc *rproc) +{ +int ret; + +mutex_unlock (&rproc->lock); + ret =rproc_detach (rproc); +mutex_lock (&rproc->lock); +if (ret) +return ret; + +if (atomic_inc_return (&rproc->power) >1 ) +return 0 ; +return rproc_attach (rproc); +} + +static int rproc_assisted_recovery (struct rproc *rproc) +{ +const struct firmware *firmware_p; +struct device *dev = &rproc->dev; +int ret; + + ret =rproc_stop (rproc, true); +if (ret) +return ret; + +/* generate coredump */ + rproc->ops->coredump (rproc); + +/* load firmware */ + ret =request_firmware (&firmware_p, rproc->firmware, dev); +if (ret <0 ) { +dev_err (dev,"request_firmware failed: %d\n" , ret); +return ret; + } + +/* boot the remote processor up again */ + ret =rproc_start (rproc, firmware_p); + +release_firmware (firmware_p); + +return ret; +} +/** * rproc_trigger_recovery() - recover a remoteproc * @rproc: the remote processor
@@ -1901,7 +1944,6 @@ static int __rproc_detach(struct rproc *rproc)*/ int rproc_trigger_recovery (struct rproc *rproc) { -const struct firmware *firmware_p;struct device *dev = &rproc->dev;int ret;
@@ -1915,24 +1957,10 @@ int rproc_trigger_recovery(struct rproc *rproc)dev_err (dev,"recovering %s\n" , rproc->name); - ret =rproc_stop (rproc, true); -if (ret) - goto unlock_mutex; - -/* generate coredump */ - rproc->ops->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; - } - -/* boot the remote processor up again */ - ret =rproc_start (rproc, firmware_p); - -release_firmware (firmware_p); +if (rproc->self_recovery) + ret =rproc_self_recovery (rproc); +else + ret =rproc_assisted_recovery (rproc); unlock_mutex:mutex_unlock (&rproc->lock);
include/linux/remoteproc.h +2 -0
@@ -529,6 +529,7 @@ struct rproc_dump_segment {* @elf_machine: firmware ELF machine * @cdev: character device of the rproc * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release +* @self_recovery: flag to indicate if remoteproc support self recovery */ struct rproc {struct list_head node;
@@ -568,6 +569,7 @@ struct rproc {u16 elf_machine;struct cdev cdev;bool cdev_put_on_release; +bool self_recovery; };/**
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 3/9] remoteproc: support self recovery after rproc crash
Quoted 99 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Current logic only support main processor to stop/start the remote processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the remote processor could do self recovery after crash and trigger watchdog reboot. It does not need main processor to load image, stop/start M4 core.
This patch add a new flag to indicate whether the SoC has self recovery capability. And introduce two functions:
rproc_self_recovery,rproc_assisted_recoveryfor the two cases. Assisted recovery is as before, let main processor to help recovery, while self recovery is recover itself withou help. To self recovery, we only do detach and attach.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 66 ++++++++++++++++++++-------- include/linux/remoteproc.h | 2 + 2 files changed, 49 insertions(+), 19 deletions(-)drivers/remoteproc/remoteproc_core.c +43
-13@@ -1887,6 +1887,49 @@ static int __rproc_detach(struct rproc *rproc)return 0 ; } +static int rproc_self_recovery (struct rproc *rproc) +{ +int ret; + +mutex_unlock (&rproc->lock); + ret =rproc_detach (rproc); +mutex_lock (&rproc->lock); +if (ret) +return ret; + +if (atomic_inc_return (&rproc->power) >1 ) +return 0 ; +return rproc_attach (rproc); +} + +static int rproc_assisted_recovery (struct rproc *rproc) +{ +const struct firmware *firmware_p; +struct device *dev = &rproc->dev; +int ret; + + ret =rproc_stop (rproc, true); +if (ret) +return ret; + +/* generate coredump */ + rproc->ops->coredump (rproc); + +/* load firmware */ + ret =request_firmware (&firmware_p, rproc->firmware, dev); +if (ret <0 ) { +dev_err (dev,"request_firmware failed: %d\n" , ret); +return ret; + } + +/* boot the remote processor up again */ + ret =rproc_start (rproc, firmware_p); + +release_firmware (firmware_p); + +return ret; +} +/** * rproc_trigger_recovery() - recover a remoteproc * @rproc: the remote processor @@ -1901,7 +1944,6 @@ static int __rproc_detach(struct rproc *rproc)*/ int rproc_trigger_recovery (struct rproc *rproc) { -const struct firmware *firmware_p;struct device *dev = &rproc->dev;int ret;@@ -1915,24 +1957,10 @@ int rproc_trigger_recovery(struct rproc *rproc)dev_err (dev,"recovering %s\n" , rproc->name); - ret =rproc_stop (rproc, true); -if (ret) - goto unlock_mutex; - -/* generate coredump */ - rproc->ops->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;
drivers/remoteproc/remoteproc_core.c int rproc_trigger_recovery(struct rproc *rproc) · line 1963
Quoted 10 lines
drivers/remoteproc/remoteproc_core.c +4
-6- } - -/* boot the remote processor up again */ - ret =rproc_start (rproc, firmware_p); - -release_firmware (firmware_p); +if (rproc->self_recovery) + ret =rproc_self_recovery (rproc); +else + ret =rproc_assisted_recovery (rproc);
The problem of how to handle crash recoveries for processors that have been attached to is difficult. Finding a solution for that should be on a patchset of its own so that people can provide input.
Quoted 26 lines
drivers/remoteproc/remoteproc_core.c +0
-0unlock_mutex:mutex_unlock (&rproc->lock);include/linux/remoteproc.h +2
-0@@ -529,6 +529,7 @@ struct rproc_dump_segment {* @elf_machine: firmware ELF machine * @cdev: character device of the rproc * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release +* @self_recovery: flag to indicate if remoteproc support self recovery */ struct rproc {struct list_head node;@@ -568,6 +569,7 @@ struct rproc {u16 elf_machine;struct cdev cdev;bool cdev_put_on_release; +bool self_recovery; };/** Signature · 1 line
2.25.1
RE: [PATCH 3/9] remoteproc: support self recovery after rproc crash
Quoted 108 lines
Subject: Re: [PATCH 3/9] remoteproc: support self recovery after rproc crash
Quoted 15 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Current logic only support main processor to stop/start the remote processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the remote processor could do self recovery after crash and trigger watchdog reboot. It does not need main processor to load image, stop/start M4 core.
This patch add a new flag to indicate whether the SoC has self recovery capability. And introduce two functions:
rproc_self_recovery,rproc_assisted_recoveryfor the two cases. Assisted recovery is as before, let main processor to help recovery, while self recovery is recover itself withou help. To self recovery, we only do detach and attach.Quoted 3 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 66++++++++++++++++++++--------
Quoted 86 lines
include/linux/remoteproc.h | 2 + 2 files changed, 49 insertions(+), 19 deletions(-)drivers/remoteproc/remoteproc_core.c +41
-19@@ -1887,6 +1887,49 @@ static int __rproc_detach(struct rproc *rproc)return 0 ; } +static int rproc_self_recovery (struct rproc *rproc) { +int ret; + +mutex_unlock (&rproc->lock); + ret =rproc_detach (rproc); +mutex_lock (&rproc->lock); +if (ret) +return ret; + +if (atomic_inc_return (&rproc->power) >1 ) +return 0 ; +return rproc_attach (rproc); +} + +static int rproc_assisted_recovery (struct rproc *rproc) { +const struct firmware *firmware_p; +struct device *dev = &rproc->dev; +int ret; + + ret =rproc_stop (rproc, true); +if (ret) +return ret; + +/* generate coredump */ + rproc->ops->coredump (rproc); + +/* load firmware */ + ret =request_firmware (&firmware_p, rproc->firmware, dev); +if (ret <0 ) { +dev_err (dev,"request_firmware failed: %d\n" , ret); +return ret; + } + +/* boot the remote processor up again */ + ret =rproc_start (rproc, firmware_p); + +release_firmware (firmware_p); + +return ret; +} +/** * rproc_trigger_recovery() - recover a remoteproc * @rproc: the remote processor @@ -1901,7 +1944,6 @@ static int __rproc_detach(struct rproc *rproc)*/ int rproc_trigger_recovery (struct rproc *rproc) { -const struct firmware *firmware_p;struct device *dev = &rproc->dev;int ret;@@ -1915,24 +1957,10 @@ int rproc_trigger_recovery(struct rproc *rproc)dev_err (dev,"recovering %s\n" , rproc->name); - ret =rproc_stop (rproc, true); -if (ret) - goto unlock_mutex; - -/* generate coredump */ - rproc->ops->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; - } - -/* boot the remote processor up again */ - ret =rproc_start (rproc, firmware_p); - -release_firmware (firmware_p);
Quoted 8 lines
drivers/remoteproc/remoteproc_core.c int rproc_trigger_recovery(struct rproc *rproc) · line 1963
Quoted 4 lines
drivers/remoteproc/remoteproc_core.c +4
-0+if (rproc->self_recovery) + ret =rproc_self_recovery (rproc); +else + ret =rproc_assisted_recovery (rproc);The problem of how to handle crash recoveries for processors that have been attached to is difficult. Finding a solution for that should be on a patchset of its own so that people can provide input.
ok, will move this patch out from the patchset.
Thanks,
Peng.
Quoted 29 lines
Quoted 29 lines
drivers/remoteproc/remoteproc_core.c +0
-0unlock_mutex:mutex_unlock (&rproc->lock);include/linux/remoteproc.h +0
-0@@ -529,6 +529,7 @@ struct rproc_dump_segment {* @elf_machine: firmware ELF machine * @cdev: character device of the rproc * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release
+ * @self_recovery: flag to indicate if remoteproc support self
+ recovery
*/
struct rproc {include/linux/remoteproc.h +1
-1struct list_head node;@@ -568,6 +569,7 @@ struct rproc {u16 elf_machine;struct cdev cdev;bool cdev_put_on_release; +bool self_recovery; };/** -- 2.25.1
PATCH 4/9 remoteproc: imx_rproc: ignore create mem entry for resource table
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
resource table will not be used for memory allocation, no need to create rproc mem entry.
--- drivers/remoteproc/imx_rproc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/imx_rproc.c +3 -0
@@ -423,6 +423,9 @@ static int imx_rproc_prepare(struct rproc *rproc)if (!strcmp (it.node->name,"vdev0buffer" ))continue ; +if (!strncmp (it.node->name,"rsc-table" ,strlen ("rsc-table" ))) +continue ; + rmem =of_reserved_mem_lookup (it.node);if (!rmem) {dev_err (priv->dev,"unable to acquire memory-region\n" );
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 4/9] remoteproc: imx_rproc: ignore create mem entry for resource table
Quoted 2 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
The "ignore" in the title should have a capital 'I'.
Quoted 1 line
resource table will not be used for memory allocation, no need to create
s/resource/Resource
Quoted 12 lines
rproc mem entry.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 3 +++ 1 file changed, 3 insertions(+)drivers/remoteproc/imx_rproc.c +0
-0
drivers/remoteproc/imx_rproc.c static int imx_rproc_prepare(struct rproc *rproc) · line 428
Quoted 6 lines
drivers/remoteproc/imx_rproc.c +3
-0@@ -423,6 +423,9 @@ static int imx_rproc_prepare(struct rproc *rproc)if (!strcmp (it.node->name,"vdev0buffer" ))continue ; +if (!strncmp (it.node->name,"rsc-table" ,strlen ("rsc-table" ))) +continue ; +
This is a bug fix that should be in a separate patch with a "Fixes:" tag.
Quoted 6 lines
drivers/remoteproc/imx_rproc.c +0
-0rmem =of_reserved_mem_lookup (it.node);if (!rmem) {dev_err (priv->dev,"unable to acquire memory-region\n" );Signature · 1 line
2.25.1
RE: [PATCH 4/9] remoteproc: imx_rproc: ignore create mem entry for resource table
Quoted 8 lines
Subject: Re: [PATCH 4/9] remoteproc:
imx_rproc: ignore create mem entry for resource tableQuoted 2 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
The "ignore" in the title should have a capital 'I'.
Fix in V2
Quoted 5 lines
Quoted 3 lines
resource table will not be used for memory allocation, no need to create
s/resource/Resource
Fix in V2.
Quoted 17 lines
Quoted 17 lines
rproc mem entry.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 3 +++ 1 file changed, 3 insertions(+)(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex75fde16f80a4..7b2578177ea8100644drivers/remoteproc/imx_rproc.c +0
-0@@ -423,6 +423,9 @@ static int imx_rproc_prepare(struct rproc *rproc)if (!strcmp (it.node->name,"vdev0buffer" ))continue ;
Quoted 5 lines
drivers/remoteproc/imx_rproc.c static int imx_rproc_prepare(struct rproc *rproc) · line 428
Quoted 3 lines
drivers/remoteproc/imx_rproc.c +3
-0+if (!strncmp (it.node->name,"rsc-table" ,strlen ("rsc-table" ))) +continue ; +This is a bug fix that should be in a separate patch with a "Fixes:" tag.
ok.
Thanks,
Peng.
Quoted 7 lines
Quoted 7 lines
drivers/remoteproc/imx_rproc.c +0
-1rmem =of_reserved_mem_lookup (it.node);if (!rmem) {dev_err (priv->dev,"unable to acquire memory-region\n" ); --2.25.1
PATCH 5/9 remoteproc: imx_rproc: make clk optional
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
To i.MX8QXP/QM/ULP and i.MX7ULP, Mcore maybe out of control of Linux. And in such case, no need clk, so make clk optional with has_clk.
--- drivers/remoteproc/imx_rproc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/remoteproc/imx_rproc.c +5 -0
@@ -89,6 +89,7 @@ struct imx_rproc {struct work_struct rproc_work;struct workqueue_struct *workqueue;void __iomem *rsc_table; +bool has_clk; };static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {
@@ -724,6 +725,9 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv)if (dcfg->method ==IMX_RPROC_NONE )return 0 ; +if (!priv->has_clk) +return 0 ; + priv->clk =devm_clk_get (dev,NULL );if (IS_ERR (priv->clk)) {dev_err (dev,"Failed to get clock\n" );
@@ -768,6 +772,7 @@ static int imx_rproc_probe(struct platform_device *pdev) priv->rproc = rproc; priv->dcfg = dcfg; priv->dev = dev; + priv->has_clk = true;dev_set_drvdata (dev, rproc); priv->workqueue =create_workqueue (dev_name (dev));
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 5/9] remoteproc: imx_rproc: make clk optional
Quoted 15 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
To i.MX8QXP/QM/ULP and i.MX7ULP, Mcore maybe out of control of Linux. And in such case, no need clk, so make clk optional with
has_clk.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/remoteproc/imx_rproc.c +0
-0
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 92
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +1
-0@@ -89,6 +89,7 @@ struct imx_rproc {struct work_struct rproc_work;struct workqueue_struct *workqueue;void __iomem *rsc_table; +bool has_clk;
I am usually weary of bloating structures with flags. I suggest achieving the same functionality with a macro that compares priv->dcfg with the right imx_rproc_dcfg structure.
Quoted 24 lines
drivers/remoteproc/imx_rproc.c +4
-0};static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {@@ -724,6 +725,9 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv)if (dcfg->method ==IMX_RPROC_NONE )return 0 ; +if (!priv->has_clk) +return 0 ; + priv->clk =devm_clk_get (dev,NULL );if (IS_ERR (priv->clk)) {dev_err (dev,"Failed to get clock\n" );@@ -768,6 +772,7 @@ static int imx_rproc_probe(struct platform_device *pdev) priv->rproc = rproc; priv->dcfg = dcfg; priv->dev = dev; + priv->has_clk = true;dev_set_drvdata (dev, rproc); priv->workqueue =create_workqueue (dev_name (dev));Signature · 1 line
2.25.1
RE: [PATCH 5/9] remoteproc: imx_rproc: make clk optional
Quoted 13 lines
Subject: Re: [PATCH 5/9] remoteproc:
imx_rproc: make clk optionalQuoted 10 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
To i.MX8QXP/QM/ULP and i.MX7ULP, Mcore maybe out of control of Linux. And in such case, no need clk, so make clk optional with
has_clk.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 14 lines
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 92
Quoted 10 lines
(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex7b2578177ea8..0e99a3ca6fbc100644drivers/remoteproc/imx_rproc.c +1
-0@@ -89,6 +89,7 @@ struct imx_rproc {struct work_struct rproc_work;struct workqueue_struct *workqueue;void __iomem *rsc_table; +bool has_clk;I am usually weary of bloating structures with flags. I suggest achieving the same functionality with a macro that compares
priv->dcfgwith the rightimx_rproc_dcfgstructure.
priv->dcfg is some kind fixed settings, however has_clk could be runtime changed, because i.MX platform M-core support multiple booting method and it could work w/o clk handled by Linux depending on some pre-configuration such as moving M-core in an separate hardware partition.
Thanks,
Peng.
Quoted 25 lines
Quoted 25 lines
drivers/remoteproc/imx_rproc.c +3
-1}; static const struct imx_rproc_att imx_rproc_att_imx8mn[] = { @@ -724,6 +725,9 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv) if (dcfg->method == IMX_RPROC_NONE) return 0; +if (!priv->has_clk) +return 0 ; + priv->clk =devm_clk_get (dev,NULL );if (IS_ERR (priv->clk)) { dev_err(dev, "Failed to get clock\n"); @@ -768,6 +772,7 @@ staticint
imx_rproc_probe(struct platform_device *pdev)drivers/remoteproc/imx_rproc.c +1
-1priv->rproc = rproc; priv->dcfg = dcfg; priv->dev = dev; + priv->has_clk = true;dev_set_drvdata (dev, rproc); priv->workqueue =create_workqueue (dev_name (dev)); --2.25.1
Mathieu Poirier
maintainerRe: [PATCH 5/9] remoteproc: imx_rproc: make clk optional
Quoted 28 lines · Peng Fan
Quoted 13 lines
Subject: Re: [PATCH 5/9] remoteproc:
imx_rproc: make clk optionalQuoted 10 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
To i.MX8QXP/QM/ULP and i.MX7ULP, Mcore maybe out of control of Linux. And in such case, no need clk, so make clk optional with
has_clk.Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 5 +++++ 1 file changed, 5 insertions(+)Quoted 14 lines
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 92
Quoted 10 lines
(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex7b2578177ea8..0e99a3ca6fbc100644drivers/remoteproc/imx_rproc.c +1
-0@@ -89,6 +89,7 @@ struct imx_rproc {struct work_struct rproc_work;struct workqueue_struct *workqueue;void __iomem *rsc_table; +bool has_clk;I am usually weary of bloating structures with flags. I suggest achieving the same functionality with a macro that compares
priv->dcfgwith the rightimx_rproc_dcfgstructure.
Quoted 4 lines
priv->dcfgis some kind fixed settings, howeverhas_clkcould be runtime changed, because i.MX platform M-core support multiple booting method and it could work w/o clk handled by Linux depending on some pre-configuration such as moving M-core in an separate hardware partition.
Unless there is an FPGA in the mix, clocks and power domains should not change. Either clocks are handled by the remote processor or the application processor, regardless of the mode (attached or detached) the platform is booting into.
Quoted 29 lines
Thanks,
Peng.Quoted 25 lines
Quoted 25 lines
drivers/remoteproc/imx_rproc.c +3
-1}; static const struct imx_rproc_att imx_rproc_att_imx8mn[] = { @@ -724,6 +725,9 @@ static int imx_rproc_clk_enable(struct imx_rproc *priv) if (dcfg->method == IMX_RPROC_NONE) return 0; +if (!priv->has_clk) +return 0 ; + priv->clk =devm_clk_get (dev,NULL );if (IS_ERR (priv->clk)) { dev_err(dev, "Failed to get clock\n"); @@ -768,6 +772,7 @@ staticint
imx_rproc_probe(struct platform_device *pdev)drivers/remoteproc/imx_rproc.c +1
-1priv->rproc = rproc; priv->dcfg = dcfg; priv->dev = dev; + priv->has_clk = true;dev_set_drvdata (dev, rproc); priv->workqueue =create_workqueue (dev_name (dev)); --2.25.1
PATCH 6/9 remoteproc: imx_rproc: support attaching to i.MX8QXP M4
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
When M4 is kicked by SCFW, M4 runs in its own hardware partition, Linux could only do IPC with M4, it could not start, stop, update image.
When M4 crash reboot, it could notify Linux, so Linux could prepare to reattach to M4 after M4 recovery.
--- drivers/remoteproc/imx_rproc.c | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
drivers/remoteproc/imx_rproc.c +96 -0
@@ -6,6 +6,7 @@#include <linux/arm-smccc.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/firmware/imx/sci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mailbox_client.h>
@@ -59,6 +60,8 @@#define IMX_SIP_RPROC_STARTED 0x01#define IMX_SIP_RPROC_STOP 0x02 +#define IMX_SC_IRQ_GROUP_REBOOTED 5 +/** * struct imx_rproc_mem - slim internal memory structure * @cpu_addr: MPU virtual address of the memory region
@@ -90,6 +93,23 @@ struct imx_rproc {struct workqueue_struct *workqueue;void __iomem *rsc_table;bool has_clk; +struct imx_sc_ipc *ipc_handle; +struct notifier_block proc_nb; +u32 rproc_pt; +u32 rsrc; +}; + +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML/U */ + {0x1FFE0000 ,0x34FE0000 ,0x00040000 ,ATT_OWN |ATT_IOMEM }, +/* OCRAM(Low 96KB) */ + {0x21000000 ,0x00100000 ,0x00018000 ,0 }, +/* OCRAM */ + {0x21100000 ,0x00100000 ,0x00040000 ,0 }, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, };static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {
@@ -236,6 +256,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8ulp = { .method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { + .att = imx_rproc_att_imx8qxp, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size =ARRAY_SIZE (imx_rproc_att_imx7ulp),
@@ -491,6 +517,11 @@ static int imx_rproc_attach(struct rproc *rproc)return 0 ; } +static int imx_rproc_detach (struct rproc *rproc) +{ +return 0 ; +} +static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) {struct imx_rproc *priv = rproc->priv;
@@ -525,6 +556,7 @@ imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach, + .detach = imx_rproc_detach, .start = imx_rproc_start, .stop = imx_rproc_stop, .kick = imx_rproc_kick,
@@ -671,6 +703,22 @@ static void imx_rproc_free_mbox(struct rproc *rproc)mbox_free_channel (priv->rx_ch); } +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->rproc_pt)) && (*(u8 *)group ==IMX_SC_IRQ_GROUP_REBOOTED ))) +return 0 ; + +rproc_report_crash (priv->rproc,RPROC_WATCHDOG ); + +pr_info ("Patition%d reset!\n" , priv->rproc_pt); + +return 0 ; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) {struct regmap_config config = { .name ="imx-rproc" };
@@ -680,6 +728,7 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)struct arm_smccc_res res;int ret;u32 val; +u8 pt;switch (dcfg->method) {case IMX_RPROC_NONE :
@@ -690,6 +739,52 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)if (res.a0) priv->rproc->state =RPROC_DETACHED ;return 0 ; +case IMX_RPROC_SCU_API : + ret =imx_scu_get_handle (&priv->ipc_handle); +if (ret) +return ret; + ret =of_property_read_u32 (dev->of_node,"rsrc-id" , &priv->rsrc); +if (ret) { +dev_err (dev,"no rsrc-id\n" ); +return ret; + } + +/* +* If Mcore resource is not owned by Acore partition, It is kicked by ROM, +* and Linux could only do IPC with Mcore and nothing else. +*/ +if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { + + priv->has_clk = false; + priv->rproc->self_recovery = true; + priv->rproc->state =RPROC_DETACHED ; + +/* Get partition id and enable irq in SCFW */ + ret =imx_sc_rm_get_resource_owner (priv->ipc_handle, priv->rsrc, &pt); +if (ret) { +dev_err (dev,"not able to get resource owner\n" ); +return ret; + } + + priv->rproc_pt = pt; + priv->proc_nb.notifier_call = imx_rproc_partition_notify; + + ret =imx_scu_irq_register_notifier (&priv->proc_nb); +if (ret) { +dev_warn (dev,"register scu notifier failed.\n" ); +return ret; + } + + ret =imx_scu_irq_group_enable (IMX_SC_IRQ_GROUP_REBOOTED , +BIT (priv->rproc_pt), true); +if (ret) { +imx_scu_irq_unregister_notifier (&priv->proc_nb); +dev_warn (dev,"Enable irq failed.\n" ); +return ret; + } + } + +return 0 ;default :break ; }
@@ -847,6 +942,7 @@ static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, + { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, };
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 6/9] remoteproc: imx_rproc: support attaching to i.MX8QXP M4
Quoted 35 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
When M4 is kicked by SCFW, M4 runs in its own hardware partition, Linux could only do IPC with M4, it could not start, stop, update image.
When M4 crash reboot, it could notify Linux, so Linux could prepare to reattach to M4 after M4 recovery.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)drivers/remoteproc/imx_rproc.c +3
-0@@ -6,6 +6,7 @@#include <linux/arm-smccc.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/firmware/imx/sci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mailbox_client.h> @@ -59,6 +60,8 @@#define IMX_SIP_RPROC_STARTED 0x01#define IMX_SIP_RPROC_STOP 0x02 +#define IMX_SC_IRQ_GROUP_REBOOTED 5 +/** * struct imx_rproc_mem - slim internal memory structure * @cpu_addr: MPU virtual address of the memory region
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 99
Quoted 7 lines
drivers/remoteproc/imx_rproc.c +4
-0@@ -90,6 +93,23 @@ struct imx_rproc {struct workqueue_struct *workqueue;void __iomem *rsc_table;bool has_clk; +struct imx_sc_ipc *ipc_handle; +struct notifier_block proc_nb; +u32 rproc_pt; +u32 rsrc;
There is no documentation for the above two fields and I have to guess what they do.
Quoted 30 lines
drivers/remoteproc/imx_rproc.c +19
-0+}; + +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML/U */ + {0x1FFE0000 ,0x34FE0000 ,0x00040000 ,ATT_OWN |ATT_IOMEM }, +/* OCRAM(Low 96KB) */ + {0x21000000 ,0x00100000 ,0x00018000 ,0 }, +/* OCRAM */ + {0x21100000 ,0x00100000 ,0x00040000 ,0 }, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, };static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {@@ -236,6 +256,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8ulp = { .method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { + .att = imx_rproc_att_imx8qxp, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size =ARRAY_SIZE (imx_rproc_att_imx7ulp),
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc) · line 522
Quoted 6 lines
drivers/remoteproc/imx_rproc.c +3
-0@@ -491,6 +517,11 @@ static int imx_rproc_attach(struct rproc *rproc)return 0 ; } +static int imx_rproc_detach (struct rproc *rproc) +{ +return 0 ;
Is it possible to detach the remote processor from the application core? If not please write a comment that says so. And shouldn't this return some kind of error so that users don't think the operation was carried out successfully?
I am out of time for today and as such will continue with this set tomorrow.
Thanks,
Mathieu
Quoted 108 lines
drivers/remoteproc/imx_rproc.c +67
-0+} +static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) {struct imx_rproc *priv = rproc->priv;@@ -525,6 +556,7 @@ imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach, + .detach = imx_rproc_detach, .start = imx_rproc_start, .stop = imx_rproc_stop, .kick = imx_rproc_kick,@@ -671,6 +703,22 @@ static void imx_rproc_free_mbox(struct rproc *rproc)mbox_free_channel (priv->rx_ch); } +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->rproc_pt)) && (*(u8 *)group ==IMX_SC_IRQ_GROUP_REBOOTED ))) +return 0 ; + +rproc_report_crash (priv->rproc,RPROC_WATCHDOG ); + +pr_info ("Patition%d reset!\n" , priv->rproc_pt); + +return 0 ; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) {struct regmap_config config = { .name ="imx-rproc" };@@ -680,6 +728,7 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)struct arm_smccc_res res;int ret;u32 val; +u8 pt;switch (dcfg->method) {case IMX_RPROC_NONE :@@ -690,6 +739,52 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)if (res.a0) priv->rproc->state =RPROC_DETACHED ;return 0 ; +case IMX_RPROC_SCU_API : + ret =imx_scu_get_handle (&priv->ipc_handle); +if (ret) +return ret; + ret =of_property_read_u32 (dev->of_node,"rsrc-id" , &priv->rsrc); +if (ret) { +dev_err (dev,"no rsrc-id\n" ); +return ret; + } + +/* +* If Mcore resource is not owned by Acore partition, It is kicked by ROM, +* and Linux could only do IPC with Mcore and nothing else. +*/ +if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { + + priv->has_clk = false; + priv->rproc->self_recovery = true; + priv->rproc->state =RPROC_DETACHED ; + +/* Get partition id and enable irq in SCFW */ + ret =imx_sc_rm_get_resource_owner (priv->ipc_handle, priv->rsrc, &pt); +if (ret) { +dev_err (dev,"not able to get resource owner\n" ); +return ret; + } + + priv->rproc_pt = pt; + priv->proc_nb.notifier_call = imx_rproc_partition_notify; + + ret =imx_scu_irq_register_notifier (&priv->proc_nb); +if (ret) { +dev_warn (dev,"register scu notifier failed.\n" ); +return ret; + } + + ret =imx_scu_irq_group_enable (IMX_SC_IRQ_GROUP_REBOOTED , +BIT (priv->rproc_pt), true); +if (ret) { +imx_scu_irq_unregister_notifier (&priv->proc_nb); +dev_warn (dev,"Enable irq failed.\n" ); +return ret; + } + } + +return 0 ;default :break ; }@@ -847,6 +942,7 @@ static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, + { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, };Signature · 1 line
2.25.1
RE: [PATCH 6/9] remoteproc: imx_rproc: support attaching to i.MX8QXP M4
Quoted 35 lines
Subject: Re: [PATCH 6/9] remoteproc:
imx_rproc: support attaching to i.MX8QXP M4Quoted 31 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
When M4 is kicked by SCFW, M4 runs in its own hardware partition, Linux could only do IPC with M4, it could not start, stop, update image.
When M4 crash reboot, it could notify Linux, so Linux could prepare to reattach to M4 after M4 recovery.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex0e99a3ca6fbc..5f04aea2f6a1100644drivers/remoteproc/imx_rproc.c +1
-0@@ -6,6 +6,7 @@#include <linux/arm-smccc.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/firmware/imx/sci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mailbox_client.h> @@ -59,6 +60,8 @@#define IMX_SIP_RPROC_STARTED 0x01#define IMX_SIP_RPROC_STOP 0x02
Quoted 16 lines
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 99
Quoted 13 lines
drivers/remoteproc/imx_rproc.c +7
-0+#define IMX_SC_IRQ_GROUP_REBOOTED 5 +/** * struct imx_rproc_mem - slim internal memory structure * @cpu_addr: MPU virtual address of the memory region @@ -90,6 +93,23 @@ struct imx_rproc { struct workqueue_struct *workqueue; void __iomem *rsc_table; bool has_clk; +struct imx_sc_ipc *ipc_handle; +struct notifier_block proc_nb; +u32 rproc_pt; +u32 rsrc; There is no documentation for the above two fields and I have to guess what they do.
Fix in V2.
Quoted 35 lines
Quoted 8 lines
drivers/remoteproc/imx_rproc.c +7
-0+}; + +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML/U */ + {0x1FFE0000 ,0x34FE0000 ,0x00040000 ,ATT_OWN |ATT_IOMEM },drivers/remoteproc/imx_rproc.c struct imx_rproc {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +6
-1+/* OCRAM(Low 96KB) */ + { 0x21000000, 0x00100000, 0x00018000, 0}, + /* OCRAM */ + { 0x21100000, 0x00100000, 0x00040000, 0}, + /* DDR (Data) */ + { 0x80000000, 0x80000000, 0x60000000, 0 }, }; static const struct imx_rproc_att imx_rproc_att_imx8mn[] = { @@ -236,6 +256,12 @@ static const struct imx_rproc_dcfg
imx_rproc_cfg_imx8ulp= {Quoted 16 lines
drivers/remoteproc/imx_rproc.c +6
-0.method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { + .att = imx_rproc_att_imx8qxp, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size =ARRAY_SIZE (imx_rproc_att_imx7ulp),@@ -491,6 +517,11 @@ static int imx_rproc_attach(struct rproc *rproc)return 0 ; }
Quoted 5 lines
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc) · line 521
Quoted 2 lines
drivers/remoteproc/imx_rproc.c +2
-0+static int imx_rproc_detach (struct rproc *rproc) { +return 0 ;Is it possible to detach the remote processor from the application core? If not please write a comment that says so.
No from my understanding.
And shouldn't this return some
Quoted 2 lines
kind of error so that users don't think the operation was carried out successfully?
No. This is to match patch 3/9 to support M-core self recovery. After M-core crash reboot, remoteproc framework just detach and re-attach.
Quoted 2 lines
I am out of time for today and as such will continue with this set tomorrow.
Thanks for you reviewing the patchset.
Thanks,
Peng.
Quoted 118 lines
Thanks,
Mathieudrivers/remoteproc/imx_rproc.c static void imx_rproc_free_mbox(struct rproc
Quoted 14 lines
drivers/remoteproc/imx_rproc.c +2
-0+} +static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) { struct imx_rproc *priv = rproc->priv; @@ -525,6 +556,7 @@imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware * static const struct
rproc_opsimx_rproc_ops= {drivers/remoteproc/imx_rproc.c +1
-0.prepare = imx_rproc_prepare, .attach = imx_rproc_attach, + .detach = imx_rproc_detach, .start = imx_rproc_start, .stop = imx_rproc_stop, .kick = imx_rproc_kick,@@ -671,6 +703,22 @@ static void imx_rproc_free_mbox(struct rproc*rproc)
drivers/remoteproc/imx_rproc.c static void imx_rproc_free_mbox(struct rproc *rproc)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +7
-0mbox_free_channel (priv->rx_ch); } +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->rproc_pt)) && (*(u8 *)group ==
IMX_SC_IRQ_GROUP_REBOOTED)))drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct
Quoted 20 lines
drivers/remoteproc/imx_rproc.c +11
-0+return 0 ; + +rproc_report_crash (priv->rproc,RPROC_WATCHDOG ); + +pr_info ("Patition%d reset!\n" , priv->rproc_pt); + +return 0 ; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) { struct regmap_config config = { .name = "imx-rproc" }; @@ -680,6 +728,7 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv) struct arm_smccc_res res;int ret;u32 val; +u8 pt;switch (dcfg->method) {case IMX_RPROC_NONE :@@ -690,6 +739,52 @@ static int imx_rproc_detect_mode(struct
imx_rproc*priv)Quoted 5 lines
drivers/remoteproc/imx_rproc.c +2
-0if (res.a0) priv->rproc->state =RPROC_DETACHED ;return 0 ; +case IMX_RPROC_SCU_API : + ret =imx_scu_get_handle (&priv->ipc_handle);drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+if (ret) +return ret; + ret =of_property_read_u32 (dev->of_node,"rsrc-id" , &priv->rsrc); +if (ret) { +dev_err (dev,"no rsrc-id\n" ); +return ret; + } + +/* +* If Mcore resource is not owned by Acore partition, It is kicked by ROM,
drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+* and Linux could only do IPC with Mcore and nothing else. +*/ +if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { + + priv->has_clk = false; + priv->rproc->self_recovery = true; + priv->rproc->state =RPROC_DETACHED ; + +/* Get partition id and enable irq in SCFW */ + ret = imx_sc_rm_get_resource_owner(priv->ipc_handle,
priv->rsrc, &pt);Quoted 5 lines
drivers/remoteproc/imx_rproc.c +5
-0+if (ret) { +dev_err (dev,"not able to get resource owner\n" ); +return ret; + } +drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+ priv->rproc_pt = pt; + priv->proc_nb.notifier_call = imx_rproc_partition_notify; + + ret =imx_scu_irq_register_notifier (&priv->proc_nb); +if (ret) { +dev_warn (dev,"register scu notifier failed.\n" ); +return ret; + } + + ret =imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_REBOOTED,
drivers/remoteproc/imx_rproc.c static const struct of_device_id
Quoted 13 lines
drivers/remoteproc/imx_rproc.c +9
-0+ BIT(priv->rproc_pt), true); +if (ret) { +imx_scu_irq_unregister_notifier (&priv->proc_nb); +dev_warn (dev,"Enable irq failed.\n" ); +return ret; + } + } + +return 0 ;default :break ; }@@ -847,6 +942,7 @@ static const struct of_device_idimx_rproc_of_match[] = {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +1
-1{ .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, + { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, }; --2.25.1
Mathieu Poirier
maintainerRe: [PATCH 6/9] remoteproc: imx_rproc: support attaching to i.MX8QXP M4
Quoted 95 lines · Peng Fan
Quoted 35 lines
Subject: Re: [PATCH 6/9] remoteproc:
imx_rproc: support attaching to i.MX8QXP M4Quoted 31 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
When M4 is kicked by SCFW, M4 runs in its own hardware partition, Linux could only do IPC with M4, it could not start, stop, update image.
When M4 crash reboot, it could notify Linux, so Linux could prepare to reattach to M4 after M4 recovery.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex0e99a3ca6fbc..5f04aea2f6a1100644drivers/remoteproc/imx_rproc.c +1
-0@@ -6,6 +6,7 @@#include <linux/arm-smccc.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/firmware/imx/sci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mailbox_client.h> @@ -59,6 +60,8 @@#define IMX_SIP_RPROC_STARTED 0x01#define IMX_SIP_RPROC_STOP 0x02Quoted 16 lines
drivers/remoteproc/imx_rproc.c struct imx_rproc { · line 99
Quoted 13 lines
drivers/remoteproc/imx_rproc.c +7
-0+#define IMX_SC_IRQ_GROUP_REBOOTED 5 +/** * struct imx_rproc_mem - slim internal memory structure * @cpu_addr: MPU virtual address of the memory region @@ -90,6 +93,23 @@ struct imx_rproc { struct workqueue_struct *workqueue; void __iomem *rsc_table; bool has_clk; +struct imx_sc_ipc *ipc_handle; +struct notifier_block proc_nb; +u32 rproc_pt; +u32 rsrc; There is no documentation for the above two fields and I have to guess what they do.
Fix in V2.
Quoted 35 lines
Quoted 8 lines
drivers/remoteproc/imx_rproc.c +7
-0+}; + +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML/U */ + {0x1FFE0000 ,0x34FE0000 ,0x00040000 ,ATT_OWN |ATT_IOMEM },drivers/remoteproc/imx_rproc.c struct imx_rproc {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +6
-1+/* OCRAM(Low 96KB) */ + { 0x21000000, 0x00100000, 0x00018000, 0}, + /* OCRAM */ + { 0x21100000, 0x00100000, 0x00040000, 0}, + /* DDR (Data) */ + { 0x80000000, 0x80000000, 0x60000000, 0 }, }; static const struct imx_rproc_att imx_rproc_att_imx8mn[] = { @@ -236,6 +256,12 @@ static const struct imx_rproc_dcfg
imx_rproc_cfg_imx8ulp= {Quoted 16 lines
drivers/remoteproc/imx_rproc.c +6
-0.method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { + .att = imx_rproc_att_imx8qxp, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size =ARRAY_SIZE (imx_rproc_att_imx7ulp),@@ -491,6 +517,11 @@ static int imx_rproc_attach(struct rproc *rproc)return 0 ; }Quoted 5 lines
drivers/remoteproc/imx_rproc.c static int imx_rproc_attach(struct rproc *rproc) · line 521
Quoted 2 lines
drivers/remoteproc/imx_rproc.c +2
-0+static int imx_rproc_detach (struct rproc *rproc) { +return 0 ;Is it possible to detach the remote processor from the application core? If not please write a comment that says so.
Quoted 8 lines
No from my understanding.
And shouldn't this return some
Quoted 2 lines
kind of error so that users don't think the operation was carried out successfully?
No. This is to match patch 3/9 to support M-core self recovery. After M-core crash reboot, remoteproc framework just detach and re-attach.
Right, but by returning 0 in imx_rproc_detach() issueing something like:
# echo detach > /sys/class/remoteproc/remoteproc0/state
will return without an error message, leading users to believe the remote processor has been detached. Returning an error code like -EINVAL would tell users the operation was not completed successfully.
More comments to come shortly...
Quoted 127 lines
Quoted 3 lines
I am out of time for today and as such will continue with this set tomorrow.
Thanks for you reviewing the patchset.
Thanks,
Peng.Quoted 118 lines
Thanks,
Mathieudrivers/remoteproc/imx_rproc.c static void imx_rproc_free_mbox(struct rproc
Quoted 14 lines
drivers/remoteproc/imx_rproc.c +2
-0+} +static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) { struct imx_rproc *priv = rproc->priv; @@ -525,6 +556,7 @@imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware * static const struct
rproc_opsimx_rproc_ops= {drivers/remoteproc/imx_rproc.c +1
-0.prepare = imx_rproc_prepare, .attach = imx_rproc_attach, + .detach = imx_rproc_detach, .start = imx_rproc_start, .stop = imx_rproc_stop, .kick = imx_rproc_kick,@@ -671,6 +703,22 @@ static void imx_rproc_free_mbox(struct rproc*rproc)
drivers/remoteproc/imx_rproc.c static void imx_rproc_free_mbox(struct rproc *rproc)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +7
-0mbox_free_channel (priv->rx_ch); } +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->rproc_pt)) && (*(u8 *)group ==
IMX_SC_IRQ_GROUP_REBOOTED)))drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct
Quoted 20 lines
drivers/remoteproc/imx_rproc.c +11
-0+return 0 ; + +rproc_report_crash (priv->rproc,RPROC_WATCHDOG ); + +pr_info ("Patition%d reset!\n" , priv->rproc_pt); + +return 0 ; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) { struct regmap_config config = { .name = "imx-rproc" }; @@ -680,6 +728,7 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv) struct arm_smccc_res res;int ret;u32 val; +u8 pt;switch (dcfg->method) {case IMX_RPROC_NONE :@@ -690,6 +739,52 @@ static int imx_rproc_detect_mode(struct
imx_rproc*priv)Quoted 5 lines
drivers/remoteproc/imx_rproc.c +2
-0if (res.a0) priv->rproc->state =RPROC_DETACHED ;return 0 ; +case IMX_RPROC_SCU_API : + ret =imx_scu_get_handle (&priv->ipc_handle);drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+if (ret) +return ret; + ret =of_property_read_u32 (dev->of_node,"rsrc-id" , &priv->rsrc); +if (ret) { +dev_err (dev,"no rsrc-id\n" ); +return ret; + } + +/* +* If Mcore resource is not owned by Acore partition, It is kicked by ROM,
drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+* and Linux could only do IPC with Mcore and nothing else. +*/ +if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { + + priv->has_clk = false; + priv->rproc->self_recovery = true; + priv->rproc->state =RPROC_DETACHED ; + +/* Get partition id and enable irq in SCFW */ + ret = imx_sc_rm_get_resource_owner(priv->ipc_handle,
priv->rsrc, &pt);Quoted 5 lines
drivers/remoteproc/imx_rproc.c +5
-0+if (ret) { +dev_err (dev,"not able to get resource owner\n" ); +return ret; + } +drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv)
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+ priv->rproc_pt = pt; + priv->proc_nb.notifier_call = imx_rproc_partition_notify; + + ret =imx_scu_irq_register_notifier (&priv->proc_nb); +if (ret) { +dev_warn (dev,"register scu notifier failed.\n" ); +return ret; + } + + ret =imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_REBOOTED,
drivers/remoteproc/imx_rproc.c static const struct of_device_id
Quoted 13 lines
drivers/remoteproc/imx_rproc.c +9
-0+ BIT(priv->rproc_pt), true); +if (ret) { +imx_scu_irq_unregister_notifier (&priv->proc_nb); +dev_warn (dev,"Enable irq failed.\n" ); +return ret; + } + } + +return 0 ;default :break ; }@@ -847,6 +942,7 @@ static const struct of_device_idimx_rproc_of_match[] = {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +1
-1{ .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, + { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, }; --2.25.1
Mathieu Poirier
maintainerRe: [PATCH 6/9] remoteproc: imx_rproc: support attaching to i.MX8QXP M4
In reply to Peng Fan (OSS)Quoted 97 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
When M4 is kicked by SCFW, M4 runs in its own hardware partition, Linux could only do IPC with M4, it could not start, stop, update image.
When M4 crash reboot, it could notify Linux, so Linux could prepare to reattach to M4 after M4 recovery.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)drivers/remoteproc/imx_rproc.c +34
-0@@ -6,6 +6,7 @@#include <linux/arm-smccc.h> #include <linux/clk.h> #include <linux/err.h> +#include <linux/firmware/imx/sci.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/mailbox_client.h> @@ -59,6 +60,8 @@#define IMX_SIP_RPROC_STARTED 0x01#define IMX_SIP_RPROC_STOP 0x02 +#define IMX_SC_IRQ_GROUP_REBOOTED 5 +/** * struct imx_rproc_mem - slim internal memory structure * @cpu_addr: MPU virtual address of the memory region @@ -90,6 +93,23 @@ struct imx_rproc {struct workqueue_struct *workqueue;void __iomem *rsc_table;bool has_clk; +struct imx_sc_ipc *ipc_handle; +struct notifier_block proc_nb; +u32 rproc_pt; +u32 rsrc; +}; + +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML/U */ + {0x1FFE0000 ,0x34FE0000 ,0x00040000 ,ATT_OWN |ATT_IOMEM }, +/* OCRAM(Low 96KB) */ + {0x21000000 ,0x00100000 ,0x00018000 ,0 }, +/* OCRAM */ + {0x21100000 ,0x00100000 ,0x00040000 ,0 }, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, };static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {@@ -236,6 +256,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8ulp = { .method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { + .att = imx_rproc_att_imx8qxp, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = { .att = imx_rproc_att_imx7ulp, .att_size =ARRAY_SIZE (imx_rproc_att_imx7ulp),@@ -491,6 +517,11 @@ static int imx_rproc_attach(struct rproc *rproc)return 0 ; } +static int imx_rproc_detach (struct rproc *rproc) +{ +return 0 ; +} +static struct resource_table *imx_rproc_get_loaded_rsc_table (struct rproc *rproc,size_t *table_sz) {struct imx_rproc *priv = rproc->priv;@@ -525,6 +556,7 @@ imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach, + .detach = imx_rproc_detach, .start = imx_rproc_start, .stop = imx_rproc_stop, .kick = imx_rproc_kick,@@ -671,6 +703,22 @@ static void imx_rproc_free_mbox(struct rproc *rproc)mbox_free_channel (priv->rx_ch); } +static int imx_rproc_partition_notify (struct notifier_block *nb, +unsigned long event,void *group)
drivers/remoteproc/imx_rproc.c static void imx_rproc_free_mbox(struct rproc *rproc) · line 717
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+{ + struct imx_rproc *priv = container_of(nb, struct imx_rproc, proc_nb); + +/* Ignore other irqs */ +if (!((event &BIT (priv->rproc_pt)) && (*(u8 *)group ==IMX_SC_IRQ_GROUP_REBOOTED ))) +return 0 ; + +rproc_report_crash (priv->rproc,RPROC_WATCHDOG ); + +pr_info ("Patition%d reset!\n" , priv->rproc_pt);
s/Patition/Partition
Quoted 24 lines
drivers/remoteproc/imx_rproc.c +10
-0+ +return 0 ; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) {struct regmap_config config = { .name ="imx-rproc" };@@ -680,6 +728,7 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)struct arm_smccc_res res;int ret;u32 val; +u8 pt;switch (dcfg->method) {case IMX_RPROC_NONE :@@ -690,6 +739,52 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)if (res.a0) priv->rproc->state =RPROC_DETACHED ;return 0 ; +case IMX_RPROC_SCU_API : + ret =imx_scu_get_handle (&priv->ipc_handle); +if (ret) +return ret; + ret =of_property_read_u32 (dev->of_node,"rsrc-id" , &priv->rsrc);
drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv) · line 756
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +10
-0+if (ret) { +dev_err (dev,"no rsrc-id\n" ); +return ret; + } + +/* +* If Mcore resource is not owned by Acore partition, It is kicked by ROM, +* and Linux could only do IPC with Mcore and nothing else. +*/ +if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) {
if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc))
return 0;drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv) · line 760
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +4
-0+ + priv->has_clk = false; + priv->rproc->self_recovery = true; + priv->rproc->state =RPROC_DETACHED ;
This is further proof that information is already available to determine if clocks should be managed on the application processor or not and that priv->has_clk carries redundant information.
Quoted 41 lines
drivers/remoteproc/imx_rproc.c +28
-0+ +/* Get partition id and enable irq in SCFW */ + ret =imx_sc_rm_get_resource_owner (priv->ipc_handle, priv->rsrc, &pt); +if (ret) { +dev_err (dev,"not able to get resource owner\n" ); +return ret; + } + + priv->rproc_pt = pt; + priv->proc_nb.notifier_call = imx_rproc_partition_notify; + + ret =imx_scu_irq_register_notifier (&priv->proc_nb); +if (ret) { +dev_warn (dev,"register scu notifier failed.\n" ); +return ret; + } + + ret =imx_scu_irq_group_enable (IMX_SC_IRQ_GROUP_REBOOTED , +BIT (priv->rproc_pt), true); +if (ret) { +imx_scu_irq_unregister_notifier (&priv->proc_nb); +dev_warn (dev,"Enable irq failed.\n" ); +return ret; + } + } + +return 0 ;default :break ; }@@ -847,6 +942,7 @@ static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, + { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, };Signature · 1 line
2.25.1
PATCH 7/9 remoteproc: imx_rproc: support kicking Mcore from Linux for i.MX8QXP
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
When M4 is in the same hardware partition with Cortex-A, it could be start/stop by Linux.
Added power domain to make sure M4 could run, it requires several power domains to work. Make clk always optional for i.MX8QXP, because SCFW handles it when power up M4 core.
--- drivers/remoteproc/imx_rproc.c | 64 +++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
drivers/remoteproc/imx_rproc.c +63 -1
@@ -16,6 +16,7 @@#include <linux/of_reserved_mem.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regmap.h> #include <linux/remoteproc.h> #include <linux/workqueue.h>
@@ -97,6 +98,9 @@ struct imx_rproc {struct notifier_block proc_nb;u32 rproc_pt;u32 rsrc; +int num_pd; +struct device **pd_dev; +struct device_link **pd_dev_link; };static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {
@@ -305,6 +309,9 @@ static int imx_rproc_start(struct rproc *rproc)arm_smccc_smc (IMX_SIP_RPROC ,IMX_SIP_RPROC_START ,0 ,0 ,0 ,0 ,0 ,0 , &res); ret = res.a0;break ; +case IMX_RPROC_SCU_API : + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 ); +break ;default :return -EOPNOTSUPP ; }
@@ -334,6 +341,9 @@ static int imx_rproc_stop(struct rproc *rproc)if (res.a1)dev_info (dev,"Not in wfi, force stopped\n" );break ; +case IMX_RPROC_SCU_API : + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 ); +break ;default :return -EOPNOTSUPP ; }
@@ -719,6 +729,56 @@ static int imx_rproc_partition_notify(struct notifier_block *nb,return 0 ; } +static int imx_rproc_attach_pd (struct imx_rproc *priv) +{ +struct device *dev = priv->dev; +int ret, i; + + priv->num_pd =of_count_phandle_with_args (dev->of_node,"power-domains" , +"#power-domain-cells" ); +if (priv->num_pd <0 ) +return priv->num_pd; + +if (!priv->num_pd) +return 0 ; + + priv->pd_dev =devm_kmalloc_array (dev, priv->num_pd,sizeof (*priv->pd_dev),GFP_KERNEL ); +if (!priv->pd_dev) +return -ENOMEM ; + + priv->pd_dev_link =devm_kmalloc_array (dev, priv->num_pd,sizeof (*priv->pd_dev_link), +GFP_KERNEL ); + +if (!priv->pd_dev_link) +return -ENOMEM ; + +for (i =0 ; i < priv->num_pd; i++) { + priv->pd_dev[i] =dev_pm_domain_attach_by_id (dev, i); +if (IS_ERR (priv->pd_dev[i])) { + ret =PTR_ERR (priv->pd_dev[i]); + goto detach_pd; + } + + priv->pd_dev_link[i] =device_link_add (dev, priv->pd_dev[i],DL_FLAG_STATELESS | +DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE ); +if (!priv->pd_dev_link[i]) { +dev_pm_domain_detach (priv->pd_dev[i], false); + ret = -EINVAL ; + goto detach_pd; + } + } + +return 0 ; + +detach_pd: +while (--i >=0 ) { +device_link_del (priv->pd_dev_link[i]); +dev_pm_domain_detach (priv->pd_dev[i], false); + } + +return ret; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) {struct regmap_config config = { .name ="imx-rproc" };
@@ -749,13 +809,13 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)return ret; } + priv->has_clk = false;/* * If Mcore resource is not owned by Acore partition, It is kicked by ROM, * and Linux could only do IPC with Mcore and nothing else. */ if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { - priv->has_clk = false; priv->rproc->self_recovery = true; priv->rproc->state =RPROC_DETACHED ;
@@ -782,6 +842,8 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)dev_warn (dev,"Enable irq failed.\n" );return ret; } + }else { +return imx_rproc_attach_pd (priv); }return 0 ;
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 7/9] remoteproc: imx_rproc: support kicking Mcore from Linux for i.MX8QXP
Quoted 37 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
When M4 is in the same hardware partition with Cortex-A, it could be start/stop by Linux.
Added power domain to make sure M4 could run, it requires several power domains to work. Make clk always optional for i.MX8QXP, because SCFW handles it when power up M4 core.
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 64 +++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)drivers/remoteproc/imx_rproc.c +4
-0@@ -16,6 +16,7 @@#include <linux/of_reserved_mem.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/pm_domain.h> #include <linux/regmap.h> #include <linux/remoteproc.h> #include <linux/workqueue.h> @@ -97,6 +98,9 @@ struct imx_rproc {struct notifier_block proc_nb;u32 rproc_pt;u32 rsrc; +int num_pd; +struct device **pd_dev; +struct device_link **pd_dev_link; };static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {
drivers/remoteproc/imx_rproc.c static int imx_rproc_start(struct rproc *rproc) · line 313
Quoted 5 lines
drivers/remoteproc/imx_rproc.c +2
-0@@ -305,6 +309,9 @@ static int imx_rproc_start(struct rproc *rproc)arm_smccc_smc (IMX_SIP_RPROC ,IMX_SIP_RPROC_START ,0 ,0 ,0 ,0 ,0 ,0 , &res); ret = res.a0;break ; +case IMX_RPROC_SCU_API : + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 );
Where does the 0x34fe0000 comes from and what happens when the boot address changes? This should come from the device tree or some HW register somewhere.
drivers/remoteproc/imx_rproc.c static int imx_rproc_stop(struct rproc *rproc) · line 346
Quoted 11 lines
drivers/remoteproc/imx_rproc.c +4
-0+break ;default :return -EOPNOTSUPP ; }@@ -334,6 +341,9 @@ static int imx_rproc_stop(struct rproc *rproc)if (res.a1)dev_info (dev,"Not in wfi, force stopped\n" );break ; +case IMX_RPROC_SCU_API : + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 ); +break ;
Same as above.
Quoted 61 lines
drivers/remoteproc/imx_rproc.c +50
-0default :return -EOPNOTSUPP ; }@@ -719,6 +729,56 @@ static int imx_rproc_partition_notify(struct notifier_block *nb,return 0 ; } +static int imx_rproc_attach_pd (struct imx_rproc *priv) +{ +struct device *dev = priv->dev; +int ret, i; + + priv->num_pd =of_count_phandle_with_args (dev->of_node,"power-domains" , +"#power-domain-cells" ); +if (priv->num_pd <0 ) +return priv->num_pd; + +if (!priv->num_pd) +return 0 ; + + priv->pd_dev =devm_kmalloc_array (dev, priv->num_pd,sizeof (*priv->pd_dev),GFP_KERNEL ); +if (!priv->pd_dev) +return -ENOMEM ; + + priv->pd_dev_link =devm_kmalloc_array (dev, priv->num_pd,sizeof (*priv->pd_dev_link), +GFP_KERNEL ); + +if (!priv->pd_dev_link) +return -ENOMEM ; + +for (i =0 ; i < priv->num_pd; i++) { + priv->pd_dev[i] =dev_pm_domain_attach_by_id (dev, i); +if (IS_ERR (priv->pd_dev[i])) { + ret =PTR_ERR (priv->pd_dev[i]); + goto detach_pd; + } + + priv->pd_dev_link[i] =device_link_add (dev, priv->pd_dev[i],DL_FLAG_STATELESS | +DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE ); +if (!priv->pd_dev_link[i]) { +dev_pm_domain_detach (priv->pd_dev[i], false); + ret = -EINVAL ; + goto detach_pd; + } + } + +return 0 ; + +detach_pd: +while (--i >=0 ) { +device_link_del (priv->pd_dev_link[i]); +dev_pm_domain_detach (priv->pd_dev[i], false); + } + +return ret; +} +static int imx_rproc_detect_mode (struct imx_rproc *priv) {struct regmap_config config = { .name ="imx-rproc" };
drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct imx_rproc *priv) · line 812
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +1
-0@@ -749,13 +809,13 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)return ret; } + priv->has_clk = false;
This statement seems to imply that for imx8qxq processors, which is the only one to use the IMX_RPROC_SCU_API, priv->has_clk is always false. If so then why bother with a flag at all?
More comments tomorrow...
Quoted 22 lines
drivers/remoteproc/imx_rproc.c +2
-1/* * If Mcore resource is not owned by Acore partition, It is kicked by ROM, * and Linux could only do IPC with Mcore and nothing else. */ if (!imx_sc_rm_is_resource_owned (priv->ipc_handle, priv->rsrc)) { - priv->has_clk = false; priv->rproc->self_recovery = true; priv->rproc->state =RPROC_DETACHED ;@@ -782,6 +842,8 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)dev_warn (dev,"Enable irq failed.\n" );return ret; } + }else { +return imx_rproc_attach_pd (priv); }return 0 ;Signature · 1 line
2.25.1
PATCH 8/9 remoteproc: imx_rproc: support i.MX8QM
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
Most logic are same as i.MX8QXP, but i.MX8QM has two general purpose M4 cores:
Use the lower 16 bits specifying core, higher 16 bits for flags. The 2nd core has different start address from SCFW view
--- drivers/remoteproc/imx_rproc.c | 55 +++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
drivers/remoteproc/imx_rproc.c +51 -4
@@ -77,8 +77,11 @@ struct imx_rproc_mem {/* att flags */ /* M4 own area. Can be mapped at probe */ -#define ATT_OWN BIT(1) -#define ATT_IOMEM BIT(2) +#define ATT_OWN BIT(31) +#define ATT_IOMEM BIT(30) +/* I = [0:7] */ +#define ATT_CORE_MASK 0xffff +#define ATT_CORE (I ) BIT((I))struct imx_rproc {struct device *dev;
@@ -98,11 +101,25 @@ struct imx_rproc {struct notifier_block proc_nb;u32 rproc_pt;u32 rsrc; +u32 reg;int num_pd;struct device **pd_dev;struct device_link **pd_dev_link; }; +static const struct imx_rproc_att imx_rproc_att_imx8qm[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML */ + {0x1FFE0000 ,0x34FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x1FFE0000 ,0x38FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* TCMU */ + {0x20000000 ,0x35000000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x20000000 ,0x39000000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, +}; +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {/* dev addr , sys addr , size , flags */ {0x08000000 ,0x08000000 ,0x10000000 ,0 },
@@ -260,6 +277,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8ulp = { .method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = { + .att = imx_rproc_att_imx8qm, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qm), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { .att = imx_rproc_att_imx8qxp, .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp),
@@ -310,7 +333,10 @@ static int imx_rproc_start(struct rproc *rproc) ret = res.a0;break ;case IMX_RPROC_SCU_API : - ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 ); +if (priv->reg) + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x38fe0000 ); +else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 );break ;default :return -EOPNOTSUPP ;
@@ -342,7 +368,10 @@ static int imx_rproc_stop(struct rproc *rproc)dev_info (dev,"Not in wfi, force stopped\n" );break ;case IMX_RPROC_SCU_API : - ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 ); +if (priv->reg) + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x38fe0000 ); +else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 );break ;default :return -EOPNOTSUPP ;
@@ -364,6 +393,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,for (i =0 ; i < dcfg->att_size; i++) {const struct imx_rproc_att *att = &dcfg->att[i]; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (da >= att->da && da + len < att->da + att->size) {unsigned int offset = da - att->da;
@@ -594,6 +628,11 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,if (!(att->flags &ATT_OWN ))continue ; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (b >=IMX_RPROC_MEM_MAX )break ;
@@ -809,6 +848,13 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)return ret; } + priv->reg =of_get_cpu_hwid (dev->of_node,0 ); +if (priv->reg == ~0U ) + priv->reg =0 ; + +if (priv->reg >1 ) +return -EINVAL ; + priv->has_clk = false;/* * If Mcore resource is not owned by Acore partition, It is kicked by ROM,
@@ -1005,6 +1051,7 @@ static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, + { .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, };
Signature · 1 line
2.25.1
Mathieu Poirier
maintainerRe: [PATCH 8/9] remoteproc: imx_rproc: support i.MX8QM
Quoted 6 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Most logic are same as i.MX8QXP, but i.MX8QM has two general purpose M4 cores:
Use the lower 16 bits specifying core, higher 16 bits for flags. The 2nd core has different start address from SCFW view
Are the cores running independently or in lockstep? This is relevant information that should be in the changelog. The above is an implementation detail that should be added as comments in the code.
Quoted 11 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 55 +++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)drivers/remoteproc/imx_rproc.c +0
-0
drivers/remoteproc/imx_rproc.c struct imx_rproc_mem { · line 81
Quoted 7 lines
drivers/remoteproc/imx_rproc.c +2
-2@@ -77,8 +77,11 @@ struct imx_rproc_mem {/* att flags */ /* M4 own area. Can be mapped at probe */ -#define ATT_OWN BIT(1) -#define ATT_IOMEM BIT(2) +#define ATT_OWN BIT(31) +#define ATT_IOMEM BIT(30)
ATT_OWN was defined in 2017 and has had the same value since. ATT_IOMEM was introduced by this commit [1] (that you signed off on), which as supposed to be a fix for another commit.
Now, overnight, both bitfields are changed without any explanation other than a cryptic comments. What about all the other platforms that previously used those bitfields - was this change tested on those as well?
I will stop here with this patchset - it needs to much work for me to continue reviewing it.
Thanks,
Mathieu
[1]. 91bb26637353 remoteproc: imx_rproc: Fix TCM io memory type
Quoted 118 lines
drivers/remoteproc/imx_rproc.c +49
-2+/* I = [0:7] */ +#define ATT_CORE_MASK 0xffff +#define ATT_CORE (I ) BIT((I))struct imx_rproc {struct device *dev;@@ -98,11 +101,25 @@ struct imx_rproc {struct notifier_block proc_nb;u32 rproc_pt;u32 rsrc; +u32 reg;int num_pd;struct device **pd_dev;struct device_link **pd_dev_link; }; +static const struct imx_rproc_att imx_rproc_att_imx8qm[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML */ + {0x1FFE0000 ,0x34FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x1FFE0000 ,0x38FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* TCMU */ + {0x20000000 ,0x35000000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x20000000 ,0x39000000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, +}; +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {/* dev addr , sys addr , size , flags */ {0x08000000 ,0x08000000 ,0x10000000 ,0 },@@ -260,6 +277,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8ulp = { .method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = { + .att = imx_rproc_att_imx8qm, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qm), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { .att = imx_rproc_att_imx8qxp, .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp),@@ -310,7 +333,10 @@ static int imx_rproc_start(struct rproc *rproc) ret = res.a0;break ;case IMX_RPROC_SCU_API : - ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 ); +if (priv->reg) + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x38fe0000 ); +else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true,0x34fe0000 );break ;default :return -EOPNOTSUPP ;@@ -342,7 +368,10 @@ static int imx_rproc_stop(struct rproc *rproc)dev_info (dev,"Not in wfi, force stopped\n" );break ;case IMX_RPROC_SCU_API : - ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 ); +if (priv->reg) + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x38fe0000 ); +else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false,0x34fe0000 );break ;default :return -EOPNOTSUPP ;@@ -364,6 +393,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,for (i =0 ; i < dcfg->att_size; i++) {const struct imx_rproc_att *att = &dcfg->att[i]; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (da >= att->da && da + len < att->da + att->size) {unsigned int offset = da - att->da;@@ -594,6 +628,11 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,if (!(att->flags &ATT_OWN ))continue ; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (b >=IMX_RPROC_MEM_MAX )break ;@@ -809,6 +848,13 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)return ret; } + priv->reg =of_get_cpu_hwid (dev->of_node,0 ); +if (priv->reg == ~0U ) + priv->reg =0 ; + +if (priv->reg >1 ) +return -EINVAL ; + priv->has_clk = false;/* * If Mcore resource is not owned by Acore partition, It is kicked by ROM, @@ -1005,6 +1051,7 @@ static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, + { .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, };Signature · 1 line
2.25.1
RE: [PATCH 8/9] remoteproc: imx_rproc: support i.MX8QM
Quoted 11 lines
Subject: Re: [PATCH 8/9] remoteproc:
imx_rproc: support i.MX8QMQuoted 6 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Most logic are same as i.MX8QXP, but i.MX8QM has two general purpose M4 cores:
Use the lower 16 bits specifying core, higher 16 bits for flags. The 2nd core has different start address from SCFW viewAre the cores running independently or in lockstep?
Independetly.
This is relevant
Quoted 2 lines
information that should be in the changelog. The above is an implementation detail that should be added as comments in the code.
Fix in V2.
Quoted 26 lines
Quoted 14 lines
Signed-off-by Peng Fan <[email protected]>--- drivers/remoteproc/imx_rproc.c | 55 +++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/remoteproc/imx_rproc.cindex09d2a06e5ed6..7bc274fbce9f100644drivers/remoteproc/imx_rproc.c struct imx_rproc_mem { · line 81
Quoted 7 lines
drivers/remoteproc/imx_rproc.c +2
-2@@ -77,8 +77,11 @@ struct imx_rproc_mem {/* att flags */ /* M4 own area. Can be mapped at probe */ -#define ATT_OWN BIT(1) -#define ATT_IOMEM BIT(2) +#define ATT_OWN BIT(31) +#define ATT_IOMEM BIT(30)
ATT_OWNwas defined in 2017 and has had the same value since.ATT_IOMEMwas introduced by this commit [1] (that you signed off on), which as supposed to be a fix for another commit.
Quoted 3 lines
Now, overnight, both bitfields are changed without any explanation other than a cryptic comments. What about all the other platforms that previously used those bitfields - was this change tested on those as well?
Yes. Actually in NXP downstream, the new bit definition has been used for quite some time and tested on many platforms.
The bit change is just to make code easy to get it is remote core0 or remote core1, no function impact to other platforms.
I'll update in V2.
Thanks,
Peng.
Quoted 137 lines
I will stop here with this patchset - it needs to much work for me to continue reviewing it.
Thanks,
Mathieu[1].
91bb26637353remoteproc:imx_rproc: Fix TCM io memory typeQuoted 45 lines
drivers/remoteproc/imx_rproc.c +16
-0+/* I = [0:7] */ +#define ATT_CORE_MASK 0xffff +#define ATT_CORE (I ) BIT((I))struct imx_rproc {struct device *dev;@@ -98,11 +101,25 @@ struct imx_rproc {struct notifier_block proc_nb;u32 rproc_pt;u32 rsrc; +u32 reg;int num_pd;struct device **pd_dev;struct device_link **pd_dev_link; }; +static const struct imx_rproc_att imx_rproc_att_imx8qm[] = { +/* dev addr , sys addr , size , flags */ + {0x08000000 ,0x08000000 ,0x10000000 ,0 }, +/* TCML */ + {0x1FFE0000 ,0x34FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x1FFE0000 ,0x38FE0000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* TCMU */ + {0x20000000 ,0x35000000 ,0x00020000 ,ATT_OWN |ATT_CORE (0 )}, + {0x20000000 ,0x39000000 ,0x00020000 ,ATT_OWN |ATT_CORE (1 )}, +/* DDR (Data) */ + {0x80000000 ,0x80000000 ,0x60000000 ,0 }, }; +static const struct imx_rproc_att imx_rproc_att_imx8qxp[] = {/* dev addr , sys addr , size , flags */ { 0x08000000, 0x08000000, 0x10000000, 0}, @@ -260,6 +277,12 @@static const struct
imx_rproc_dcfgimx_rproc_cfg_imx8ulp= {drivers/remoteproc/imx_rproc.c +6
-0.method = IMX_RPROC_NONE, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qm = { + .att = imx_rproc_att_imx8qm, + .att_size =ARRAY_SIZE (imx_rproc_att_imx8qm), + .method =IMX_RPROC_SCU_API , +}; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8qxp = { .att = imx_rproc_att_imx8qxp, .att_size =ARRAY_SIZE (imx_rproc_att_imx8qxp),drivers/remoteproc/imx_rproc.c static int imx_rproc_start(struct rproc *rproc) · line 313
Quoted 4 lines
drivers/remoteproc/imx_rproc.c +0
-1@@ -310,7 +333,10 @@ static int imx_rproc_start(struct rproc *rproc) ret = res.a0;break ;case IMX_RPROC_SCU_API : - ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc, true,
0x34fe0000);drivers/remoteproc/imx_rproc.c static int imx_rproc_start(struct rproc *rproc) · line 337
Quoted 2 lines
drivers/remoteproc/imx_rproc.c +2
-0+if (priv->reg) + ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc, true,
0x38fe0000);drivers/remoteproc/imx_rproc.c static int imx_rproc_stop(struct rproc *rproc) · line 345
Quoted 11 lines
drivers/remoteproc/imx_rproc.c +3
-1+else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, true, +0x34fe0000 );break ;default :return -EOPNOTSUPP ;@@ -342,7 +368,10 @@ static int imx_rproc_stop(struct rproc *rproc)dev_info (dev,"Not in wfi, force stopped\n" );break ;case IMX_RPROC_SCU_API : - ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc, false,
0x34fe0000);drivers/remoteproc/imx_rproc.c static int imx_rproc_stop(struct rproc *rproc) · line 372
Quoted 2 lines
drivers/remoteproc/imx_rproc.c +2
-0+if (priv->reg) + ret = imx_sc_pm_cpu_start(priv->ipc_handle, priv->rsrc, false,
0x38fe0000);drivers/remoteproc/imx_rproc.c static int imx_rproc_da_to_sys(struct imx_rproc
Quoted 7 lines
drivers/remoteproc/imx_rproc.c +3
-0+else + ret =imx_sc_pm_cpu_start (priv->ipc_handle, priv->rsrc, false, +0x34fe0000 );break ;default :return -EOPNOTSUPP ;@@ -364,6 +393,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc*priv, u64 da,
drivers/remoteproc/imx_rproc.c static int imx_rproc_addr_init(struct imx_rproc
Quoted 12 lines
drivers/remoteproc/imx_rproc.c +5
-0for (i =0 ; i < dcfg->att_size; i++) {const struct imx_rproc_att *att = &dcfg->att[i]; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (da >= att->da && da + len < att->da + att->size) {unsigned int offset = da - att->da;@@ -594,6 +628,11 @@ static int imx_rproc_addr_init(struct imx_rproc*priv,
drivers/remoteproc/imx_rproc.c static int imx_rproc_detect_mode(struct
Quoted 12 lines
drivers/remoteproc/imx_rproc.c +5
-0if (!(att->flags &ATT_OWN ))continue ; +if (att->flags &ATT_CORE_MASK ) { +if (!((BIT (priv->reg)) & (att->flags &ATT_CORE_MASK ))) +continue ; + } +if (b >=IMX_RPROC_MEM_MAX )break ;@@ -809,6 +848,13 @@ static int imx_rproc_detect_mode(struct
imx_rproc*priv)Quoted 13 lines
drivers/remoteproc/imx_rproc.c +7
-0return ret; } + priv->reg =of_get_cpu_hwid (dev->of_node,0 ); +if (priv->reg == ~0U ) + priv->reg =0 ; + +if (priv->reg >1 ) +return -EINVAL ; + priv->has_clk = false;/* * If Mcore resource is not owned by Acore partition, It is kicked Quoted 1 line
by ROM, @@ -1005,6 +1051,7 @@ static const struct
of_device_idimx_rproc_of_match[] = {
Quoted 10 lines
drivers/remoteproc/imx_rproc.c +1
-1{ .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn }, { .compatible = "fsl,imx8qxp-cm4", .data = &imx_rproc_cfg_imx8qxp }, + { .compatible = "fsl,imx8qm-cm4", .data = &imx_rproc_cfg_imx8qm }, { .compatible = "fsl,imx8ulp-cm33", .data = &imx_rproc_cfg_imx8ulp }, {}, }; --2.25.1
PATCH 9/9 remoteproc: imx_rproc: request mbox channel later
In reply to Peng Fan (OSS)From: Peng Fan <[email protected]>
It is possible that when remote processor crash, the communication channel will be broken with garbage value in mailbox, such as when Linux is issuing a message through mailbox, remote processor crashes, we need free & rebuild the mailbox channels to make sure no garbage value in mailbox channels.
So move the request/free to start/stop for managing remote procesosr in Linux, move to attach/detach for remote processor is out of control of Linux.
--- drivers/remoteproc/imx_rproc.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
drivers/remoteproc/imx_rproc.c +19 -11
@@ -83,6 +83,9 @@ struct imx_rproc_mem {#define ATT_CORE_MASK 0xffff#define ATT_CORE (I ) BIT((I)) +static int imx_rproc_xtr_mbox_init (struct rproc *rproc); +static void imx_rproc_free_mbox (struct rproc *rproc); +struct imx_rproc {struct device *dev;struct regmap *regmap;
@@ -323,6 +326,10 @@ static int imx_rproc_start(struct rproc *rproc)struct arm_smccc_res res;int ret; + ret =imx_rproc_xtr_mbox_init (rproc); +if (ret) +return ret; +switch (dcfg->method) {case IMX_RPROC_MMIO : ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
@@ -379,6 +386,8 @@ static int imx_rproc_stop(struct rproc *rproc)if (ret)dev_err (dev,"Failed to stop remote core\n" ); +else +imx_rproc_free_mbox (rproc);return ret; }
@@ -558,11 +567,12 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)static int imx_rproc_attach (struct rproc *rproc) { -return 0 ; +return imx_rproc_xtr_mbox_init (rproc); }static int imx_rproc_detach (struct rproc *rproc) { +imx_rproc_free_mbox (rproc);return 0 ; }
@@ -716,6 +726,9 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc)struct mbox_client *cl;int ret; +if (priv->tx_ch && priv->rx_ch) +return 0 ; +if (!of_get_property (dev->of_node,"mbox-names" ,NULL ))return 0 ;
@@ -750,6 +763,8 @@ static void imx_rproc_free_mbox(struct rproc *rproc)mbox_free_channel (priv->tx_ch);mbox_free_channel (priv->rx_ch); + priv->tx_ch =NULL ; + priv->rx_ch =NULL ; } static int imx_rproc_partition_notify(struct notifier_block *nb,
@@ -985,23 +1000,19 @@ static int imx_rproc_probe(struct platform_device *pdev) goto err_put_rproc; } - ret =imx_rproc_xtr_mbox_init (rproc); -if (ret) - goto err_put_wkq; - ret =imx_rproc_addr_init (priv, pdev);if (ret) {dev_err (dev,"failed on imx_rproc_addr_init\n" ); - goto err_put_mbox; + goto err_put_wkq; } ret =imx_rproc_detect_mode (priv);if (ret) - goto err_put_mbox; + goto err_put_wkq; ret =imx_rproc_clk_enable (priv);if (ret) - goto err_put_mbox; + goto err_put_wkq;INIT_WORK (&priv->rproc_work, imx_rproc_vq_work);
@@ -1018,8 +1029,6 @@ static int imx_rproc_probe(struct platform_device *pdev) err_put_clk:clk_disable_unprepare (priv->clk); -err_put_mbox: -imx_rproc_free_mbox (rproc); err_put_wkq:destroy_workqueue (priv->workqueue); err_put_rproc:
@@ -1035,7 +1044,6 @@ static int imx_rproc_remove(struct platform_device *pdev)clk_disable_unprepare (priv->clk);rproc_del (rproc); -imx_rproc_free_mbox (rproc);destroy_workqueue (priv->workqueue);rproc_free (rproc);
Signature · 1 line
2.25.1
Hi,
Quoted 17 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
If there is a resource table device tree node, use the address as the resource table address, otherwise use the
address(where .resource_table section loaded)inside the Cortex-M elf file.And there is an update in NXP SDK that Resource Domain Control(RDC) enabled to protect TCM, linux not able to write the TCM space when updating resource table status and cause kernel dump. So use the address from device tree could avoid kernel dump.
Note: NXP M4 SDK not check resource table update, so it does not matter use whether resource table address specified in elf file or in device tree. But to reflect the fact that if people specific resource table address in device tree, it means people are aware and going to use it, not the address specified in elf file.
Quoted 5 lines
Signed-off-by Peng Fan <[email protected]>---
V2:
Update commit message
What is the status of this patch?
Regards,
Marco
Quoted 39 lines
drivers/remoteproc/imx_rproc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/remoteproc/imx_rproc.c +12
-1@@ -499,6 +499,17 @@ static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc *rprocreturn (struct resource_table *)priv->rsc_table; } +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->rsc_table) +return (struct resource_table *)priv->rsc_table; + +return rproc_elf_find_loaded_rsc_table (rproc, fw); +} +static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach,@@ -508,7 +519,7 @@ static const struct rproc_ops imx_rproc_ops = { .da_to_va = imx_rproc_da_to_va, .load = rproc_elf_load_segments, .parse_fw = imx_rproc_parse_fw, - .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table, .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr,Signature · 1 line
2.25.1
Mathieu Poirier
maintainerQuoted 21 lines · Marco Felsch
Hi,
Quoted 17 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
If there is a resource table device tree node, use the address as the resource table address, otherwise use the
address(where .resource_table section loaded)inside the Cortex-M elf file.And there is an update in NXP SDK that Resource Domain Control(RDC) enabled to protect TCM, linux not able to write the TCM space when updating resource table status and cause kernel dump. So use the address from device tree could avoid kernel dump.
Note: NXP M4 SDK not check resource table update, so it does not matter use whether resource table address specified in elf file or in device tree. But to reflect the fact that if people specific resource table address in device tree, it means people are aware and going to use it, not the address specified in elf file.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Peng Fan <[email protected]>---
V2:
Update commit messageWhat is the status of this patch?
That one has obviously slipped through the cracks... It boggles my mind that nobody, i.e Peng, has reminded me of it, which raises obvious doubts about the real necessity of the patch.
Marco - do you need this patch and if so, are you in a position to provide a Tested-by?
Quoted 42 lines
Regards,
MarcoQuoted 39 lines
drivers/remoteproc/imx_rproc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/remoteproc/imx_rproc.c +12
-2@@ -499,6 +499,17 @@ static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc *rprocreturn (struct resource_table *)priv->rsc_table; } +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->rsc_table) +return (struct resource_table *)priv->rsc_table; + +return rproc_elf_find_loaded_rsc_table (rproc, fw); +} +static const struct rproc_ops imx_rproc_ops = { .prepare = imx_rproc_prepare, .attach = imx_rproc_attach,@@ -508,7 +519,7 @@ static const struct rproc_ops imx_rproc_ops = { .da_to_va = imx_rproc_da_to_va, .load = rproc_elf_load_segments, .parse_fw = imx_rproc_parse_fw, - .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .find_loaded_rsc_table = imx_rproc_elf_find_loaded_rsc_table, .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr, --2.25.1