Skip to content

Commit 8f454f9

Browse files
TE-N-ShengjiuWangmathieupoirier
authored andcommitted
remoteproc: core: Remove state checking before calling rproc_boot()
There is no mutex protection of the state checking before rproc_boot(), which can't guarantee there is no another instance is trying to do same operation. Consider two instances case: Instance1: echo start > /sys/class/remoteproc/remoteproc0/state Instance2: echo start > /sys/class/remoteproc/remoteproc0/state ... Instance2: echo stop > /sys/class/remoteproc/remoteproc0/state ... Instance1: echo stop > /sys/class/remoteproc/remoteproc0/state The one issue is that the instance2 case may success when 'start' happens at same time as instance1, then rproc->power = 2; Or it may fail with -BUSY, then rproc->power = 1; which is uncertain. The another issue is for 'stop' operation, if the rproc->power = 1, when instance2 'stop' the remoteproc the instance1 will be impacted for it still needs the service at that time. The reference counter rproc->power is used to manage state changing and there is mutex protection in each operation function for multi instance case. So remove this state checking in rproc_cdev_write() and state_store() for 'start' operation, just let reference counter rproc->power to manage the behaviors. Signed-off-by: Shengjiu Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 79a43db commit 8f454f9

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

drivers/remoteproc/remoteproc_cdev.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
3232
return -EFAULT;
3333

3434
if (!strncmp(cmd, "start", len)) {
35-
if (rproc->state == RPROC_RUNNING ||
36-
rproc->state == RPROC_ATTACHED)
37-
return -EBUSY;
38-
3935
ret = rproc_boot(rproc);
4036
} else if (!strncmp(cmd, "stop", len)) {
4137
if (rproc->state != RPROC_RUNNING &&

drivers/remoteproc/remoteproc_sysfs.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ static ssize_t state_store(struct device *dev,
194194
int ret = 0;
195195

196196
if (sysfs_streq(buf, "start")) {
197-
if (rproc->state == RPROC_RUNNING ||
198-
rproc->state == RPROC_ATTACHED)
199-
return -EBUSY;
200-
201197
ret = rproc_boot(rproc);
202198
if (ret)
203199
dev_err(&rproc->dev, "Boot failed: %d\n", ret);

0 commit comments

Comments
 (0)