linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor
@ 2021-03-10 21:10 Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del() Mathieu Poirier
                   ` (16 more replies)
  0 siblings, 17 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

This set provides support for the remoteproc core to release resources
associated with a remote processor without having to switch it off. That
way a platform driver can be removed or the application processor power
cycled while the remote processor is still operating.

The main difference in this revision is patch 11/16 (in V6).  It was split
split in two part in order to simplify handling of the resource table when
the remote processor is detached or stopped.  Other modifications are
detailed in the changelog of each patch.

Applies cleanly on v5.12-rc2.

Thanks,
Mathieu

Arnaud POULIQUEN (1):
  remoteproc: stm32: Move memory parsing to rproc_ops

Mathieu Poirier (16):
  remoteproc: Remove useless check in rproc_del()
  remoteproc: Rename function rproc_actuate()
  remoteproc: Add new RPROC_ATTACHED state
  remoteproc: Properly represent the attached state
  remoteproc: Add new get_loaded_rsc_table() to rproc_ops
  remoteproc: stm32: Move resource table setup to rproc_ops
  remoteproc: Add new detach() remoteproc operation
  remoteproc: Introduce function __rproc_detach()
  remoteproc: Introduce function rproc_detach()
  remoteproc: Properly deal with the resource table when detaching
  remoteproc: Properly deal with the resource table when stopping
  remoteproc: Properly deal with a kernel panic when attached
  remoteproc: Properly deal with a start request when attached
  remoteproc: Properly deal with a stop request when attached
  remoteproc: Properly deal with a detach request when attached
  remoteproc: Refactor function rproc_cdev_release()

 drivers/remoteproc/remoteproc_cdev.c     |  21 +-
 drivers/remoteproc/remoteproc_core.c     | 302 ++++++++++++++++++++---
 drivers/remoteproc/remoteproc_internal.h |  10 +
 drivers/remoteproc/remoteproc_sysfs.c    |  17 +-
 drivers/remoteproc/stm32_rproc.c         | 168 ++++++-------
 include/linux/remoteproc.h               |  21 +-
 6 files changed, 401 insertions(+), 138 deletions(-)

-- 
2.25.1


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

* [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del()
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 02/17] remoteproc: Rename function rproc_actuate() Mathieu Poirier
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Whether started at probe() time or thereafter from the command
line, a remote processor needs to be shut down before the final
cleanup phases can happen.  Otherwise the system may be left in
an unpredictable state where the remote processor is expecting
the remoteproc core to be providing services when in fact it
no longer exist.

Invariably calling rproc_shutdown() is fine since it will return
immediately if the remote processor has already been switched
off.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ab150765d124..d2704501b653 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2347,10 +2347,8 @@ int rproc_del(struct rproc *rproc)
 	if (!rproc)
 		return -EINVAL;
 
-	/* if rproc is marked always-on, rproc_add() booted it */
 	/* TODO: make sure this works with rproc->power > 1 */
-	if (rproc->auto_boot)
-		rproc_shutdown(rproc);
+	rproc_shutdown(rproc);
 
 	mutex_lock(&rproc->lock);
 	rproc->state = RPROC_DELETED;
-- 
2.25.1


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

* [PATCH v7 02/17] remoteproc: Rename function rproc_actuate()
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del() Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 03/17] remoteproc: Add new RPROC_ATTACHED state Mathieu Poirier
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Rename function rproc_actuate() to rproc_attach().  That way it is
easy to understand that it does the opposite of rproc_detach().

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index d2704501b653..7b66e1e96e4a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1416,7 +1416,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)
 	return ret;
 }
 
-static int rproc_attach(struct rproc *rproc)
+static int __rproc_attach(struct rproc *rproc)
 {
 	struct device *dev = &rproc->dev;
 	int ret;
@@ -1541,7 +1541,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
  * Attach to remote processor - similar to rproc_fw_boot() but without
  * the steps that deal with the firmware image.
  */
-static int rproc_actuate(struct rproc *rproc)
+static int rproc_attach(struct rproc *rproc)
 {
 	struct device *dev = &rproc->dev;
 	int ret;
@@ -1581,7 +1581,7 @@ static int rproc_actuate(struct rproc *rproc)
 		goto clean_up_resources;
 	}
 
-	ret = rproc_attach(rproc);
+	ret = __rproc_attach(rproc);
 	if (ret)
 		goto clean_up_resources;
 
@@ -1802,7 +1802,7 @@ int rproc_boot(struct rproc *rproc)
 	if (rproc->state == RPROC_DETACHED) {
 		dev_info(dev, "attaching to %s\n", rproc->name);
 
-		ret = rproc_actuate(rproc);
+		ret = rproc_attach(rproc);
 	} else {
 		dev_info(dev, "powering up %s\n", rproc->name);
 
-- 
2.25.1


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

* [PATCH v7 03/17] remoteproc: Add new RPROC_ATTACHED state
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del() Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 02/17] remoteproc: Rename function rproc_actuate() Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 04/17] remoteproc: Properly represent the attached state Mathieu Poirier
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Add a new RPROC_ATTACHED state to take into account scenarios
where the remoteproc core needs to attach to a remote processor
that is booted by another entity.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_sysfs.c | 1 +
 include/linux/remoteproc.h            | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 1dbef895e65e..4b4aab0d4c4b 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -172,6 +172,7 @@ static const char * const rproc_state_string[] = {
 	[RPROC_RUNNING]		= "running",
 	[RPROC_CRASHED]		= "crashed",
 	[RPROC_DELETED]		= "deleted",
+	[RPROC_ATTACHED]	= "attached",
 	[RPROC_DETACHED]	= "detached",
 	[RPROC_LAST]		= "invalid",
 };
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index f28ee75d1005..b0a57ff73849 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -405,6 +405,8 @@ struct rproc_ops {
  * @RPROC_RUNNING:	device is up and running
  * @RPROC_CRASHED:	device has crashed; need to start recovery
  * @RPROC_DELETED:	device is deleted
+ * @RPROC_ATTACHED:	device has been booted by another entity and the core
+ *			has attached to it
  * @RPROC_DETACHED:	device has been booted by another entity and waiting
  *			for the core to attach to it
  * @RPROC_LAST:		just keep this one at the end
@@ -421,8 +423,9 @@ enum rproc_state {
 	RPROC_RUNNING	= 2,
 	RPROC_CRASHED	= 3,
 	RPROC_DELETED	= 4,
-	RPROC_DETACHED	= 5,
-	RPROC_LAST	= 6,
+	RPROC_ATTACHED	= 5,
+	RPROC_DETACHED	= 6,
+	RPROC_LAST	= 7,
 };
 
 /**
-- 
2.25.1


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

* [PATCH v7 04/17] remoteproc: Properly represent the attached state
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (2 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 03/17] remoteproc: Add new RPROC_ATTACHED state Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 05/17] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Mathieu Poirier
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

There is a need to know when a remote processor has been attached
to rather than booted by the remoteproc core.  In order to avoid
manipulating two variables, i.e rproc::autonomous and
rproc::state, get rid of the former and simply use the newly
introduced RPROC_ATTACHED state.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c  | 20 +-------------------
 drivers/remoteproc/remoteproc_sysfs.c |  5 +----
 include/linux/remoteproc.h            |  2 --
 3 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 7b66e1e96e4a..8c7e9f1d50d7 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1444,7 +1444,7 @@ static int __rproc_attach(struct rproc *rproc)
 		goto stop_rproc;
 	}
 
-	rproc->state = RPROC_RUNNING;
+	rproc->state = RPROC_ATTACHED;
 
 	dev_info(dev, "remote processor %s is now attached\n", rproc->name);
 
@@ -1659,14 +1659,6 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
 
 	rproc->state = RPROC_OFFLINE;
 
-	/*
-	 * The remote processor has been stopped and is now offline, which means
-	 * that the next time it is brought back online the remoteproc core will
-	 * be responsible to load its firmware.  As such it is no longer
-	 * autonomous.
-	 */
-	rproc->autonomous = false;
-
 	dev_info(dev, "stopped remote processor %s\n", rproc->name);
 
 	return 0;
@@ -2077,16 +2069,6 @@ int rproc_add(struct rproc *rproc)
 	if (ret < 0)
 		return ret;
 
-	/*
-	 * Remind ourselves the remote processor has been attached to rather
-	 * than booted by the remoteproc core.  This is important because the
-	 * RPROC_DETACHED state will be lost as soon as the remote processor
-	 * has been attached to.  Used in firmware_show() and reset in
-	 * rproc_stop().
-	 */
-	if (rproc->state == RPROC_DETACHED)
-		rproc->autonomous = true;
-
 	/* if rproc is marked always-on, request it to boot */
 	if (rproc->auto_boot) {
 		ret = rproc_trigger_auto_boot(rproc);
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 4b4aab0d4c4b..f9694def9b54 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -138,11 +138,8 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
 	 * If the remote processor has been started by an external
 	 * entity we have no idea of what image it is running.  As such
 	 * simply display a generic string rather then rproc->firmware.
-	 *
-	 * Here we rely on the autonomous flag because a remote processor
-	 * may have been attached to and currently in a running state.
 	 */
-	if (rproc->autonomous)
+	if (rproc->state == RPROC_ATTACHED)
 		firmware = "unknown";
 
 	return sprintf(buf, "%s\n", firmware);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index b0a57ff73849..6b0a0ed30a03 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -512,7 +512,6 @@ struct rproc_dump_segment {
  * @table_sz: size of @cached_table
  * @has_iommu: flag to indicate if remote processor is behind an MMU
  * @auto_boot: flag to indicate if remote processor should be auto-started
- * @autonomous: true if an external entity has booted the remote processor
  * @dump_segments: list of segments in the firmware
  * @nb_vdev: number of vdev currently handled by rproc
  * @char_dev: character device of the rproc
@@ -549,7 +548,6 @@ struct rproc {
 	size_t table_sz;
 	bool has_iommu;
 	bool auto_boot;
-	bool autonomous;
 	struct list_head dump_segments;
 	int nb_vdev;
 	u8 elf_class;
-- 
2.25.1


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

* [PATCH v7 05/17] remoteproc: Add new get_loaded_rsc_table() to rproc_ops
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (3 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 04/17] remoteproc: Properly represent the attached state Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 06/17] remoteproc: stm32: Move resource table setup " Mathieu Poirier
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Add a new get_loaded_rsc_table() operation in order to support
scenarios where the remoteproc core has booted a remote processor
and detaches from it.  When re-attaching to the remote processor,
the core needs to know where the resource table has been placed
in memory.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c     | 32 ++++++++++++++++++++++++
 drivers/remoteproc/remoteproc_internal.h | 10 ++++++++
 include/linux/remoteproc.h               |  6 ++++-
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 8c7e9f1d50d7..bf6f6d15b1c3 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1537,6 +1537,32 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
 	return ret;
 }
 
+static int rproc_set_rsc_table(struct rproc *rproc)
+{
+	struct resource_table *table_ptr;
+	struct device *dev = &rproc->dev;
+	size_t table_sz;
+	int ret;
+
+	table_ptr = rproc_get_loaded_rsc_table(rproc, &table_sz);
+	if (!table_ptr) {
+		/* Not having a resource table is acceptable */
+		return 0;
+	}
+
+	if (IS_ERR(table_ptr)) {
+		ret = PTR_ERR(table_ptr);
+		dev_err(dev, "can't load resource table: %d\n", ret);
+		return ret;
+	}
+
+	rproc->cached_table = NULL;
+	rproc->table_ptr = table_ptr;
+	rproc->table_sz = table_sz;
+
+	return 0;
+}
+
 /*
  * Attach to remote processor - similar to rproc_fw_boot() but without
  * the steps that deal with the firmware image.
@@ -1556,6 +1582,12 @@ static int rproc_attach(struct rproc *rproc)
 		return ret;
 	}
 
+	ret = rproc_set_rsc_table(rproc);
+	if (ret) {
+		dev_err(dev, "can't load resource table: %d\n", ret);
+		goto disable_iommu;
+	}
+
 	/* reset max_notifyid */
 	rproc->max_notifyid = -1;
 
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index c34002888d2c..4f73aac7e60d 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -177,6 +177,16 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
 	return NULL;
 }
 
+static inline
+struct resource_table *rproc_get_loaded_rsc_table(struct rproc *rproc,
+						  size_t *size)
+{
+	if (rproc->ops->get_loaded_rsc_table)
+		return rproc->ops->get_loaded_rsc_table(rproc, size);
+
+	return NULL;
+}
+
 static inline
 bool rproc_u64_fit_in_size_t(u64 val)
 {
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 6b0a0ed30a03..51538a7d120d 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -368,7 +368,9 @@ enum rsc_handling_status {
  * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a
  * negative value on error
  * @load_rsc_table:	load resource table from firmware image
- * @find_loaded_rsc_table: find the loaded resouce table
+ * @find_loaded_rsc_table: find the loaded resource table from firmware image
+ * @get_loaded_rsc_table: get resource table installed in memory
+ *			  by external entity
  * @load:		load firmware to memory, where the remote processor
  *			expects to find it
  * @sanity_check:	sanity check the fw image
@@ -390,6 +392,8 @@ struct rproc_ops {
 			  int offset, int avail);
 	struct resource_table *(*find_loaded_rsc_table)(
 				struct rproc *rproc, const struct firmware *fw);
+	struct resource_table *(*get_loaded_rsc_table)(
+				struct rproc *rproc, size_t *size);
 	int (*load)(struct rproc *rproc, const struct firmware *fw);
 	int (*sanity_check)(struct rproc *rproc, const struct firmware *fw);
 	u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw);
-- 
2.25.1


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

* [PATCH v7 06/17] remoteproc: stm32: Move resource table setup to rproc_ops
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (4 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 05/17] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 07/17] remoteproc: stm32: Move memory parsing " Mathieu Poirier
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Move the setting of the resource table installed by an external
entity to rproc_ops::get_loaded_rsc_table().  This is to support
scenarios where a remote processor has been attached to but is
detached at a later stage.  To re-attach the remote processor,
the address of the resource table needs to be available
at a later time than the platform driver's probe() function.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/stm32_rproc.c | 141 +++++++++++++++----------------
 1 file changed, 68 insertions(+), 73 deletions(-)

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index ccb3c14a0023..f647e565014b 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -546,6 +546,73 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
 	}
 }
 
+static int stm32_rproc_da_to_pa(struct rproc *rproc,
+				u64 da, phys_addr_t *pa)
+{
+	struct stm32_rproc *ddata = rproc->priv;
+	struct device *dev = rproc->dev.parent;
+	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 struct resource_table *
+stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
+{
+	struct stm32_rproc *ddata = rproc->priv;
+	struct device *dev = rproc->dev.parent;
+	phys_addr_t rsc_pa;
+	u32 rsc_da;
+	int err;
+
+	/* The resource table has already been mapped, nothing to do */
+	if (ddata->rsc_va)
+		goto done;
+
+	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_PTR(-EINVAL);
+	}
+
+	if (!rsc_da)
+		/* no rsc table */
+		return ERR_PTR(-ENOENT);
+
+	err = stm32_rproc_da_to_pa(rproc, rsc_da, &rsc_pa);
+	if (err)
+		return ERR_PTR(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 ERR_PTR(-ENOMEM);
+	}
+
+done:
+	/* Assuming the resource table fits in 1kB is fair */
+	*table_sz = RSC_TBL_SIZE;
+	return (struct resource_table *)ddata->rsc_va;
+}
+
 static const struct rproc_ops st_rproc_ops = {
 	.start		= stm32_rproc_start,
 	.stop		= stm32_rproc_stop,
@@ -554,6 +621,7 @@ static const struct rproc_ops st_rproc_ops = {
 	.load		= rproc_elf_load_segments,
 	.parse_fw	= stm32_rproc_parse_fw,
 	.find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+	.get_loaded_rsc_table = stm32_rproc_get_loaded_rsc_table,
 	.sanity_check	= rproc_elf_sanity_check,
 	.get_boot_addr	= rproc_elf_get_boot_addr,
 };
@@ -695,75 +763,6 @@ 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;
@@ -803,10 +802,6 @@ 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;
-- 
2.25.1


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

* [PATCH v7 07/17] remoteproc: stm32: Move memory parsing to rproc_ops
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (5 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 06/17] remoteproc: stm32: Move resource table setup " Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 08/17] remoteproc: Add new detach() remoteproc operation Mathieu Poirier
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

From: Arnaud POULIQUEN <arnaud.pouliquen@foss.st.com>

Some actions such as memory resources reallocation are needed when
trying to reattach a co-processor. Use the prepare() operation for
these actions.

Co-developed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Arnaud POULIQUEN <arnaud.pouliquen@foss.st.com>
---
 drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++--
 drivers/remoteproc/stm32_rproc.c     | 27 ++++++---------------------
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index bf6f6d15b1c3..1d8bb588d996 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1582,10 +1582,17 @@ static int rproc_attach(struct rproc *rproc)
 		return ret;
 	}
 
+	/* Do anything that is needed to boot the remote processor */
+	ret = rproc_prepare_device(rproc);
+	if (ret) {
+		dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret);
+		goto disable_iommu;
+	}
+
 	ret = rproc_set_rsc_table(rproc);
 	if (ret) {
 		dev_err(dev, "can't load resource table: %d\n", ret);
-		goto disable_iommu;
+		goto unprepare_device;
 	}
 
 	/* reset max_notifyid */
@@ -1602,7 +1609,7 @@ static int rproc_attach(struct rproc *rproc)
 	ret = rproc_handle_resources(rproc, rproc_loading_handlers);
 	if (ret) {
 		dev_err(dev, "Failed to process resources: %d\n", ret);
-		goto disable_iommu;
+		goto unprepare_device;
 	}
 
 	/* Allocate carveout resources associated to rproc */
@@ -1621,6 +1628,9 @@ static int rproc_attach(struct rproc *rproc)
 
 clean_up_resources:
 	rproc_resource_cleanup(rproc);
+unprepare_device:
+	/* release HW resources if needed */
+	rproc_unprepare_device(rproc);
 disable_iommu:
 	rproc_disable_iommu(rproc);
 	return ret;
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index f647e565014b..3d45f51de4d0 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -207,16 +207,7 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name)
 	return -EINVAL;
 }
 
-static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc,
-					  const struct firmware *fw)
-{
-	if (rproc_elf_load_rsc_table(rproc, fw))
-		dev_warn(&rproc->dev, "no resource table found for this firmware\n");
-
-	return 0;
-}
-
-static int stm32_rproc_parse_memory_regions(struct rproc *rproc)
+static int stm32_rproc_prepare(struct rproc *rproc)
 {
 	struct device *dev = rproc->dev.parent;
 	struct device_node *np = dev->of_node;
@@ -274,12 +265,10 @@ static int stm32_rproc_parse_memory_regions(struct rproc *rproc)
 
 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;
+	if (rproc_elf_load_rsc_table(rproc, fw))
+		dev_warn(&rproc->dev, "no resource table found for this firmware\n");
 
-	return stm32_rproc_elf_load_rsc_table(rproc, fw);
+	return 0;
 }
 
 static irqreturn_t stm32_rproc_wdg(int irq, void *data)
@@ -614,6 +603,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
 }
 
 static const struct rproc_ops st_rproc_ops = {
+	.prepare	= stm32_rproc_prepare,
 	.start		= stm32_rproc_start,
 	.stop		= stm32_rproc_stop,
 	.attach		= stm32_rproc_attach,
@@ -796,14 +786,9 @@ 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) {
-- 
2.25.1


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

* [PATCH v7 08/17] remoteproc: Add new detach() remoteproc operation
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (6 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 07/17] remoteproc: stm32: Move memory parsing " Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 09/17] remoteproc: Introduce function __rproc_detach() Mathieu Poirier
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Add an new detach() operation in order to support scenarios where
the remoteproc core is going away but the remote processor is
kept operating.  This could be the case when the system is
rebooted or when the platform driver is removed.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 include/linux/remoteproc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 51538a7d120d..eff55ec72e80 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -361,6 +361,7 @@ enum rsc_handling_status {
  * @start:	power on the device and boot it
  * @stop:	power off the device
  * @attach:	attach to a device that his already powered up
+ * @detach:	detach from a device, leaving it powered up
  * @kick:	kick a virtqueue (virtqueue id given as a parameter)
  * @da_to_va:	optional platform hook to perform address translations
  * @parse_fw:	parse firmware to extract information (e.g. resource table)
@@ -385,6 +386,7 @@ struct rproc_ops {
 	int (*start)(struct rproc *rproc);
 	int (*stop)(struct rproc *rproc);
 	int (*attach)(struct rproc *rproc);
+	int (*detach)(struct rproc *rproc);
 	void (*kick)(struct rproc *rproc, int vqid);
 	void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len);
 	int (*parse_fw)(struct rproc *rproc, const struct firmware *fw);
-- 
2.25.1


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

* [PATCH v7 09/17] remoteproc: Introduce function __rproc_detach()
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (7 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 08/17] remoteproc: Add new detach() remoteproc operation Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 10/17] remoteproc: Introduce function rproc_detach() Mathieu Poirier
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Introduce function __rproc_detach() to perform the same kind of
operation as rproc_stop(), but instead of switching off the
remote processor using rproc->ops->stop(), it uses
rproc->ops->detach().  That way it is possible for the core
to release the resources associated with a remote processor while
the latter is kept operating.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 1d8bb588d996..f2a005eadfd5 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1706,6 +1706,36 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
 	return 0;
 }
 
+/*
+ * __rproc_detach(): Does the opposite of __rproc_attach()
+ */
+static int __maybe_unused __rproc_detach(struct rproc *rproc)
+{
+	struct device *dev = &rproc->dev;
+	int ret;
+
+	/* No need to continue if a detach() operation has not been provided */
+	if (!rproc->ops->detach)
+		return -EINVAL;
+
+	/* Stop any subdevices for the remote processor */
+	rproc_stop_subdevices(rproc, false);
+
+	/* Tell the remote processor the core isn't available anymore */
+	ret = rproc->ops->detach(rproc);
+	if (ret) {
+		dev_err(dev, "can't detach from rproc: %d\n", ret);
+		return ret;
+	}
+
+	rproc_unprepare_subdevices(rproc);
+
+	rproc->state = RPROC_DETACHED;
+
+	dev_info(dev, "detached remote processor %s\n", rproc->name);
+
+	return 0;
+}
 
 /**
  * rproc_trigger_recovery() - recover a remoteproc
-- 
2.25.1


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

* [PATCH v7 10/17] remoteproc: Introduce function rproc_detach()
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (8 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 09/17] remoteproc: Introduce function __rproc_detach() Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching Mathieu Poirier
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Introduce function rproc_detach() to enable the remoteproc
core to release the resources associated with a remote processor
without stopping its operation.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 58 +++++++++++++++++++++++++++-
 include/linux/remoteproc.h           |  1 +
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f2a005eadfd5..5eaa47c3ba92 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1709,7 +1709,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
 /*
  * __rproc_detach(): Does the opposite of __rproc_attach()
  */
-static int __maybe_unused __rproc_detach(struct rproc *rproc)
+static int __rproc_detach(struct rproc *rproc)
 {
 	struct device *dev = &rproc->dev;
 	int ret;
@@ -1948,6 +1948,62 @@ void rproc_shutdown(struct rproc *rproc)
 }
 EXPORT_SYMBOL(rproc_shutdown);
 
+/**
+ * rproc_detach() - Detach the remote processor from the
+ * remoteproc core
+ *
+ * @rproc: the remote processor
+ *
+ * Detach a remote processor (previously attached to with rproc_attach()).
+ *
+ * In case @rproc is still being used by an additional user(s), then
+ * this function will just decrement the power refcount and exit,
+ * without disconnecting the device.
+ *
+ * Function rproc_detach() calls __rproc_detach() in order to let a remote
+ * processor know that services provided by the application processor are
+ * no longer available.  From there it should be possible to remove the
+ * platform driver and even power cycle the application processor (if the HW
+ * supports it) without needing to switch off the remote processor.
+ */
+int rproc_detach(struct rproc *rproc)
+{
+	struct device *dev = &rproc->dev;
+	int ret;
+
+	ret = mutex_lock_interruptible(&rproc->lock);
+	if (ret) {
+		dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
+		return ret;
+	}
+
+	/* if the remote proc is still needed, bail out */
+	if (!atomic_dec_and_test(&rproc->power)) {
+		ret = 0;
+		goto out;
+	}
+
+	ret = __rproc_detach(rproc);
+	if (ret) {
+		atomic_inc(&rproc->power);
+		goto out;
+	}
+
+	/* clean up all acquired resources */
+	rproc_resource_cleanup(rproc);
+
+	/* release HW resources if needed */
+	rproc_unprepare_device(rproc);
+
+	rproc_disable_iommu(rproc);
+
+	rproc->table_ptr = NULL;
+out:
+	mutex_unlock(&rproc->lock);
+	return ret;
+}
+EXPORT_SYMBOL(rproc_detach);
+
 /**
  * rproc_get_by_phandle() - find a remote processor by phandle
  * @phandle: phandle to the rproc
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index eff55ec72e80..e1c843c19cc6 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -662,6 +662,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len,
 
 int rproc_boot(struct rproc *rproc);
 void rproc_shutdown(struct rproc *rproc);
+int rproc_detach(struct rproc *rproc);
 int rproc_set_firmware(struct rproc *rproc, const char *fw_name);
 void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
 void rproc_coredump_using_sections(struct rproc *rproc);
-- 
2.25.1


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

* [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (9 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 10/17] remoteproc: Introduce function rproc_detach() Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-11  9:09   ` Arnaud POULIQUEN
  2021-03-10 21:10 ` [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Mathieu Poirier
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

If it is possible to detach the remote processor, keep an untouched
copy of the resource table.  That way we can start from the same
resource table without having to worry about original values or what
elements the startup code has changed when re-attaching to the remote
processor.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
New for V7:
  New Patch, used to be part of 11/16 in V6.
---
 drivers/remoteproc/remoteproc_core.c | 77 ++++++++++++++++++++++++++++
 include/linux/remoteproc.h           |  3 ++
 2 files changed, 80 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 5eaa47c3ba92..e9ea2558432d 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1556,6 +1556,24 @@ static int rproc_set_rsc_table(struct rproc *rproc)
 		return ret;
 	}
 
+	/*
+	 * If it is possible to detach the remote processor, keep an untouched
+	 * copy of the resource table.  That way we can start fresh again when
+	 * the remote processor is re-attached, that is:
+	 *
+	 *      DETACHED -> ATTACHED -> DETACHED -> ATTACHED
+	 *
+	 * Free'd in rproc_reset_rsc_table_on_detach() and
+	 * rproc_reset_rsc_table_on_stop().
+	 */
+	if (rproc->ops->detach) {
+		rproc->clean_table = kmemdup(table_ptr, table_sz, GFP_KERNEL);
+		if (!rproc->clean_table)
+			return -ENOMEM;
+	} else {
+		rproc->clean_table = NULL;
+	}
+
 	rproc->cached_table = NULL;
 	rproc->table_ptr = table_ptr;
 	rproc->table_sz = table_sz;
@@ -1563,6 +1581,59 @@ static int rproc_set_rsc_table(struct rproc *rproc)
 	return 0;
 }
 
+static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
+{
+	struct resource_table *table_ptr;
+
+	/* A resource table was never retrieved, nothing to do here */
+	if (!rproc->table_ptr)
+		return 0;
+
+	/*
+	 * If we made it to this point a clean_table _must_ have been
+	 * allocated in rproc_set_rsc_table().  If one isn't present
+	 * something went really wrong and we must complain.
+	 */
+	if (WARN_ON(!rproc->clean_table))
+		return -EINVAL;
+
+	/* Remember where the external entity installed the resource table */
+	table_ptr = rproc->table_ptr;
+
+	/*
+	 * If we made it here the remote processor was started by another
+	 * entity and a cache table doesn't exist.  As such make a copy of
+	 * the resource table currently used by the remote processor and
+	 * use that for the rest of the shutdown process.  The memory
+	 * allocated here is free'd in rproc_detach().
+	 */
+	rproc->cached_table = kmemdup(rproc->table_ptr,
+				      rproc->table_sz, GFP_KERNEL);
+	if (!rproc->cached_table)
+		return -ENOMEM;
+
+	/*
+	 * Use a copy of the resource table for the remainder of the
+	 * shutdown process.
+	 */
+	rproc->table_ptr = rproc->cached_table;
+
+	/*
+	 * Reset the memory area where the firmware loaded the resource table
+	 * to its original value.  That way when we re-attach the remote
+	 * processor the resource table is clean and ready to be used again.
+	 */
+	memcpy(table_ptr, rproc->clean_table, rproc->table_sz);
+
+	/*
+	 * The clean resource table is no longer needed.  Allocated in
+	 * rproc_set_rsc_table().
+	 */
+	kfree(rproc->clean_table);
+
+	return 0;
+}
+
 /*
  * Attach to remote processor - similar to rproc_fw_boot() but without
  * the steps that deal with the firmware image.
@@ -1721,6 +1792,9 @@ static int __rproc_detach(struct rproc *rproc)
 	/* Stop any subdevices for the remote processor */
 	rproc_stop_subdevices(rproc, false);
 
+	/* the installed resource table is no longer accessible */
+	ret = rproc_reset_rsc_table_on_detach(rproc);
+
 	/* Tell the remote processor the core isn't available anymore */
 	ret = rproc->ops->detach(rproc);
 	if (ret) {
@@ -1997,6 +2071,9 @@ int rproc_detach(struct rproc *rproc)
 
 	rproc_disable_iommu(rproc);
 
+	/* Free the copy of the resource table */
+	kfree(rproc->cached_table);
+	rproc->cached_table = NULL;
 	rproc->table_ptr = NULL;
 out:
 	mutex_unlock(&rproc->lock);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index e1c843c19cc6..e5f52a12a650 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -514,6 +514,8 @@ struct rproc_dump_segment {
  * @recovery_disabled: flag that state if recovery was disabled
  * @max_notifyid: largest allocated notify id.
  * @table_ptr: pointer to the resource table in effect
+ * @clean_table: copy of the resource table without modifications.  Used
+ *		 when a remote processor is attached or detached from the core
  * @cached_table: copy of the resource table
  * @table_sz: size of @cached_table
  * @has_iommu: flag to indicate if remote processor is behind an MMU
@@ -550,6 +552,7 @@ struct rproc {
 	bool recovery_disabled;
 	int max_notifyid;
 	struct resource_table *table_ptr;
+	struct resource_table *clean_table;
 	struct resource_table *cached_table;
 	size_t table_sz;
 	bool has_iommu;
-- 
2.25.1


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

* [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (10 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 23:00   ` kernel test robot
  2021-03-10 23:53   ` Bjorn Andersson
  2021-03-10 21:10 ` [PATCH v7 13/17] remoteproc: Properly deal with a kernel panic when attached Mathieu Poirier
                   ` (4 subsequent siblings)
  16 siblings, 2 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

When a remote processor that was attached to is stopped, special care
must be taken to make sure the shutdown process is similar to what
it would be had it been started by the remoteproc core.

This patch takes care of that by making a copy of the resource
table currently used by the remote processor.  From that point on
the copy is used, as if the remote processor had been started by
the remoteproc core.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
New for V7:
  New Patch, used to be part of 11/16 in V6.
---
 drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e9ea2558432d..c488b1aa6119 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
 	return 0;
 }
 
+static int rproc_reset_rsc_table_on_stop(struct rproc *rproc)
+{
+	struct resource_table *table_ptr;
+
+	/* A resource table was never retrieved, nothing to do here */
+	if (!rproc->table_ptr)
+		return 0;
+
+	/*
+	 * If a cache table exists the remote processor was started by
+	 * the remoteproc core.  That cache table should be used for
+	 * the rest of the shutdown process.
+	 */
+	if (rproc->cached_table)
+		goto out;
+
+	/* Remember where the external entity installed the resource table */
+	table_ptr = rproc->table_ptr;
+
+	/*
+	 * If we made it here the remote processor was started by another
+	 * entity and a cache table doesn't exist.  As such make a copy of
+	 * the resource table currently used by the remote processor and
+	 * use that for the rest of the shutdown process.  The memory
+	 * allocated here is free'd in rproc_shutdown().
+	 */
+	rproc->cached_table = kmemdup(rproc->table_ptr,
+				      rproc->table_sz, GFP_KERNEL);
+	if (!rproc->cached_table)
+		return -ENOMEM;
+
+	/*
+	 * Since the remote processor is being switched off the clean table
+	 * won't be needed.  Allocated in rproc_set_rsc_table().
+	 */
+	kfree(rproc->clean_table);
+
+out:
+	/*
+	 * Use a copy of the resource table for the remainder of the
+	 * shutdown process.
+	 */
+	rproc->table_ptr = rproc->cached_table;
+	return 0;
+}
+
 /*
  * Attach to remote processor - similar to rproc_fw_boot() but without
  * the steps that deal with the firmware image.
@@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
 	rproc_stop_subdevices(rproc, crashed);
 
 	/* the installed resource table is no longer accessible */
-	rproc->table_ptr = rproc->cached_table;
+	ret = rproc_reset_rsc_table_on_stop(rproc);
+	if (ret) {
+		dev_err(dev, "can't reset resource table: %d\n", ret);
+		return ret;
+	}
+
 
 	/* power off the remote processor */
 	ret = rproc->ops->stop(rproc);
-- 
2.25.1


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

* [PATCH v7 13/17] remoteproc: Properly deal with a kernel panic when attached
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (11 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 14/17] remoteproc: Properly deal with a start request " Mathieu Poirier
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

The panic handler operation of registered remote processors
should also be called when remote processors have been
attached to.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c488b1aa6119..f6f0813dade5 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2728,7 +2728,11 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event,
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(rproc, &rproc_list, node) {
-		if (!rproc->ops->panic || rproc->state != RPROC_RUNNING)
+		if (!rproc->ops->panic)
+			continue;
+
+		if (rproc->state != RPROC_RUNNING &&
+		    rproc->state != RPROC_ATTACHED)
 			continue;
 
 		d = rproc->ops->panic(rproc);
-- 
2.25.1


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

* [PATCH v7 14/17] remoteproc: Properly deal with a start request when attached
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (12 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 13/17] remoteproc: Properly deal with a kernel panic when attached Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 15/17] remoteproc: Properly deal with a stop " Mathieu Poirier
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

This patch takes into account scenarios where a remote processor
has been attached to when receiving a "start" command from sysfs.

As with the case with the running state, the command can't be
carried out if the remote processor is already in operation.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_cdev.c  | 3 ++-
 drivers/remoteproc/remoteproc_sysfs.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index b19ea3057bde..b2cee9afb41b 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -32,7 +32,8 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
 		return -EFAULT;
 
 	if (!strncmp(cmd, "start", len)) {
-		if (rproc->state == RPROC_RUNNING)
+		if (rproc->state == RPROC_RUNNING ||
+		    rproc->state == RPROC_ATTACHED)
 			return -EBUSY;
 
 		ret = rproc_boot(rproc);
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index f9694def9b54..66801e6fe5cd 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -194,7 +194,8 @@ static ssize_t state_store(struct device *dev,
 	int ret = 0;
 
 	if (sysfs_streq(buf, "start")) {
-		if (rproc->state == RPROC_RUNNING)
+		if (rproc->state == RPROC_RUNNING ||
+		    rproc->state == RPROC_ATTACHED)
 			return -EBUSY;
 
 		ret = rproc_boot(rproc);
-- 
2.25.1


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

* [PATCH v7 15/17] remoteproc: Properly deal with a stop request when attached
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (13 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 14/17] remoteproc: Properly deal with a start request " Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 16/17] remoteproc: Properly deal with a detach " Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release() Mathieu Poirier
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Allow a remote processor that was started by another entity to be
switched off by the remoteproc core.  For that to happen a
rproc::ops::stop() operation needs to be available.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_cdev.c  | 3 ++-
 drivers/remoteproc/remoteproc_core.c  | 4 ++++
 drivers/remoteproc/remoteproc_sysfs.c | 3 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index b2cee9afb41b..0249d8f6c3f8 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -38,7 +38,8 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
 
 		ret = rproc_boot(rproc);
 	} else if (!strncmp(cmd, "stop", len)) {
-		if (rproc->state != RPROC_RUNNING)
+		if (rproc->state != RPROC_RUNNING &&
+		    rproc->state != RPROC_ATTACHED)
 			return -EINVAL;
 
 		rproc_shutdown(rproc);
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f6f0813dade5..3670b70390dd 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1801,6 +1801,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
 	struct device *dev = &rproc->dev;
 	int ret;
 
+	/* No need to continue if a stop() operation has not been provided */
+	if (!rproc->ops->stop)
+		return -EINVAL;
+
 	/* Stop any subdevices for the remote processor */
 	rproc_stop_subdevices(rproc, crashed);
 
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 66801e6fe5cd..09eb700c5e7e 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -202,7 +202,8 @@ static ssize_t state_store(struct device *dev,
 		if (ret)
 			dev_err(&rproc->dev, "Boot failed: %d\n", ret);
 	} else if (sysfs_streq(buf, "stop")) {
-		if (rproc->state != RPROC_RUNNING)
+		if (rproc->state != RPROC_RUNNING &&
+		    rproc->state != RPROC_ATTACHED)
 			return -EINVAL;
 
 		rproc_shutdown(rproc);
-- 
2.25.1


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

* [PATCH v7 16/17] remoteproc: Properly deal with a detach request when attached
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (14 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 15/17] remoteproc: Properly deal with a stop " Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  2021-03-10 21:10 ` [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release() Mathieu Poirier
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

This patch introduces the capability to detach a remote processor
that has been attached to by the remoteproc core.  For that to happen
a rproc::ops::detach() operation needs to be available.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_cdev.c  | 5 +++++
 drivers/remoteproc/remoteproc_sysfs.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index 0249d8f6c3f8..2db494816d5f 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -43,6 +43,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
 			return -EINVAL;
 
 		rproc_shutdown(rproc);
+	} else if (!strncmp(cmd, "detach", len)) {
+		if (rproc->state != RPROC_ATTACHED)
+			return -EINVAL;
+
+		ret = rproc_detach(rproc);
 	} else {
 		dev_err(&rproc->dev, "Unrecognized option\n");
 		ret = -EINVAL;
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 09eb700c5e7e..ad3dd208024c 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -207,6 +207,11 @@ static ssize_t state_store(struct device *dev,
 			return -EINVAL;
 
 		rproc_shutdown(rproc);
+	} else if (sysfs_streq(buf, "detach")) {
+		if (rproc->state != RPROC_ATTACHED)
+			return -EINVAL;
+
+		ret = rproc_detach(rproc);
 	} else {
 		dev_err(&rproc->dev, "Unrecognised option: %s\n", buf);
 		ret = -EINVAL;
-- 
2.25.1


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

* [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release()
  2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
                   ` (15 preceding siblings ...)
  2021-03-10 21:10 ` [PATCH v7 16/17] remoteproc: Properly deal with a detach " Mathieu Poirier
@ 2021-03-10 21:10 ` Mathieu Poirier
  16 siblings, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-10 21:10 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Refactor function rproc_cdev_release() to take into account the
current state of the remote processor when choosing the state to
transition to.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
New for V7:
  Keep the behavior of the shutdown operation in rproc_del() intact. 
---
 drivers/remoteproc/remoteproc_cdev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index 2db494816d5f..0b8a84c04f76 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -86,11 +86,17 @@ static long rproc_device_ioctl(struct file *filp, unsigned int ioctl, unsigned l
 static int rproc_cdev_release(struct inode *inode, struct file *filp)
 {
 	struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev);
+	int ret = 0;
+
+	if (!rproc->cdev_put_on_release)
+		return 0;
 
-	if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING)
+	if (rproc->state == RPROC_RUNNING)
 		rproc_shutdown(rproc);
+	else if (rproc->state == RPROC_ATTACHED)
+		ret = rproc_detach(rproc);
 
-	return 0;
+	return ret;
 }
 
 static const struct file_operations rproc_fops = {
-- 
2.25.1


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

* Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping
  2021-03-10 21:10 ` [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Mathieu Poirier
@ 2021-03-10 23:00   ` kernel test robot
  2021-03-10 23:53   ` Bjorn Andersson
  1 sibling, 0 replies; 23+ messages in thread
From: kernel test robot @ 2021-03-10 23:00 UTC (permalink / raw)
  To: Mathieu Poirier, ohad, bjorn.andersson
  Cc: kbuild-all, arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

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

Hi Mathieu,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.12-rc2 next-20210310]
[cannot apply to remoteproc/for-next rpmsg/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mathieu-Poirier/remoteproc-Add-support-for-detaching-a-remote-processor/20210311-051242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 144c79ef33536b4ecb4951e07dbc1f2b7fa99d32
config: arm-randconfig-r036-20210310 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/6715f51e2b7ade7b5121eced81cad8065d4f5525
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mathieu-Poirier/remoteproc-Add-support-for-detaching-a-remote-processor/20210311-051242
        git checkout 6715f51e2b7ade7b5121eced81cad8065d4f5525
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/remoteproc/remoteproc_core.c: In function 'rproc_reset_rsc_table_on_stop':
>> drivers/remoteproc/remoteproc_core.c:1639:25: warning: variable 'table_ptr' set but not used [-Wunused-but-set-variable]
    1639 |  struct resource_table *table_ptr;
         |                         ^~~~~~~~~


vim +/table_ptr +1639 drivers/remoteproc/remoteproc_core.c

  1636	
  1637	static int rproc_reset_rsc_table_on_stop(struct rproc *rproc)
  1638	{
> 1639		struct resource_table *table_ptr;
  1640	
  1641		/* A resource table was never retrieved, nothing to do here */
  1642		if (!rproc->table_ptr)
  1643			return 0;
  1644	
  1645		/*
  1646		 * If a cache table exists the remote processor was started by
  1647		 * the remoteproc core.  That cache table should be used for
  1648		 * the rest of the shutdown process.
  1649		 */
  1650		if (rproc->cached_table)
  1651			goto out;
  1652	
  1653		/* Remember where the external entity installed the resource table */
  1654		table_ptr = rproc->table_ptr;
  1655	
  1656		/*
  1657		 * If we made it here the remote processor was started by another
  1658		 * entity and a cache table doesn't exist.  As such make a copy of
  1659		 * the resource table currently used by the remote processor and
  1660		 * use that for the rest of the shutdown process.  The memory
  1661		 * allocated here is free'd in rproc_shutdown().
  1662		 */
  1663		rproc->cached_table = kmemdup(rproc->table_ptr,
  1664					      rproc->table_sz, GFP_KERNEL);
  1665		if (!rproc->cached_table)
  1666			return -ENOMEM;
  1667	
  1668		/*
  1669		 * Since the remote processor is being switched off the clean table
  1670		 * won't be needed.  Allocated in rproc_set_rsc_table().
  1671		 */
  1672		kfree(rproc->clean_table);
  1673	
  1674	out:
  1675		/*
  1676		 * Use a copy of the resource table for the remainder of the
  1677		 * shutdown process.
  1678		 */
  1679		rproc->table_ptr = rproc->cached_table;
  1680		return 0;
  1681	}
  1682	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25803 bytes --]

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

* Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping
  2021-03-10 21:10 ` [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Mathieu Poirier
  2021-03-10 23:00   ` kernel test robot
@ 2021-03-10 23:53   ` Bjorn Andersson
  2021-03-11  9:14     ` Arnaud POULIQUEN
  2021-03-11 17:13     ` Mathieu Poirier
  1 sibling, 2 replies; 23+ messages in thread
From: Bjorn Andersson @ 2021-03-10 23:53 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: ohad, arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

On Wed 10 Mar 15:10 CST 2021, Mathieu Poirier wrote:

> When a remote processor that was attached to is stopped, special care
> must be taken to make sure the shutdown process is similar to what
> it would be had it been started by the remoteproc core.
> 
> This patch takes care of that by making a copy of the resource
> table currently used by the remote processor.  From that point on
> the copy is used, as if the remote processor had been started by
> the remoteproc core.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> New for V7:
>   New Patch, used to be part of 11/16 in V6.
> ---
>  drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++-
>  1 file changed, 52 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index e9ea2558432d..c488b1aa6119 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
>  	return 0;
>  }
>  
> +static int rproc_reset_rsc_table_on_stop(struct rproc *rproc)
> +{
> +	struct resource_table *table_ptr;
> +
> +	/* A resource table was never retrieved, nothing to do here */
> +	if (!rproc->table_ptr)
> +		return 0;
> +
> +	/*
> +	 * If a cache table exists the remote processor was started by
> +	 * the remoteproc core.  That cache table should be used for
> +	 * the rest of the shutdown process.
> +	 */
> +	if (rproc->cached_table)
> +		goto out;
> +
> +	/* Remember where the external entity installed the resource table */
> +	table_ptr = rproc->table_ptr;
> +

Afaict this is just a remnant from the detach case.

I think the series looks really good now, please let me know and I can
drop the local "table_ptr" as I apply the patches.

Regards,
Bjorn

> +	/*
> +	 * If we made it here the remote processor was started by another
> +	 * entity and a cache table doesn't exist.  As such make a copy of
> +	 * the resource table currently used by the remote processor and
> +	 * use that for the rest of the shutdown process.  The memory
> +	 * allocated here is free'd in rproc_shutdown().
> +	 */
> +	rproc->cached_table = kmemdup(rproc->table_ptr,
> +				      rproc->table_sz, GFP_KERNEL);
> +	if (!rproc->cached_table)
> +		return -ENOMEM;
> +
> +	/*
> +	 * Since the remote processor is being switched off the clean table
> +	 * won't be needed.  Allocated in rproc_set_rsc_table().
> +	 */
> +	kfree(rproc->clean_table);
> +
> +out:
> +	/*
> +	 * Use a copy of the resource table for the remainder of the
> +	 * shutdown process.
> +	 */
> +	rproc->table_ptr = rproc->cached_table;
> +	return 0;
> +}
> +
>  /*
>   * Attach to remote processor - similar to rproc_fw_boot() but without
>   * the steps that deal with the firmware image.
> @@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
>  	rproc_stop_subdevices(rproc, crashed);
>  
>  	/* the installed resource table is no longer accessible */
> -	rproc->table_ptr = rproc->cached_table;
> +	ret = rproc_reset_rsc_table_on_stop(rproc);
> +	if (ret) {
> +		dev_err(dev, "can't reset resource table: %d\n", ret);
> +		return ret;
> +	}
> +
>  
>  	/* power off the remote processor */
>  	ret = rproc->ops->stop(rproc);
> -- 
> 2.25.1
> 

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

* Re: [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching
  2021-03-10 21:10 ` [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching Mathieu Poirier
@ 2021-03-11  9:09   ` Arnaud POULIQUEN
  0 siblings, 0 replies; 23+ messages in thread
From: Arnaud POULIQUEN @ 2021-03-11  9:09 UTC (permalink / raw)
  To: Mathieu Poirier, ohad, bjorn.andersson
  Cc: arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

Hi Mathieu,

Just a minor comment, with that
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>


On 3/10/21 10:10 PM, Mathieu Poirier wrote:
> If it is possible to detach the remote processor, keep an untouched
> copy of the resource table.  That way we can start from the same
> resource table without having to worry about original values or what
> elements the startup code has changed when re-attaching to the remote
> processor.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> New for V7:
>   New Patch, used to be part of 11/16 in V6.
> ---
>  drivers/remoteproc/remoteproc_core.c | 77 ++++++++++++++++++++++++++++
>  include/linux/remoteproc.h           |  3 ++
>  2 files changed, 80 insertions(+)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 5eaa47c3ba92..e9ea2558432d 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1556,6 +1556,24 @@ static int rproc_set_rsc_table(struct rproc *rproc)
>  		return ret;
>  	}
>  
> +	/*
> +	 * If it is possible to detach the remote processor, keep an untouched
> +	 * copy of the resource table.  That way we can start fresh again when
> +	 * the remote processor is re-attached, that is:
> +	 *
> +	 *      DETACHED -> ATTACHED -> DETACHED -> ATTACHED
> +	 *
> +	 * Free'd in rproc_reset_rsc_table_on_detach() and
> +	 * rproc_reset_rsc_table_on_stop().
> +	 */
> +	if (rproc->ops->detach) {
> +		rproc->clean_table = kmemdup(table_ptr, table_sz, GFP_KERNEL);
> +		if (!rproc->clean_table)
> +			return -ENOMEM;
> +	} else {
> +		rproc->clean_table = NULL;
> +	}
> +
>  	rproc->cached_table = NULL;
>  	rproc->table_ptr = table_ptr;
>  	rproc->table_sz = table_sz;
> @@ -1563,6 +1581,59 @@ static int rproc_set_rsc_table(struct rproc *rproc)
>  	return 0;
>  }
>  
> +static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
> +{
> +	struct resource_table *table_ptr;
> +
> +	/* A resource table was never retrieved, nothing to do here */
> +	if (!rproc->table_ptr)
> +		return 0;
> +
> +	/*
> +	 * If we made it to this point a clean_table _must_ have been
> +	 * allocated in rproc_set_rsc_table().  If one isn't present
> +	 * something went really wrong and we must complain.
> +	 */
> +	if (WARN_ON(!rproc->clean_table))
> +		return -EINVAL;
> +
> +	/* Remember where the external entity installed the resource table */
> +	table_ptr = rproc->table_ptr;
> +
> +	/*
> +	 * If we made it here the remote processor was started by another
> +	 * entity and a cache table doesn't exist.  As such make a copy of
> +	 * the resource table currently used by the remote processor and
> +	 * use that for the rest of the shutdown process.  The memory
> +	 * allocated here is free'd in rproc_detach().
> +	 */
> +	rproc->cached_table = kmemdup(rproc->table_ptr,
> +				      rproc->table_sz, GFP_KERNEL);
> +	if (!rproc->cached_table)
> +		return -ENOMEM;
> +
> +	/*
> +	 * Use a copy of the resource table for the remainder of the
> +	 * shutdown process.
> +	 */
> +	rproc->table_ptr = rproc->cached_table;
> +
> +	/*
> +	 * Reset the memory area where the firmware loaded the resource table
> +	 * to its original value.  That way when we re-attach the remote
> +	 * processor the resource table is clean and ready to be used again.
> +	 */
> +	memcpy(table_ptr, rproc->clean_table, rproc->table_sz);
> +
> +	/*
> +	 * The clean resource table is no longer needed.  Allocated in
> +	 * rproc_set_rsc_table().
> +	 */
> +	kfree(rproc->clean_table);
> +
> +	return 0;
> +}
> +
>  /*
>   * Attach to remote processor - similar to rproc_fw_boot() but without
>   * the steps that deal with the firmware image.
> @@ -1721,6 +1792,9 @@ static int __rproc_detach(struct rproc *rproc)
>  	/* Stop any subdevices for the remote processor */
>  	rproc_stop_subdevices(rproc, false);
>  
> +	/* the installed resource table is no longer accessible */
> +	ret = rproc_reset_rsc_table_on_detach(rproc);
> +

Something seems missing here to treat the error case.

Regards,

Arnaud

>  	/* Tell the remote processor the core isn't available anymore */
>  	ret = rproc->ops->detach(rproc);
>  	if (ret) {
> @@ -1997,6 +2071,9 @@ int rproc_detach(struct rproc *rproc)
>  
>  	rproc_disable_iommu(rproc);
>  
> +	/* Free the copy of the resource table */
> +	kfree(rproc->cached_table);
> +	rproc->cached_table = NULL;
>  	rproc->table_ptr = NULL;
>  out:
>  	mutex_unlock(&rproc->lock);
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index e1c843c19cc6..e5f52a12a650 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -514,6 +514,8 @@ struct rproc_dump_segment {
>   * @recovery_disabled: flag that state if recovery was disabled
>   * @max_notifyid: largest allocated notify id.
>   * @table_ptr: pointer to the resource table in effect
> + * @clean_table: copy of the resource table without modifications.  Used
> + *		 when a remote processor is attached or detached from the core
>   * @cached_table: copy of the resource table
>   * @table_sz: size of @cached_table
>   * @has_iommu: flag to indicate if remote processor is behind an MMU
> @@ -550,6 +552,7 @@ struct rproc {
>  	bool recovery_disabled;
>  	int max_notifyid;
>  	struct resource_table *table_ptr;
> +	struct resource_table *clean_table;
>  	struct resource_table *cached_table;
>  	size_t table_sz;
>  	bool has_iommu;
> 

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

* Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping
  2021-03-10 23:53   ` Bjorn Andersson
@ 2021-03-11  9:14     ` Arnaud POULIQUEN
  2021-03-11 17:13     ` Mathieu Poirier
  1 sibling, 0 replies; 23+ messages in thread
From: Arnaud POULIQUEN @ 2021-03-11  9:14 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier
  Cc: ohad, arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel



On 3/11/21 12:53 AM, Bjorn Andersson wrote:
> On Wed 10 Mar 15:10 CST 2021, Mathieu Poirier wrote:
> 
>> When a remote processor that was attached to is stopped, special care
>> must be taken to make sure the shutdown process is similar to what
>> it would be had it been started by the remoteproc core.
>>
>> This patch takes care of that by making a copy of the resource
>> table currently used by the remote processor.  From that point on
>> the copy is used, as if the remote processor had been started by
>> the remoteproc core.
>>
>> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
>> ---
>> New for V7:
>>   New Patch, used to be part of 11/16 in V6.
>> ---
>>  drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++-
>>  1 file changed, 52 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
>> index e9ea2558432d..c488b1aa6119 100644
>> --- a/drivers/remoteproc/remoteproc_core.c
>> +++ b/drivers/remoteproc/remoteproc_core.c
>> @@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
>>  	return 0;
>>  }
>>  
>> +static int rproc_reset_rsc_table_on_stop(struct rproc *rproc)
>> +{
>> +	struct resource_table *table_ptr;
>> +
>> +	/* A resource table was never retrieved, nothing to do here */
>> +	if (!rproc->table_ptr)
>> +		return 0;
>> +
>> +	/*
>> +	 * If a cache table exists the remote processor was started by
>> +	 * the remoteproc core.  That cache table should be used for
>> +	 * the rest of the shutdown process.
>> +	 */
>> +	if (rproc->cached_table)
>> +		goto out;
>> +
>> +	/* Remember where the external entity installed the resource table */
>> +	table_ptr = rproc->table_ptr;
>> +
> 
> Afaict this is just a remnant from the detach case.
> 
> I think the series looks really good now, please let me know and I can
> drop the local "table_ptr" as I apply the patches.
> 

Just a minor comment on patch 11, then the series LGTM also,

For this one
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>

Thanks,
Arnaud

> Regards,
> Bjorn
> 
>> +	/*
>> +	 * If we made it here the remote processor was started by another
>> +	 * entity and a cache table doesn't exist.  As such make a copy of
>> +	 * the resource table currently used by the remote processor and
>> +	 * use that for the rest of the shutdown process.  The memory
>> +	 * allocated here is free'd in rproc_shutdown().
>> +	 */
>> +	rproc->cached_table = kmemdup(rproc->table_ptr,
>> +				      rproc->table_sz, GFP_KERNEL);
>> +	if (!rproc->cached_table)
>> +		return -ENOMEM;
>> +
>> +	/*
>> +	 * Since the remote processor is being switched off the clean table
>> +	 * won't be needed.  Allocated in rproc_set_rsc_table().
>> +	 */
>> +	kfree(rproc->clean_table);
>> +
>> +out:
>> +	/*
>> +	 * Use a copy of the resource table for the remainder of the
>> +	 * shutdown process.
>> +	 */
>> +	rproc->table_ptr = rproc->cached_table;
>> +	return 0;
>> +}
>> +
>>  /*
>>   * Attach to remote processor - similar to rproc_fw_boot() but without
>>   * the steps that deal with the firmware image.
>> @@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
>>  	rproc_stop_subdevices(rproc, crashed);
>>  
>>  	/* the installed resource table is no longer accessible */
>> -	rproc->table_ptr = rproc->cached_table;
>> +	ret = rproc_reset_rsc_table_on_stop(rproc);
>> +	if (ret) {
>> +		dev_err(dev, "can't reset resource table: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>>  
>>  	/* power off the remote processor */
>>  	ret = rproc->ops->stop(rproc);
>> -- 
>> 2.25.1
>>

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

* Re: [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping
  2021-03-10 23:53   ` Bjorn Andersson
  2021-03-11  9:14     ` Arnaud POULIQUEN
@ 2021-03-11 17:13     ` Mathieu Poirier
  1 sibling, 0 replies; 23+ messages in thread
From: Mathieu Poirier @ 2021-03-11 17:13 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: ohad, arnaud.pouliquen, mcoquelin.stm32, alexandre.torgue,
	linux-remoteproc, linux-kernel, linux-arm-kernel

On Wed, Mar 10, 2021 at 05:53:04PM -0600, Bjorn Andersson wrote:
> On Wed 10 Mar 15:10 CST 2021, Mathieu Poirier wrote:
> 
> > When a remote processor that was attached to is stopped, special care
> > must be taken to make sure the shutdown process is similar to what
> > it would be had it been started by the remoteproc core.
> > 
> > This patch takes care of that by making a copy of the resource
> > table currently used by the remote processor.  From that point on
> > the copy is used, as if the remote processor had been started by
> > the remoteproc core.
> > 
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > ---
> > New for V7:
> >   New Patch, used to be part of 11/16 in V6.
> > ---
> >  drivers/remoteproc/remoteproc_core.c | 53 +++++++++++++++++++++++++++-
> >  1 file changed, 52 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> > index e9ea2558432d..c488b1aa6119 100644
> > --- a/drivers/remoteproc/remoteproc_core.c
> > +++ b/drivers/remoteproc/remoteproc_core.c
> > @@ -1634,6 +1634,52 @@ static int rproc_reset_rsc_table_on_detach(struct rproc *rproc)
> >  	return 0;
> >  }
> >  
> > +static int rproc_reset_rsc_table_on_stop(struct rproc *rproc)
> > +{
> > +	struct resource_table *table_ptr;
> > +
> > +	/* A resource table was never retrieved, nothing to do here */
> > +	if (!rproc->table_ptr)
> > +		return 0;
> > +
> > +	/*
> > +	 * If a cache table exists the remote processor was started by
> > +	 * the remoteproc core.  That cache table should be used for
> > +	 * the rest of the shutdown process.
> > +	 */
> > +	if (rproc->cached_table)
> > +		goto out;
> > +
> > +	/* Remember where the external entity installed the resource table */
> > +	table_ptr = rproc->table_ptr;
> > +
> 
> Afaict this is just a remnant from the detach case.
> 
> I think the series looks really good now, please let me know and I can
> drop the local "table_ptr" as I apply the patches.

(sigh) No matter how long you stare at a patchset there is always one that gets
away.  I will address Arnaud's comment and fix this in a new revision.

Thanks,
Mathieu 

> 
> Regards,
> Bjorn
> 
> > +	/*
> > +	 * If we made it here the remote processor was started by another
> > +	 * entity and a cache table doesn't exist.  As such make a copy of
> > +	 * the resource table currently used by the remote processor and
> > +	 * use that for the rest of the shutdown process.  The memory
> > +	 * allocated here is free'd in rproc_shutdown().
> > +	 */
> > +	rproc->cached_table = kmemdup(rproc->table_ptr,
> > +				      rproc->table_sz, GFP_KERNEL);
> > +	if (!rproc->cached_table)
> > +		return -ENOMEM;
> > +
> > +	/*
> > +	 * Since the remote processor is being switched off the clean table
> > +	 * won't be needed.  Allocated in rproc_set_rsc_table().
> > +	 */
> > +	kfree(rproc->clean_table);
> > +
> > +out:
> > +	/*
> > +	 * Use a copy of the resource table for the remainder of the
> > +	 * shutdown process.
> > +	 */
> > +	rproc->table_ptr = rproc->cached_table;
> > +	return 0;
> > +}
> > +
> >  /*
> >   * Attach to remote processor - similar to rproc_fw_boot() but without
> >   * the steps that deal with the firmware image.
> > @@ -1759,7 +1805,12 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
> >  	rproc_stop_subdevices(rproc, crashed);
> >  
> >  	/* the installed resource table is no longer accessible */
> > -	rproc->table_ptr = rproc->cached_table;
> > +	ret = rproc_reset_rsc_table_on_stop(rproc);
> > +	if (ret) {
> > +		dev_err(dev, "can't reset resource table: %d\n", ret);
> > +		return ret;
> > +	}
> > +
> >  
> >  	/* power off the remote processor */
> >  	ret = rproc->ops->stop(rproc);
> > -- 
> > 2.25.1
> > 

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

end of thread, other threads:[~2021-03-11 17:14 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 21:10 [PATCH v7 00/17] remoteproc: Add support for detaching a remote processor Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 01/17] remoteproc: Remove useless check in rproc_del() Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 02/17] remoteproc: Rename function rproc_actuate() Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 03/17] remoteproc: Add new RPROC_ATTACHED state Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 04/17] remoteproc: Properly represent the attached state Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 05/17] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 06/17] remoteproc: stm32: Move resource table setup " Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 07/17] remoteproc: stm32: Move memory parsing " Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 08/17] remoteproc: Add new detach() remoteproc operation Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 09/17] remoteproc: Introduce function __rproc_detach() Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 10/17] remoteproc: Introduce function rproc_detach() Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 11/17] remoteproc: Properly deal with the resource table when detaching Mathieu Poirier
2021-03-11  9:09   ` Arnaud POULIQUEN
2021-03-10 21:10 ` [PATCH v7 12/17] remoteproc: Properly deal with the resource table when stopping Mathieu Poirier
2021-03-10 23:00   ` kernel test robot
2021-03-10 23:53   ` Bjorn Andersson
2021-03-11  9:14     ` Arnaud POULIQUEN
2021-03-11 17:13     ` Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 13/17] remoteproc: Properly deal with a kernel panic when attached Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 14/17] remoteproc: Properly deal with a start request " Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 15/17] remoteproc: Properly deal with a stop " Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 16/17] remoteproc: Properly deal with a detach " Mathieu Poirier
2021-03-10 21:10 ` [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release() Mathieu Poirier

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