[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201218173228.2277032-14-mathieu.poirier@linaro.org>
Date: Fri, 18 Dec 2020 10:32:24 -0700
From: Mathieu Poirier <mathieu.poirier@...aro.org>
To: ohad@...ery.com, bjorn.andersson@...aro.org, robh+dt@...nel.org
Cc: arnaud.pouliquen@...com, linux-remoteproc@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v4 13/17] remoteproc: Add return value to function rproc_shutdown()
Add a return value to function rproc_shutdown() in order to
properly deal with error conditions that may occur.
Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
Reviewed-by: Peng Fan <peng.fan@....com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@...com>
---
drivers/remoteproc/remoteproc_core.c | 19 ++++++++++++++-----
include/linux/remoteproc.h | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ece3f15070b9..90057ad1bb6c 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1886,7 +1886,7 @@ EXPORT_SYMBOL(rproc_boot);
* returns, and users can still use it with a subsequent rproc_boot(), if
* needed.
*/
-void rproc_shutdown(struct rproc *rproc)
+int rproc_shutdown(struct rproc *rproc)
{
struct device *dev = &rproc->dev;
int ret;
@@ -1894,15 +1894,19 @@ void rproc_shutdown(struct rproc *rproc)
ret = mutex_lock_interruptible(&rproc->lock);
if (ret) {
dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
- return;
+ return ret;
}
- if (rproc->state != RPROC_RUNNING)
+ if (rproc->state != RPROC_RUNNING) {
+ ret = -EPERM;
goto out;
+ }
/* if the remote proc is still needed, bail out */
- if (!atomic_dec_and_test(&rproc->power))
+ if (!atomic_dec_and_test(&rproc->power)) {
+ ret = -EBUSY;
goto out;
+ }
ret = rproc_stop(rproc, false);
if (ret) {
@@ -1914,7 +1918,11 @@ void rproc_shutdown(struct rproc *rproc)
rproc_resource_cleanup(rproc);
/* release HW resources if needed */
- rproc_unprepare_device(rproc);
+ ret = rproc_unprepare_device(rproc);
+ if (ret) {
+ atomic_inc(&rproc->power);
+ goto out;
+ }
rproc_disable_iommu(rproc);
@@ -1924,6 +1932,7 @@ void rproc_shutdown(struct rproc *rproc)
rproc->table_ptr = NULL;
out:
mutex_unlock(&rproc->lock);
+ return ret;
}
EXPORT_SYMBOL(rproc_shutdown);
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 65ece6f177b7..aa5bceb72015 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -658,7 +658,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len,
u32 da, const char *name, ...);
int rproc_boot(struct rproc *rproc);
-void rproc_shutdown(struct rproc *rproc);
+int 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);
--
2.25.1
Powered by blists - more mailing lists