remoteproc: core: Remove state checking before calling rproc_boot()
authorShengjiu Wang <shengjiu.wang@nxp.com>
Mon, 28 Mar 2022 02:20:11 +0000 (10:20 +0800)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Thu, 14 Apr 2022 17:08:26 +0000 (11:08 -0600)
commit8f454f950dbb663180f596db18c3dc7ec26497f0
tree5e823280a53f91e418ecfe92a7f78adcf1e6a30d
parent79a43db93399cfc7825a908a03320677c52ef919
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 <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1648434012-16655-2-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/remoteproc_cdev.c
drivers/remoteproc/remoteproc_sysfs.c