Skip to content

Commit bc86281

Browse files
bwicaksononvwilldeacon
authored andcommitted
perf/arm_cspmu: Add arm_cspmu_acpi_dev_get
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>
1 parent f5caf26 commit bc86281

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

drivers/perf/arm_cspmu/arm_cspmu.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* The user should refer to the vendor technical documentation to get details
1717
* about the supported events.
1818
*
19-
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
19+
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2020
*
2121
*/
2222

@@ -1132,6 +1132,23 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
11321132

11331133
return 0;
11341134
}
1135+
1136+
struct acpi_device *arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu)
1137+
{
1138+
char hid[16] = {};
1139+
char uid[16] = {};
1140+
const struct acpi_apmt_node *apmt_node;
1141+
1142+
apmt_node = arm_cspmu_apmt_node(cspmu->dev);
1143+
if (!apmt_node || apmt_node->type != ACPI_APMT_NODE_TYPE_ACPI)
1144+
return NULL;
1145+
1146+
memcpy(hid, &apmt_node->inst_primary, sizeof(apmt_node->inst_primary));
1147+
snprintf(uid, sizeof(uid), "%u", apmt_node->inst_secondary);
1148+
1149+
return acpi_dev_get_first_match_dev(hid, uid, -1);
1150+
}
1151+
EXPORT_SYMBOL_GPL(arm_cspmu_acpi_dev_get);
11351152
#else
11361153
static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
11371154
{

drivers/perf/arm_cspmu/arm_cspmu.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* SPDX-License-Identifier: GPL-2.0
22
*
33
* ARM CoreSight Architecture PMU driver.
4-
* Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
* Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
55
*
66
*/
77

88
#ifndef __ARM_CSPMU_H__
99
#define __ARM_CSPMU_H__
1010

11+
#include <linux/acpi.h>
1112
#include <linux/bitfield.h>
1213
#include <linux/cpumask.h>
1314
#include <linux/device.h>
@@ -255,4 +256,18 @@ int arm_cspmu_impl_register(const struct arm_cspmu_impl_match *impl_match);
255256
/* Unregister vendor backend. */
256257
void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match *impl_match);
257258

259+
#if defined(CONFIG_ACPI) && defined(CONFIG_ARM64)
260+
/**
261+
* Get ACPI device associated with the PMU.
262+
* The caller is responsible for calling acpi_dev_put() on the returned device.
263+
*/
264+
struct acpi_device *arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu);
265+
#else
266+
static inline struct acpi_device *
267+
arm_cspmu_acpi_dev_get(const struct arm_cspmu *cspmu)
268+
{
269+
return NULL;
270+
}
271+
#endif
272+
258273
#endif /* __ARM_CSPMU_H__ */

0 commit comments

Comments
 (0)