Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: perf: Include threshold control fields in PMEVTYPER mask

FEAT_PMUv3_TH (Armv8.8) adds two new fields to PMEVTYPER, so include
them in the mask. These aren't writable on 32 bit kernels as they are in
the high part of the register, so only include them for arm64.

It would be difficult to do this statically in the asm header files for
each platform without resulting in circular includes or #ifdefs inline
in the code. For that reason the ARMV8_PMU_EVTYPE_MASK definition has
been removed and the mask is constructed programmatically.

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20231211161331.1277825-6-james.clark@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

James Clark and committed by
Will Deacon
3115ee02 d30f09b6

+10 -2
+8 -1
drivers/perf/arm_pmuv3.c
··· 558 558 static void armv8pmu_write_evtype(int idx, u32 val) 559 559 { 560 560 u32 counter = ARMV8_IDX_TO_COUNTER(idx); 561 + unsigned long mask = ARMV8_PMU_EVTYPE_EVENT | 562 + ARMV8_PMU_INCLUDE_EL2 | 563 + ARMV8_PMU_EXCLUDE_EL0 | 564 + ARMV8_PMU_EXCLUDE_EL1; 561 565 562 - val &= ARMV8_PMU_EVTYPE_MASK; 566 + if (IS_ENABLED(CONFIG_ARM64)) 567 + mask |= ARMV8_PMU_EVTYPE_TC | ARMV8_PMU_EVTYPE_TH; 568 + 569 + val &= mask; 563 570 write_pmevtypern(counter, val); 564 571 } 565 572
+2 -1
include/linux/perf/arm_pmuv3.h
··· 233 233 /* 234 234 * PMXEVTYPER: Event selection reg 235 235 */ 236 - #define ARMV8_PMU_EVTYPE_MASK 0xc800ffff /* Mask for writable bits */ 237 236 #define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */ 237 + #define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32) 238 + #define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61) 238 239 239 240 /* 240 241 * Event filters for PMUv3