Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

remoteproc: Properly deal with a stop request when attached

Allow a remote processor that was started by another entity to be
switched off by the remoteproc core. For that to happen a
rproc::ops::stop() operation needs to be available.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Link: https://lore.kernel.org/r/20210312162453.1234145-16-mathieu.poirier@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Mathieu Poirier and committed by
Bjorn Andersson
d2008a96 83d4e671

+8 -2
+2 -1
drivers/remoteproc/remoteproc_cdev.c
··· 38 38 39 39 ret = rproc_boot(rproc); 40 40 } else if (!strncmp(cmd, "stop", len)) { 41 - if (rproc->state != RPROC_RUNNING) 41 + if (rproc->state != RPROC_RUNNING && 42 + rproc->state != RPROC_ATTACHED) 42 43 return -EINVAL; 43 44 44 45 rproc_shutdown(rproc);
+4
drivers/remoteproc/remoteproc_core.c
··· 1802 1802 struct device *dev = &rproc->dev; 1803 1803 int ret; 1804 1804 1805 + /* No need to continue if a stop() operation has not been provided */ 1806 + if (!rproc->ops->stop) 1807 + return -EINVAL; 1808 + 1805 1809 /* Stop any subdevices for the remote processor */ 1806 1810 rproc_stop_subdevices(rproc, crashed); 1807 1811
+2 -1
drivers/remoteproc/remoteproc_sysfs.c
··· 202 202 if (ret) 203 203 dev_err(&rproc->dev, "Boot failed: %d\n", ret); 204 204 } else if (sysfs_streq(buf, "stop")) { 205 - if (rproc->state != RPROC_RUNNING) 205 + if (rproc->state != RPROC_RUNNING && 206 + rproc->state != RPROC_ATTACHED) 206 207 return -EINVAL; 207 208 208 209 rproc_shutdown(rproc);