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

remoteproc: Properly deal with a detach request when attached

This patch introduces the capability to detach a remote processor
that has been attached to by the remoteproc core. For that to happen
a rproc::ops::detach() 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-17-mathieu.poirier@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Mathieu Poirier and committed by
Bjorn Andersson
5daaeb5f d2008a96

+10
+5
drivers/remoteproc/remoteproc_cdev.c
··· 43 43 return -EINVAL; 44 44 45 45 rproc_shutdown(rproc); 46 + } else if (!strncmp(cmd, "detach", len)) { 47 + if (rproc->state != RPROC_ATTACHED) 48 + return -EINVAL; 49 + 50 + ret = rproc_detach(rproc); 46 51 } else { 47 52 dev_err(&rproc->dev, "Unrecognized option\n"); 48 53 ret = -EINVAL;
+5
drivers/remoteproc/remoteproc_sysfs.c
··· 207 207 return -EINVAL; 208 208 209 209 rproc_shutdown(rproc); 210 + } else if (sysfs_streq(buf, "detach")) { 211 + if (rproc->state != RPROC_ATTACHED) 212 + return -EINVAL; 213 + 214 + ret = rproc_detach(rproc); 210 215 } else { 211 216 dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); 212 217 ret = -EINVAL;