From patchwork Wed May 7 01:41:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 4124831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B9BA99F1E1 for ; Wed, 7 May 2014 01:44:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C353B2024F for ; Wed, 7 May 2014 01:44:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA22020222 for ; Wed, 7 May 2014 01:44:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Whqs9-0006GJ-J5; Wed, 07 May 2014 01:42:13 +0000 Received: from mail-pd0-x22c.google.com ([2607:f8b0:400e:c02::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Whqs7-0006Fp-AB for linux-arm-kernel@lists.infradead.org; Wed, 07 May 2014 01:42:11 +0000 Received: by mail-pd0-f172.google.com with SMTP id g10so311780pdj.17 for ; Tue, 06 May 2014 18:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=GOboPWq0tK8fpwLpb9KCAMkE5BkxvoH9XR3igGiAl1M=; b=wSFdG3sctJy4nfHRF5oguja4cpT4VjpFjJ/Xgi3hGYiHcnlz6WzZNfHLulHVnXIbH2 JR6e02iJ4vJHMc4RrjFy/lMkL51GTJOVCPJLh8v3fGwJAK+XhyVI4yhg0H0tpJf25eIu oI6+qub2qQ6siJ1LHSfvj06FsOkptfpN6EgmiSYbkT7/QLWVI5Bw6uiPuQUgsmeURiiY 2XqfjkoQjiSt0mY8V8FB3J8I5rOY6qtj8G3oHguZjl/T81LXmWDkUG58r8LKgLkd3BiS I35qeI1haonvZO+XteBqW1xxrlrgwODoCPxvTd7M5avIuCQ7XllD/2Y968goDZvE4l0f mJow== X-Received: by 10.66.102.39 with SMTP id fl7mr12749748pab.43.1399426910055; Tue, 06 May 2014 18:41:50 -0700 (PDT) Received: from localhost ([122.179.39.122]) by mx.google.com with ESMTPSA id su8sm64273pbc.72.2014.05.06.18.41.46 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 06 May 2014 18:41:48 -0700 (PDT) From: arunks.linux@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v1 1/2] arm64: Fix machine_shutdown() definition Date: Wed, 7 May 2014 07:11:22 +0530 Message-Id: <1399426883-13779-1-git-send-email-arunks.linux@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140506_184211_390176_DE90A786 X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -0.1 (/) Cc: catalin.marinas@arm.com, Arun KS , swarren@nvidia.com, sboyd@codeaurora.org, Arun KS X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arun KS This patch ports most of commit 19ab428f4b79 "ARM: 7759/1: decouple CPU offlining from reboot/shutdown" by Stephen Warren from arch/arm to arch/arm64. machine_shutdown() is a hook for kexec. Add a comment saying so, since it isn't obvious from the function name. Halt, power-off, and restart have different requirements re: stopping secondary CPUs than kexec has. The former simply require the secondary CPUs to be quiesced somehow, whereas kexec requires them to be completely non-operational, so that no matter where the kexec target images are written in RAM, they won't influence operation of the secondary CPUS,which could happen if the CPUs were still executing some kind of pin loop. To this end, modify machine_halt, power_off, and restart to call smp_send_stop() directly, rather than calling machine_shutdown(). In machine_shutdown(), replace the call to smp_send_stop() with a call to disable_nonboot_cpus(). This completely disables all but one CPU, thus satisfying the kexec requirements a couple paragraphs above. Signed-off-by: Arun KS Acked-by: Stephen Warren --- arch/arm64/kernel/process.c | 41 +++++++++++++++++++++++++++++++++++------ 1 files changed, 35 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 6391485..2d43614 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -113,29 +113,58 @@ void arch_cpu_idle_dead(void) } #endif +/* + * Called by kexec, immediately prior to machine_kexec(). + * + * This must completely disable all secondary CPUs; simply causing those CPUs + * to execute e.g. a RAM-based pin loop is not sufficient. This allows the + * kexec'd kernel to use any and all RAM as it sees fit, without having to + * avoid any code or data used by any SW CPU pin loop. The CPU hotplug + * functionality embodied in disable_nonboot_cpus() to achieve this. + */ void machine_shutdown(void) { -#ifdef CONFIG_SMP - smp_send_stop(); -#endif + disable_nonboot_cpus(); } +/* + * Halting simply requires that the secondary CPUs stop performing any + * activity (executing tasks, handling interrupts). smp_send_stop() + * achieves this. + */ void machine_halt(void) { - machine_shutdown(); + smp_send_stop(); while (1); } +/* + * Power-off simply requires that the secondary CPUs stop performing any + * activity (executing tasks, handling interrupts). smp_send_stop() + * achieves this. When the system power is turned off, it will take all CPUs + * with it. + */ void machine_power_off(void) { - machine_shutdown(); + smp_send_stop(); if (pm_power_off) pm_power_off(); } +/* + * Restart requires that the secondary CPUs stop performing any activity + * while the primary CPU resets the system. Systems with a single CPU can + * use soft_restart() as their machine descriptor's .restart hook, since that + * will cause the only available CPU to reset. Systems with multiple CPUs must + * provide a HW restart implementation, to ensure that all CPUs reset at once. + * This is required so that any code running after reset on the primary CPU + * doesn't have to co-ordinate with other CPUs to ensure they aren't still + * executing pre-reset code, and using RAM that the primary CPU's code wishes + * to use. Implementing such co-ordination would be essentially impossible. + */ void machine_restart(char *cmd) { - machine_shutdown(); + smp_send_stop(); /* Disable interrupts first */ local_irq_disable();