diff mbox series

[v3,14/15] remoteproc: Properly deal with detach request

Message ID 20201126210642.897302-15-mathieu.poirier@linaro.org
State Superseded
Headers show
Series remoteproc: Add support for detaching from rproc | expand

Commit Message

Mathieu Poirier Nov. 26, 2020, 9:06 p.m. UTC
This patch introduces the capability to detach a remote processor
that has been attached to or booted by the remoteproc core.  For
that to happen a rproc::ops::detach() operation need to be
available.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

---
 drivers/remoteproc/remoteproc_cdev.c  | 6 ++++++
 drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++
 2 files changed, 12 insertions(+)

-- 
2.25.1

Comments

Arnaud POULIQUEN Dec. 9, 2020, 8:47 a.m. UTC | #1
On 11/26/20 10:06 PM, Mathieu Poirier wrote:
> This patch introduces the capability to detach a remote processor

> that has been attached to or booted by the remoteproc core.  For

> that to happen a rproc::ops::detach() operation need to be

> available.

> 

> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> Reviewed-by: Peng Fan <peng.fan@nxp.com>


Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>


Thanks,
Arnaud
> ---

>  drivers/remoteproc/remoteproc_cdev.c  | 6 ++++++

>  drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++

>  2 files changed, 12 insertions(+)

> 

> diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c

> index 61541bc7d26c..f7645f289563 100644

> --- a/drivers/remoteproc/remoteproc_cdev.c

> +++ b/drivers/remoteproc/remoteproc_cdev.c

> @@ -43,6 +43,12 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_

>  			return -EINVAL;

>  

>  		ret = rproc_shutdown(rproc);

> +	} else if (!strncmp(cmd, "detach", len)) {

> +		if (rproc->state != RPROC_RUNNING &&

> +		    rproc->state != RPROC_ATTACHED)

> +			return -EINVAL;

> +

> +		ret = rproc_detach(rproc);

>  	} else {

>  		dev_err(&rproc->dev, "Unrecognized option\n");

>  		ret = -EINVAL;

> diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c

> index 7d281cfe3e03..5a239df5877e 100644

> --- a/drivers/remoteproc/remoteproc_sysfs.c

> +++ b/drivers/remoteproc/remoteproc_sysfs.c

> @@ -207,6 +207,12 @@ static ssize_t state_store(struct device *dev,

>  			return -EINVAL;

>  

>  		ret = rproc_shutdown(rproc);

> +	} else if (sysfs_streq(buf, "detach")) {

> +		if (rproc->state != RPROC_RUNNING &&

> +		    rproc->state != RPROC_ATTACHED)

> +			return -EINVAL;

> +

> +		ret = rproc_detach(rproc);

>  	} else {

>  		dev_err(&rproc->dev, "Unrecognised option: %s\n", buf);

>  		ret = -EINVAL;

>
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index 61541bc7d26c..f7645f289563 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -43,6 +43,12 @@  static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
 			return -EINVAL;
 
 		ret = rproc_shutdown(rproc);
+	} else if (!strncmp(cmd, "detach", len)) {
+		if (rproc->state != RPROC_RUNNING &&
+		    rproc->state != RPROC_ATTACHED)
+			return -EINVAL;
+
+		ret = rproc_detach(rproc);
 	} else {
 		dev_err(&rproc->dev, "Unrecognized option\n");
 		ret = -EINVAL;
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 7d281cfe3e03..5a239df5877e 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -207,6 +207,12 @@  static ssize_t state_store(struct device *dev,
 			return -EINVAL;
 
 		ret = rproc_shutdown(rproc);
+	} else if (sysfs_streq(buf, "detach")) {
+		if (rproc->state != RPROC_RUNNING &&
+		    rproc->state != RPROC_ATTACHED)
+			return -EINVAL;
+
+		ret = rproc_detach(rproc);
 	} else {
 		dev_err(&rproc->dev, "Unrecognised option: %s\n", buf);
 		ret = -EINVAL;