[PATCH v2 6/8] remoteproc: qcom: pas: Sequence HPASS ADSP cluster boot root-first
From: Shawn Guo
Date: Tue Dec 01 2026 - 02:02:38 EST
The cluster root owns the HPASS resources shared with its siblings and
initializes them as part of its own boot, so ADSP1/ADSP2 can only cold
boot once ADSP0 is up. Booting a dependent member first leaves it
without the clocks, resets and NoC configuration it needs.
Gate a dependent member's qcom_pas_start() on the root having started.
The root being enabled in DT does not imply it has already bound, as
probe order between the two is not guaranteed, so fail the boot if the
root has not bound rather than dereferencing it. If the root has bound
but is not running yet, wait briefly on a completion the root signals
from its own qcom_pas_start(), so that a member racing the root through
a restart does not fail outright.
The completion is signaled by the root's successful start or attach,
and only cleared again once the root's own qcom_pas_stop() runs. It
starts out cleared, so that a dependent member cold booted alongside the
root, e.g. with both auto-booting, still waits for it. A root that has
crashed but whose recovery has not stopped it yet leaves the completion
signaled, so a dependent member observing it fails on the root's
RPROC_CRASHED state instead. The state check cannot be RPROC_RUNNING,
as the root signals the completion from its ops->start, before the
remoteproc core marks it running.
The wait is bounded at 10 s, enough for a whole root boot, which may
spend up to 5 s in qcom_q6v5_wait_for_start() alone.
Signed-off-by: Shawn Guo <shengchao.guo@xxxxxxxxxxxxxxxx>
---
drivers/remoteproc/qcom_q6v5_pas.c | 87 ++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index 0665a9498d07..5c96b2b82903 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -178,6 +178,7 @@ struct qcom_pas {
* @lock: protects @members and @root
* @members: list of struct qcom_pas, linked via cluster_node
* @root: the member owning the resources shared across the cluster
+ * @root_booted: signaled once @root has started, cleared when it goes down
* @refcount: number of members currently attached to this cluster
*
* PAS instances whose descriptors reference the same qcom_pas_cluster_desc
@@ -190,10 +191,22 @@ struct qcom_pas_cluster {
struct mutex lock;
struct list_head members;
struct qcom_pas *root;
+ struct completion root_booted;
int refcount;
};
+/*
+ * How long a dependent member waits for its root to finish booting before
+ * giving up. This has to outlast a whole root boot, which may spend up to 5 s
+ * in qcom_q6v5_wait_for_start() alone, whether the two are cold booting
+ * together or the root is being restarted after a crash. A dependent that
+ * gives up early from crash recovery stays offline, as rproc_boot_recovery()
+ * does not release its rproc power reference on failure, making any later
+ * rproc_boot() a no-op.
+ */
+#define QCOM_PAS_CLUSTER_ROOT_BOOT_TIMEOUT (10 * HZ)
+
static LIST_HEAD(qcom_pas_cluster_list);
static DEFINE_MUTEX(qcom_pas_cluster_list_lock);
@@ -218,6 +231,7 @@ qcom_pas_cluster_get(const struct qcom_pas_cluster_desc *desc)
cluster->desc = desc;
mutex_init(&cluster->lock);
INIT_LIST_HEAD(&cluster->members);
+ init_completion(&cluster->root_booted);
cluster->refcount = 1;
list_add_tail(&cluster->list, &qcom_pas_cluster_list);
@@ -284,6 +298,62 @@ 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
+ *
+ * The cluster root owns the resources its siblings need, and initializes them
+ * as part of its own boot, so a dependent member can only be started once the
+ * root is up.
+ *
+ * Return: 0 if the root is up, negative errno otherwise.
+ */
+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 has not necessarily bound yet, and may have
+ * unbound again. Without it there is nothing to sequence this member's
+ * boot against, so fail rather than boot into a DSP whose shared
+ * resources were never initialized.
+ *
+ * Note that nothing refcounts members across unbind, so a root freed
+ * under a concurrent sibling boot remains unhandled.
+ */
+ scoped_guard(mutex, &cluster->lock)
+ root = cluster->root ? cluster->root->rproc : NULL;
+
+ if (!root) {
+ dev_err(pas->dev, "cluster root not bound\n");
+ return -ENODEV;
+ }
+
+ if (root->state == RPROC_RUNNING || root->state == RPROC_ATTACHED)
+ return 0;
+
+ 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;
+ }
+
+ /*
+ * The completion is only re-armed once the root's own qcom_pas_stop()
+ * runs, so a root that has crashed but not been stopped yet still
+ * leaves it signaled. Don't trust it then. Any other state is fine:
+ * the root signals this from inside ops->start, before the core moves
+ * it to RPROC_RUNNING.
+ */
+ if (root->state == RPROC_CRASHED) {
+ dev_err(pas->dev, "cluster root crashed\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
static void qcom_pas_segment_dump(struct rproc *rproc,
struct rproc_dump_segment *segment,
void *dest, size_t offset, size_t size)
@@ -446,6 +516,12 @@ static int qcom_pas_start(struct rproc *rproc)
struct qcom_pas *pas = rproc->priv;
int ret;
+ if (pas->cluster && !pas->is_cluster_root) {
+ ret = qcom_pas_cluster_wait_for_root(pas);
+ if (ret)
+ return ret;
+ }
+
ret = qcom_q6v5_prepare(&pas->q6v5);
if (ret)
return ret;
@@ -516,6 +592,9 @@ static int qcom_pas_start(struct rproc *rproc)
if (pas->dtb_pas_id)
qcom_pas_metadata_release(pas->dtb_pas_ctx);
+ if (pas->cluster && pas->is_cluster_root)
+ complete_all(&pas->cluster->root_booted);
+
/* firmware is used to pass reference from qcom_pas_start(), drop it now */
pas->firmware = NULL;
@@ -572,6 +651,11 @@ static int qcom_pas_stop(struct rproc *rproc)
int dtb_ret;
int ret;
+ if (pas->cluster && pas->is_cluster_root) {
+ scoped_guard(mutex, &pas->cluster->lock)
+ reinit_completion(&pas->cluster->root_booted);
+ }
+
ret = qcom_q6v5_request_stop(&pas->q6v5, pas->sysmon);
if (ret == -ETIMEDOUT)
dev_err(pas->dev, "timed out on wait\n");
@@ -707,6 +791,9 @@ static int qcom_pas_attach(struct rproc *rproc)
qcom_q6v5_report_fatal(&pas->q6v5);
}
+ if (pas->cluster && pas->is_cluster_root)
+ complete_all(&pas->cluster->root_booted);
+
return 0;
disable_running:
--
2.43.0