]> git.baikalelectronics.ru Git - kernel.git/commit
remoteproc: re-check state in rproc_trigger_recovery()
authorAlex Elder <elder@linaro.org>
Fri, 28 Feb 2020 18:33:56 +0000 (12:33 -0600)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Thu, 26 Mar 2020 05:29:43 +0000 (22:29 -0700)
commit81b2808a131c2253aca413a434a2d9c048c8e45e
treeee31bac9a9e91b541aac48e1b590167390e2cc19
parentb49b5a74774d431f11428f5f37c9fdbad53adc17
remoteproc: re-check state in rproc_trigger_recovery()

Two places call rproc_trigger_recovery():
  - rproc_crash_handler_work() sets rproc->state to CRASHED under
    protection of the mutex, then calls it if recovery is not
    disabled.  This function is called in workqueue context when
    scheduled in rproc_report_crash().
  - rproc_recovery_write() calls it in two spots, both of which
    the only call it if the rproc->state is CRASHED.

The mutex is taken right away in rproc_trigger_recovery().  However,
by the time the mutex is acquired, something else might have changed
rproc->state to something other than CRASHED.

The work that follows that is only appropriate for a remoteproc in
CRASHED state.  So check the state after acquiring the mutex, and
only proceed with the recovery work if the remoteproc is still in
CRASHED state.

Delay reporting that recovering has begun until after we hold the
mutex and we know the remote processor is in CRASHED state.

Signed-off-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20200228183359.16229-2-elder@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/remoteproc_core.c