[PATCH v2 5/8] remoteproc: qcom: pas: Track HPASS ADSP cluster membership

From: Shawn Guo

Date: Tue Dec 01 2026 - 02:02:44 EST


On Nord, ADSP0/1/2 share HPASS-domain resources (PLLs, AG_NOC, RSCp,
CESTA, THROTTLE, QTMR) owned by ADSP0, and their firmware cannot
tolerate one member being started or stopped independently of the
others. Modeling that requires each PAS instance to know which other
instances it is grouped with.

None of the shared resources are visible to the OS: they are programmed
by TZ on the owning DSP's behalf as part of authenticating and booting
its image, and the AP has no clock, reset or interconnect handle on any
of them. So the grouping cannot be expressed by having each member
reference the shared providers and letting the clk, reset and ICC
frameworks refcount them, as it would be for resources Linux drives
itself. It also is not a board property, being fixed by the SoC's HPASS
design, so it comes from the compatible.

Add a small registry of clusters, keyed by a static per-cluster
descriptor referenced from the qcom_pas_data of every member, and join it
at probe. Which instance owns the shared resources is likewise inherent
to the instance, and comes from the same descriptor.

Publish the cluster in rproc->cluster, which is all sysmon and
glink_ssr need to stop notifying siblings of each other's SSR events.
The cluster is left only after rproc_del() has stopped this member, so
that the suppression is still in effect for that stop, and is unwound on
every probe error path, since a member freed while still linked into the
cluster would be walked by its siblings.

Instances whose descriptor names no cluster are completely unaffected:
qcom_pas.cluster stays NULL for them.

Signed-off-by: Shawn Guo <shengchao.guo@xxxxxxxxxxxxxxxx>
---
drivers/remoteproc/qcom_q6v5_pas.c | 146 +++++++++++++++++++++++++++++
1 file changed, 146 insertions(+)

diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index e8cf02e81a94..0665a9498d07 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -9,12 +9,14 @@
*/

#include <linux/clk.h>
+#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/iommu.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
@@ -52,6 +54,18 @@ struct tmd_name {
int id;
};

+/**
+ * struct qcom_pas_cluster_desc - static description of a cluster of PAS instances
+ * @name: human-readable cluster name, used in log messages
+ *
+ * One instance of this exists per cluster in a given SoC, and is referenced by
+ * the qcom_pas_data of every member. The pointer itself identifies the cluster,
+ * so members are exactly those instances whose descriptor points here.
+ */
+struct qcom_pas_cluster_desc {
+ const char *name;
+};
+
struct qcom_pas_data {
int crash_reason_smem;
const char *firmware_name;
@@ -84,8 +98,13 @@ struct qcom_pas_data {
int region_assign_vmid;
bool early_boot;
bool needs_tzmem;
+
+ const struct qcom_pas_cluster_desc *cluster;
+ bool cluster_root;
};

+struct qcom_pas_cluster;
+
struct qcom_pas {
struct device *dev;
struct rproc *rproc;
@@ -146,8 +165,125 @@ struct qcom_pas {
struct qcom_pas_context *dtb_pas_ctx;

struct qmi_tmd_client *tmd_inst;
+
+ struct qcom_pas_cluster *cluster;
+ struct list_head cluster_node;
+ bool is_cluster_root;
};

+/**
+ * struct qcom_pas_cluster - state shared by clustered PAS instances
+ * @desc: static description of this cluster, the key into the global list
+ * @list: linkage in qcom_pas_cluster_list
+ * @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
+ * @refcount: number of members currently attached to this cluster
+ *
+ * PAS instances whose descriptors reference the same qcom_pas_cluster_desc
+ * share one of these.
+ */
+struct qcom_pas_cluster {
+ const struct qcom_pas_cluster_desc *desc;
+ struct list_head list;
+
+ struct mutex lock;
+ struct list_head members;
+ struct qcom_pas *root;
+
+ int refcount;
+};
+
+static LIST_HEAD(qcom_pas_cluster_list);
+static DEFINE_MUTEX(qcom_pas_cluster_list_lock);
+
+static struct qcom_pas_cluster *
+qcom_pas_cluster_get(const struct qcom_pas_cluster_desc *desc)
+{
+ struct qcom_pas_cluster *cluster;
+
+ guard(mutex)(&qcom_pas_cluster_list_lock);
+
+ list_for_each_entry(cluster, &qcom_pas_cluster_list, list) {
+ if (cluster->desc == desc) {
+ cluster->refcount++;
+ return cluster;
+ }
+ }
+
+ cluster = kzalloc(sizeof(*cluster), GFP_KERNEL);
+ if (!cluster)
+ return NULL;
+
+ cluster->desc = desc;
+ mutex_init(&cluster->lock);
+ INIT_LIST_HEAD(&cluster->members);
+ cluster->refcount = 1;
+ list_add_tail(&cluster->list, &qcom_pas_cluster_list);
+
+ return cluster;
+}
+
+static void qcom_pas_cluster_put(struct qcom_pas_cluster *cluster)
+{
+ guard(mutex)(&qcom_pas_cluster_list_lock);
+
+ if (--cluster->refcount == 0) {
+ list_del(&cluster->list);
+ kfree(cluster);
+ }
+}
+
+/**
+ * qcom_pas_cluster_init() - join the cluster described by @desc, if any
+ * @pas: PAS instance being probed
+ * @desc: @pas's static description
+ *
+ * Cluster membership and root-ness are properties of the DSP instance itself,
+ * not of the board, so both come from the compatible via @desc. Instances
+ * whose descriptor names no cluster are not part of one; @pas->cluster is left
+ * NULL and this is a no-op (e.g. cdsp0-3).
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+static int qcom_pas_cluster_init(struct qcom_pas *pas,
+ const struct qcom_pas_data *desc)
+{
+ if (!desc->cluster)
+ return 0;
+
+ pas->cluster = qcom_pas_cluster_get(desc->cluster);
+ if (!pas->cluster)
+ return -ENOMEM;
+
+ pas->is_cluster_root = desc->cluster_root;
+
+ scoped_guard(mutex, &pas->cluster->lock) {
+ list_add_tail(&pas->cluster_node, &pas->cluster->members);
+ if (pas->is_cluster_root)
+ pas->cluster->root = pas;
+ }
+
+ return 0;
+}
+
+static void qcom_pas_cluster_exit(struct qcom_pas *pas)
+{
+ struct qcom_pas_cluster *cluster = pas->cluster;
+
+ if (!cluster)
+ return;
+
+ scoped_guard(mutex, &cluster->lock) {
+ list_del(&pas->cluster_node);
+ if (cluster->root == pas)
+ cluster->root = NULL;
+ }
+
+ qcom_pas_cluster_put(cluster);
+ pas->cluster = NULL;
+}
+
static void qcom_pas_segment_dump(struct rproc *rproc,
struct rproc_dump_segment *segment,
void *dest, size_t offset, size_t size)
@@ -959,6 +1095,12 @@ static int qcom_pas_probe(struct platform_device *pdev)
pas = rproc->priv;
pas->dev = &pdev->dev;
pas->rproc = rproc;
+
+ ret = qcom_pas_cluster_init(pas, desc);
+ if (ret)
+ return ret;
+ rproc->cluster = pas->cluster;
+
pas->minidump_id = desc->minidump_id;
pas->pas_id = desc->pas_id;
pas->lite_pas_id = desc->lite_pas_id;
@@ -1066,6 +1208,7 @@ static int qcom_pas_probe(struct platform_device *pdev)
qcom_pas_unassign_memory_region(pas);
free_rproc:
device_init_wakeup(pas->dev, false);
+ qcom_pas_cluster_exit(pas);

return ret;
}
@@ -1082,6 +1225,9 @@ static void qcom_pas_remove(struct platform_device *pdev)
if (pas->tmd_inst)
qmi_tmd_exit(pas->tmd_inst);

+ pas->rproc->cluster = NULL;
+ qcom_pas_cluster_exit(pas);
+
qcom_q6v5_deinit(&pas->q6v5);
qcom_pas_unassign_memory_region(pas);
qcom_remove_glink_subdev(pas->rproc, &pas->glink_subdev);
--
2.43.0