linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 11/18] powerpc/pmac/smp: Properly NAP offlined CPU on G5
Date: Tue,  8 Mar 2011 17:37:23 +1100	[thread overview]
Message-ID: <1299566250-10516-12-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1299566250-10516-1-git-send-email-benh@kernel.crashing.org>

The current code soft-disables, and then goes to NAP mode which
turns interrupts on. That means that if an interrupt occurs, we
will hit the masked interrupt code path which isn't what we want,
as it will return with EE off, which will either get us out of
NAP mode, or fail to enter it (according to spec).

Instead, let's just rely on the fact that it is safe to take
decrementer interrupts on an offline CPU and leave interrupts
enabled. We can also get rid of the special case in asm for
power4_cpu_offline_powersave() and just use power4_idle().

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/include/asm/machdep.h    |    1 -
 arch/powerpc/kernel/head_64.S         |    7 +++++++
 arch/powerpc/kernel/idle_power4.S     |   21 ---------------------
 arch/powerpc/platforms/powermac/smp.c |   14 ++++++++------
 4 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index bcfc0da..578d330 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -266,7 +266,6 @@ struct machdep_calls {
 
 extern void e500_idle(void);
 extern void power4_idle(void);
-extern void power4_cpu_offline_powersave(void);
 extern void ppc6xx_idle(void);
 extern void book3e_idle(void);
 
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 782f23d..271140b 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -536,6 +536,13 @@ _GLOBAL(pmac_secondary_start)
 	add	r13,r13,r4		/* for this processor.		*/
 	mtspr	SPRN_SPRG_PACA,r13	/* Save vaddr of paca in an SPRG*/
 
+	/* Mark interrupts soft and hard disabled (they might be enabled
+	 * in the PACA when doing hotplug)
+	 */
+	li	r0,0
+	stb	r0,PACASOFTIRQEN(r13)
+	stb	r0,PACAHARDIRQEN(r13)
+
 	/* Create a temp kernel stack for use before relocation is on.	*/
 	ld	r1,PACAEMERGSP(r13)
 	subi	r1,r1,STACK_FRAME_OVERHEAD
diff --git a/arch/powerpc/kernel/idle_power4.S b/arch/powerpc/kernel/idle_power4.S
index 5328709..ba31954 100644
--- a/arch/powerpc/kernel/idle_power4.S
+++ b/arch/powerpc/kernel/idle_power4.S
@@ -53,24 +53,3 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 	isync
 	b	1b
 
-_GLOBAL(power4_cpu_offline_powersave)
-	/* Go to NAP now */
-	mfmsr	r7
-	rldicl	r0,r7,48,1
-	rotldi	r0,r0,16
-	mtmsrd	r0,1			/* hard-disable interrupts */
-	li	r0,1
-	li	r6,0
-	stb	r0,PACAHARDIRQEN(r13)	/* we'll hard-enable shortly */
-	stb	r6,PACASOFTIRQEN(r13)	/* soft-disable irqs */
-BEGIN_FTR_SECTION
-	DSSALL
-	sync
-END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
-	ori	r7,r7,MSR_EE
-	oris	r7,r7,MSR_POW@h
-	sync
-	isync
-	mtmsrd	r7
-	isync
-	blr
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 53bee66..837989e 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -916,18 +916,20 @@ static void pmac_cpu_die(void)
 	preempt_enable();
 
 	/*
-	 * hard-disable interrupts for the non-NAP case, the NAP code
-	 * needs to re-enable interrupts (but soft-disables them)
+	 * Re-enable interrupts. The NAP code needs to enable them
+	 * anyways, do it now so we deal with the case where one already
+	 * happened while soft-disabled.
+	 * We shouldn't get any external interrupts, only decrementer, and the
+	 * decrementer handler is safe for use on offline CPUs
 	 */
-	hard_irq_disable();
+	local_irq_enable();
 
 	while (1) {
 		/* let's not take timer interrupts too often ... */
 		set_dec(0x7fffffff);
 
-		/* should always be true at this point */
-		if (cpu_has_feature(CPU_FTR_CAN_NAP))
-			power4_cpu_offline_powersave();
+		/* Enter NAP mode */
+		power4_idle();
 	}
 }
 
-- 
1.7.1

  parent reply	other threads:[~2011-03-08  6:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08  6:37 [PATCHES] powerpc: Cleanup and fix CPU hotplug Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 01/18] powerpc: Make decrementer interrupt robust against offlined CPUs Benjamin Herrenschmidt
2011-03-10  8:01   ` Michael Ellerman
2011-03-08  6:37 ` [PATCH 02/18] powerpc/smp: soft-replugged CPUs must go back to start_secondary Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 03/18] powerpc/smp: Fix generic_mach_cpu_die() Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 04/18] powerpc/smp: Remove unused generic_cpu_enable() Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 05/18] powerpc/smp: Remove unused smp_ops->cpu_enable() Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 06/18] powerpc/pmac/smp: Fix 32-bit PowerMac cpu_die Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 07/18] powerpc/pmac/smp: Rename fixup_irqs() to migrate_irqs() and use it on ppc32 Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 08/18] powerpc/pmac/smp: Fixup smp_core99_cpu_disable() and use it on 64-bit Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 09/18] powerpc/pmac/smp: Consolidate 32-bit and 64-bit PowerMac cpu_die in one file Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 10/18] powerpc/pmac/smp: Remove HMT changes for PowerMac offline code Benjamin Herrenschmidt
2011-03-08  6:37 ` Benjamin Herrenschmidt [this message]
2011-03-08  6:37 ` [PATCH 12/18] powerpc/pmac: Rename cpu_state in therm_pm72 to avoid collision Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 13/18] powerpc/smp: Add a smp_ops->bringup_up() done callback Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 14/18] powerpc/pmac/smp: Fix CPU hotplug crashes on some machines Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 15/18] powerpc/smp: Don't expose per-cpu "cpu_state" array Benjamin Herrenschmidt
2011-03-29  5:37   ` Michael Ellerman
2011-03-29  8:13     ` Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 16/18] powerpc/smp: Create idle threads on demand and properly reset them Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 17/18] powerpc/smp: Increase vdso_data->processorCount, not just decrease it Benjamin Herrenschmidt
2011-03-10  3:41   ` Michael Ellerman
2011-03-10  3:46     ` Benjamin Herrenschmidt
2011-03-08  6:37 ` [PATCH 18/18] powerpc/pmac/smp: Remove no-longer needed preempt workaround Benjamin Herrenschmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299566250-10516-12-git-send-email-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).