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

Configure Feed

Select the types of activity you want to include in your feed.

arm: perf: Use GENMASK for PMMIR fields

This is so that FIELD_GET and FIELD_PREP can be used and that the fields
are in a consistent format to arm64/tools/sysreg

Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20231211161331.1277825-4-james.clark@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

James Clark and committed by
Will Deacon
2f6a00f3 62e1f212

+6 -11
+3 -5
drivers/perf/arm_pmuv3.c
··· 332 332 { 333 333 struct pmu *pmu = dev_get_drvdata(dev); 334 334 struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu); 335 - u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK; 335 + u32 slots = FIELD_GET(ARMV8_PMU_SLOTS, cpu_pmu->reg_pmmir); 336 336 337 337 return sysfs_emit(page, "0x%08x\n", slots); 338 338 } ··· 344 344 { 345 345 struct pmu *pmu = dev_get_drvdata(dev); 346 346 struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu); 347 - u32 bus_slots = (cpu_pmu->reg_pmmir >> ARMV8_PMU_BUS_SLOTS_SHIFT) 348 - & ARMV8_PMU_BUS_SLOTS_MASK; 347 + u32 bus_slots = FIELD_GET(ARMV8_PMU_BUS_SLOTS, cpu_pmu->reg_pmmir); 349 348 350 349 return sysfs_emit(page, "0x%08x\n", bus_slots); 351 350 } ··· 356 357 { 357 358 struct pmu *pmu = dev_get_drvdata(dev); 358 359 struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu); 359 - u32 bus_width = (cpu_pmu->reg_pmmir >> ARMV8_PMU_BUS_WIDTH_SHIFT) 360 - & ARMV8_PMU_BUS_WIDTH_MASK; 360 + u32 bus_width = FIELD_GET(ARMV8_PMU_BUS_WIDTH, cpu_pmu->reg_pmmir); 361 361 u32 val = 0; 362 362 363 363 /* Encoded as Log2(number of bytes), plus one */
+3 -6
include/linux/perf/arm_pmuv3.h
··· 250 250 #define ARMV8_PMU_USERENR_ER (1 << 3) /* Event counter can be read at EL0 */ 251 251 252 252 /* PMMIR_EL1.SLOTS mask */ 253 - #define ARMV8_PMU_SLOTS_MASK 0xff 254 - 255 - #define ARMV8_PMU_BUS_SLOTS_SHIFT 8 256 - #define ARMV8_PMU_BUS_SLOTS_MASK 0xff 257 - #define ARMV8_PMU_BUS_WIDTH_SHIFT 16 258 - #define ARMV8_PMU_BUS_WIDTH_MASK 0xf 253 + #define ARMV8_PMU_SLOTS GENMASK(7, 0) 254 + #define ARMV8_PMU_BUS_SLOTS GENMASK(15, 8) 255 + #define ARMV8_PMU_BUS_WIDTH GENMASK(19, 16) 259 256 260 257 /* 261 258 * This code is really good