@@ -87,7 +87,18 @@ static int rproc_cdev_release(struct inode *inode, struct file *filp)
{
struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev);
- if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING)
+ if (!rproc->cdev_put_on_release)
+ return 0;
+
+ /*
+ * The application has crashed or is releasing its file handle. Detach
+ * or shutdown the remote processor based on the policy specified in the
+ * DT. No need to check rproc->state right away, it will be done
+ * in either rproc_detach() or rproc_shutdown().
+ */
+ if (rproc->autonomous_on_core_reboot)
+ rproc_detach(rproc);
+ else
rproc_shutdown(rproc);
return 0;
@@ -2393,8 +2393,16 @@ int rproc_del(struct rproc *rproc)
if (!rproc)
return -EINVAL;
- /* TODO: make sure this works with rproc->power > 1 */
- rproc_shutdown(rproc);
+ /*
+ * TODO: make sure this works with rproc->power > 1
+ *
+ * No need to check rproc->state right away, it will be done in either
+ * rproc_detach() or rproc_shutdown().
+ */
+ if (rproc->autonomous_on_core_reboot)
+ rproc_detach(rproc);
+ else
+ rproc_shutdown(rproc);
mutex_lock(&rproc->lock);
rproc->state = RPROC_DELETED;
Refactor function rproc_del() and rproc_cdev_release() to take into account the policy specified in the device tree. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> --- drivers/remoteproc/remoteproc_cdev.c | 13 ++++++++++++- drivers/remoteproc/remoteproc_core.c | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-)