diff options
authorSuman Anna <s-anna@ti.com>2018-09-10 12:30:26 -0500
committerGrzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>2020-12-21 23:25:38 +0100
commitc8406901a1f28750e3821c67b6c18949b9949b6d (patch)
parent08dcdb72183f59e4e1e93fb47566ddb44eba0eff (diff)
remoteproc: Introduce deny_sysfs_ops flag
The remoteproc framework provides sysfs interfaces for changing the firmware name and for starting/stopping a remote processor through the sysfs files 'state' and 'firmware'. These interfaces are currently allowed irrespective of how the remoteprocs were booted (like remoteproc self auto-boot, remoteproc client-driven boot etc). These interfaces can adversely affect a remoteproc and its clients especially when a remoteproc is being controlled by a remoteproc client driver(s). Also, not all remoteproc drivers may want to support the sysfs interfaces by default. Add support to deny the sysfs state/firmware change by introducing a state flag 'deny_sysfs_ops' that the individual remoteproc drivers can set based on their usage needs. The default behavior is to allow the sysfs operations as before. Signed-off-by: Suman Anna <s-anna@ti.com> [grzegorz: solve conflicts]
2 files changed, 10 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
index 1dbef895e65e..8c057f919704 100644
--- a/drivers/remoteproc/remoteproc_sysfs.c
+++ b/drivers/remoteproc/remoteproc_sysfs.c
@@ -156,6 +156,10 @@ static ssize_t firmware_store(struct device *dev,
struct rproc *rproc = to_rproc(dev);
int err;
+ /* restrict sysfs operations if not allowed by remoteproc drivers */
+ if (rproc->deny_sysfs_ops)
+ return -EPERM;
err = rproc_set_firmware(rproc, buf);
return err ? err : count;
@@ -195,6 +199,10 @@ static ssize_t state_store(struct device *dev,
struct rproc *rproc = to_rproc(dev);
int ret = 0;
+ /* restrict sysfs operations if not allowed by remoteproc drivers */
+ if (rproc->deny_sysfs_ops)
+ return -EPERM;
if (sysfs_streq(buf, "start")) {
if (rproc->state == RPROC_RUNNING)
return -EBUSY;
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index f28ee75d1005..af5fb6acf7d0 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -510,6 +510,7 @@ struct rproc_dump_segment {
* @has_iommu: flag to indicate if remote processor is behind an MMU
* @auto_boot: flag to indicate if remote processor should be auto-started
* @autonomous: true if an external entity has booted the remote processor
+ * @deny_sysfs_ops: flag to not permit sysfs operations on state and firmware
* @dump_segments: list of segments in the firmware
* @nb_vdev: number of vdev currently handled by rproc
* @char_dev: character device of the rproc
@@ -547,6 +548,7 @@ struct rproc {
bool has_iommu;
bool auto_boot;
bool autonomous;
+ unsigned int deny_sysfs_ops : 1;
struct list_head dump_segments;
int nb_vdev;
u8 elf_class;