Skip to contentSkip to conversation

POWER9 PMU stops after idle workaround

PATCH Applied Nicholas Piggin 7 participants 7 messages Jul 20, 2017 – Sep 13, 2017 PowerPC

lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

PATCH 1/1 POWER9 PMU stops after idle workaround

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

---
 arch/powerpc/kernel/idle_book3s.S | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/kernel/idle_book3s.S +7 -1
index 516ebef905c0..e6252c5a57a4 100644
@@ -460,11 +460,17 @@ pnv_restore_hyp_resource_arch300:
 	/*
 	 * Workaround for POWER9, if we lost resources, the ERAT
 	 * might have been mixed up and needs flushing. We also need
-	 * to reload MMCR0 (see comment above).
+	 * to reload MMCR0 (see comment above). We also need to set
+	 * then clear bit 60 in MMCRA to ensure the PMU starts running.
 	 */
 	blt	cr3,1f
 	PPC_INVALIDATE_ERAT
 	ld	r1,PACAR1(r13)
+	mfspr	r4,SPRN_MMCRA
+	ori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
+	xori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
 	ld	r4,_MMCR0(r1)
 	mtspr	SPRN_MMCR0,r4
 1:
Signature · 1 line
2.11.0
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Nicholas Piggin

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

Quoted 29 lines
---
  arch/powerpc/kernel/idle_book3s.S | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/kernel/idle_book3s.S +7 -1
index 516ebef905c0..e6252c5a57a4 100644
@@ -460,11 +460,17 @@ pnv_restore_hyp_resource_arch300:
  	/*
  	 * Workaround for POWER9, if we lost resources, the ERAT
  	 * might have been mixed up and needs flushing. We also need
-	 * to reload MMCR0 (see comment above).
+	 * to reload MMCR0 (see comment above). We also need to set
+	 * then clear bit 60 in MMCRA to ensure the PMU starts running.
  	 */
  	blt	cr3,1f
  	PPC_INVALIDATE_ERAT
  	ld	r1,PACAR1(r13)
+	mfspr	r4,SPRN_MMCRA
+	ori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
+	xori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
  	ld	r4,_MMCR0(r1)
  	mtspr	SPRN_MMCR0,r4
  1:
Reviewed-by on v1 1/1
#2 lore raw
In reply to Nicholas Piggin
Quoted 6 lines · Nicholas Piggin

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

Quoted 14 lines
---
 arch/powerpc/kernel/idle_book3s.S | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/kernel/idle_book3s.S +1 -1
index 516ebef905c0..e6252c5a57a4 100644
@@ -460,11 +460,17 @@ pnv_restore_hyp_resource_arch300:
 	/*
 	 * Workaround for POWER9, if we lost resources, the ERAT
 	 * might have been mixed up and needs flushing. We also need
-	 * to reload MMCR0 (see comment above).
+	 * to reload MMCR0 (see comment above). We also need to set

arch/powerpc/kernel/idle_book3s.S pnv_restore_hyp_resource_arch300: · line 473

Quoted 10 lines
arch/powerpc/kernel/idle_book3s.S +6 -0
+	 * then clear bit 60 in MMCRA to ensure the PMU starts running.
 	 */
 	blt	cr3,1f
 	PPC_INVALIDATE_ERAT
 	ld	r1,PACAR1(r13)
+	mfspr	r4,SPRN_MMCRA
+	ori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
+	xori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4

Timing is ok to resolve the issue? Does back-to-back bit flip of MMCRA[60] gets the job done for all cases? Just asking since this issue in itself is a corner case ;)

--Vaidy

Acked-by on v1 1/1
#3 lore raw
In reply to Nicholas Piggin

Hi Nick,

Quoted 4 lines

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

Looks good.

Anton

Quoted 28 lines
---
 arch/powerpc/kernel/idle_book3s.S | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/arch/powerpc/kernel/idle_book3s.S index 516ebef905c0..e6252c5a57a4 100644 --- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S

arch/powerpc/kernel/idle_book3s.S +2 -1
@@ -460,11 +460,17 @@ pnv_restore_hyp_resource_arch300:
 	/*
 	 * Workaround for POWER9, if we lost resources, the ERAT
 	 * might have been mixed up and needs flushing. We also need
-	 * to reload MMCR0 (see comment above).
+	 * to reload MMCR0 (see comment above). We also need to set
+	 * then clear bit 60 in MMCRA to ensure the PMU starts

running. */

arch/powerpc/kernel/idle_book3s.S +5 -0
 	blt	cr3,1f
 	PPC_INVALIDATE_ERAT
 	ld	r1,PACAR1(r13)
+	mfspr	r4,SPRN_MMCRA
+	ori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
+	xori	r4,r4,(1 << (63-60))
+	mtspr	SPRN_MMCRA,r4
 	ld	r4,_MMCR0(r1)
 	mtspr	SPRN_MMCR0,r4
 1:
#4 lore raw
In reply to Nicholas Piggin
Quoted 9 lines · Nicholas Piggin

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/bdd21ddb919d28f9c62cdc6286cac9

cheers

#5 lore raw
Quoted 11 lines · On Thu, 3 Aug 2017 20:19:38 +1000 (AEST) Michael Ellerman…
Quoted 9 lines · Nicholas Piggin

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from state-loss idle.

Quoted 5 lines

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/bdd21ddb919d28f9c62cdc6286cac9

cheers

Not there anymore. I see this only in the merge branch.

Thanks

Michal

#6 lore raw

Yeah I messed up the subject when comitting, from memory, so I had to rebase and force push.

I think this is it:

https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=09539f9b123652e969894d6299ae0df2fe12cb5d

cheers

Quoted 26 lines · Michal Suchánek
Quoted 4 lines · On Thu, 3 Aug 2017 20:19:38 +1000 (AEST) Michael Ellerman…
Quoted 3 lines · Nicholas Piggin

POWER9 DD2 PMU can stop after a state-loss idle in some conditions.

A solution is to set then clear MMCRA[60] after wake from

state-loss

Quoted 7 lines
Quoted 6 lines

idle.

Quoted 5 lines

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/bdd21ddb919d28f9c62cdc6286cac9

cheers

Not there anymore. I see this only in the merge branch.

Thanks

Michal

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.