Skip to content

Commit 7114327

Browse files
Zaid Al-Bassamwilldeacon
authored andcommitted
perf: pmuv3: Abstract PMU version checks
The current PMU version definitions are available for arm64 only, As we want to add PMUv3 support to arm (32-bit), abstracts these definitions by using arch-specific helpers. Signed-off-by: Zaid Al-Bassam <zalbassam@google.com> Tested-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20230317195027.3746949-4-zalbassam@google.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent df29ddf commit 7114327

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

arch/arm64/include/asm/arm_pmuv3.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,20 @@ static inline u32 read_pmceid1(void)
134134
return read_sysreg(pmceid1_el0);
135135
}
136136

137+
static inline bool pmuv3_implemented(int pmuver)
138+
{
139+
return !(pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
140+
pmuver == ID_AA64DFR0_EL1_PMUVer_NI);
141+
}
142+
143+
static inline bool is_pmuv3p4(int pmuver)
144+
{
145+
return pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P4;
146+
}
147+
148+
static inline bool is_pmuv3p5(int pmuver)
149+
{
150+
return pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P5;
151+
}
152+
137153
#endif

drivers/perf/arm_pmuv3.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static const struct attribute_group armv8_pmuv3_caps_attr_group = {
392392
*/
393393
static bool armv8pmu_has_long_event(struct arm_pmu *cpu_pmu)
394394
{
395-
return (cpu_pmu->pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P5);
395+
return (is_pmuv3p5(cpu_pmu->pmuver));
396396
}
397397

398398
static inline bool armv8pmu_event_has_user_read(struct perf_event *event)
@@ -1084,8 +1084,7 @@ static void __armv8pmu_probe_pmu(void *info)
10841084
int pmuver;
10851085

10861086
pmuver = read_pmuver();
1087-
if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF ||
1088-
pmuver == ID_AA64DFR0_EL1_PMUVer_NI)
1087+
if (!pmuv3_implemented(pmuver))
10891088
return;
10901089

10911090
cpu_pmu->pmuver = pmuver;
@@ -1111,7 +1110,7 @@ static void __armv8pmu_probe_pmu(void *info)
11111110
pmceid, ARMV8_PMUV3_MAX_COMMON_EVENTS);
11121111

11131112
/* store PMMIR register for sysfs */
1114-
if (pmuver >= ID_AA64DFR0_EL1_PMUVer_V3P4 && (pmceid_raw[1] & BIT(31)))
1113+
if (is_pmuv3p4(pmuver) && (pmceid_raw[1] & BIT(31)))
11151114
cpu_pmu->reg_pmmir = read_pmmir();
11161115
else
11171116
cpu_pmu->reg_pmmir = 0;

0 commit comments

Comments
 (0)