[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251027-cpu_cluster_component_pm-v1-3-31355ac588c2@oss.qualcomm.com>
Date: Mon, 27 Oct 2025 23:28:05 -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 03/12] coresight-funnel: Handle delay probe for CPU cluster
funnel
Delay probe the cpu cluster funnel when all CPUs of this cluster are
offline, re-probe the funnel when any CPU in the cluster comes online.
Key changes:
- Introduce a global list to track delayed funnels waiting for CPU online.
- Add CPU hotplug callback to retry registration when the CPU comes up.
Signed-off-by: Yuanfang Zhang <yuanfang.zhang@....qualcomm.com>
---
drivers/hwtracing/coresight/coresight-funnel.c | 62 +++++++++++++++++++++++---
1 file changed, 57 insertions(+), 5 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 12c29eb98b2122a3ade4cbed9a0d91c67ec777ed..43b9287a865eb26ce021521e4a5f193c48188bba 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -32,6 +32,9 @@
#define FUNNEL_ENSx_MASK 0xff
DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");
+static LIST_HEAD(funnel_delay_probe);
+static enum cpuhp_state hp_online;
+static DEFINE_SPINLOCK(delay_lock);
/**
* struct funnel_drvdata - specifics associated to a funnel component
@@ -42,6 +45,8 @@ DEFINE_CORESIGHT_DEVLIST(funnel_devs, "funnel");
* @priority: port selection order.
* @spinlock: serialize enable/disable operations.
* @cpumask: CPU mask representing the CPUs related to this funnel.
+ * @dev: pointer to the device associated with this funnel.
+ * @link: list node for adding this funnel to the delayed probe list.
*/
struct funnel_drvdata {
void __iomem *base;
@@ -51,6 +56,8 @@ struct funnel_drvdata {
unsigned long priority;
raw_spinlock_t spinlock;
struct cpumask *cpumask;
+ struct device *dev;
+ struct list_head link;
};
struct funnel_smp_arg {
@@ -372,7 +379,7 @@ static int funnel_probe(struct device *dev, struct resource *res)
drvdata->cpumask = funnel_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,
@@ -380,10 +387,15 @@ static int funnel_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, &funnel_delay_probe);
+ cpus_read_unlock();
return 0;
+ }
+
+ cpus_read_unlock();
} else if (res) {
funnel_clear_self_claim_tag(drvdata);
}
@@ -395,9 +407,12 @@ static int funnel_remove(struct device *dev)
{
struct funnel_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;
}
@@ -535,8 +550,41 @@ static struct amba_driver dynamic_funnel_driver = {
.id_table = dynamic_funnel_ids,
};
+static int funnel_online_cpu(unsigned int cpu)
+{
+ struct funnel_drvdata *drvdata, *tmp;
+ int ret;
+
+ list_for_each_entry_safe(drvdata, tmp, &funnel_delay_probe, link) {
+ if (cpumask_test_cpu(cpu, drvdata->cpumask)) {
+ scoped_guard(spinlock, &delay_lock)
+ list_del(&drvdata->link);
+
+ ret = pm_runtime_resume_and_get(drvdata->dev);
+ if (ret < 0)
+ return 0;
+
+ funnel_clear_self_claim_tag(drvdata);
+ funnel_add_coresight_dev(drvdata->dev);
+ pm_runtime_put(drvdata->dev);
+ }
+ }
+ return 0;
+}
+
static int __init funnel_init(void)
{
+ int ret;
+
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+ "arm/coresight-funnel:online",
+ funnel_online_cpu, NULL);
+
+ if (ret > 0)
+ hp_online = ret;
+ else
+ return ret;
+
return coresight_init_driver("funnel", &dynamic_funnel_driver, &funnel_driver,
THIS_MODULE);
}
@@ -544,6 +592,10 @@ static int __init funnel_init(void)
static void __exit funnel_exit(void)
{
coresight_remove_driver(&dynamic_funnel_driver, &funnel_driver);
+ if (hp_online) {
+ cpuhp_remove_state_nocalls(hp_online);
+ hp_online = 0;
+ }
}
module_init(funnel_init);
--
2.34.1
Powered by blists - more mailing lists