From patchwork Thu Nov 15 18:17:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas KANDAGATLA X-Patchwork-Id: 1751341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 99F14DF2AB for ; Thu, 15 Nov 2012 18:21:08 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TZ420-0002NU-7l; Thu, 15 Nov 2012 18:19:16 +0000 Received: from eu1sys200aog117.obsmtp.com ([207.126.144.143]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1TZ41w-0002NC-Q8 for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2012 18:19:13 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob117.postini.com ([207.126.147.11]) with SMTP ID DSNKUKUyF69WqBdFswtCo3haqMPGSpCc9iBm@postini.com; Thu, 15 Nov 2012 18:19:12 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 04925CD; Thu, 15 Nov 2012 18:18:55 +0000 (GMT) Received: from mail7.sgp.st.com (mail7.sgp.st.com [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A3377462E; Thu, 15 Nov 2012 18:18:55 +0000 (GMT) Received: from localhost (king.bri.st.com [10.65.51.147]) by mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id ARM41016 (AUTH srinivak); Thu, 15 Nov 2012 19:18:55 +0100 From: Srinivas KANDAGATLA To: linux@arm.linux.org.uk, will.deacon@arm.com Subject: [RFC PATCH 3.7.0-rc4] ARM:smp: introduce smp_notify_cpu_stop to fix kexec smp case Date: Thu, 15 Nov 2012 18:17:58 +0000 Message-Id: <1353003478-22291-1-git-send-email-srinivas.kandagatla@st.com> X-Mailer: git-send-email 1.7.0.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121115_131913_099231_37566027 X-CRM114-Status: GOOD ( 23.04 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.126.144.143 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org, srinivas.kandagatla@st.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Srinivas Kandagatla Use-case is simple kexec on smp system. Lets say there are two cores core-0 and core-1. sequence here is: As part of kexec call, the secondary cores are stopped by calling machine_shutdown(), which in turn issues IPIs to off-line the other CPUs and then call smp_ops.cpu_kill. machine_shutdown invokes smp_send_stop from core-0 which then sends IPI_CPU_STOP ipi message for core-1 and then smp_kill_cpus call smp_ops.cpu_kill from core-0 with cpu=1. The expectation here is that cpu_kill will relocate secondary-core to safe location from primary-core(core-0). This is a catch 22 situation for SOCs, which can't change PC's of other cores. At the point when cpu_kill is invoked, it cant execute any function calls for core-1, as it is off-line and is spinning in cpu_relax. So the only way is to put the core into safe place by executing some SOC specific relocation code. Having a callback from ipi handler when cpu is stopped would be very usefull for SOC's which want to relocate the secondary-core to safe location. Signed-off-by: Srinivas Kandagatla --- Hi All, I just tried kexec on an CA9 dual core board, and it looks like it is broken on smp system. It looks like its a very basic issue, Am not not sure if I missed something here? It is almost impossible to get kexec working, For cases where SOC's can't change PC of secondary-core from a primary-core. As cpu_kill is the only callback which is invoked from primary core to stop an secondary-core during machine_shutdown it to relocate the secondary-core to safe place, as it is offine and it is spinning in cpu_relax. Having a callback from ipi handler when cpu is stopped would be very usefull for SOC's which want to relocate the secondary-core to safe location. Thanks, srini arch/arm/include/asm/smp.h | 7 +++++++ arch/arm/kernel/smp.c | 3 +++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h index 2e3be16..0071a54 100644 --- a/arch/arm/include/asm/smp.h +++ b/arch/arm/include/asm/smp.h @@ -100,6 +100,13 @@ struct smp_operations { * This also gives us the initial stack to use for this CPU. */ int (*smp_boot_secondary)(unsigned int cpu, struct task_struct *idle); + + /* Notify interested parties before parking core in cpu_relax. + * SOC's can park cores in safe place in this callback, is very useful + * for cases like kexec. Stopping cpu is the victim cpu in this case. + */ + int (*smp_notify_cpu_stop)(unsigned int cpu); + #ifdef CONFIG_HOTPLUG_CPU int (*cpu_kill)(unsigned int cpu); void (*cpu_die)(unsigned int cpu); diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index fbc8b26..06fcef9 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -564,6 +564,9 @@ static void ipi_cpu_stop(unsigned int cpu) local_fiq_disable(); local_irq_disable(); + if (smp_ops.smp_notify_cpu_stop) + smp_ops.smp_notify_cpu_stop(cpu); + while (1) cpu_relax(); }