diff mbox series

remoteproc: core: check state in rproc_boot

Message ID 20220519064111.3244079-1-peng.fan@oss.nxp.com (mailing list archive)
State New
Headers show
Series remoteproc: core: check state in rproc_boot | expand

Commit Message

Peng Fan (OSS) May 19, 2022, 6:41 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

If remote processor has already been in RUNNING or ATTACHED
state, report it. Not just increment the power counter and return
success.

Without this patch, if m7 is in RUNNING state, and start it again,
nothing output to console.
If wanna to stop the m7, we need write twice 'stop'.

This patch is to improve that the 2nd start would show some useful
info.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

Not sure to keep power counter or not.

 drivers/remoteproc/remoteproc_core.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 02a04ab34a23..f37e0758c096 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2005,6 +2005,12 @@  int rproc_boot(struct rproc *rproc)
 		goto unlock_mutex;
 	}
 
+	if (rproc->state == RPROC_RUNNING || rproc->state == RPROC_ATTACHED) {
+		ret = -EINVAL;
+		dev_err(dev, "%s already booted\n", rproc->name);
+		goto unlock_mutex;
+	}
+
 	/* skip the boot or attach process if rproc is already powered up */
 	if (atomic_inc_return(&rproc->power) > 1) {
 		ret = 0;