remoteproc sysfs fixes/improvements
v2 cover remoteproc sysfs fixes/improvements
Hi All,
This is a refresh of the unaccepted patches from an old series [1]. Patches 2 and 3 from that series were merged and these are rebased and revised versions of the same patches. I had forgotten about these patches, and am resurrecting these again. Patches are on top of latest 5.10-rc4.
The features being introduced here will be needed by the recently posted PRU remoteproc driver [2] in addition to the existing Wkup M3 remoteproc driver. Both of these drivers follow a client-driven boot methodology, with the latter strictly booted by another driver in kernel. The PRU remoteproc driver will be supporting both in-kernel clients as well as control from userspace orthogonally. The logic though is applicable and useful to any remoteproc driver not using 'auto-boot' and using an external driver/application to boot the remoteproc.
regards
Suman
[1] https://patchwork.kernel.org/project/linux-remoteproc/cover/[email protected]/
[2] https://patchwork.kernel.org/project/linux-remoteproc/cover/[email protected]/
Suman Anna (3):
remoteproc: Fix unbalanced boot with sysfs for no auto-boot rprocs
remoteproc: Introduce deny_sysfs_ops flag
remoteproc: wkup_m3: Set deny_sysfs_ops flag
drivers/remoteproc/remoteproc_sysfs.c | 28 ++++++++++++++++++++++++++- drivers/remoteproc/wkup_m3_rproc.c | 1 + include/linux/remoteproc.h | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-)
Signature · 1 line
2.28.0
PATCH v2 1/3 remoteproc: Fix unbalanced boot with sysfs for no auto-boot rprocs
The remoteproc core performs automatic boot and shutdown of a remote processor during rproc_add() and rproc_del() for remote processors supporting 'auto-boot'. The remoteproc devices not using 'auto-boot' require either a remoteproc client driver or a userspace client to use the sysfs 'state' variable to perform the boot and shutdown. The in-kernel client drivers hold the corresponding remoteproc driver module's reference count when they acquire a rproc handle through the rproc_get_by_phandle() API, but there is no such support for userspace applications performing the boot through sysfs interface.
The shutdown of a remoteproc upon removing a remoteproc platform driver is automatic only with 'auto-boot' and this can cause a remoteproc with no auto-boot to stay powered on and never freed up if booted using the sysfs interface without a matching stop, and when the remoteproc driver module is removed or unbound from the device. This will result in a memory leak as well as the corresponding remoteproc ida being never deallocated. Fix this by holding a module reference count for the remoteproc's driver during a sysfs 'start' and releasing it during the sysfs 'stop' operation.
---
v2: rebased version, no changes
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/
drivers/remoteproc/remoteproc_sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_sysfs.c +15 -1
@@ -3,6 +3,7 @@* Remote Processor Framework */ +#include <linux/module.h> #include <linux/remoteproc.h> #include <linux/slab.h>
@@ -228,14 +229,27 @@ static ssize_t state_store(struct device *dev,if (rproc->state ==RPROC_RUNNING )return -EBUSY ; +/* +* prevent underlying implementation from being removed +* when remoteproc does not support auto-boot +*/ +if (!rproc->auto_boot && + !try_module_get (dev->parent->driver->owner)) +return -EINVAL ; + ret =rproc_boot (rproc); -if (ret) +if (ret) {dev_err (&rproc->dev,"Boot failed: %d\n" , ret); +if (!rproc->auto_boot) +module_put (dev->parent->driver->owner); + } }else if (sysfs_streq (buf,"stop" )) {if (rproc->state !=RPROC_RUNNING )return -EINVAL ;rproc_shutdown (rproc); +if (!rproc->auto_boot) +module_put (dev->parent->driver->owner); }else {dev_err (&rproc->dev,"Unrecognised option: %s\n" , buf); ret = -EINVAL ;
Signature · 1 line
2.28.0
Mathieu Poirier
maintainerRe: [PATCH v2 1/3] remoteproc: Fix unbalanced boot with sysfs for no auto-boot rprocs
Quoted 58 lines · Suman Anna
The remoteproc core performs automatic boot and shutdown of a remote processor during
rproc_add()andrproc_del()for remote processors supporting 'auto-boot'. The remoteproc devices not using 'auto-boot' require either a remoteproc client driver or a userspace client to use the sysfs 'state' variable to perform the boot and shutdown. The in-kernel client drivers hold the corresponding remoteproc driver module's reference count when they acquire a rproc handle through therproc_get_by_phandle()API, but there is no such support for userspace applications performing the boot through sysfs interface.The shutdown of a remoteproc upon removing a remoteproc platform driver is automatic only with 'auto-boot' and this can cause a remoteproc with no auto-boot to stay powered on and never freed up if booted using the sysfs interface without a matching stop, and when the remoteproc driver module is removed or unbound from the device. This will result in a memory leak as well as the corresponding remoteproc ida being never deallocated. Fix this by holding a module reference count for the remoteproc's driver during a sysfs 'start' and releasing it during the sysfs 'stop' operation.
Signed-off-by Suman Anna <[email protected]>Acked-by Arnaud Pouliquen <[email protected]>---
v2: rebased version, no changes
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/remoteproc_sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/remoteproc/remoteproc_sysfs.c +10
-1@@ -3,6 +3,7 @@* Remote Processor Framework */ +#include <linux/module.h> #include <linux/remoteproc.h> #include <linux/slab.h> @@ -228,14 +229,27 @@ static ssize_t state_store(struct device *dev,if (rproc->state ==RPROC_RUNNING )return -EBUSY ; +/* +* prevent underlying implementation from being removed +* when remoteproc does not support auto-boot +*/ +if (!rproc->auto_boot && + !try_module_get (dev->parent->driver->owner)) +return -EINVAL ; + ret =rproc_boot (rproc); -if (ret) +if (ret) {dev_err (&rproc->dev,"Boot failed: %d\n" , ret);
drivers/remoteproc/remoteproc_sysfs.c static ssize_t state_store(struct device *dev, · line 252
Quoted 10 lines
drivers/remoteproc/remoteproc_sysfs.c +5
-0+if (!rproc->auto_boot) +module_put (dev->parent->driver->owner); + } }else if (sysfs_streq (buf,"stop" )) {if (rproc->state !=RPROC_RUNNING )return -EINVAL ;rproc_shutdown (rproc); +if (!rproc->auto_boot) +module_put (dev->parent->driver->owner);
I tackled the same problem by fixing another problem we had in the core. Patch 2 [1] and 3 [2] of this set [3] get rid of the problem related to the auto_boot check without having to deal with module counters.
Please see if that covers the use case you are dealing with.
Thanks,
Mathieu
[1]. https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/
[2]. https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/
[3]. https://patchwork.kernel.org/project/linux-remoteproc/list/?series=391789
Quoted 6 lines
drivers/remoteproc/remoteproc_sysfs.c +0
-0}else {dev_err (&rproc->dev,"Unrecognised option: %s\n" , buf); ret = -EINVAL ;Signature · 1 line
2.28.0
PATCH v2 2/3 remoteproc: Introduce deny_sysfs_ops flag
In reply to Suman AnnaThe remoteproc framework provides sysfs interfaces for changing the firmware name and for starting/stopping a remote processor through the sysfs files 'state' and 'firmware'. The 'recovery' sysfs file can also be used similarly to control the error recovery state machine of a remoteproc. 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/recovery 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.
---
v2: revised to account for the 'recovery' sysfs file as well, patch
description updated accordingly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/
drivers/remoteproc/remoteproc_sysfs.c | 12 ++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+)
drivers/remoteproc/remoteproc_sysfs.c +12 -0
@@ -49,6 +49,10 @@ static ssize_t recovery_store(struct device *dev, {struct rproc *rproc =to_rproc (dev); +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; +if (sysfs_streq (buf,"enabled" )) {/* change the flag and begin the recovery process if needed */ rproc->recovery_disabled = false;
@@ -158,6 +162,10 @@ static ssize_t firmware_store(struct device *dev,char *p;int err, len = count; +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; + err =mutex_lock_interruptible (&rproc->lock);if (err) {dev_err (dev,"can't lock rproc %s: %d\n" , rproc->name, err);
@@ -225,6 +233,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 ;
include/linux/remoteproc.h +2 -0
@@ -508,6 +508,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, firmware and recovery * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc
@@ -545,6 +546,7 @@ struct rproc {bool has_iommu;bool auto_boot;bool autonomous; +bool deny_sysfs_ops;struct list_head dump_segments;int nb_vdev;u8 elf_class;
Signature · 1 line
2.28.0
Re: [PATCH v2 2/3] remoteproc: Introduce deny_sysfs_ops flag
Quoted 12 lines · Suman Anna
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'. The 'recovery' sysfs file can also be used similarly to control the error recovery state machine of a remoteproc. 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.
Quoted 5 lines
Add support to deny the sysfs state/firmware/recovery 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.
This makes sense, but can't we implement attribute_group->is_visible to simply hide these entries from userspace instead of leaving them "broken"?
Regards,
Bjorn
Quoted 70 lines
Signed-off-by Suman Anna <[email protected]>---
v2: revised to account for the 'recovery' sysfs file as well, patch
description updated accordingly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/remoteproc_sysfs.c | 12 ++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+)drivers/remoteproc/remoteproc_sysfs.c +12
-0@@ -49,6 +49,10 @@ static ssize_t recovery_store(struct device *dev, {struct rproc *rproc =to_rproc (dev); +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; +if (sysfs_streq (buf,"enabled" )) {/* change the flag and begin the recovery process if needed */ rproc->recovery_disabled = false;@@ -158,6 +162,10 @@ static ssize_t firmware_store(struct device *dev,char *p;int err, len = count; +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; + err =mutex_lock_interruptible (&rproc->lock);if (err) {dev_err (dev,"can't lock rproc %s: %d\n" , rproc->name, err);@@ -225,6 +233,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 ;include/linux/remoteproc.h +2
-0@@ -508,6 +508,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, firmware and recovery * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -545,6 +546,7 @@ struct rproc {bool has_iommu;bool auto_boot;bool autonomous; +bool deny_sysfs_ops;struct list_head dump_segments;int nb_vdev;u8 elf_class;Signature · 1 line
2.28.0
Re: [PATCH v2 2/3] remoteproc: Introduce deny_sysfs_ops flag
Quoted 20 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
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'. The 'recovery' sysfs file can also be used similarly to control the error recovery state machine of a remoteproc. 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.
Quoted 5 lines
Add support to deny the sysfs state/firmware/recovery 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.
Quoted 3 lines
This makes sense, but can't we implement
attribute_group->is_visibleto simply hide these entries from userspace instead of leaving them "broken"?
I would have to look into that, but can that be changed dynamically? Also, note that the enforcement is only on the writes/stores which impact the state-machine, but not the reads/shows.
For PRU usecases, we will be setting this dynamically.
regards
Suman
Quoted 74 lines
Regards,
BjornQuoted 70 lines
Signed-off-by Suman Anna <[email protected]>---
v2: revised to account for the 'recovery' sysfs file as well, patch
description updated accordingly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/remoteproc_sysfs.c | 12 ++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+)drivers/remoteproc/remoteproc_sysfs.c +12
-0@@ -49,6 +49,10 @@ static ssize_t recovery_store(struct device *dev, {struct rproc *rproc =to_rproc (dev); +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; +if (sysfs_streq (buf,"enabled" )) {/* change the flag and begin the recovery process if needed */ rproc->recovery_disabled = false;@@ -158,6 +162,10 @@ static ssize_t firmware_store(struct device *dev,char *p;int err, len = count; +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; + err =mutex_lock_interruptible (&rproc->lock);if (err) {dev_err (dev,"can't lock rproc %s: %d\n" , rproc->name, err);@@ -225,6 +233,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 ;include/linux/remoteproc.h +2
-0@@ -508,6 +508,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, firmware and recovery * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -545,6 +546,7 @@ struct rproc {bool has_iommu;bool auto_boot;bool autonomous; +bool deny_sysfs_ops;struct list_head dump_segments;int nb_vdev;u8 elf_class;Signature · 1 line
2.28.0
Re: [PATCH v2 2/3] remoteproc: Introduce deny_sysfs_ops flag
Quoted 25 lines · Suman Anna
Quoted 20 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
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'. The 'recovery' sysfs file can also be used similarly to control the error recovery state machine of a remoteproc. 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.
Quoted 5 lines
Add support to deny the sysfs state/firmware/recovery 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.Quoted 3 lines
This makes sense, but can't we implement
attribute_group->is_visibleto simply hide these entries from userspace instead of leaving them "broken"?
Quoted 6 lines
I would have to look into that, but can that be changed dynamically? Also, note that the enforcement is only on the writes/stores which impact the state-machine, but not the reads/shows.
For PRU usecases, we will be setting this dynamically.
It looks to be dynamic, but I don't know if there's any "caching" involved. Please have a look and let me know.
Regards,
Bjorn
Quoted 78 lines
regards
SumanQuoted 74 lines
Regards,
BjornQuoted 70 lines
Signed-off-by Suman Anna <[email protected]>---
v2: revised to account for the 'recovery' sysfs file as well, patch
description updated accordingly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/remoteproc_sysfs.c | 12 ++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+)drivers/remoteproc/remoteproc_sysfs.c +12
-0@@ -49,6 +49,10 @@ static ssize_t recovery_store(struct device *dev, {struct rproc *rproc =to_rproc (dev); +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; +if (sysfs_streq (buf,"enabled" )) {/* change the flag and begin the recovery process if needed */ rproc->recovery_disabled = false;@@ -158,6 +162,10 @@ static ssize_t firmware_store(struct device *dev,char *p;int err, len = count; +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; + err =mutex_lock_interruptible (&rproc->lock);if (err) {dev_err (dev,"can't lock rproc %s: %d\n" , rproc->name, err);@@ -225,6 +233,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 ;include/linux/remoteproc.h +2
-0@@ -508,6 +508,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, firmware and recovery * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -545,6 +546,7 @@ struct rproc {bool has_iommu;bool auto_boot;bool autonomous; +bool deny_sysfs_ops;struct list_head dump_segments;int nb_vdev;u8 elf_class;Signature · 1 line
2.28.0
Re: [PATCH v2 2/3] remoteproc: Introduce deny_sysfs_ops flag
Quoted 31 lines · Bjorn Andersson
Quoted 29 lines · Suman Anna
Quoted 20 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
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'. The 'recovery' sysfs file can also be used similarly to control the error recovery state machine of a remoteproc. 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.
Quoted 5 lines
Add support to deny the sysfs state/firmware/recovery 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.Quoted 3 lines
This makes sense, but can't we implement
attribute_group->is_visibleto simply hide these entries from userspace instead of leaving them "broken"?I would have to look into that, but can that be changed dynamically? Also, note that the enforcement is only on the writes/stores which impact the state-machine, but not the reads/shows.
Quoted 5 lines
Quoted 2 lines
For PRU usecases, we will be setting this dynamically.
It looks to be dynamic, but I don't know if there's any "caching" involved. Please have a look and let me know.
OK, will do. I can only check the week after though.
regards
Suman
Quoted 82 lines
Regards,
BjornQuoted 78 lines
regards
SumanQuoted 74 lines
Regards,
BjornQuoted 70 lines
Signed-off-by Suman Anna <[email protected]>---
v2: revised to account for the 'recovery' sysfs file as well, patch
description updated accordingly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/remoteproc_sysfs.c | 12 ++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 14 insertions(+)drivers/remoteproc/remoteproc_sysfs.c +12
-0@@ -49,6 +49,10 @@ static ssize_t recovery_store(struct device *dev, {struct rproc *rproc =to_rproc (dev); +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; +if (sysfs_streq (buf,"enabled" )) {/* change the flag and begin the recovery process if needed */ rproc->recovery_disabled = false;@@ -158,6 +162,10 @@ static ssize_t firmware_store(struct device *dev,char *p;int err, len = count; +/* restrict sysfs operations if not allowed by remoteproc drivers */ +if (rproc->deny_sysfs_ops) +return -EPERM ; + err =mutex_lock_interruptible (&rproc->lock);if (err) {dev_err (dev,"can't lock rproc %s: %d\n" , rproc->name, err);@@ -225,6 +233,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 ;include/linux/remoteproc.h +2
-0@@ -508,6 +508,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, firmware and recovery * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -545,6 +546,7 @@ struct rproc {bool has_iommu;bool auto_boot;bool autonomous; +bool deny_sysfs_ops;struct list_head dump_segments;int nb_vdev;u8 elf_class;Signature · 1 line
2.28.0
PATCH v2 3/3 remoteproc: wkup_m3: Set deny_sysfs_ops flag
In reply to Suman AnnaThe Wakeup M3 remote processor is controlled by the wkup_m3_ipc client driver, so set the newly introduced 'deny_sysfs_ops' flag to not allow any overriding of the remoteproc firmware or state from userspace.
---
v2: rebased version, no code changes, patch title adjusted slightly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/
drivers/remoteproc/wkup_m3_rproc.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/wkup_m3_rproc.c +1 -0
@@ -160,6 +160,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) } rproc->auto_boot = false; + rproc->deny_sysfs_ops = true; wkupm3 = rproc->priv; wkupm3->rproc = rproc;
Signature · 1 line
2.28.0
Re: [PATCH v2 3/3] remoteproc: wkup_m3: Set deny_sysfs_ops flag
Quoted 5 lines · Suman Anna
The Wakeup M3 remote processor is controlled by the
wkup_m3_ipcclient driver, so set the newly introduced 'deny_sysfs_ops' flag to not allow any overriding of the remoteproc firmware or state from userspace.
Quoted 23 lines
Signed-off-by Suman Anna <[email protected]>---
v2: rebased version, no code changes, patch title adjusted slightly
v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/drivers/remoteproc/wkup_m3_rproc.c | 1 + 1 file changed, 1 insertion(+)drivers/remoteproc/wkup_m3_rproc.c +1
-0@@ -160,6 +160,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev) } rproc->auto_boot = false; + rproc->deny_sysfs_ops = true; wkupm3 = rproc->priv; wkupm3->rproc = rproc;Signature · 1 line
2.28.0
Hi all.
Am Sa., 21. Nov. 2020 um 04:05 Uhr schrieb Suman Anna <[email protected]>:
Quoted 27 lines
Hi All,
This is a refresh of the unaccepted patches from an old series [1]. Patches 2 and 3 from that series were merged and these are rebased and revised versions of the same patches. I had forgotten about these patches, and am resurrecting these again. Patches are on top of latest 5.10-rc4.
The features being introduced here will be needed by the recently posted PRU remoteproc driver [2] in addition to the existing Wkup M3 remoteproc driver. Both of these drivers follow a client-driven boot methodology, with the latter strictly booted by another driver in kernel. The PRU remoteproc driver will be supporting both in-kernel clients as well as control from userspace orthogonally. The logic though is applicable and useful to any remoteproc driver not using 'auto-boot' and using an external driver/application to boot the remoteproc.
regards
Suman[1] https://patchwork.kernel.org/project/linux-remoteproc/cover/[email protected]/
[2] https://patchwork.kernel.org/project/linux-remoteproc/cover/[email protected]/Suman Anna (3):
remoteproc: Fix unbalanced boot with sysfs for no auto-boot rprocs
remoteproc: Introducedeny_sysfs_opsflag
remoteproc:wkup_m3: Setdeny_sysfs_opsflag
Quoted 8 lines
drivers/remoteproc/remoteproc_sysfs.c | 28 ++++++++++++++++++++++++++- drivers/remoteproc/wkup_m3_rproc.c | 1 + include/linux/remoteproc.h | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-)--
2.28.0
Is there any update on this patch series?
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy