Re: [PATCH 3/8] perf/arm_cspmu: Add arm_cspmu_acpi_dev_get

From: Ilkka Koskinen

Date: Thu Jan 29 2026 - 17:23:30 EST



Hi Besar,

On Mon, 26 Jan 2026, Besar Wicaksono wrote:
Add interface to get ACPI device associated with the
PMU. This ACPI device may contain additional properties
not covered by the standard properties.

Signed-off-by: Besar Wicaksono <bwicaksono@xxxxxxxxxx>
---
drivers/perf/arm_cspmu/arm_cspmu.c | 24 +++++++++++++++++++++++-
drivers/perf/arm_cspmu/arm_cspmu.h | 17 ++++++++++++++++-
2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 34430b68f602..dadc9b765d80 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -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,28 @@ 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];
+ struct acpi_device *adev;
+ 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;
+
+ memset(hid, 0, sizeof(hid));
+ memset(uid, 0, sizeof(uid));
+
+ memcpy(hid, &apmt_node->inst_primary, sizeof(apmt_node->inst_primary));
+ snprintf(uid, sizeof(uid), "%u", apmt_node->inst_secondary);
+
+ adev = acpi_dev_get_first_match_dev(hid, uid, -1);
+ return adev;

I'd probably just do

return acpi_dev_get_first_match_dev(hid, uid, -1);

but it doesn't really matter. Regardless,

Reviewed-by: Ilkka Koskinen <ilkka@xxxxxxxxxxxxxxxxxxxxxx>

Cheers, Ilkka