Skip to contentSkip to conversation

powerpc/cpuidle: Only clear LPCR decrementer wakeup bit on fast sleep entry

PATCH In review Michael Neuling 4 participants 7 messages Jun 2, 2014 – Jun 5, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc/cpuidle: Only clear LPCR decrementer wakeup bit on fast sleep entry

Currently when entering fastsleep we clear all LPCR PECE bits.

This patch changes it to only clear the decrementer bit (ie. PECE1), which is the only bit we really need to clear here. This is needed if we want to set other wakeup causes like the PECEDH bit so we can use hypervisor doorbells on powernv.

---
 drivers/cpuidle/cpuidle-powernv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/cpuidle-powernv.c +1 -1
index 719f6fb..7f7798e 100644
@@ -73,7 +73,7 @@ static int fastsleep_loop(struct cpuidle_device *dev,
 		return index;
 
 	new_lpcr = old_lpcr;
-	new_lpcr &= ~(LPCR_MER | LPCR_PECE); /* lpcr[mer] must be 0 */
+	new_lpcr &= ~(LPCR_MER | LPCR_PECE1); /* lpcr[mer] must be 0 */
 
 	/* exit powersave upon external interrupt, but not decrementer
 	 * interrupt.
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 powerpc/powernv: Enable POWER8 doorbell IPIs

This patch enables POWER8 doorbell IPIs on powernv.

Since doorbells can only IPI within a core, we test to see when we can use doorbells and if not we fall back to XICS. This also enables hypervisor doorbells to wakeup us up from nap/sleep via the LPCR PECEDH bit.

Based on tests by Anton, the best case IPI latency between two threads dropped from 894ns to 512ns.

---
 arch/powerpc/kernel/cpu_setup_power.S | 2 ++
 arch/powerpc/platforms/powernv/smp.c  | 6 ++++++
 arch/powerpc/sysdev/xics/icp-native.c | 9 ++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 1557e7c..4673353 100644
@@ -56,6 +56,7 @@ _GLOBAL(__setup_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr	r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
@@ -74,6 +75,7 @@ _GLOBAL(__restore_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr   r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
arch/powerpc/platforms/powernv/smp.c +6 -0
index 0062a43..5fcfcf4 100644
@@ -32,6 +32,7 @@
 #include <asm/opal.h>
 #include <asm/runlatch.h>
 #include <asm/code-patching.h>
+#include <asm/dbell.h>
 
 #include "powernv.h"
 
@@ -46,6 +47,11 @@ static void pnv_smp_setup_cpu(int cpu)
 {
 	if (cpu != boot_cpuid)
 		xics_setup_cpu();
+
+#ifdef CONFIG_PPC_DOORBELL
+	if (cpu_has_feature(CPU_FTR_DBELL))
+		doorbell_setup_this_cpu();
+#endif
 }
 
 int pnv_smp_kick_cpu(int nr)
arch/powerpc/sysdev/xics/icp-native.c +8 -1
index 9dee470..de8d948 100644
@@ -26,6 +26,7 @@
 #include <asm/errno.h>
 #include <asm/xics.h>
 #include <asm/kvm_ppc.h>
+#include <asm/dbell.h>
 
 struct icp_ipl {
 	union {
@@ -145,7 +146,13 @@ static unsigned int icp_native_get_irq(void)
 static void icp_native_cause_ipi(int cpu, unsigned long data)
 {
 	kvmppc_set_host_ipi(cpu, 1);
-	icp_native_set_qirr(cpu, IPI_PRIORITY);
+#ifdef CONFIG_PPC_DOORBELL
+	if (cpu_has_feature(CPU_FTR_DBELL) &&
+	    (cpumask_test_cpu(cpu, cpu_sibling_mask(smp_processor_id()))))
+		doorbell_cause_ipi(cpu, data);
+	else
+#endif
+		icp_native_set_qirr(cpu, IPI_PRIORITY);
 }
 
 void xics_wake_cpu(int cpu)
Signature · 1 line
1.9.1
Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] powerpc/powernv: Enable POWER8 doorbell IPIs

Hi,

Quoted 11 lines

This patch enables POWER8 doorbell IPIs on powernv.

Since doorbells can only IPI within a core, we test to see when we can use doorbells and if not we fall back to XICS. This also enables hypervisor doorbells to wakeup us up from nap/sleep via the LPCR PECEDH bit.

Based on tests by Anton, the best case IPI latency between two threads dropped from 894ns to 512ns.

Thanks Mikey!

Anton

#3 lore raw

Re: [PATCH 2/2] powerpc/powernv: Enable POWER8 doorbell IPIs

In reply to Michael Neuling
Quoted 49 lines · Michael Neuling

This patch enables POWER8 doorbell IPIs on powernv.

Since doorbells can only IPI within a core, we test to see when we can use doorbells and if not we fall back to XICS. This also enables hypervisor doorbells to wakeup us up from nap/sleep via the LPCR PECEDH bit.

Based on tests by Anton, the best case IPI latency between two threads dropped from 894ns to 512ns.

---
 arch/powerpc/kernel/cpu_setup_power.S | 2 ++
 arch/powerpc/platforms/powernv/smp.c  | 6 ++++++
 arch/powerpc/sysdev/xics/icp-native.c | 9 ++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 1557e7c..4673353 100644
@@ -56,6 +56,7 @@ _GLOBAL(__setup_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr	r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
@@ -74,6 +75,7 @@ _GLOBAL(__restore_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr   r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
arch/powerpc/platforms/powernv/smp.c +1 -0
index 0062a43..5fcfcf4 100644
@@ -32,6 +32,7 @@
 #include <asm/opal.h>
 #include <asm/runlatch.h>
 #include <asm/code-patching.h>
+#include <asm/dbell.h>
 
 #include "powernv.h"
 

arch/powerpc/platforms/powernv/smp.c static void pnv_smp_setup_cpu(int cpu) · line 55

Quoted 9 lines
arch/powerpc/platforms/powernv/smp.c +5 -0
@@ -46,6 +47,11 @@ static void pnv_smp_setup_cpu(int cpu)
 {
 	if (cpu != boot_cpuid)
 		xics_setup_cpu();
+
+#ifdef CONFIG_PPC_DOORBELL
+	if (cpu_has_feature(CPU_FTR_DBELL))
+		doorbell_setup_this_cpu();
+#endif
 }

Where does CONFIG_PPC_DOORBELL get set?

It looks like the only place you can be getting it is from CONFIG_PPC_PSERIES. If you build a POWERNV only kernel it will get disabled, which I don't think is what we want.

I think we should select it for POWERNV as well as PSERIES. That would mean it's always enabled for any build of the files you touch, so you shouldn't need the #ifdefs.

cheers

#4 lore raw

Re: [PATCH 2/2] powerpc/powernv: Enable POWER8 doorbell IPIs

Quoted 4 lines · Michael Ellerman
Quoted 3 lines · Michael Neuling

This patch enables POWER8 doorbell IPIs on powernv.
=20
Since doorbells can only IPI within a core, we test to see when we can =

use

Quoted 1 line
Quoted 1 line

doorbells and if not we fall back to XICS. This also enables hyperviso=

r

Quoted 3 lines
Quoted 3 lines

doorbells to wakeup us up from nap/sleep via the LPCR PECEDH bit. =20
Based on tests by Anton, the best case IPI latency between two threads =

dropped

Quoted 10 lines

arch/powerpc/kerne=

Quoted 10 lines

from 894ns to 512ns.
=20

---
 arch/powerpc/kernel/cpu_setup_power.S | 2 ++
 arch/powerpc/platforms/powernv/smp.c  | 6 ++++++
 arch/powerpc/sysdev/xics/icp-native.c | 9 ++++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

=20

arch/powerpc/kerne= renamed from arch/powerpc/kernel/cpu_setup_power.S +0 -0

l/cpu_setup_power.S

Quoted 12 lines
Quoted 12 lines

index 1557e7c..4673353 100644

arch/powerpc/kernel/cpu_setup_power.S +1 -0
@@ -56,6 +56,7 @@ _GLOBAL(__setup_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr	r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
@@ -74,6 +75,7 @@ _GLOBAL(__restore_cpu_power8)
Quoted 8 lines

arch/powerpc/platfo=

Quoted 8 lines
arch/powerpc/kernel/cpu_setup_power.S +1 -0
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr   r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
arch/powerpc/platfo= renamed from arch/powerpc/platforms/powernv/smp.c +0 -0

rms/powernv/smp.c

Quoted 15 lines
Quoted 15 lines

index 0062a43..5fcfcf4 100644

arch/powerpc/platforms/powernv/smp.c +1 -0
@@ -32,6 +32,7 @@
 #include <asm/opal.h>
 #include <asm/runlatch.h>
 #include <asm/code-patching.h>
+#include <asm/dbell.h>

=20
#include "powernv.h"
=20

arch/powerpc/platforms/powernv/smp.c +0 -0
@@ -46,6 +47,11 @@ static void pnv_smp_setup_cpu(int cpu)
 {
 	if (cpu !=3D boot_cpuid)
 		xics_setup_cpu();
Quoted 8 lines

arch/powerpc/platforms/powernv/smp.c static void pnv_smp_setup_cpu(int cpu) · line 55

Quoted 6 lines
arch/powerpc/platforms/powernv/smp.c +5 -0
+
+#ifdef CONFIG_PPC_DOORBELL
+	if (cpu_has_feature(CPU_FTR_DBELL))
+		doorbell_setup_this_cpu();
+#endif
 }

=20
Where does CONFIG_PPC_DOORBELL get set?

No where.

Quoted 1 line

It looks like the only place you can be getting it is from CONFIG_PPC_PSE=

RIES.

Quoted 1 line

If you build a POWERNV only kernel it will get disabled, which I don't th=

ink is

Quoted 3 lines

what we want.
=20
I think we should select it for POWERNV as well as PSERIES. That would me=

an

Quoted 1 line

it's always enabled for any build of the files you touch, so you shouldn'=

t need

Quoted 1 line

the #ifdefs.

Ok, I'll add and resend.

Mikey

#5 lore raw

PATCH v2 2/2 powerpc/powernv: Enable POWER8 doorbell IPIs

In reply to Michael Ellerman

This patch enables POWER8 doorbell IPIs on powernv.

Since doorbells can only IPI within a core, we test to see when we can use doorbells and if not we fall back to XICS. This also enables hypervisor doorbells to wakeup us up from nap/sleep via the LPCR PECEDH bit.

Based on tests by Anton, the best case IPI latency between two threads drop= ped
from 894ns to 512ns.

---
v2:
Adds select of PPC_DOORBELL for PSERIES and POWERNV as suggested by mpe.

arch/powerpc/kernel/cp= renamed from arch/powerpc/kernel/cpu_setup_power.S +0 -0

u_setup_power.S
index 1557e7c..4673353 100644

arch/powerpc/kernel/cpu_setup_power.S +2 -0
@@ -56,6 +56,7 @@ _GLOBAL(__setup_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr	r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
@@ -74,6 +75,7 @@ _GLOBAL(__restore_cpu_power8)
 	li	r0,0
 	mtspr	SPRN_LPID,r0
 	mfspr   r3,SPRN_LPCR
+	ori	r3, r3, LPCR_PECEDH
 	bl	__init_LPCR
 	bl	__init_HFSCR
 	bl	__init_tlb_power8
arch/powerpc/platform= renamed from arch/powerpc/platforms/powernv/Kconfig +0 -0

s/powernv/Kconfig
index c252ee9..45a8ed0 100644

arch/powerpc/platforms/powernv/Kconfig +1 -0
@@ -17,6 +17,7 @@ config PPC_POWERNV
 	select CPU_FREQ_GOV_USERSPACE
 	select CPU_FREQ_GOV_ONDEMAND
 	select CPU_FREQ_GOV_CONSERVATIVE
+	select PPC_DOORBELL
 	default y

=20
config PPC_POWERNV_RTAS

arch/powerpc/platforms/= renamed from arch/powerpc/platforms/powernv/smp.c +0 -0

powernv/smp.c
index 0062a43..5fcfcf4 100644

arch/powerpc/platforms/powernv/smp.c +1 -0
@@ -32,6 +32,7 @@
 #include <asm/opal.h>
 #include <asm/runlatch.h>
 #include <asm/code-patching.h>
+#include <asm/dbell.h>

=20
#include "powernv.h"
=20
@@ -46,6 +47,11 @@ static void pnv_smp_setup_cpu(int cpu)
{
if (cpu !=3D boot_cpuid)
xics_setup_cpu();
+
+#ifdef CONFIG_PPC_DOORBELL
+ if (cpu_has_feature(CPU_FTR_DBELL))
+ doorbell_setup_this_cpu();
+#endif
}
=20
int pnv_smp_kick_cpu(int nr)

arch/powerpc/platform= renamed from arch/powerpc/platforms/pseries/Kconfig +0 -0

s/pseries/Kconfig
index 2cb8b77..756b482 100644

arch/powerpc/platforms/pseries/Kconfig +1 -0
@@ -21,6 +21,7 @@ config PPC_PSERIES
 	select HAVE_CONTEXT_TRACKING
 	select HOTPLUG_CPU if SMP
 	select ARCH_RANDOM
+	select PPC_DOORBELL
 	default y

=20
config PPC_SPLPAR

arch/powerpc/sysdev/xi= renamed from arch/powerpc/sysdev/xics/icp-native.c +0 -0

cs/icp-native.c
index 9dee470..de8d948 100644

arch/powerpc/sysdev/xics/icp-native.c +1 -0
@@ -26,6 +26,7 @@
 #include <asm/errno.h>
 #include <asm/xics.h>
 #include <asm/kvm_ppc.h>
+#include <asm/dbell.h>

=20
struct icp_ipl {
union {
@@ -145,7 +146,13 @@ static unsigned int icp_native_get_irq(void)
static void icp_native_cause_ipi(int cpu, unsigned long data) {
kvmppc_set_host_ipi(cpu, 1);
- icp_native_set_qirr(cpu, IPI_PRIORITY);
+#ifdef CONFIG_PPC_DOORBELL
+ if (cpu_has_feature(CPU_FTR_DBELL) &&
+ (cpumask_test_cpu(cpu, cpu_sibling_mask(smp_processor_id()))))
+ doorbell_cause_ipi(cpu, data);
+ else
+#endif
+ icp_native_set_qirr(cpu, IPI_PRIORITY);
}
=20
void xics_wake_cpu(int cpu)

#6 lore raw
In reply to Michael Neuling
Quoted 17 lines · Michael Neuling

Currently when entering fastsleep we clear all LPCR PECE bits.

This patch changes it to only clear the decrementer bit (ie. PECE1), which is the only bit we really need to clear here. This is needed if we want to set other wakeup causes like the PECEDH bit so we can use hypervisor doorbells on powernv.

---
 drivers/cpuidle/cpuidle-powernv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpuidle/cpuidle-powernv.c +0 -0
index 719f6fb..7f7798e 100644

drivers/cpuidle/cpuidle-powernv.c static int fastsleep_loop(struct cpuidle_device *dev, · line 79

Quoted 8 lines
drivers/cpuidle/cpuidle-powernv.c +1 -1
@@ -73,7 +73,7 @@ static int fastsleep_loop(struct cpuidle_device *dev,
 		return index;
 
 	new_lpcr = old_lpcr;
-	new_lpcr &= ~(LPCR_MER | LPCR_PECE); /* lpcr[mer] must be 0 */
+	new_lpcr &= ~(LPCR_MER | LPCR_PECE1); /* lpcr[mer] must be 0 */
 
 	/* exit powersave upon external interrupt, but not decrementer
 	 * interrupt.

You might want to remove this comment and instead simply add /* Do not exit powersave upon decrementer interrupt */

Besides this, the following line which clears the wakeup from external interrupt bit can be removed as well, since we are not clearing it anyway ?

new_lpcr |= LPCR_PECE0
^^^

Regards
Preeti U Murthy

Quoted 1 line