[RFC LINUX PATCH 18/19] remoteproc: shutdown: set state to OFFLINE after stopping remote

From: Wendy Liang
Date: Fri Mar 24 2017 - 15:31:25 EST


From: Wendy Liang <wendy.liang@xxxxxxxxxx>

Set rproc state to OFFLINE right after it stops the remote.
Some remoteproc virtio operations depends on rproc state. And thus,
we should set the rproc state to OFFLINE right after it stops
the remote.

Signed-off-by: Wendy Liang <jliang@xxxxxxxxxx>
Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx>
---
drivers/remoteproc/remoteproc_core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ffd1de2..62c0356 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1369,6 +1369,7 @@ void rproc_shutdown(struct rproc *rproc)
{
struct device *dev = &rproc->dev;
int ret;
+ int pre_rproc_state;

ret = mutex_lock_interruptible(&rproc->lock);
if (ret) {
@@ -1391,6 +1392,9 @@ void rproc_shutdown(struct rproc *rproc)
goto out;
}

+ pre_rproc_state = rproc->state;
+ rproc->state = RPROC_OFFLINE;
+
/* clean up all acquired resources */
rproc_resource_cleanup(rproc);

@@ -1402,11 +1406,9 @@ void rproc_shutdown(struct rproc *rproc)
rproc->table_ptr = NULL;

/* if in crash state, unlock crash handler */
- if (rproc->state == RPROC_CRASHED)
+ if (pre_rproc_state == RPROC_CRASHED)
complete_all(&rproc->crash_comp);

- rproc->state = RPROC_OFFLINE;
-
dev_info(dev, "stopped remote processor %s\n", rproc->name);

out:
--
1.9.1