From patchwork Tue May 6 15:55:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 4122791 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35EACBFF02 for ; Tue, 6 May 2014 15:58:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BF472022A for ; Tue, 6 May 2014 15:58:35 +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 3823F2012B for ; Tue, 6 May 2014 15:58:34 +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 1Whhj1-0003ax-SB; Tue, 06 May 2014 15:56:11 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Whhiy-0003Pi-5N for linux-arm-kernel@lists.infradead.org; Tue, 06 May 2014 15:56:09 +0000 Received: by mail-pa0-f42.google.com with SMTP id rd3so672960pab.1 for ; Tue, 06 May 2014 08:55:43 -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=bY8vnRGvIncYYKxjerSdU1Qj4ziVGW4cKK1E1QwApZs=; b=urOq46VtlTgJdeiZDiKE2XAI0gasxnUwYnDm68r5dG4h+H7MT/kEr8Q3I0xPfwAdIm aa7D8ifPmVtND2f/5a14q8Fit7C5AEkrQ8FsGLWCDPA0p3Qj48IByYV2ahjH4QCM7Aaf FkTiBkNPs6rmoSuzKVljE4bxRK8ygj50BH46YH0JBdEqqQxhPgYpx3RnGJOLiGZQJx34 tCYrWP4SwQQxjSEJxlrXYibIgTLZOxqtW+BFmRTyhFxLvr/OR57kHU4vY7LoivboSDm+ 30t5MxvAJnKQ5EBLZsRjXU/VqRZeqXm2tdBomx+KS70MhXJml/OT5xxP4fFTJn74PLB/ grAw== X-Received: by 10.66.141.109 with SMTP id rn13mr7817193pab.117.1399391743696; Tue, 06 May 2014 08:55:43 -0700 (PDT) Received: from localhost ([122.179.57.79]) by mx.google.com with ESMTPSA id xz7sm98884839pac.3.2014.05.06.08.55.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 06 May 2014 08:55:43 -0700 (PDT) From: arunks.linux@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: arm64: Fix machine_shutdown() definition Date: Tue, 6 May 2014 21:25:07 +0530 Message-Id: <1399391708-13442-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_085608_584319_1645CA16 X-CRM114-Status: GOOD ( 17.38 ) X-Spam-Score: -0.8 (/) Cc: catalin.marinas@arm.com, Arun KS , Arun KS , Stephen Warren , 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=unavailable 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 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: Stephen Warren Signed-off-by: Arun KS Signed-off-by: Arun KS --- 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();