From: sashiko-bot@kernel.org
To: "Shawn Guo" <shengchao.guo@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 6/8] remoteproc: qcom: pas: Sequence HPASS ADSP cluster boot root-first
Date: Sat, 15 Aug 2026 13:34:40 +0000 [thread overview]
Message-ID: <20260815133441.369171F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260815132541.1575121-7-shengchao.guo@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Accessing `root->state` outside `cluster->lock` without holding an `rproc` device reference causes a Use-After-Free if the root device is unbound concurrently.
- [High] Missing state check after `wait_for_completion_timeout()` completely breaks boot sequencing, allowing dependent members to cold boot before the root.
- [Medium] Concurrent execution of `reinit_completion()` and `wait_for_completion_timeout()` causes a data race on `cluster->root_booted`.
--
--- Patch [6]: [PATCH 6/8] remoteproc: qcom: pas: Sequence HPASS ADSP cluster boot root-first ---
commit 7abf00410ddb06041e837e4d053d61bb3ef43922
Author: Shawn Guo <shengchao.guo@oss.qualcomm.com>
remoteproc: qcom: pas: Sequence HPASS ADSP cluster boot root-first
This commit gates dependent member boots on the cluster root having started.
It introduces a wait mechanism using a completion to handle racing dependent
member restarts with the root's start and stop paths.
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index dc6e7d601a9bd..ef38a1929f56b 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
[ ... ]
> @@ -267,6 +283,51 @@ static void qcom_pas_cluster_exit(struct qcom_pas *pas)
> pas->cluster = NULL;
> }
>
> +/**
> + * qcom_pas_cluster_wait_for_root() - gate a dependent member's boot on its root
> + * @pas: the non-root cluster member being started
[ ... ]
> +static int qcom_pas_cluster_wait_for_root(struct qcom_pas *pas)
> +{
> + struct qcom_pas_cluster *cluster = pas->cluster;
> + struct rproc *root;
> +
> + /*
> + * The root's PAS instance is enabled in DT (checked in
> + * qcom_pas_cluster_init()) but has not necessarily bound yet, and may
> + * have unbound again. Without it there is nothing to sequence this
> + * member's boot against.
> + *
> + * Note that nothing refcounts members across unbind, so a root freed
> + * under a concurrent sibling boot remains unhandled.
> + */
> + mutex_lock(&cluster->lock);
> + root = cluster->root ? cluster->root->rproc : NULL;
> + mutex_unlock(&cluster->lock);
> +
> + if (!root) {
> + dev_err(pas->dev, "cluster root not bound\n");
> + return -ENODEV;
> + }
> +
[Severity: High]
Is there a risk of a use-after-free here if the root device is unbound
concurrently?
Since the cluster->lock is dropped above and no reference is taken on
the rproc device (e.g., via get_device(&root->dev)), could root be freed via
devres before we evaluate root->state?
> + if (root->state == RPROC_RUNNING || root->state == RPROC_ATTACHED)
> + return 0;
> +
[Severity: Medium]
Could this wait_for_completion_timeout() race with the reinit_completion()
called in qcom_pas_stop()?
In qcom_pas_stop():
if (pas->cluster && pas->is_cluster_root) {
mutex_lock(&pas->cluster->lock);
reinit_completion(&pas->cluster->root_booted);
mutex_unlock(&pas->cluster->lock);
}
Since the wait happens outside the cluster->lock but reinit_completion()
modifies the completion directly, does this result in a data race on
cluster->root_booted?
> + if (!wait_for_completion_timeout(&cluster->root_booted,
> + QCOM_PAS_CLUSTER_ROOT_BOOT_TIMEOUT)) {
> + dev_err(pas->dev, "cluster root not started\n");
> + return -ENODEV;
> + }
> +
[Severity: High]
The commit message mentions that the dependent member "falls back to failing
on the root's state" when it observes a stale completion.
Since cluster->root_booted is initialized as signaled during probe via
complete_all(), wait_for_completion_timeout() will immediately return success
here on a cold boot.
Are we missing the fallback check to re-evaluate root->state before returning
0? Without it, dependent members might successfully bypass the wait and
cold boot before the root.
> + return 0;
> +}
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260815132541.1575121-1-shengchao.guo@oss.qualcomm.com?part=6
next prev parent reply other threads:[~2026-08-15 13:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 13:25 [PATCH 0/8] remoteproc: qcom: Support the Nord HPASS ADSP cluster Shawn Guo
2026-08-15 13:25 ` [PATCH 1/8] dt-bindings: remoteproc: qcom,nord-pas: Add qcom,cluster-root property Shawn Guo
2026-08-15 13:35 ` sashiko-bot
2026-08-15 13:25 ` [PATCH 2/8] remoteproc: Add cluster field to struct rproc Shawn Guo
2026-08-15 13:25 ` [PATCH 3/8] remoteproc: qcom: sysmon: Suppress notify between cluster siblings Shawn Guo
2026-08-15 13:33 ` sashiko-bot
2026-08-15 13:25 ` [PATCH 4/8] rpmsg: qcom_glink_ssr: Suppress cleanup " Shawn Guo
2026-08-15 13:36 ` sashiko-bot
2026-08-15 13:25 ` [PATCH 5/8] remoteproc: qcom: pas: Track HPASS ADSP cluster membership Shawn Guo
2026-08-15 13:25 ` [PATCH 6/8] remoteproc: qcom: pas: Sequence HPASS ADSP cluster boot root-first Shawn Guo
2026-08-15 13:34 ` sashiko-bot [this message]
2026-08-15 13:25 ` [PATCH 7/8] remoteproc: qcom: pas: Enforce coupled stop/crash for HPASS ADSP clusters Shawn Guo
2026-08-15 13:39 ` sashiko-bot
2026-08-15 13:25 ` [PATCH 8/8] remoteproc: qcom: pas: Add Nord ADSP1/2 support Shawn Guo
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=20260815133441.369171F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shengchao.guo@oss.qualcomm.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