[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251027-cpu_cluster_component_pm-v1-5-31355ac588c2@oss.qualcomm.com>
Date: Mon, 27 Oct 2025 23:28:07 -0700
From: Yuanfang Zhang <yuanfang.zhang@....qualcomm.com>
To: Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
James Clark <james.clark@...aro.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Leo Yan <leo.yan@...ux.dev>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>
Cc: kernel@....qualcomm.com, coresight@...ts.linaro.org,
linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
Yuanfang Zhang <yuanfang.zhang@....qualcomm.com>
Subject: [PATCH 05/12] coresight-replicator: Handle delayed probe for CPU
cluster replicator
Delay probe the CPU cluster replicator when all CPUs of the cluster are
offline, and re-probe the replicator when any CPU in the cluster comes
online.
Key changes:
- Maintain a global list to track delayed replicators waiting for
CPU online.
- Add a CPU hotplug callback to retry registration on CPU online events.
Signed-off-by: Yuanfang Zhang <yuanfang.zhang@....qualcomm.com>
---
drivers/hwtracing/coresight/coresight-replicator.c | 65 ++++++++++++++++++++--
1 file changed, 61 insertions(+), 4 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index c5a9c7a2adfa90ae22890ed730fc008fe6901778..1dfe11940cd6001db3cf17249b0493027b65e19c 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -26,6 +26,9 @@
#define REPLICATOR_IDFILTER1 0x004
DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
+static LIST_HEAD(replicator_delay_probe);
+static enum cpuhp_state hp_online;
+static DEFINE_SPINLOCK(delay_lock);
/**
* struct replicator_drvdata - specifics associated to a replicator component
@@ -37,6 +40,8 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator");
* @spinlock: serialize enable/disable operations.
* @check_idfilter_val: check if the context is lost upon clock removal.
* @cpumask: CPU mask representing the CPUs related to this replicator.
+ * @dev: pointer to the device associated with this replicator.
+ * @link: link to the delay_probed list.
*/
struct replicator_drvdata {
void __iomem *base;
@@ -46,6 +51,8 @@ struct replicator_drvdata {
raw_spinlock_t spinlock;
bool check_idfilter_val;
struct cpumask *cpumask;
+ struct device *dev;
+ struct list_head link;
};
struct replicator_smp_arg {
@@ -395,7 +402,7 @@ static int replicator_probe(struct device *dev, struct resource *res)
drvdata->cpumask = replicator_get_cpumask(dev);
if (!drvdata->cpumask)
return -EINVAL;
-
+ drvdata->dev = dev;
cpus_read_lock();
for_each_cpu(cpu, drvdata->cpumask) {
ret = smp_call_function_single(cpu,
@@ -403,10 +410,15 @@ static int replicator_probe(struct device *dev, struct resource *res)
if (!ret)
break;
}
- cpus_read_unlock();
- if (ret)
+ if (ret) {
+ scoped_guard(spinlock, &delay_lock)
+ list_add(&drvdata->link, &replicator_delay_probe);
+ cpus_read_unlock();
return 0;
+ }
+
+ cpus_read_unlock();
} else if (res) {
replicator_init_hw(drvdata);
}
@@ -420,8 +432,13 @@ static int replicator_remove(struct device *dev)
{
struct replicator_drvdata *drvdata = dev_get_drvdata(dev);
- if (drvdata->csdev)
+ if (drvdata->csdev) {
coresight_unregister(drvdata->csdev);
+ } else {
+ scoped_guard(spinlock, &delay_lock)
+ list_del(&drvdata->link);
+ }
+
return 0;
}
@@ -554,8 +571,44 @@ static struct amba_driver dynamic_replicator_driver = {
.id_table = dynamic_replicator_ids,
};
+static int replicator_online_cpu(unsigned int cpu)
+{
+ struct replicator_drvdata *drvdata, *tmp;
+ int ret;
+
+ spin_lock(&delay_lock);
+ list_for_each_entry_safe(drvdata, tmp, &replicator_delay_probe, link) {
+ if (cpumask_test_cpu(cpu, drvdata->cpumask)) {
+ list_del(&drvdata->link);
+ spin_unlock(&delay_lock);
+ ret = pm_runtime_resume_and_get(drvdata->dev);
+ if (ret < 0)
+ return 0;
+
+ replicator_clear_self_claim_tag(drvdata);
+ replicator_reset(drvdata);
+ replicator_add_coresight_dev(drvdata->dev);
+ pm_runtime_put(drvdata->dev);
+ spin_lock(&delay_lock);
+ }
+ }
+ spin_unlock(&delay_lock);
+ return 0;
+}
+
static int __init replicator_init(void)
{
+ int ret;
+
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+ "arm/coresight-replicator:online",
+ replicator_online_cpu, NULL);
+
+ if (ret > 0)
+ hp_online = ret;
+ else
+ return ret;
+
return coresight_init_driver("replicator", &dynamic_replicator_driver, &replicator_driver,
THIS_MODULE);
}
@@ -563,6 +616,10 @@ static int __init replicator_init(void)
static void __exit replicator_exit(void)
{
coresight_remove_driver(&dynamic_replicator_driver, &replicator_driver);
+ if (hp_online) {
+ cpuhp_remove_state_nocalls(hp_online);
+ hp_online = 0;
+ }
}
module_init(replicator_init);
--
2.34.1
Powered by blists - more mailing lists