From patchwork Sat Jul 18 20:08:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 497417 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4AD6A1409BB for ; Sun, 19 Jul 2015 06:27:20 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 311E51A33C1 for ; Sun, 19 Jul 2015 06:27:20 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0130.outbound.protection.outlook.com [157.56.110.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 1D5811A1998 for ; Sun, 19 Jul 2015 06:09:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=none (message not signed) header.d=none; Received: from snotra.am.freescale.net (192.88.168.49) by CY1PR03MB1486.namprd03.prod.outlook.com (10.163.17.16) with Microsoft SMTP Server (TLS) id 15.1.213.14; Sat, 18 Jul 2015 20:09:31 +0000 From: Scott Wood To: Subject: [RFC PATCH 14/17] powerpc/book3e-64/kexec: Enable SMP release Date: Sat, 18 Jul 2015 15:08:51 -0500 Message-ID: <1437250134-307-15-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437250134-307-1-git-send-email-scottwood@freescale.com> References: <1437250134-307-1-git-send-email-scottwood@freescale.com> MIME-Version: 1.0 X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BY2PR21CA0002.namprd21.prod.outlook.com (25.162.74.140) To CY1PR03MB1486.namprd03.prod.outlook.com (25.163.17.16) X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1486; 2:smQUamc8W72rQ0yU6x4fBJaTCe5ylPURcNxQCDGrj3cr4SP3O6L3cXDC5XOa62m3; 3:eSQqGOOJ/VyHNr7bbt1+IL/YK+GTUTR3u8Ml6/M67KWR6+qzHkxIpidlHkCJ8k4JC39Y78rWhuEA/ArhAd+83ycKrX8kJM8YkSuobsAVG6ffUIiJggqB83WofeRDLyk/yptl7CpjQI5Z2vnw7dJwRA==; 25:etYwNRk5OSAvd0pHQWgGvKgrdRwp/IZ704t2n5xfgaYD64ComXuKfQp6Js/wL2fpSHFEsjP98cqXpprTnmVs3a0MoIcrjKCNib5ILZgO41SBPH9EjKKcz2klAXHjOsnOSnMlxBy+9AClCDIVltgptinmnJ73xxdrUaTfSTFZLXfzj/T3XR666Li7vsKaSzIXVhRKi39D+3nIaa8+L3PD6d0cNm3yIcpBSHY+2y2A9l+09sAaJvWWIXIBXpb85cw3CYRpkxcnG0qNR4EY1dcdYw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1486; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1486; 20:nIHIm4uo8pwIfJEwj+Prb+FPWba+H3q3Y3do7rWpBVFQND2oRiNMVP3wDz5Vcg5CnvVtXMVBXx9Gu4YgsEW+rIbMbcDXqtBnGZVX5fnX8onZ7m9LPLuMh1rLAk4p5mNUVJQZBLqcgBWzpPDggfVnaR8t/+3miyiAUDI8GUjXeN4WR5JlEOgHCMQIjmPqbMXVlLqB1OwPjVlO7mTpvQA/WQkmz66AVV+WGaLaHBPtmyWVzDhcSC8mgXbt6wmIJXd/xQOvEdGbzankbupCBsiwNuPf8HWpftoTb4mXpGFQ25qQmHuTADLWlYAjEaaVuHB+pibWnncOJmJ/BZT21l7c0ycnnkUn1RnR66aedR9lGefVJ69NF6iAUDJ7iXDOOZmDNBDgOf8EHWgZ0B6GkJTkk7xhT6+dJoCKSQ3iKImF5p3uzJoCz8UgNrHCMmvYtHAV+CTiuJ9vvL9mbUaq9TLauIdt6cenmFfRHscqmKZisxIEH9CB540krmrokK95CALb; 4:aMYh6ulKdHHi3UAwSQVWIkI4c7pkHe9WofvYM/U5LJcinGJdHjzL4RxotJaH3Yz1qD+/jLLCCak4SXqW5IWW6gI0KITQH/3hN6byGgwnhBgRbpu43FeewVo/a26u8XsHn+7qXKyObxdLbFARd5WzfhGZaxwRTB41/3JdFsgK6bJer5K7o84VwkzN+gegun13+9weEIXJgERXhoIw3BUsHZpXcoQ9vM6PiL8q9/wqgSAkzL+n/Y+7zm648xTe1PDX2Hh1LUmDjkj7vSvQRJQ1uBQ/U/DgWa2WDp66bNBLP2g= CY1PR03MB1486: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:CY1PR03MB1486; BCL:0; PCL:0; RULEID:; SRVR:CY1PR03MB1486; X-Forefront-PRVS: 0641678E68 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(19580395003)(50466002)(15975445007)(19580405001)(229853001)(36756003)(46102003)(2351001)(42186005)(40100003)(87976001)(122386002)(33646002)(86362001)(62966003)(5001960100002)(5001920100001)(92566002)(2950100001)(110136002)(77096005)(107886002)(48376002)(77156002)(50986999)(76176999)(66066001)(47776003)(50226001)(5003940100001)(189998001)(217873001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR03MB1486; H:snotra.am.freescale.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1486; 23:MuI/hiVlGVvmMZCdPXFnjlxf6vFV6BeetFIg6484hoMYPmJRZt3rfqiD9qkNidY3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wctJajU1C26A==; 24:0kNLFLQADIe5PgTSjS0dexW0RGasRW2pJYyoyXPzyNi/GR7cUCjOCHr236H6QIItQWMcOTv6HBwAY8cQ/YGm9fh9iY9vkoxSNuq5QgfaryA=; 20:+zSNAo3hqMxrdXMIjSRN0xJWhb+9/Aht1hUxODd0ZBAT0hwPV/Gtt2sX7CJLNk560WP9Q23ztDT/ZfG0EWzmYQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2015 20:09:31.5867 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1486 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Scott Wood , Tiejun Chen , kexec@lists.infradead.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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 #include +#include #include #include #include @@ -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,