]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf/arm_cspmu: Add arm_cspmu_acpi_dev_get
authorBesar Wicaksono <bwicaksono@nvidia.com>
Tue, 24 Mar 2026 01:29:47 +0000 (01:29 +0000)
committerWill Deacon <will@kernel.org>
Tue, 24 Mar 2026 12:37:32 +0000 (12:37 +0000)
Add interface to get ACPI device associated with the
PMU. This ACPI device may contain additional properties
not covered by the standard properties.

Reviewed-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/arm_cspmu/arm_cspmu.c
drivers/perf/arm_cspmu/arm_cspmu.h

index 34430b68f60254e9666f230ba42f1f875b20b1b8..49e8a1f381319a41e37b3fd09c07ec18b8907f19 100644 (file)
@@ -16,7 +16,7 @@
  * The user should refer to the vendor technical documentation to get details
  * about the supported events.
  *
- * Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ * Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
  *
  */
 
@@ -1132,6 +1132,23 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
 
        return 0;
 }
+
+struct acpi_device *arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu)
+{
+       char hid[16] = {};
+       char uid[16] = {};
+       const struct acpi_apmt_node *apmt_node;
+
+       apmt_node = arm_cspmu_apmt_node(cspmu->dev);
+       if (!apmt_node || apmt_node->type != ACPI_APMT_NODE_TYPE_ACPI)
+               return NULL;
+
+       memcpy(hid, &apmt_node->inst_primary, sizeof(apmt_node->inst_primary));
+       snprintf(uid, sizeof(uid), "%u", apmt_node->inst_secondary);
+
+       return acpi_dev_get_first_match_dev(hid, uid, -1);
+}
+EXPORT_SYMBOL_GPL(arm_cspmu_acpi_dev_get);
 #else
 static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
 {
index cd65a58dbd884e7af983ecf8e0ceaf886f15ea8d..3fc5c8d772663c93ac7b61020c6a3b85c4d521e4 100644 (file)
@@ -1,13 +1,14 @@
 /* SPDX-License-Identifier: GPL-2.0
  *
  * ARM CoreSight Architecture PMU driver.
- * Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ * Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
  *
  */
 
 #ifndef __ARM_CSPMU_H__
 #define __ARM_CSPMU_H__
 
+#include <linux/acpi.h>
 #include <linux/bitfield.h>
 #include <linux/cpumask.h>
 #include <linux/device.h>
@@ -255,4 +256,18 @@ int arm_cspmu_impl_register(const struct arm_cspmu_impl_match *impl_match);
 /* Unregister vendor backend. */
 void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match *impl_match);
 
+#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
+/**
+ * Get ACPI device associated with the PMU.
+ * The caller is responsible for calling acpi_dev_put() on the returned device.
+ */
+struct acpi_device *arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu);
+#else
+static inline struct acpi_device *
+arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu)
+{
+       return NULL;
+}
+#endif
+
 #endif /* __ARM_CSPMU_H__ */