linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: Tiejun Chen <tiejun.chen@intel.com>, <kexec@lists.infradead.org>,
	"Scott Wood" <scottwood@freescale.com>
Subject: [RFC PATCH 14/17] powerpc/book3e-64/kexec: Enable SMP release
Date: Sat, 18 Jul 2015 15:08:51 -0500	[thread overview]
Message-ID: <1437250134-307-15-git-send-email-scottwood@freescale.com> (raw)
In-Reply-To: <1437250134-307-1-git-send-email-scottwood@freescale.com>

booted_from_exec is similar to __run_at_load, except that it is set for
regular kexec as well as kdump.

The flag is needed because the SMP release mechanism for FSL book3e is
different from when booting with normal hardware.  In theory we could
simulate the normal spin table mechanism, but not at the addresses
U-Boot put in the device tree -- so there'd need to be even more
communication between the kernel and kexec to set that up.  Since
there's already a similar flag being set (for kdump only), this seemed
like a reasonable approach.

Unlike __run_at_kexec in http://patchwork.ozlabs.org/patch/257657/
("book3e/kexec/kdump: introduce a kexec kernel flag"), this flag is at
a fixed address for ABI stability, and actually gets set properly in
the kdump case (i.e. on the crash kernel, not on the crashing kernel).

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
This depends on the kexec-tools patch "ppc64: Add a flag to tell the
kernel it's booting from kexec":
http://lists.infradead.org/pipermail/kexec/2015-July/014048.html
---
 arch/powerpc/include/asm/smp.h    |  1 +
 arch/powerpc/kernel/head_64.S     | 15 +++++++++++++++
 arch/powerpc/kernel/setup_64.c    | 14 +++++++++++++-
 arch/powerpc/platforms/85xx/smp.c | 16 ++++++++++++----
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 825663c..f9245df 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -197,6 +197,7 @@ extern void generic_secondary_thread_init(void);
 extern unsigned long __secondary_hold_spinloop;
 extern unsigned long __secondary_hold_acknowledge;
 extern char __secondary_hold;
+extern u32 booted_from_kexec;
 
 extern void __early_start(void);
 #endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 1b77956..ae2d6b5 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -91,6 +91,21 @@ __secondary_hold_spinloop:
 __secondary_hold_acknowledge:
 	.llong	0x0
 
+	/* Do not move this variable as kexec-tools knows about it. */
+	. = 0x58
+	.globl	booted_from_kexec
+booted_from_kexec:
+	/*
+	 * "nkxc" -- not (necessarily) from kexec by default
+	 *
+	 * This flag is set to 1 by a loader if the kernel is being
+	 * booted by kexec.  Older kexec-tools don't know about this
+	 * flag, so platforms other than fsl-book3e should treat a value
+	 * of "nkxc" as inconclusive.  fsl-book3e relies on this to
+	 * know how to release secondary cpus.
+	 */
+	.long	0x6e6b7863
+
 #ifdef CONFIG_RELOCATABLE
 	/* This flag is set to 1 by a loader if the kernel should run
 	 * at the loaded address instead of the linked address.  This
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 505ec2c..baeddcc 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -340,11 +340,23 @@ void early_setup_secondary(void)
 #endif /* CONFIG_SMP */
 
 #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
+static bool use_spinloop(void)
+{
+#ifdef CONFIG_PPC_FSL_BOOK3E
+	return booted_from_kexec == 1;
+#else
+	return true;
+#endif
+}
+
 void smp_release_cpus(void)
 {
 	unsigned long *ptr;
 	int i;
 
+	if (!use_spinloop())
+		return;
+
 	DBG(" -> smp_release_cpus()\n");
 
 	/* All secondary cpus are spinning on a common spinloop, release them
@@ -524,7 +536,7 @@ void __init setup_system(void)
 	 * Freescale Book3e parts spin in a loop provided by firmware,
 	 * so smp_release_cpus() does nothing for them
 	 */
-#if defined(CONFIG_SMP) && !defined(CONFIG_PPC_FSL_BOOK3E)
+#if defined(CONFIG_SMP)
 	/* Release secondary cpus out of their spinloops at 0x60 now that
 	 * we can map physical -> logical CPU ids
 	 */
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 5152289..4abda43 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -20,6 +20,7 @@
 #include <linux/highmem.h>
 #include <linux/cpu.h>
 
+#include <asm/kexec.h>
 #include <asm/machdep.h>
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -203,6 +204,7 @@ static int smp_85xx_kick_cpu(int nr)
 	int hw_cpu = get_hard_smp_processor_id(nr);
 	int ioremappable;
 	int ret = 0;
+	bool have_spin_table = true;
 
 	WARN_ON(nr < 0 || nr >= NR_CPUS);
 	WARN_ON(hw_cpu < 0 || hw_cpu >= NR_CPUS);
@@ -210,6 +212,9 @@ static int smp_85xx_kick_cpu(int nr)
 	pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr);
 
 #ifdef CONFIG_PPC64
+	if (booted_from_kexec == 1 && system_state != SYSTEM_RUNNING)
+		have_spin_table = false;
+
 	/* Threads don't use the spin table */
 	if (cpu_thread_in_core(nr) != 0) {
 		int primary = cpu_first_thread_sibling(nr);
@@ -305,10 +310,13 @@ static int smp_85xx_kick_cpu(int nr)
 		__secondary_hold_acknowledge = -1;
 	}
 #endif
-	flush_spin_table(spin_table);
-	out_be32(&spin_table->pir, hw_cpu);
-	out_be32(&spin_table->addr_l, __pa(__early_start));
-	flush_spin_table(spin_table);
+
+	if (have_spin_table) {
+		flush_spin_table(spin_table);
+		out_be32(&spin_table->pir, hw_cpu);
+		out_be32(&spin_table->addr_l, __pa(__early_start));
+		flush_spin_table(spin_table);
+	}
 
 	/* Wait a bit for the CPU to ack. */
 	if (!spin_event_timeout(__secondary_hold_acknowledge == hw_cpu,
-- 
2.1.4

  parent reply	other threads:[~2015-07-18 20:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-18 20:08 [RFC PATCH 00/17] powerpc/fsl-book3e-64: kexec/kdump support Scott Wood
2015-07-18 20:08 ` [RFC PATCH 01/17] powerpc/85xx: Load all early TLB entries at once Scott Wood
2015-07-18 20:08 ` [RFC PATCH 02/17] powerpc/85xx: Don't use generic timebase sync on 64-bit Scott Wood
2015-07-18 20:08 ` [RFC PATCH 03/17] crypto: caam: Blacklist CAAM when kexec is enabled Scott Wood
2015-07-18 20:08 ` [RFC PATCH 04/17] powerpc/fsl-corenet: Disable coreint if " Scott Wood
2015-07-18 20:08 ` [RFC PATCH 05/17] powerpc/fsl-booke-64: Don't limit ppc64_rma_size to one TLB entry Scott Wood
2015-07-18 20:08 ` [RFC PATCH 06/17] powerpc/85xx: Implement 64-bit kexec support Scott Wood
2015-07-18 20:08 ` [RFC PATCH 07/17] powerpc/e6500: kexec: Handle hardware threads Scott Wood
2015-07-18 20:08 ` [RFC PATCH 08/17] powerpc/book3e-64: rename interrupt_end_book3e with __end_interrupts Scott Wood
2015-07-18 20:08 ` [RFC PATCH 09/17] powerpc/booke64: Fix args to copy_and_flush Scott Wood
2015-07-18 20:08 ` [RFC PATCH 10/17] powerpc/book3e: support CONFIG_RELOCATABLE Scott Wood
2015-07-18 20:08 ` [RFC PATCH 11/17] powerpc/book3e/kdump: Enable crash_kexec_wait_realmode Scott Wood
2015-07-18 20:08 ` [RFC PATCH 12/17] powerpc/book3e-64: Don't limit paca to 256 MiB Scott Wood
2015-07-18 20:08 ` [RFC PATCH 13/17] powerpc/book3e-64/kexec: create an identity TLB mapping Scott Wood
2015-07-18 20:08 ` Scott Wood [this message]
2015-08-18  4:51   ` [RFC,14/17] powerpc/book3e-64/kexec: Enable SMP release Michael Ellerman
2015-08-18  5:09     ` Scott Wood
2015-08-20  4:54   ` [RFC PATCH 14/17] " Michael Ellerman
2015-08-24 20:25     ` Scott Wood
2015-08-25  1:57       ` Michael Ellerman
2015-08-25 23:40         ` Scott Wood
2015-08-26  1:13           ` Michael Ellerman
2015-07-18 20:08 ` [RFC PATCH 15/17] powerpc/booke: Only use VIRT_PHYS_OFFSET on booke32 Scott Wood
2015-07-18 20:08 ` [RFC PATCH 16/17] powerpc/book3e-64/kexec: Set "r4 = 0" when entering spinloop Scott Wood
2015-07-18 20:08 ` [RFC PATCH 17/17] powerpc/book3e-64: Enable kexec Scott Wood

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=1437250134-307-15-git-send-email-scottwood@freescale.com \
    --to=scottwood@freescale.com \
    --cc=kexec@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=tiejun.chen@intel.com \
    /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).