Linux-remoteproc Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V2 0/4] remoteproc: imx: support remote cores booted early
@ 2021-03-30  5:30 peng.fan
  2021-03-30  5:30 ` [PATCH V2 1/4] remoteproc: imx: add missing of_node_put peng.fan
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: peng.fan @ 2021-03-30  5:30 UTC (permalink / raw)
  To: ohad, bjorn.andersson, mathieu.poirier, o.rempel
  Cc: shawnguo, s.hauer, kernel, festevam, linux-remoteproc,
	linux-arm-kernel, linux-kernel, Peng Fan

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

V2:
 Patch [1,3]/4 is new
 Patch 4/4: Update commit message, drop unneeded code that already implemented by core

This patchset is to support booted remote cores could be attached to linux.
- Add missing of_node_put to decrease device node refcount
- Enlarge IMX7D_RPROC_MEM_MAX because need more imx_rproc_mem, such as resource table.
- Following stm32 remoteproc practice, move memory parsing to rproc_ops
- Support attaching booted cores, by adding attach, get loaded resource table and etc.

Peng Fan (4):
  remoteproc: imx: add missing of_node_put
  remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX
  remoteproc: imx: move memory parsing to rproc_ops
  remoteproc: imx_rproc: support remote cores booted before Linux Kernel

 drivers/remoteproc/imx_rproc.c | 65 ++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 10 deletions(-)

-- 
2.30.0


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

* [PATCH V2 1/4] remoteproc: imx: add missing of_node_put
  2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
@ 2021-03-30  5:30 ` peng.fan
  2021-04-07 16:29   ` Mathieu Poirier
  2021-03-30  5:30 ` [PATCH V2 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX peng.fan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: peng.fan @ 2021-03-30  5:30 UTC (permalink / raw)
  To: ohad, bjorn.andersson, mathieu.poirier, o.rempel
  Cc: shawnguo, s.hauer, kernel, festevam, linux-remoteproc,
	linux-arm-kernel, linux-kernel, Peng Fan

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

After of_parse_phandle, we need of_node_put to decrease the refcount
of the device_node.

Reported-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6d3207ccbaef..077413319f58 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -459,6 +459,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 			return err;
 		}
 
+		of_node_put(node);
+
 		if (b >= IMX7D_RPROC_MEM_MAX)
 			break;
 
-- 
2.30.0


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

* [PATCH V2 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX
  2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
  2021-03-30  5:30 ` [PATCH V2 1/4] remoteproc: imx: add missing of_node_put peng.fan
@ 2021-03-30  5:30 ` peng.fan
  2021-03-30  5:30 ` [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops peng.fan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: peng.fan @ 2021-03-30  5:30 UTC (permalink / raw)
  To: ohad, bjorn.andersson, mathieu.poirier, o.rempel
  Cc: shawnguo, s.hauer, kernel, festevam, linux-remoteproc,
	linux-arm-kernel, linux-kernel, Peng Fan

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

8 is not enough when we need more, such as resource table for remote cores
that booted before Linux Kernel, so enlarge IMX7D_RPROC_MEM_MAX to 32.
And also rename it to IMX_RPROC_MEM_MAX which make more sense.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/remoteproc/imx_rproc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 077413319f58..b05aae0ad7a2 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -48,7 +48,7 @@
 					 | IMX6SX_SW_M4C_NON_SCLR_RST \
 					 | IMX6SX_SW_M4C_RST)
 
-#define IMX7D_RPROC_MEM_MAX		8
+#define IMX_RPROC_MEM_MAX		32
 
 /**
  * struct imx_rproc_mem - slim internal memory structure
@@ -88,7 +88,7 @@ struct imx_rproc {
 	struct regmap			*regmap;
 	struct rproc			*rproc;
 	const struct imx_rproc_dcfg	*dcfg;
-	struct imx_rproc_mem		mem[IMX7D_RPROC_MEM_MAX];
+	struct imx_rproc_mem		mem[IMX_RPROC_MEM_MAX];
 	struct clk			*clk;
 	struct mbox_client		cl;
 	struct mbox_chan		*tx_ch;
@@ -272,7 +272,7 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *i
 	if (imx_rproc_da_to_sys(priv, da, len, &sys))
 		return NULL;
 
-	for (i = 0; i < IMX7D_RPROC_MEM_MAX; i++) {
+	for (i = 0; i < IMX_RPROC_MEM_MAX; i++) {
 		if (sys >= priv->mem[i].sys_addr && sys + len <
 		    priv->mem[i].sys_addr +  priv->mem[i].size) {
 			unsigned int offset = sys - priv->mem[i].sys_addr;
@@ -425,7 +425,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 		if (!(att->flags & ATT_OWN))
 			continue;
 
-		if (b >= IMX7D_RPROC_MEM_MAX)
+		if (b >= IMX_RPROC_MEM_MAX)
 			break;
 
 		priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev,
@@ -461,7 +461,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
 		of_node_put(node);
 
-		if (b >= IMX7D_RPROC_MEM_MAX)
+		if (b >= IMX_RPROC_MEM_MAX)
 			break;
 
 		/* Not use resource version, because we might share region */
-- 
2.30.0


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

* [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops
  2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
  2021-03-30  5:30 ` [PATCH V2 1/4] remoteproc: imx: add missing of_node_put peng.fan
  2021-03-30  5:30 ` [PATCH V2 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX peng.fan
@ 2021-03-30  5:30 ` peng.fan
  2021-04-07 16:36   ` Mathieu Poirier
  2021-04-07 16:59   ` Mathieu Poirier
  2021-03-30  5:30 ` [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel peng.fan
  2021-04-14  2:20 ` [PATCH V2 0/4] remoteproc: imx: support remote cores booted early patchwork-bot+linux-remoteproc
  4 siblings, 2 replies; 10+ messages in thread
From: peng.fan @ 2021-03-30  5:30 UTC (permalink / raw)
  To: ohad, bjorn.andersson, mathieu.poirier, o.rempel
  Cc: shawnguo, s.hauer, kernel, festevam, linux-remoteproc,
	linux-arm-kernel, linux-kernel, Peng Fan

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

Use the rproc_ops::prepare() hook for doing memory resources
reallocation when reattach an remote procesor.

Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index b05aae0ad7a2..7cd09971d1a4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -317,7 +317,7 @@ static int imx_rproc_mem_release(struct rproc *rproc,
 	return 0;
 }
 
-static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+static int imx_rproc_prepare(struct rproc *rproc)
 {
 	struct imx_rproc *priv = rproc->priv;
 	struct device_node *np = priv->dev->of_node;
@@ -363,10 +363,7 @@ static int imx_rproc_parse_memory_regions(struct rproc *rproc)
 
 static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
 {
-	int ret = imx_rproc_parse_memory_regions(rproc);
-
-	if (ret)
-		return ret;
+	int ret;
 
 	ret = rproc_elf_load_rsc_table(rproc, fw);
 	if (ret)
@@ -399,6 +396,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
 }
 
 static const struct rproc_ops imx_rproc_ops = {
+	.prepare	= imx_rproc_prepare,
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
 	.kick		= imx_rproc_kick,
-- 
2.30.0


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

* [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel
  2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
                   ` (2 preceding siblings ...)
  2021-03-30  5:30 ` [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops peng.fan
@ 2021-03-30  5:30 ` peng.fan
  2021-04-07 17:03   ` Mathieu Poirier
  2021-04-14  2:20 ` [PATCH V2 0/4] remoteproc: imx: support remote cores booted early patchwork-bot+linux-remoteproc
  4 siblings, 1 reply; 10+ messages in thread
From: peng.fan @ 2021-03-30  5:30 UTC (permalink / raw)
  To: ohad, bjorn.andersson, mathieu.poirier, o.rempel
  Cc: shawnguo, s.hauer, kernel, festevam, linux-remoteproc,
	linux-arm-kernel, linux-kernel, Peng Fan

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

 - Add rsc_table to hold the resource table published by remote cores.
 - Add attach hook.
 - Add imx_rproc_get_loaded_rsc_table to get resource table published by
   remote processors.
 - Add imx_rproc_detect_mode to detect remote cores' working mode.

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

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 7cd09971d1a4..d6338872c6db 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -95,6 +95,7 @@ struct imx_rproc {
 	struct mbox_chan		*rx_ch;
 	struct work_struct		rproc_work;
 	struct workqueue_struct		*workqueue;
+	void __iomem			*rsc_table;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -395,8 +396,26 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
 			__func__, vqid, err);
 }
 
+static int imx_rproc_attach(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;
+
+	/* The resource table has already been mapped in imx_rproc_addr_init */
+	if (!priv->rsc_table)
+		return NULL;
+
+	*table_sz = SZ_1K;
+	return (struct resource_table *)priv->rsc_table;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
 	.prepare	= imx_rproc_prepare,
+	.attach		= imx_rproc_attach,
 	.start		= imx_rproc_start,
 	.stop		= imx_rproc_stop,
 	.kick		= imx_rproc_kick,
@@ -404,6 +423,7 @@ static const struct rproc_ops imx_rproc_ops = {
 	.load		= rproc_elf_load_segments,
 	.parse_fw	= imx_rproc_parse_fw,
 	.find_loaded_rsc_table = 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,
 };
@@ -470,6 +490,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 		}
 		priv->mem[b].sys_addr = res.start;
 		priv->mem[b].size = resource_size(&res);
+		if (!strcmp(node->name, "rsc_table"))
+			priv->rsc_table = priv->mem[b].cpu_addr;
 		b++;
 	}
 
@@ -536,6 +558,25 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
 	mbox_free_channel(priv->rx_ch);
 }
 
+static int imx_rproc_detect_mode(struct imx_rproc *priv)
+{
+	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+	struct device *dev = priv->dev;
+	int ret;
+	u32 val;
+
+	ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
+	if (ret) {
+		dev_err(dev, "Failed to read src\n");
+		return ret;
+	}
+
+	if (!(val & dcfg->src_stop))
+		priv->rproc->state = RPROC_DETACHED;
+
+	return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -590,6 +631,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
 		goto err_put_mbox;
 	}
 
+	ret = imx_rproc_detect_mode(priv);
+	if (ret)
+		goto err_put_mbox;
+
 	priv->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		dev_err(dev, "Failed to get clock\n");
-- 
2.30.0


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

* Re: [PATCH V2 1/4] remoteproc: imx: add missing of_node_put
  2021-03-30  5:30 ` [PATCH V2 1/4] remoteproc: imx: add missing of_node_put peng.fan
@ 2021-04-07 16:29   ` Mathieu Poirier
  0 siblings, 0 replies; 10+ messages in thread
From: Mathieu Poirier @ 2021-04-07 16:29 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, o.rempel, shawnguo, s.hauer, kernel,
	festevam, linux-remoteproc, linux-arm-kernel, linux-kernel,
	Peng Fan

On Tue, Mar 30, 2021 at 01:30:32PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> After of_parse_phandle, we need of_node_put to decrease the refcount
> of the device_node.
> 
> Reported-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 6d3207ccbaef..077413319f58 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -459,6 +459,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
>  			return err;
>  		}
>  
> +		of_node_put(node);
> +

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

>  		if (b >= IMX7D_RPROC_MEM_MAX)
>  			break;
>  
> -- 
> 2.30.0
> 

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

* Re: [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops
  2021-03-30  5:30 ` [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops peng.fan
@ 2021-04-07 16:36   ` Mathieu Poirier
  2021-04-07 16:59   ` Mathieu Poirier
  1 sibling, 0 replies; 10+ messages in thread
From: Mathieu Poirier @ 2021-04-07 16:36 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, o.rempel, shawnguo, s.hauer, kernel,
	festevam, linux-remoteproc, linux-arm-kernel, linux-kernel,
	Peng Fan

On Tue, Mar 30, 2021 at 01:30:34PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use the rproc_ops::prepare() hook for doing memory resources
> reallocation when reattach an remote procesor.
> 
> Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index b05aae0ad7a2..7cd09971d1a4 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -317,7 +317,7 @@ static int imx_rproc_mem_release(struct rproc *rproc,
>  	return 0;
>  }
>  
> -static int imx_rproc_parse_memory_regions(struct rproc *rproc)
> +static int imx_rproc_prepare(struct rproc *rproc)
>  {
>  	struct imx_rproc *priv = rproc->priv;
>  	struct device_node *np = priv->dev->of_node;
> @@ -363,10 +363,7 @@ static int imx_rproc_parse_memory_regions(struct rproc *rproc)
>  
>  static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
>  {
> -	int ret = imx_rproc_parse_memory_regions(rproc);
> -
> -	if (ret)
> -		return ret;
> +	int ret;
>  
>  	ret = rproc_elf_load_rsc_table(rproc, fw);
>  	if (ret)
> @@ -399,6 +396,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
>  }
>  
>  static const struct rproc_ops imx_rproc_ops = {
> +	.prepare	= imx_rproc_prepare,
>  	.start		= imx_rproc_start,
>  	.stop		= imx_rproc_stop,
>  	.kick		= imx_rproc_kick,
> -- 
> 2.30.0
> 

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

* Re: [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops
  2021-03-30  5:30 ` [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops peng.fan
  2021-04-07 16:36   ` Mathieu Poirier
@ 2021-04-07 16:59   ` Mathieu Poirier
  1 sibling, 0 replies; 10+ messages in thread
From: Mathieu Poirier @ 2021-04-07 16:59 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, o.rempel, shawnguo, s.hauer, kernel,
	festevam, linux-remoteproc, linux-arm-kernel, linux-kernel,
	Peng Fan

On Tue, Mar 30, 2021 at 01:30:34PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use the rproc_ops::prepare() hook for doing memory resources
> reallocation when reattach an remote procesor.

s/when reattach an remote/when reattaching a remote/

> 
> Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index b05aae0ad7a2..7cd09971d1a4 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -317,7 +317,7 @@ static int imx_rproc_mem_release(struct rproc *rproc,
>  	return 0;
>  }
>  
> -static int imx_rproc_parse_memory_regions(struct rproc *rproc)
> +static int imx_rproc_prepare(struct rproc *rproc)
>  {
>  	struct imx_rproc *priv = rproc->priv;
>  	struct device_node *np = priv->dev->of_node;
> @@ -363,10 +363,7 @@ static int imx_rproc_parse_memory_regions(struct rproc *rproc)
>  
>  static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
>  {
> -	int ret = imx_rproc_parse_memory_regions(rproc);
> -
> -	if (ret)
> -		return ret;
> +	int ret;
>  
>  	ret = rproc_elf_load_rsc_table(rproc, fw);
>  	if (ret)
> @@ -399,6 +396,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
>  }
>  
>  static const struct rproc_ops imx_rproc_ops = {
> +	.prepare	= imx_rproc_prepare,
>  	.start		= imx_rproc_start,
>  	.stop		= imx_rproc_stop,
>  	.kick		= imx_rproc_kick,
> -- 
> 2.30.0
> 

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

* Re: [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel
  2021-03-30  5:30 ` [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel peng.fan
@ 2021-04-07 17:03   ` Mathieu Poirier
  0 siblings, 0 replies; 10+ messages in thread
From: Mathieu Poirier @ 2021-04-07 17:03 UTC (permalink / raw)
  To: peng.fan
  Cc: ohad, bjorn.andersson, o.rempel, shawnguo, s.hauer, kernel,
	festevam, linux-remoteproc, linux-arm-kernel, linux-kernel,
	Peng Fan

On Tue, Mar 30, 2021 at 01:30:35PM +0800, peng.fan@oss.nxp.com wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
>  - Add rsc_table to hold the resource table published by remote cores.
>  - Add attach hook.
>  - Add imx_rproc_get_loaded_rsc_table to get resource table published by
>    remote processors.
>  - Add imx_rproc_detect_mode to detect remote cores' working mode.
>

This is describing _what_ is being done rather than _why_ it is done.

Moreover for patches 1 an 3 the subject line is tagged with "imx" while patches
2 and 4 have "imx_rproc".  I don't mind which one is used as long as it is
consistent.
 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 45 ++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 7cd09971d1a4..d6338872c6db 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -95,6 +95,7 @@ struct imx_rproc {
>  	struct mbox_chan		*rx_ch;
>  	struct work_struct		rproc_work;
>  	struct workqueue_struct		*workqueue;
> +	void __iomem			*rsc_table;
>  };
>  
>  static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
> @@ -395,8 +396,26 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
>  			__func__, vqid, err);
>  }
>  
> +static int imx_rproc_attach(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;
> +
> +	/* The resource table has already been mapped in imx_rproc_addr_init */
> +	if (!priv->rsc_table)
> +		return NULL;
> +
> +	*table_sz = SZ_1K;
> +	return (struct resource_table *)priv->rsc_table;
> +}
> +
>  static const struct rproc_ops imx_rproc_ops = {
>  	.prepare	= imx_rproc_prepare,
> +	.attach		= imx_rproc_attach,
>  	.start		= imx_rproc_start,
>  	.stop		= imx_rproc_stop,
>  	.kick		= imx_rproc_kick,
> @@ -404,6 +423,7 @@ static const struct rproc_ops imx_rproc_ops = {
>  	.load		= rproc_elf_load_segments,
>  	.parse_fw	= imx_rproc_parse_fw,
>  	.find_loaded_rsc_table = 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,
>  };
> @@ -470,6 +490,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
>  		}
>  		priv->mem[b].sys_addr = res.start;
>  		priv->mem[b].size = resource_size(&res);
> +		if (!strcmp(node->name, "rsc_table"))
> +			priv->rsc_table = priv->mem[b].cpu_addr;
>  		b++;
>  	}
>  
> @@ -536,6 +558,25 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
>  	mbox_free_channel(priv->rx_ch);
>  }
>  
> +static int imx_rproc_detect_mode(struct imx_rproc *priv)
> +{
> +	const struct imx_rproc_dcfg *dcfg = priv->dcfg;
> +	struct device *dev = priv->dev;
> +	int ret;
> +	u32 val;
> +
> +	ret = regmap_read(priv->regmap, dcfg->src_reg, &val);
> +	if (ret) {
> +		dev_err(dev, "Failed to read src\n");
> +		return ret;
> +	}
> +
> +	if (!(val & dcfg->src_stop))
> +		priv->rproc->state = RPROC_DETACHED;
> +
> +	return 0;
> +}
> +
>  static int imx_rproc_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -590,6 +631,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
>  		goto err_put_mbox;
>  	}
>  
> +	ret = imx_rproc_detect_mode(priv);
> +	if (ret)
> +		goto err_put_mbox;
> +

With the above:

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

>  	priv->clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(priv->clk)) {
>  		dev_err(dev, "Failed to get clock\n");
> -- 
> 2.30.0
> 

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

* Re: [PATCH V2 0/4] remoteproc: imx: support remote cores booted early
  2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
                   ` (3 preceding siblings ...)
  2021-03-30  5:30 ` [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel peng.fan
@ 2021-04-14  2:20 ` patchwork-bot+linux-remoteproc
  4 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+linux-remoteproc @ 2021-04-14  2:20 UTC (permalink / raw)
  To: Peng Fan; +Cc: linux-remoteproc

Hello:

This series was applied to andersson/remoteproc.git (refs/heads/for-next):

On Tue, 30 Mar 2021 13:30:31 +0800 you wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> V2:
>  Patch [1,3]/4 is new
>  Patch 4/4: Update commit message, drop unneeded code that already implemented by core
> 
> This patchset is to support booted remote cores could be attached to linux.
> - Add missing of_node_put to decrease device node refcount
> - Enlarge IMX7D_RPROC_MEM_MAX because need more imx_rproc_mem, such as resource table.
> - Following stm32 remoteproc practice, move memory parsing to rproc_ops
> - Support attaching booted cores, by adding attach, get loaded resource table and etc.
> 
> [...]

Here is the summary with links:
  - [V2,1/4] remoteproc: imx: add missing of_node_put
    https://git.kernel.org/andersson/remoteproc/c/6e962bfe56b9
  - [V2,2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX
    https://git.kernel.org/andersson/remoteproc/c/f638a19775ae
  - [V2,3/4] remoteproc: imx: move memory parsing to rproc_ops
    https://git.kernel.org/andersson/remoteproc/c/10a3d4079eae
  - [V2,4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel
    https://git.kernel.org/andersson/remoteproc/c/5e4c1243071d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, back to index

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30  5:30 [PATCH V2 0/4] remoteproc: imx: support remote cores booted early peng.fan
2021-03-30  5:30 ` [PATCH V2 1/4] remoteproc: imx: add missing of_node_put peng.fan
2021-04-07 16:29   ` Mathieu Poirier
2021-03-30  5:30 ` [PATCH V2 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX peng.fan
2021-03-30  5:30 ` [PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops peng.fan
2021-04-07 16:36   ` Mathieu Poirier
2021-04-07 16:59   ` Mathieu Poirier
2021-03-30  5:30 ` [PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel peng.fan
2021-04-07 17:03   ` Mathieu Poirier
2021-04-14  2:20 ` [PATCH V2 0/4] remoteproc: imx: support remote cores booted early patchwork-bot+linux-remoteproc

Linux-remoteproc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-remoteproc/0 linux-remoteproc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-remoteproc linux-remoteproc/ https://lore.kernel.org/linux-remoteproc \
		linux-remoteproc@vger.kernel.org
	public-inbox-index linux-remoteproc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-remoteproc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git