Skip to content

Commit ac347a0

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: "Mostly PMU fixes and a reworking of the pseudo-NMI disabling on broken MediaTek firmware: - Move the MediaTek GIC quirk handling from irqchip to core. Before the merging window commit 44bd78d ("irqchip/gic-v3: Disable pseudo NMIs on MediaTek devices w/ firmware issues") temporarily addressed this issue. Fixed now at a deeper level in the arch code - Reject events meant for other PMUs in the CoreSight PMU driver, otherwise some of the core PMU events would disappear - Fix the Armv8 PMUv3 driver driver to not truncate 64-bit registers, causing some events to be invisible - Remove duplicate declaration of __arm64_sys##name following the patch to avoid prototype warning for syscalls - Typos in the elf_hwcap documentation" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64/syscall: Remove duplicate declaration Revert "arm64: smp: avoid NMI IPIs with broken MediaTek FW" arm64: Move MediaTek GIC quirk handling from irqchip to core arm64/arm: arm_pmuv3: perf: Don't truncate 64-bit registers perf: arm_cspmu: Reject events meant for other PMUs Documentation/arm64: Fix typos in elf_hwcaps
2 parents e1d809b + f861280 commit ac347a0

File tree

9 files changed

+78
-86
lines changed

9 files changed

+78
-86
lines changed

Documentation/arch/arm64/elf_hwcaps.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ HWCAP2_DCPODP
174174
Functionality implied by ID_AA64ISAR1_EL1.DPB == 0b0010.
175175

176176
HWCAP2_SVE2
177-
Functionality implied by ID_AA64ZFR0_EL1.SVEVer == 0b0001.
177+
Functionality implied by ID_AA64ZFR0_EL1.SVEver == 0b0001.
178178

179179
HWCAP2_SVEAES
180180
Functionality implied by ID_AA64ZFR0_EL1.AES == 0b0001.
@@ -222,7 +222,7 @@ HWCAP2_RNG
222222
Functionality implied by ID_AA64ISAR0_EL1.RNDR == 0b0001.
223223

224224
HWCAP2_BTI
225-
Functionality implied by ID_AA64PFR0_EL1.BT == 0b0001.
225+
Functionality implied by ID_AA64PFR1_EL1.BT == 0b0001.
226226

227227
HWCAP2_MTE
228228
Functionality implied by ID_AA64PFR1_EL1.MTE == 0b0010, as described
@@ -232,7 +232,7 @@ HWCAP2_ECV
232232
Functionality implied by ID_AA64MMFR0_EL1.ECV == 0b0001.
233233

234234
HWCAP2_AFP
235-
Functionality implied by ID_AA64MFR1_EL1.AFP == 0b0001.
235+
Functionality implied by ID_AA64MMFR1_EL1.AFP == 0b0001.
236236

237237
HWCAP2_RPRES
238238
Functionality implied by ID_AA64ISAR2_EL1.RPRES == 0b0001.

arch/arm/include/asm/arm_pmuv3.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define PMUSERENR __ACCESS_CP15(c9, 0, c14, 0)
2424
#define PMINTENSET __ACCESS_CP15(c9, 0, c14, 1)
2525
#define PMINTENCLR __ACCESS_CP15(c9, 0, c14, 2)
26+
#define PMCEID2 __ACCESS_CP15(c9, 0, c14, 4)
27+
#define PMCEID3 __ACCESS_CP15(c9, 0, c14, 5)
2628
#define PMMIR __ACCESS_CP15(c9, 0, c14, 6)
2729
#define PMCCFILTR __ACCESS_CP15(c14, 0, c15, 7)
2830

@@ -150,21 +152,6 @@ static inline u64 read_pmccntr(void)
150152
return read_sysreg(PMCCNTR);
151153
}
152154

153-
static inline void write_pmxevcntr(u32 val)
154-
{
155-
write_sysreg(val, PMXEVCNTR);
156-
}
157-
158-
static inline u32 read_pmxevcntr(void)
159-
{
160-
return read_sysreg(PMXEVCNTR);
161-
}
162-
163-
static inline void write_pmxevtyper(u32 val)
164-
{
165-
write_sysreg(val, PMXEVTYPER);
166-
}
167-
168155
static inline void write_pmcntenset(u32 val)
169156
{
170157
write_sysreg(val, PMCNTENSET);
@@ -205,16 +192,6 @@ static inline void write_pmuserenr(u32 val)
205192
write_sysreg(val, PMUSERENR);
206193
}
207194

208-
static inline u32 read_pmceid0(void)
209-
{
210-
return read_sysreg(PMCEID0);
211-
}
212-
213-
static inline u32 read_pmceid1(void)
214-
{
215-
return read_sysreg(PMCEID1);
216-
}
217-
218195
static inline void kvm_set_pmu_events(u32 set, struct perf_event_attr *attr) {}
219196
static inline void kvm_clr_pmu_events(u32 clr) {}
220197
static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr)
@@ -231,6 +208,7 @@ static inline void kvm_vcpu_pmu_resync_el0(void) {}
231208

232209
/* PMU Version in DFR Register */
233210
#define ARMV8_PMU_DFR_VER_NI 0
211+
#define ARMV8_PMU_DFR_VER_V3P1 0x4
234212
#define ARMV8_PMU_DFR_VER_V3P4 0x5
235213
#define ARMV8_PMU_DFR_VER_V3P5 0x6
236214
#define ARMV8_PMU_DFR_VER_IMP_DEF 0xF
@@ -251,4 +229,24 @@ static inline bool is_pmuv3p5(int pmuver)
251229
return pmuver >= ARMV8_PMU_DFR_VER_V3P5;
252230
}
253231

232+
static inline u64 read_pmceid0(void)
233+
{
234+
u64 val = read_sysreg(PMCEID0);
235+
236+
if (read_pmuver() >= ARMV8_PMU_DFR_VER_V3P1)
237+
val |= (u64)read_sysreg(PMCEID2) << 32;
238+
239+
return val;
240+
}
241+
242+
static inline u64 read_pmceid1(void)
243+
{
244+
u64 val = read_sysreg(PMCEID1);
245+
246+
if (read_pmuver() >= ARMV8_PMU_DFR_VER_V3P1)
247+
val |= (u64)read_sysreg(PMCEID3) << 32;
248+
249+
return val;
250+
}
251+
254252
#endif

arch/arm64/include/asm/arm_pmuv3.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ static inline u32 read_pmuver(void)
4646
ID_AA64DFR0_EL1_PMUVer_SHIFT);
4747
}
4848

49-
static inline void write_pmcr(u32 val)
49+
static inline void write_pmcr(u64 val)
5050
{
5151
write_sysreg(val, pmcr_el0);
5252
}
5353

54-
static inline u32 read_pmcr(void)
54+
static inline u64 read_pmcr(void)
5555
{
5656
return read_sysreg(pmcr_el0);
5757
}
@@ -71,21 +71,6 @@ static inline u64 read_pmccntr(void)
7171
return read_sysreg(pmccntr_el0);
7272
}
7373

74-
static inline void write_pmxevcntr(u32 val)
75-
{
76-
write_sysreg(val, pmxevcntr_el0);
77-
}
78-
79-
static inline u32 read_pmxevcntr(void)
80-
{
81-
return read_sysreg(pmxevcntr_el0);
82-
}
83-
84-
static inline void write_pmxevtyper(u32 val)
85-
{
86-
write_sysreg(val, pmxevtyper_el0);
87-
}
88-
8974
static inline void write_pmcntenset(u32 val)
9075
{
9176
write_sysreg(val, pmcntenset_el0);
@@ -106,7 +91,7 @@ static inline void write_pmintenclr(u32 val)
10691
write_sysreg(val, pmintenclr_el1);
10792
}
10893

109-
static inline void write_pmccfiltr(u32 val)
94+
static inline void write_pmccfiltr(u64 val)
11095
{
11196
write_sysreg(val, pmccfiltr_el0);
11297
}
@@ -126,12 +111,12 @@ static inline void write_pmuserenr(u32 val)
126111
write_sysreg(val, pmuserenr_el0);
127112
}
128113

129-
static inline u32 read_pmceid0(void)
114+
static inline u64 read_pmceid0(void)
130115
{
131116
return read_sysreg(pmceid0_el0);
132117
}
133118

134-
static inline u32 read_pmceid1(void)
119+
static inline u64 read_pmceid1(void)
135120
{
136121
return read_sysreg(pmceid1_el0);
137122
}

arch/arm64/include/asm/syscall_wrapper.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \
5555
static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
5656
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
57-
asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \
5857
asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \
5958
{ \
6059
return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \

arch/arm64/kernel/cpufeature.c

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,37 @@ static void init_32bit_cpu_features(struct cpuinfo_32bit *info)
999999
init_cpu_ftr_reg(SYS_MVFR2_EL1, info->reg_mvfr2);
10001000
}
10011001

1002+
#ifdef CONFIG_ARM64_PSEUDO_NMI
1003+
static bool enable_pseudo_nmi;
1004+
1005+
static int __init early_enable_pseudo_nmi(char *p)
1006+
{
1007+
return kstrtobool(p, &enable_pseudo_nmi);
1008+
}
1009+
early_param("irqchip.gicv3_pseudo_nmi", early_enable_pseudo_nmi);
1010+
1011+
static __init void detect_system_supports_pseudo_nmi(void)
1012+
{
1013+
struct device_node *np;
1014+
1015+
if (!enable_pseudo_nmi)
1016+
return;
1017+
1018+
/*
1019+
* Detect broken MediaTek firmware that doesn't properly save and
1020+
* restore GIC priorities.
1021+
*/
1022+
np = of_find_compatible_node(NULL, NULL, "arm,gic-v3");
1023+
if (np && of_property_read_bool(np, "mediatek,broken-save-restore-fw")) {
1024+
pr_info("Pseudo-NMI disabled due to MediaTek Chromebook GICR save problem\n");
1025+
enable_pseudo_nmi = false;
1026+
}
1027+
of_node_put(np);
1028+
}
1029+
#else /* CONFIG_ARM64_PSEUDO_NMI */
1030+
static inline void detect_system_supports_pseudo_nmi(void) { }
1031+
#endif
1032+
10021033
void __init init_cpu_features(struct cpuinfo_arm64 *info)
10031034
{
10041035
/* Before we start using the tables, make sure it is sorted */
@@ -1057,6 +1088,13 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
10571088
*/
10581089
init_cpucap_indirect_list();
10591090

1091+
/*
1092+
* Detect broken pseudo-NMI. Must be called _before_ the call to
1093+
* setup_boot_cpu_capabilities() since it interacts with
1094+
* can_use_gic_priorities().
1095+
*/
1096+
detect_system_supports_pseudo_nmi();
1097+
10601098
/*
10611099
* Detect and enable early CPU capabilities based on the boot CPU,
10621100
* after we have initialised the CPU feature infrastructure.
@@ -2085,14 +2123,6 @@ static void cpu_enable_e0pd(struct arm64_cpu_capabilities const *cap)
20852123
#endif /* CONFIG_ARM64_E0PD */
20862124

20872125
#ifdef CONFIG_ARM64_PSEUDO_NMI
2088-
static bool enable_pseudo_nmi;
2089-
2090-
static int __init early_enable_pseudo_nmi(char *p)
2091-
{
2092-
return kstrtobool(p, &enable_pseudo_nmi);
2093-
}
2094-
early_param("irqchip.gicv3_pseudo_nmi", early_enable_pseudo_nmi);
2095-
20962126
static bool can_use_gic_priorities(const struct arm64_cpu_capabilities *entry,
20972127
int scope)
20982128
{

arch/arm64/kernel/smp.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,7 @@ static void smp_cross_call(const struct cpumask *target, unsigned int ipinr)
965965

966966
static bool ipi_should_be_nmi(enum ipi_msg_type ipi)
967967
{
968-
DECLARE_STATIC_KEY_FALSE(supports_pseudo_nmis);
969-
970-
if (!system_uses_irq_prio_masking() ||
971-
!static_branch_likely(&supports_pseudo_nmis))
968+
if (!system_uses_irq_prio_masking())
972969
return false;
973970

974971
switch (ipi) {

drivers/irqchip/irq-gic-v3.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939

4040
#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)
4141
#define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1)
42-
#define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2)
43-
#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 3)
42+
#define FLAGS_WORKAROUND_ASR_ERRATUM_8601001 (1ULL << 2)
4443

4544
#define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1)
4645

@@ -106,7 +105,7 @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key);
106105
* - Figure 4-7 Secure read of the priority field for a Non-secure Group 1
107106
* interrupt.
108107
*/
109-
DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis);
108+
static DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis);
110109

111110
DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities);
112111
EXPORT_SYMBOL(gic_nonsecure_priorities);
@@ -1779,15 +1778,6 @@ static bool gic_enable_quirk_msm8996(void *data)
17791778
return true;
17801779
}
17811780

1782-
static bool gic_enable_quirk_mtk_gicr(void *data)
1783-
{
1784-
struct gic_chip_data *d = data;
1785-
1786-
d->flags |= FLAGS_WORKAROUND_MTK_GICR_SAVE;
1787-
1788-
return true;
1789-
}
1790-
17911781
static bool gic_enable_quirk_cavium_38539(void *data)
17921782
{
17931783
struct gic_chip_data *d = data;
@@ -1888,11 +1878,6 @@ static const struct gic_quirk gic_quirks[] = {
18881878
.compatible = "asr,asr8601-gic-v3",
18891879
.init = gic_enable_quirk_asr8601,
18901880
},
1891-
{
1892-
.desc = "GICv3: Mediatek Chromebook GICR save problem",
1893-
.property = "mediatek,broken-save-restore-fw",
1894-
.init = gic_enable_quirk_mtk_gicr,
1895-
},
18961881
{
18971882
.desc = "GICv3: HIP06 erratum 161010803",
18981883
.iidr = 0x0204043b,
@@ -1959,11 +1944,6 @@ static void gic_enable_nmi_support(void)
19591944
if (!gic_prio_masking_enabled())
19601945
return;
19611946

1962-
if (gic_data.flags & FLAGS_WORKAROUND_MTK_GICR_SAVE) {
1963-
pr_warn("Skipping NMI enable due to firmware issues\n");
1964-
return;
1965-
}
1966-
19671947
rdist_nmi_refs = kcalloc(gic_data.ppi_nr + SGI_NR,
19681948
sizeof(*rdist_nmi_refs), GFP_KERNEL);
19691949
if (!rdist_nmi_refs)

drivers/perf/arm_cspmu/arm_cspmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ static int arm_cspmu_event_init(struct perf_event *event)
676676

677677
cspmu = to_arm_cspmu(event->pmu);
678678

679+
if (event->attr.type != event->pmu->type)
680+
return -ENOENT;
681+
679682
/*
680683
* Following other "uncore" PMUs, we do not support sampling mode or
681684
* attach to a task (per-process mode).

drivers/perf/arm_pmuv3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,12 @@ static inline bool armv8pmu_event_is_chained(struct perf_event *event)
428428
#define ARMV8_IDX_TO_COUNTER(x) \
429429
(((x) - ARMV8_IDX_COUNTER0) & ARMV8_PMU_COUNTER_MASK)
430430

431-
static inline u32 armv8pmu_pmcr_read(void)
431+
static inline u64 armv8pmu_pmcr_read(void)
432432
{
433433
return read_pmcr();
434434
}
435435

436-
static inline void armv8pmu_pmcr_write(u32 val)
436+
static inline void armv8pmu_pmcr_write(u64 val)
437437
{
438438
val &= ARMV8_PMU_PMCR_MASK;
439439
isb();
@@ -957,7 +957,7 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
957957
static void armv8pmu_reset(void *info)
958958
{
959959
struct arm_pmu *cpu_pmu = (struct arm_pmu *)info;
960-
u32 pmcr;
960+
u64 pmcr;
961961

962962
/* The counter and interrupt enable registers are unknown at reset. */
963963
armv8pmu_disable_counter(U32_MAX);

0 commit comments

Comments
 (0)