[PATCH 6/8] perf/arm_pmu: Support ACPI devices in the platform probe
From: Leo Yan
Date: Mon Nov 16 2026 - 13:23:16 EST
Add pmu_get_match_data() to select the initialization callback for DT
and ACPI devices. Use OF match data for devices with a DT node, and
match the platform device name against the existing compatible table
otherwise. This also handles devices described by software nodes.
Return -ENODEV when no initializer or fallback probe table is available.
Append the platform device ID to numbered PMU names, leaving unnumbered
DT device names unchanged.
Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
drivers/perf/arm_pmu_platform.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c
index 1c9e50a13201528edf4cfbdc2504d305b49d4913..397fdb148dc9b6be083e654e091ecc6a95c4905b 100644
--- a/drivers/perf/arm_pmu_platform.c
+++ b/drivers/perf/arm_pmu_platform.c
@@ -20,7 +20,9 @@
#include <linux/perf/arm_pmu.h>
#include <linux/platform_device.h>
#include <linux/printk.h>
+#include <linux/slab.h>
#include <linux/smp.h>
+#include <linux/string.h>
static int probe_current_pmu(struct arm_pmu *pmu,
const struct pmu_probe_info *info)
@@ -185,6 +187,23 @@ static void armpmu_free_irqs(struct arm_pmu *armpmu)
}
}
+static const void *pmu_get_match_data(struct platform_device *pdev,
+ const struct of_device_id *of_table)
+{
+ const struct of_device_id *match;
+
+ if (pdev->dev.of_node)
+ return of_device_get_match_data(&pdev->dev);
+
+ /* ACPI platform devices use a compatible string as their name */
+ for (match = of_table; match && match->compatible[0]; match++) {
+ if (!strcmp(pdev->name, match->compatible))
+ return match->data;
+ }
+
+ return NULL;
+}
+
int arm_pmu_device_probe(struct platform_device *pdev,
const struct of_device_id *of_table,
const struct pmu_probe_info *probe_table)
@@ -205,7 +224,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
if (ret)
goto out_free;
- init_fn = of_device_get_match_data(dev);
+ init_fn = pmu_get_match_data(pdev, of_table);
if (init_fn) {
pmu->secure_access = of_property_read_bool(dev->of_node,
"secure-reg-access");
@@ -220,6 +239,8 @@ int arm_pmu_device_probe(struct platform_device *pdev,
} else if (probe_table) {
cpumask_setall(&pmu->supported_cpus);
ret = probe_current_pmu(pmu, probe_table);
+ } else {
+ ret = -ENODEV;
}
if (ret) {
@@ -227,6 +248,16 @@ int arm_pmu_device_probe(struct platform_device *pdev,
goto out_free;
}
+ /* Append instance suffix (for only ACPI devices) */
+ if (pdev->id >= 0) {
+ pmu->name = devm_kasprintf(dev, GFP_KERNEL, "%s_%d",
+ pmu->name, pdev->id);
+ if (!pmu->name) {
+ ret = -ENOMEM;
+ goto out_free;
+ }
+ }
+
ret = armpmu_request_irqs(pmu);
if (ret)
goto out_free_irqs;
--
2.34.1