From patchwork Fri May 12 16:55:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9724653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37C4A60382 for ; Fri, 12 May 2017 16:55:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31BF328844 for ; Fri, 12 May 2017 16:55:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 267B12885E; Fri, 12 May 2017 16:55:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 727332885A for ; Fri, 12 May 2017 16:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758222AbdELQzd (ORCPT ); Fri, 12 May 2017 12:55:33 -0400 Received: from mout.gmx.net ([212.227.17.20]:60824 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755920AbdELQz2 (ORCPT ); Fri, 12 May 2017 12:55:28 -0400 Received: from ls3530.fritz.box ([193.159.23.168]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MCfcc-1dIXVG1kpO-009Oxl; Fri, 12 May 2017 18:55:16 +0200 Date: Fri, 12 May 2017 18:55:13 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Stop CPUs via PAT firmware before system halt or reboot. Message-ID: <20170512165513.GA23551@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.0 (2017-02-23) X-Provags-ID: V03:K0:W1mI+MgX9XXprv8wHshQxc1DBDtoeFTkayX+oRZ9EZitjN17bBr wVYAH/Nrxebia//Sj6epzTA4THREoGMwK8dxNEvqZUSypsJvpL2TG9gX3OjFYEhqi/n9I8S FVgkv0Q9AP4uO5nI9m2p1SvSAUDtFL9GUsPTPMMpSmsKpPWdtKzdUTrzpM62IgTFb7uM9U4 AgTEs97MEkiVFhO581qvA== X-UI-Out-Filterresults: notjunk:1; V01:K0:k0Zk4x/bClE=:9m6M7D/34KO/cdOJSA1rD3 COJ53HL0uBXh9EK2OzQY5Dqs++XVzfpO7SoONk8tLxnrGewGSwU7BiIciwp1t+x/ErtVAy8s5 dKJWydPlFNyu2SuOd4URlY4ZZRmtGQygz9j+SYW00bpXfy1SjJ3aTaoXFisFd57celqYaeSFo ltqlRmXIR09+Qe+a/f2Wte8zi62sZVCRKq+o4B7AbWD5ITAumHFdA3UgpI1cQRmhxvqN4eFGN QpqKC4YbM8gOgoMl4XqzxsAykw0iAXyRCqFJaTP27f4HOfjc113fOgyQFxK2rLQR/rNOmBPrq 6eaWqWvjxEjo+RtcPN5ycUfZM2QDmM3TdtD0PDZmU4HbaNZ+VrcNxjFwe26nkl9otWxXl/6pr lcgC+uq5y+wrtZSnOwDV+z0rBh5cyA1VGifHuP8tQTTIOVf7AypOCnzwdQptgljWGQKtPYRXT NehAh3QUrgqVqhJOqEuzmBWNW+u77DPx+gtk5BmNMRyAzl9LPPbZ8Z2Cvuldy0aauhIlhWQp7 ez1N4np5YJAE/JvkpRO5WK6Wmasia4c4I/FmFerTEJ+6BEGki/CRsEk8HztHeHI2PqmDLjCkJ infgDAERXR7reanjTSU5sQn3iaR1Z2STI0hnsoH+F27aHnLHDmg0F4+u+b24XWPbcKvipQt3m Oc4Oe9RswXu/YTPJYg/xoz6rRGwGKFX37UMHLA+8oY5X/GdVBnIDGvKam4BlokAww1ViBRKqq siwOquOlY9qThhpuSVrYnF9Yks7M7l+9s86VawNI6gGZ4MwQhLzwiZx/ASU= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dave reported that he had issued a "shutdown -r" and a panic occurred during the reboot while all CPUs were still up. After this, stall messages were output to console after the firmware version was printed. To avoid that issue, add functions to call PAT firmware to stop all CPUs (with the exception of the currently running CPU) before a panic reboot or a system halt is issued. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/include/asm/pdcpat.h b/arch/parisc/include/asm/pdcpat.h index 32e105f..0ef789e 100644 --- a/arch/parisc/include/asm/pdcpat.h +++ b/arch/parisc/include/asm/pdcpat.h @@ -307,6 +307,7 @@ extern int pdc_pat_cell_module(unsigned long *actcnt, unsigned long ploc, unsign extern int pdc_pat_cell_num_to_loc(void *, unsigned long); extern int pdc_pat_cpu_get_number(struct pdc_pat_cpu_num *cpu_info, unsigned long hpa); +extern int pdc_pat_cpu_stop_cpu(unsigned long hpa, unsigned long hpa_vec); extern int pdc_pat_pd_get_addr_map(unsigned long *actual_len, void *mem_addr, unsigned long count, unsigned long offset); diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c index 9819025..3f55db6 100644 --- a/arch/parisc/kernel/firmware.c +++ b/arch/parisc/kernel/firmware.c @@ -1308,6 +1308,31 @@ int pdc_pat_cpu_get_number(struct pdc_pat_cpu_num *cpu_info, unsigned long hpa) } /** + * pdc_pat_cpu_stop_cpu - Stop current cpu. + * @hpa: The Hard Physical Address of the CPU which should be informed when + * current cpu has stopped. + * @hpa_vec: Mask of interrupts which should be signalled on CPU at @hpa. + * + * Stop the CPU in which the call is made. Flushes caches and purges TLB and + * places CPU in a firmware loop. If the CPU is the last in a cell, an + * interrupt message is sent to the CPU at @hpa. + */ +int pdc_pat_cpu_stop_cpu(unsigned long hpa, unsigned long hpa_vec) +{ + int retval; + unsigned long flags; + + if (!hpa) + hpa_vec = -1UL; + spin_lock_irqsave(&pdc_lock, flags); + retval = mem_pdc_call(PDC_PAT_CPU, PDC_PAT_CPU_STOP, hpa, hpa_vec); + spin_unlock_irqrestore(&pdc_lock, flags); + + return retval; +} + + +/** * pdc_pat_get_irt_size - Retrieve the number of entries in the cell's interrupt table. * @num_entries: The return value. * @cell_num: The target cell. diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 4516a5b..1615a9a 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -98,6 +98,9 @@ void machine_restart(char *cmd) #endif /* set up a new led state on systems shipped with a LED State panel */ pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN); + + /* stops all CPUs but the current one */ + smp_send_stop(); /* "Normal" system reset */ pdc_do_reset(); @@ -116,6 +119,9 @@ void machine_halt(void) ** The LED/ChassisCodes are updated by the led_halt() ** function, called by the reboot notifier chain. */ + + /* stops all CPUs but the current one */ + smp_send_stop(); } void (*chassis_power_off)(void); @@ -126,6 +132,9 @@ void (*chassis_power_off)(void); */ void machine_power_off(void) { + /* stops all CPUs but the current one */ + smp_send_stop(); + /* If there is a registered power off handler, call it. */ if (chassis_power_off) chassis_power_off(); diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 6336510..afd9142 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -42,6 +42,7 @@ #include /* for CPU_IRQ_REGION and friends */ #include #include +#include #include #include #include @@ -112,6 +113,9 @@ halt_processor(void) /* REVISIT : does PM *know* this CPU isn't available? */ set_cpu_online(smp_processor_id(), false); local_irq_disable(); +#ifdef CONFIG_64BIT + pdc_pat_cpu_stop_cpu(0, -1UL); +#endif for (;;) ; }