Skip to contentSkip to conversation

remoteproc: stm32: Add support for attaching to M4

PATCH Applied Mathieu Poirier 3 participants 15 messages Jul 14, 2020 – Jul 22, 2020

Subsystems (2)
lore
Share & tools
lore

Mathieu Poirier

author maintainer
#0 lore raw

v6 cover remoteproc: stm32: Add support for attaching to M4

This set applies on top of [1] and refactors the STM32 platform code in order to attach to the M4 remote processor when it has been started by the boot loader.

New to V6:
1) Removed extra newline in patch 06.
2) Re-worked title and changelog of patch 08 to better reflect what is done by the patch.

Tested on ST's mp157c development board.

Thanks,
Mathieu

[1].https://patchwork.kernel.org/project/linux-remoteproc/list/?series=318275

Mathieu Poirier (11):
remoteproc: stm32: Decouple rproc from memory translation
remoteproc: stm32: Request IRQ with platform device
remoteproc: stm32: Decouple rproc from DT parsing
remoteproc: stm32: Remove memory translation from DT parsing
remoteproc: stm32: Parse syscon that will manage M4 synchronisation
remoteproc: stm32: Properly set co-processor state when attaching
remoteproc: Make function rproc_resource_cleanup() public
remoteproc: stm32: Parse memory regions when attaching to M4
remoteproc: stm32: Properly handle the resource table when attaching
remoteproc: stm32: Introduce new attach() operation
remoteproc: stm32: Update M4 state in stm32_rproc_stop()

 drivers/remoteproc/remoteproc_core.c |   3 +-
 drivers/remoteproc/stm32_rproc.c     | 214 ++++++++++++++++++++++++---
 include/linux/remoteproc.h           |   1 +
 3 files changed, 198 insertions(+), 20 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH v6 1/11 remoteproc: stm32: Decouple rproc from memory translation

Remove the remote processor from the process of parsing the memory ranges since there is no correlation between them.

---
 drivers/remoteproc/stm32_rproc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/remoteproc/stm32_rproc.c +4 -4
index 062797a447c6..2973ba201c1d 100644
@@ -128,10 +128,10 @@ static int stm32_rproc_mem_release(struct rproc *rproc,
 	return 0;
 }
 
-static int stm32_rproc_of_memory_translations(struct rproc *rproc)
+static int stm32_rproc_of_memory_translations(struct platform_device *pdev,
+					      struct stm32_rproc *ddata)
 {
-	struct device *parent, *dev = rproc->dev.parent;
-	struct stm32_rproc *ddata = rproc->priv;
+	struct device *parent, *dev = &pdev->dev;
 	struct device_node *np;
 	struct stm32_rproc_mem *p_mems;
 	struct stm32_rproc_mem_ranges *mem_range;
@@ -607,7 +607,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 
 	rproc->auto_boot = of_property_read_bool(np, "st,auto-boot");
 
-	return stm32_rproc_of_memory_translations(rproc);
+	return stm32_rproc_of_memory_translations(pdev, ddata);
 }
 
 static int stm32_rproc_probe(struct platform_device *pdev)
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH v6 2/11 remoteproc: stm32: Request IRQ with platform device

In reply to Mathieu Poirier

Request IRQ with platform device rather than remote proc in order to call stm32_rproc_parse_dt() before rproc_alloc(). That way we can know whether we need to synchronise with the MCU or not.

---
 drivers/remoteproc/stm32_rproc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/remoteproc/stm32_rproc.c +3 -2
index 2973ba201c1d..c00f60d42ab6 100644
@@ -262,7 +262,8 @@ static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
 
 static irqreturn_t stm32_rproc_wdg(int irq, void *data)
 {
-	struct rproc *rproc = data;
+	struct platform_device *pdev = data;
+	struct rproc *rproc = platform_get_drvdata(pdev);
 
 	rproc_report_crash(rproc, RPROC_WATCHDOG);
 
@@ -554,7 +555,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 
 	if (irq > 0) {
 		err = devm_request_irq(dev, irq, stm32_rproc_wdg, 0,
-				       dev_name(dev), rproc);
+				       dev_name(dev), pdev);
 		if (err) {
 			dev_err(dev, "failed to request wdg irq\n");
 			return err;
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH v6 3/11 remoteproc: stm32: Decouple rproc from DT parsing

In reply to Mathieu Poirier

Remove the remote processor from the process of parsing the device tree since (1) there is no correlation between them and (2) to use the information that was gathered to make a decision on whether to synchronise with the M4 or not.

---
 drivers/remoteproc/stm32_rproc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/remoteproc/stm32_rproc.c +12 -11
index c00f60d42ab6..cbba995a80a2 100644
@@ -539,12 +539,11 @@ static int stm32_rproc_get_syscon(struct device_node *np, const char *prop,
 	return err;
 }
 
-static int stm32_rproc_parse_dt(struct platform_device *pdev)
+static int stm32_rproc_parse_dt(struct platform_device *pdev,
+				struct stm32_rproc *ddata, bool *auto_boot)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct rproc *rproc = platform_get_drvdata(pdev);
-	struct stm32_rproc *ddata = rproc->priv;
 	struct stm32_syscon tz;
 	unsigned int tzen;
 	int err, irq;
@@ -590,7 +589,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 
 	err = regmap_read(tz.map, tz.reg, &tzen);
 	if (err) {
-		dev_err(&rproc->dev, "failed to read tzen\n");
+		dev_err(dev, "failed to read tzen\n");
 		return err;
 	}
 	ddata->secured_soc = tzen & tz.mask;
@@ -606,7 +605,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev)
 	if (err)
 		dev_info(dev, "failed to get pdds\n");
 
-	rproc->auto_boot = of_property_read_bool(np, "st,auto-boot");
+	*auto_boot = of_property_read_bool(np, "st,auto-boot");
 
 	return stm32_rproc_of_memory_translations(pdev, ddata);
 }
@@ -627,9 +626,15 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	if (!rproc)
 		return -ENOMEM;
 
+	ddata = rproc->priv;
+
 	rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE);
+
+	ret = stm32_rproc_parse_dt(pdev, ddata, &rproc->auto_boot);
+	if (ret)
+		goto free_rproc;
+
 	rproc->has_iommu = false;
-	ddata = rproc->priv;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {
 		dev_err(dev, "cannot create workqueue\n");
@@ -639,13 +644,9 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rproc);
 
-	ret = stm32_rproc_parse_dt(pdev);
-	if (ret)
-		goto free_wkq;
-
 	ret = stm32_rproc_request_mbox(rproc);
 	if (ret)
-		goto free_rproc;
+		goto free_wkq;
 
 	ret = rproc_add(rproc);
 	if (ret)
Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH v6 4/11 remoteproc: stm32: Remove memory translation from DT parsing

In reply to Mathieu Poirier

Other than one has to be done after the other, there is no correlation between memory translation and DT parsing. As such move function stm32_rproc_of_memory_translations() to stm32_rproc_probe() so that stm32_rproc_parse_dt() can be extended to look for attach bindings in a clean way.

---
 drivers/remoteproc/stm32_rproc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +5 -1
index cbba995a80a2..986f34a336a7 100644
@@ -607,7 +607,7 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev,
 
 	*auto_boot = of_property_read_bool(np, "st,auto-boot");
 
-	return stm32_rproc_of_memory_translations(pdev, ddata);
+	return 0;
 }
 
 static int stm32_rproc_probe(struct platform_device *pdev)
@@ -634,6 +634,10 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	if (ret)
 		goto free_rproc;
 
+	ret = stm32_rproc_of_memory_translations(pdev, ddata);
+	if (ret)
+		goto free_rproc;
+
 	rproc->has_iommu = false;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {
Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH v6 5/11 remoteproc: stm32: Parse syscon that will manage M4 synchronisation

In reply to Mathieu Poirier

Get from the DT the syncon to probe the state of the remote processor and the location of the resource table.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/remoteproc/stm32_rproc.c +26 -0
index 986f34a336a7..961a53f67ec5 100644
@@ -71,6 +71,8 @@ struct stm32_rproc {
 	struct reset_control *rst;
 	struct stm32_syscon hold_boot;
 	struct stm32_syscon pdds;
+	struct stm32_syscon m4_state;
+	struct stm32_syscon rsctbl;
 	int wdg_irq;
 	u32 nb_rmems;
 	struct stm32_rproc_mem *rmems;
@@ -607,6 +609,30 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev,
 
 	*auto_boot = of_property_read_bool(np, "st,auto-boot");
 
+	/*
+	 * See if we can check the M4 status, i.e if it was started
+	 * from the boot loader or not.
+	 */
+	err = stm32_rproc_get_syscon(np, "st,syscfg-m4-state",
+				     &ddata->m4_state);
+	if (err) {
+		/* remember this */
+		ddata->m4_state.map = NULL;
+		/* no coprocessor state syscon (optional) */
+		dev_warn(dev, "m4 state not supported\n");
+
+		/* no need to go further */
+		return 0;
+	}
+
+	/* See if we can get the resource table */
+	err = stm32_rproc_get_syscon(np, "st,syscfg-rsc-tbl",
+				     &ddata->rsctbl);
+	if (err) {
+		/* no rsc table syscon (optional) */
+		dev_warn(dev, "rsc tbl syscon not supported\n");
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
author maintainer
#6 lore raw

PATCH v6 6/11 remoteproc: stm32: Properly set co-processor state when attaching

In reply to Mathieu Poirier

Introduce the required mechanic to set the state of the M4 in order to properly deal with scenarios where the co-processor has been started by another entity.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/remoteproc/stm32_rproc.c +31 -0
index 961a53f67ec5..f393f2503106 100644
@@ -39,6 +39,13 @@
 #define STM32_MBX_VQ1_ID	1
 #define STM32_MBX_SHUTDOWN	"shutdown"
 
+#define M4_STATE_OFF		0
+#define M4_STATE_INI		1
+#define M4_STATE_CRUN		2
+#define M4_STATE_CSTOP		3
+#define M4_STATE_STANDBY	4
+#define M4_STATE_CRASH		5
+
 struct stm32_syscon {
 	struct regmap *map;
 	u32 reg;
@@ -636,12 +643,29 @@ static int stm32_rproc_parse_dt(struct platform_device *pdev,
 	return 0;
 }
 
+static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata,
+				     unsigned int *state)
+{
+	/* See stm32_rproc_parse_dt() */
+	if (!ddata->m4_state.map) {
+		/*
+		 * We couldn't get the coprocessor's state, assume
+		 * it is not running.
+		 */
+		state = M4_STATE_OFF;
+		return 0;
+	}
+
+	return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state);
+}
+
 static int stm32_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct stm32_rproc *ddata;
 	struct device_node *np = dev->of_node;
 	struct rproc *rproc;
+	unsigned int state;
 	int ret;
 
 	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
@@ -664,6 +688,13 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	if (ret)
 		goto free_rproc;
 
+	ret = stm32_rproc_get_m4_status(ddata, &state);
+	if (ret)
+		goto free_rproc;
+
+	if (state == M4_STATE_CRUN)
+		rproc->state = RPROC_DETACHED;
+
 	rproc->has_iommu = false;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {
Signature · 1 line
2.25.1
author maintainer
#7 lore raw

PATCH v6 7/11 remoteproc: Make function rproc_resource_cleanup() public

In reply to Mathieu Poirier

Make function rproc_resource_cleanup() public so that it can be used by platform drivers when allocating resources to be used by a detached remote processor.

---
 drivers/remoteproc/remoteproc_core.c | 3 ++-
 include/linux/remoteproc.h           | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +2 -1
index 099c76ab198f..6e0f985e9c9a 100644
@@ -1271,7 +1271,7 @@ static void rproc_coredump_cleanup(struct rproc *rproc)
  * This function will free all resources acquired for @rproc, and it
  * is called whenever @rproc either shuts down or fails to boot.
  */
-static void rproc_resource_cleanup(struct rproc *rproc)
+void rproc_resource_cleanup(struct rproc *rproc)
 {
 	struct rproc_mem_entry *entry, *tmp;
 	struct rproc_debug_trace *trace, *ttmp;
@@ -1315,6 +1315,7 @@ static void rproc_resource_cleanup(struct rproc *rproc)
 
 	rproc_coredump_cleanup(rproc);
 }
+EXPORT_SYMBOL(rproc_resource_cleanup);
 
 static int rproc_start(struct rproc *rproc, const struct firmware *fw)
 {
include/linux/remoteproc.h +1 -0
index cf5e31556780..7c0567029f7c 100644
@@ -610,6 +610,7 @@ void rproc_put(struct rproc *rproc);
 int rproc_add(struct rproc *rproc);
 int rproc_del(struct rproc *rproc);
 void rproc_free(struct rproc *rproc);
+void rproc_resource_cleanup(struct rproc *rproc);
 
 struct rproc *devm_rproc_alloc(struct device *dev, const char *name,
 			       const struct rproc_ops *ops,
Signature · 1 line
2.25.1
author maintainer
#8 lore raw

PATCH v6 8/11 remoteproc: stm32: Parse memory regions when attaching to M4

In reply to Mathieu Poirier

Split function stm32_rproc_parse_fw() in two parts, the first one to parse the memory regions and the second one to load the resource table. That way parsing of the memory regions can be done without having do deal with the resource table when attaching to a remote processor.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/remoteproc/stm32_rproc.c +20 -3
index f393f2503106..2a1cccd8d311 100644
@@ -213,7 +213,7 @@ static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc,
 	return 0;
 }
 
-static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+static int stm32_rproc_parse_memory_regions(struct rproc *rproc)
 {
 	struct device *dev = rproc->dev.parent;
 	struct device_node *np = dev->of_node;
@@ -266,6 +266,16 @@ static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
 		index++;
 	}
 
+	return 0;
+}
+
+static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+	int ret = stm32_rproc_parse_memory_regions(rproc);
+
+	if (ret)
+		return ret;
+
 	return stm32_rproc_elf_load_rsc_table(rproc, fw);
 }
 
@@ -692,15 +702,20 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	if (ret)
 		goto free_rproc;
 
-	if (state == M4_STATE_CRUN)
+	if (state == M4_STATE_CRUN) {
 		rproc->state = RPROC_DETACHED;
 
+		ret = stm32_rproc_parse_memory_regions(rproc);
+		if (ret)
+			goto free_resources;
+	}
+
 	rproc->has_iommu = false;
 	ddata->workqueue = create_workqueue(dev_name(dev));
 	if (!ddata->workqueue) {
 		dev_err(dev, "cannot create workqueue\n");
 		ret = -ENOMEM;
-		goto free_rproc;
+		goto free_resources;
 	}
 
 	platform_set_drvdata(pdev, rproc);
@@ -719,6 +734,8 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	stm32_rproc_free_mbox(rproc);
 free_wkq:
 	destroy_workqueue(ddata->workqueue);
+free_resources:
+	rproc_resource_cleanup(rproc);
 free_rproc:
 	if (device_may_wakeup(dev)) {
 		dev_pm_clear_wake_irq(dev);
Signature · 1 line
2.25.1
author maintainer
#9 lore raw

PATCH v6 9/11 remoteproc: stm32: Properly handle the resource table when attaching

In reply to Mathieu Poirier

Properly set the remote processor's resource table based on where it was loaded by the external entity when attaching to a remote processor.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 76 ++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
drivers/remoteproc/stm32_rproc.c +76 -0
index 2a1cccd8d311..882229f3b1c9 100644
@@ -39,6 +39,8 @@
 #define STM32_MBX_VQ1_ID	1
 #define STM32_MBX_SHUTDOWN	"shutdown"
 
+#define RSC_TBL_SIZE		1024
+
 #define M4_STATE_OFF		0
 #define M4_STATE_INI		1
 #define M4_STATE_CRUN		2
@@ -86,6 +88,7 @@ struct stm32_rproc {
 	struct stm32_mbox mb[MBOX_NB_MBX];
 	struct workqueue_struct *workqueue;
 	bool secured_soc;
+	void __iomem *rsc_va;
 };
 
 static int stm32_rproc_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da)
@@ -669,6 +672,75 @@ static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata,
 	return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state);
 }
 
+static int stm32_rproc_da_to_pa(struct platform_device *pdev,
+				struct stm32_rproc *ddata,
+				u64 da, phys_addr_t *pa)
+{
+	struct device *dev = &pdev->dev;
+	struct stm32_rproc_mem *p_mem;
+	unsigned int i;
+
+	for (i = 0; i < ddata->nb_rmems; i++) {
+		p_mem = &ddata->rmems[i];
+
+		if (da < p_mem->dev_addr ||
+		    da >= p_mem->dev_addr + p_mem->size)
+			continue;
+
+		*pa = da - p_mem->dev_addr + p_mem->bus_addr;
+		dev_dbg(dev, "da %llx to pa %#x\n", da, *pa);
+
+		return 0;
+	}
+
+	dev_err(dev, "can't translate da %llx\n", da);
+
+	return -EINVAL;
+}
+
+static int stm32_rproc_get_loaded_rsc_table(struct platform_device *pdev,
+					    struct rproc *rproc,
+					    struct stm32_rproc *ddata)
+{
+	struct device *dev = &pdev->dev;
+	phys_addr_t rsc_pa;
+	u32 rsc_da;
+	int err;
+
+	err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da);
+	if (err) {
+		dev_err(dev, "failed to read rsc tbl addr\n");
+		return err;
+	}
+
+	if (!rsc_da)
+		/* no rsc table */
+		return 0;
+
+	err = stm32_rproc_da_to_pa(pdev, ddata, rsc_da, &rsc_pa);
+	if (err)
+		return err;
+
+	ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE);
+	if (IS_ERR_OR_NULL(ddata->rsc_va)) {
+		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
+			&rsc_pa, RSC_TBL_SIZE);
+		ddata->rsc_va = NULL;
+		return -ENOMEM;
+	}
+
+	/*
+	 * The resource table is already loaded in device memory, no need
+	 * to work with a cached table.
+	 */
+	rproc->cached_table = NULL;
+	/* Assuming the resource table fits in 1kB is fair */
+	rproc->table_sz = RSC_TBL_SIZE;
+	rproc->table_ptr = (struct resource_table *)ddata->rsc_va;
+
+	return 0;
+}
+
 static int stm32_rproc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -708,6 +780,10 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 		ret = stm32_rproc_parse_memory_regions(rproc);
 		if (ret)
 			goto free_resources;
+
+		ret = stm32_rproc_get_loaded_rsc_table(pdev, rproc, ddata);
+		if (ret)
+			goto free_resources;
 	}
 
 	rproc->has_iommu = false;
Signature · 1 line
2.25.1
author maintainer
#10 lore raw

PATCH v6 10/11 remoteproc: stm32: Introduce new attach() operation

In reply to Mathieu Poirier

Introduce new attach function to be used when attaching to a remote processor.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/remoteproc/stm32_rproc.c +8 -0
index 882229f3b1c9..7145cd49616e 100644
@@ -460,6 +460,13 @@ static int stm32_rproc_start(struct rproc *rproc)
 	return stm32_rproc_set_hold_boot(rproc, true);
 }
 
+static int stm32_rproc_attach(struct rproc *rproc)
+{
+	stm32_rproc_add_coredump_trace(rproc);
+
+	return stm32_rproc_set_hold_boot(rproc, true);
+}
+
 static int stm32_rproc_stop(struct rproc *rproc)
 {
 	struct stm32_rproc *ddata = rproc->priv;
@@ -525,6 +532,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
 static struct rproc_ops st_rproc_ops = {
 	.start		= stm32_rproc_start,
 	.stop		= stm32_rproc_stop,
+	.attach		= stm32_rproc_attach,
 	.kick		= stm32_rproc_kick,
 	.load		= rproc_elf_load_segments,
 	.parse_fw	= stm32_rproc_parse_fw,
Signature · 1 line
2.25.1
author maintainer
#11 lore raw

PATCH v6 11/11 remoteproc: stm32: Update M4 state in stm32_rproc_stop()

In reply to Mathieu Poirier

Update the co-processor state in function stm32_rproc_stop() so that it can be used in scenarios where the remoteproc core is attaching to the M4.

Mainly based on the work published by Arnaud Pouliquen [1].

[1]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=239877

---
 drivers/remoteproc/stm32_rproc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/remoteproc/stm32_rproc.c +12 -0
index 7145cd49616e..f4da42fc0eeb 100644
@@ -504,6 +504,18 @@ static int stm32_rproc_stop(struct rproc *rproc)
 		}
 	}
 
+	/* update coprocessor state to OFF if available */
+	if (ddata->m4_state.map) {
+		err = regmap_update_bits(ddata->m4_state.map,
+					 ddata->m4_state.reg,
+					 ddata->m4_state.mask,
+					 M4_STATE_OFF);
+		if (err) {
+			dev_err(&rproc->dev, "failed to set copro state\n");
+			return err;
+		}
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
Acked-by on the v6 series
#12 lore raw
In reply to Mathieu Poirier

Hi Mathieu

Quoted 16 lines

-----Original Message-----
From: Mathieu Poirier <[email protected]>
Sent: mardi 14 juillet 2020 22:05
To: [email protected]; [email protected]; Loic PALLARDY <[email protected]>; Arnaud POULIQUEN <[email protected]>; [email protected]; Alexandre TORGUE <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH v6 00/11] remoteproc: stm32: Add support for attaching to M4

This set applies on top of [1] and refactors the STM32 platform code in order to attach to the M4 remote processor when it has been started by the boot loader.

Quoted 6 lines

New to V6:
1) Removed extra newline in patch 06.
2) Re-worked title and changelog of patch 08 to better reflect what is done by the patch.

Tested on ST's mp157c development board.

I don' t know if you don't see it on last version or if you prefer that I review your update first... so for the series

Thanks,
Arnaud

Quoted 28 lines

Thanks,
Mathieu

[1].https://patchwork.kernel.org/project/linux-
remoteproc/list/?series=318275

Mathieu Poirier (11):
remoteproc: stm32: Decouple rproc from memory translation
remoteproc: stm32: Request IRQ with platform device
remoteproc: stm32: Decouple rproc from DT parsing
remoteproc: stm32: Remove memory translation from DT parsing
remoteproc: stm32: Parse syscon that will manage M4 synchronisation
remoteproc: stm32: Properly set co-processor state when attaching
remoteproc: Make function rproc_resource_cleanup() public
remoteproc: stm32: Parse memory regions when attaching to M4
remoteproc: stm32: Properly handle the resource table when attaching
remoteproc: stm32: Introduce new attach() operation
remoteproc: stm32: Update M4 state in stm32_rproc_stop()

 drivers/remoteproc/remoteproc_core.c |   3 +-
 drivers/remoteproc/stm32_rproc.c     | 214 ++++++++++++++++++++++++--
-
 include/linux/remoteproc.h           |   1 +
 3 files changed, 198 insertions(+), 20 deletions(-)

--
2.25.1

author maintainer
#13 lore raw
Quoted 19 lines · Arnaud POULIQUEN

Hi Mathieu

Quoted 16 lines

-----Original Message-----
From: Mathieu Poirier <[email protected]>
Sent: mardi 14 juillet 2020 22:05
To: [email protected]; [email protected]; Loic PALLARDY <[email protected]>; Arnaud POULIQUEN <[email protected]>; [email protected]; Alexandre TORGUE <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH v6 00/11] remoteproc: stm32: Add support for attaching to M4

This set applies on top of [1] and refactors the STM32 platform code in order to attach to the M4 remote processor when it has been started by the boot loader.

Quoted 8 lines
Quoted 6 lines

New to V6:
1) Removed extra newline in patch 06.
2) Re-worked title and changelog of patch 08 to better reflect what is done by the patch.

Tested on ST's mp157c development board.

I don' t know if you don't see it on last version or if you prefer that I review your update first... so for the series

Ah yes, my apologies on that - I misread the comment you left me in 00/11 of the V5 set.

Quoted 35 lines

Thanks,
Arnaud

Quoted 28 lines

Thanks,
Mathieu

[1].https://patchwork.kernel.org/project/linux-
remoteproc/list/?series=318275

Mathieu Poirier (11):
remoteproc: stm32: Decouple rproc from memory translation
remoteproc: stm32: Request IRQ with platform device
remoteproc: stm32: Decouple rproc from DT parsing
remoteproc: stm32: Remove memory translation from DT parsing
remoteproc: stm32: Parse syscon that will manage M4 synchronisation
remoteproc: stm32: Properly set co-processor state when attaching
remoteproc: Make function rproc_resource_cleanup() public
remoteproc: stm32: Parse memory regions when attaching to M4
remoteproc: stm32: Properly handle the resource table when attaching
remoteproc: stm32: Introduce new attach() operation
remoteproc: stm32: Update M4 state in stm32_rproc_stop()

 drivers/remoteproc/remoteproc_core.c |   3 +-
 drivers/remoteproc/stm32_rproc.c     | 214 ++++++++++++++++++++++++--
-
 include/linux/remoteproc.h           |   1 +
 3 files changed, 198 insertions(+), 20 deletions(-)

--
2.25.1

#14 lore raw
In reply to Mathieu Poirier
This series was applied to andersson/remoteproc.git (refs/heads/for-next).

Hello:

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

Quoted 10 lines · On Tue, 14 Jul 2020 14:04:34 -0600 you wrote:

This set applies on top of [1] and refactors the STM32 platform code in order to attach to the M4 remote processor when it has been started by the boot loader.

New to V6:
1) Removed extra newline in patch 06.
2) Re-worked title and changelog of patch 08 to better reflect what is done by the patch.

[...]

Here is a summary with links:
- [v6,01/11] remoteproc: stm32: Decouple rproc from memory translation

    https://git.kernel.org/andersson/remoteproc/c/7b9f18ca933ae35b90add6fe1787056bbc789a8a
  - [v6,02/11] remoteproc: stm32: Request IRQ with platform device
    https://git.kernel.org/andersson/remoteproc/c/b8631ab137c78f58afacd7e7f822cd3fc296f589
  - [v6,03/11] remoteproc: stm32: Decouple rproc from DT parsing
    https://git.kernel.org/andersson/remoteproc/c/8210fc873d2f1a550ad41093d21a7c18217f75fb
  - [v6,04/11] remoteproc: stm32: Remove memory translation from DT parsing
    https://git.kernel.org/andersson/remoteproc/c/95e32f868aa67cb0d581ca8ced456dc2fac5edf7
  - [v6,05/11] remoteproc: stm32: Parse syscon that will manage M4 synchronisation
    https://git.kernel.org/andersson/remoteproc/c/9276536f455b38b965ea16958a01f77bfae385f3
  - [v6,06/11] remoteproc: stm32: Properly set co-processor state when attaching
    https://git.kernel.org/andersson/remoteproc/c/376ffdc044568fcd9982a89d57eed67874566f85
  - [v6,07/11] remoteproc: Make function rproc_resource_cleanup() public
    https://git.kernel.org/andersson/remoteproc/c/d9473cbfb0c5cbb279dfdeaec780934729537d27
  - [v6,08/11] remoteproc: stm32: Parse memory regions when attaching to M4
    https://git.kernel.org/andersson/remoteproc/c/dadbdb9c304c51038465e0735585538a78e8578b
  - [v6,09/11] remoteproc: stm32: Properly handle the resource table when attaching
    https://git.kernel.org/andersson/remoteproc/c/11a7aaa72cc5539591bd34c637ab12e55cb79e1e
  - [v6,10/11] remoteproc: stm32: Introduce new attach() operation
    https://git.kernel.org/andersson/remoteproc/c/bee04d4672e0e8f6b82b62b092763b88a395da22
  - [v6,11/11] remoteproc: stm32: Update M4 state in stm32_rproc_stop()
    https://git.kernel.org/andersson/remoteproc/c/efd8626213f6897b416e573e87f4582810086b93

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot