From: Mukesh Ojha <quic_mojha@quicinc.com>
To: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com>,
<andersson@kernel.org>, <mathieu.poirier@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH] remoteproc: sysfs: fix race while updating recovery flag
Date: Mon, 30 Jan 2023 13:33:42 +0530 [thread overview]
Message-ID: <d9708f4b-e533-e400-acbf-3d8e816f242e@quicinc.com> (raw)
In-Reply-To: <20230129225106.10606-1-quic_satyap@quicinc.com>
On 1/30/2023 4:21 AM, Satya Durga Srinivasu Prabhala wrote:
> When multiple clients try to update the recovery flag, it is
Multiple user-space clients ?
> possible that, race condition would lead to undesired results
> as updates to recovery flag isn't protected by any mechanism
> today. To avoid such issues, take remoteproc mutex lock before
> updating recovery flag and release the lock once done.
But your patch also adds locks for the case which does not update
recovery flag..
>
> Signed-off-by: Satya Durga Srinivasu Prabhala <quic_satyap@quicinc.com>
> ---
> drivers/remoteproc/remoteproc_sysfs.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c
> index 8c7ea8922638..ec37176e1589 100644
> --- a/drivers/remoteproc/remoteproc_sysfs.c
> +++ b/drivers/remoteproc/remoteproc_sysfs.c
> @@ -48,16 +48,21 @@ static ssize_t recovery_store(struct device *dev,
> {
> struct rproc *rproc = to_rproc(dev);
>
> + mutex_lock(&rproc->lock);
> if (sysfs_streq(buf, "enabled")) {
> /* change the flag and begin the recovery process if needed */
> rproc->recovery_disabled = false;
> + mutex_unlock(&rproc->lock);
> rproc_trigger_recovery(rproc);
> } else if (sysfs_streq(buf, "disabled")) {
> rproc->recovery_disabled = true;
> + mutex_unlock(&rproc->lock);
> } else if (sysfs_streq(buf, "recover")) {
> /* begin the recovery process without changing the flag */
> + mutex_unlock(&rproc->lock);
is it really needed for this case?
> rproc_trigger_recovery(rproc);
> } else {
> + mutex_unlock(&rproc->lock);
same here..
> return -EINVAL;
> }
>
Do you also need to add lock for rproc_recovery_write in
drivers/remoteproc/remoteproc_debugfs.c ?
-Mukesh
next prev parent reply other threads:[~2023-01-30 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 22:51 [PATCH] remoteproc: sysfs: fix race while updating recovery flag Satya Durga Srinivasu Prabhala
2023-01-30 8:03 ` Mukesh Ojha [this message]
2023-01-30 17:43 ` Satya Durga Srinivasu Prabhala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9708f4b-e533-e400-acbf-3d8e816f242e@quicinc.com \
--to=quic_mojha@quicinc.com \
--cc=andersson@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=quic_satyap@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox