Skip to content

Commit 101dd59

Browse files
npigginmpe
authored andcommitted
powerpc/perf: Avoid spurious PMU interrupts after idle
POWER9 DD2 can see spurious PMU interrupts after state-loss idle in some conditions. A solution is to save and reload MMCR0 over state-loss idle. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Acked-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Tested-by: Anton Blanchard <anton@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent a70b487 commit 101dd59

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

arch/powerpc/kernel/idle_book3s.S

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* Use unused space in the interrupt stack to save and restore
3131
* registers for winkle support.
3232
*/
33+
#define _MMCR0 GPR0
3334
#define _SDR1 GPR3
3435
#define _PTCR GPR3
3536
#define _RPR GPR4
@@ -272,6 +273,14 @@ power_enter_stop:
272273
b pnv_wakeup_noloss
273274

274275
.Lhandle_esl_ec_set:
276+
/*
277+
* POWER9 DD2 can incorrectly set PMAO when waking up after a
278+
* state-loss idle. Saving and restoring MMCR0 over idle is a
279+
* workaround.
280+
*/
281+
mfspr r4,SPRN_MMCR0
282+
std r4,_MMCR0(r1)
283+
275284
/*
276285
* Check if the requested state is a deep idle state.
277286
*/
@@ -450,10 +459,14 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
450459
pnv_restore_hyp_resource_arch300:
451460
/*
452461
* Workaround for POWER9, if we lost resources, the ERAT
453-
* might have been mixed up and needs flushing.
462+
* might have been mixed up and needs flushing. We also need
463+
* to reload MMCR0 (see comment above).
454464
*/
455465
blt cr3,1f
456466
PPC_INVALIDATE_ERAT
467+
ld r1,PACAR1(r13)
468+
ld r4,_MMCR0(r1)
469+
mtspr SPRN_MMCR0,r4
457470
1:
458471
/*
459472
* POWER ISA 3. Use PSSCR to determine if we

0 commit comments

Comments
 (0)