From 7517114b4facdc9ca80e27c30dfc6ef8a1f165f4 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Wed, 6 Mar 2019 14:16:38 -0600 Subject: [PATCH] Revert "remoteproc: Remove depricated crash completion" This reverts commit b26210cda63564a7478486faaea713f6ea965633. The commit b26210cda635 ("remoteproc: Remove depricated crash completion") has dropped the crash_comp completion variable as it was not needed after the rproc_trigger_recovery() function was modified to leverage rproc_stop() and rproc_start() functions in commit 7e83cab824a8 ("remoteproc: Modify recovery path to use rproc_{start,stop}()"). These new functions execute only a portion of the previous functions, and break the error recovery on OMAP remoteproc devices. Reintroduce the crash completion variable by reverting the above commit in preparation for reverting the error recovery logic to not use the rproc_start() and rproc_stop() functions. Signed-off-by: Suman Anna --- drivers/remoteproc/remoteproc_core.c | 10 ++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 89580b957d66..76fd36413c56 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1206,6 +1206,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc_unprepare_subdevices(rproc); + /* if in crash state, unlock crash handler */ + if (rproc->state == RPROC_CRASHED) + complete_all(&rproc->crash_comp); + rproc->state = RPROC_OFFLINE; dev_info(dev, "stopped remote processor %s\n", rproc->name); @@ -1339,6 +1343,8 @@ int rproc_trigger_recovery(struct rproc *rproc) dev_err(dev, "recovering %s\n", rproc->name); + init_completion(&rproc->crash_comp); + ret = mutex_lock_interruptible(&rproc->lock); if (ret) return ret; @@ -1350,6 +1356,9 @@ int rproc_trigger_recovery(struct rproc *rproc) /* generate coredump */ rproc_coredump(rproc); + /* wait until there is no more rproc users */ + wait_for_completion(&rproc->crash_comp); + /* load firmware */ ret = request_firmware(&firmware_p, rproc->firmware, dev); if (ret < 0) { @@ -1786,6 +1795,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, INIT_LIST_HEAD(&rproc->dump_segments); INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work); + init_completion(&rproc->crash_comp); rproc->state = RPROC_OFFLINE; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e0baae1659c2..ed33b09ff0ce 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -476,6 +476,7 @@ struct rproc_dump_segment { * @index: index of this rproc device * @crash_handler: workqueue for handling a crash * @crash_cnt: crash counter + * @crash_comp: completion used to sync crash handler and the rproc reload * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id. * @table_ptr: pointer to the resource table in effect @@ -511,6 +512,7 @@ struct rproc { int index; struct work_struct crash_handler; unsigned int crash_cnt; + struct completion crash_comp; bool recovery_disabled; int max_notifyid; struct resource_table *table_ptr; -- 2.39.2