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

drivers/perf: Add support for ARMv8.3-SPE

Armv8.3 extends the SPE by adding:
- Alignment field in the Events packet, and filtering on this event
using PMSEVFR_EL1.
- Support for the Scalable Vector Extension (SVE).

The main additions for SVE are:
- Recording the vector length for SVE operations in the Operation Type
packet. It is not possible to filter on vector length.
- Incomplete predicate and empty predicate fields in the Events packet,
and filtering on these events using PMSEVFR_EL1.

Update the check of pmsevfr for empty/partial predicated SVE and
alignment event in SPE driver.

Signed-off-by: Wei Li <liwei391@huawei.com>
Link: https://lore.kernel.org/r/20201203141609.14148-1-liwei391@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Wei Li and committed by
Will Deacon
4a669e24 19c329f6

+23 -3
+8 -1
arch/arm64/include/asm/sysreg.h
··· 291 291 #define SYS_PMSFCR_EL1_ST_SHIFT 18 292 292 293 293 #define SYS_PMSEVFR_EL1 sys_reg(3, 0, 9, 9, 5) 294 - #define SYS_PMSEVFR_EL1_RES0 0x0000ffff00ff0f55UL 294 + #define SYS_PMSEVFR_EL1_RES0_8_2 \ 295 + (GENMASK_ULL(47, 32) | GENMASK_ULL(23, 16) | GENMASK_ULL(11, 8) |\ 296 + BIT_ULL(6) | BIT_ULL(4) | BIT_ULL(2) | BIT_ULL(0)) 297 + #define SYS_PMSEVFR_EL1_RES0_8_3 \ 298 + (SYS_PMSEVFR_EL1_RES0_8_2 & ~(BIT_ULL(18) | BIT_ULL(17) | BIT_ULL(11))) 295 299 296 300 #define SYS_PMSLATFR_EL1 sys_reg(3, 0, 9, 9, 6) 297 301 #define SYS_PMSLATFR_EL1_MINLAT_SHIFT 0 ··· 847 843 #define ID_AA64DFR0_PMUVER_8_4 0x5 848 844 #define ID_AA64DFR0_PMUVER_8_5 0x6 849 845 #define ID_AA64DFR0_PMUVER_IMP_DEF 0xf 846 + 847 + #define ID_AA64DFR0_PMSVER_8_2 0x1 848 + #define ID_AA64DFR0_PMSVER_8_3 0x2 850 849 851 850 #define ID_DFR0_PERFMON_SHIFT 24 852 851
+15 -2
drivers/perf/arm_spe_pmu.c
··· 54 54 struct hlist_node hotplug_node; 55 55 56 56 int irq; /* PPI */ 57 - 57 + u16 pmsver; 58 58 u16 min_period; 59 59 u16 counter_sz; 60 60 ··· 655 655 return IRQ_HANDLED; 656 656 } 657 657 658 + static u64 arm_spe_pmsevfr_res0(u16 pmsver) 659 + { 660 + switch (pmsver) { 661 + case ID_AA64DFR0_PMSVER_8_2: 662 + return SYS_PMSEVFR_EL1_RES0_8_2; 663 + case ID_AA64DFR0_PMSVER_8_3: 664 + /* Return the highest version we support in default */ 665 + default: 666 + return SYS_PMSEVFR_EL1_RES0_8_3; 667 + } 668 + } 669 + 658 670 /* Perf callbacks */ 659 671 static int arm_spe_pmu_event_init(struct perf_event *event) 660 672 { ··· 682 670 !cpumask_test_cpu(event->cpu, &spe_pmu->supported_cpus)) 683 671 return -ENOENT; 684 672 685 - if (arm_spe_event_to_pmsevfr(event) & SYS_PMSEVFR_EL1_RES0) 673 + if (arm_spe_event_to_pmsevfr(event) & arm_spe_pmsevfr_res0(spe_pmu->pmsver)) 686 674 return -EOPNOTSUPP; 687 675 688 676 if (attr->exclude_idle) ··· 949 937 fld, smp_processor_id()); 950 938 return; 951 939 } 940 + spe_pmu->pmsver = (u16)fld; 952 941 953 942 /* Read PMBIDR first to determine whether or not we have access */ 954 943 reg = read_sysreg_s(SYS_PMBIDR_EL1);