From patchwork Wed Feb 6 07:07:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10798863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75DAC1390 for ; Wed, 6 Feb 2019 07:07:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61EE92B396 for ; Wed, 6 Feb 2019 07:07:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55BA42B914; Wed, 6 Feb 2019 07:07:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 E64FA2B396 for ; Wed, 6 Feb 2019 07:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725897AbfBFHHu (ORCPT ); Wed, 6 Feb 2019 02:07:50 -0500 Received: from tomli.me ([153.92.126.73]:49936 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbfBFHHu (ORCPT ); Wed, 6 Feb 2019 02:07:50 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 3060678a; Wed, 6 Feb 2019 07:07:47 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b75:4650) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Wed, 06 Feb 2019 07:07:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:mime-version:content-transfer-encoding; s=1490979754; bh=TXmS04p0/Vjvf2HiVvC4vH1nuwaTteSpJPhSTTK+8OY=; b=FcceSwUbGiM6vg+yxFZkVBAKHRbf3y8nPiXFmt8mLOoBTAatoC3ihfaHsShhzkSv/NwFAAoX0jLLcZdQHd+w8jcNAMh5uy2BB37b7KvqL5lqT2VaWE0+1YhjPQkaojf/eodtergLFWlEOAd+LWmjRaX0W2mxSfP2NN1DHm21mP3zmf59RAlUFV3iCkOBMeLcg9fxIJh1NxPptfqwQ15jNj4neCBNtwc3WQnXIpaJfdEn2DDjdSP/EdUBacekCpYCuajjAi97T7qi7s6d3ujD8fK0xKDdh+erOSDqnx0RMeYY4icl9ySRAFmZUKjDF5nWRLR4ksPD2L+MgqXeQihb1Q== From: Yifeng Li To: linux-mips@vger.kernel.org Cc: Huacai Chen , Ralf Baechle , Paul Burton , James Hogan , Yifeng Li , linux-kernel@vger.kernel.org, Aaro Koskinen Subject: [PATCH] mips: loongson64: remove unreachable(), fix loongson_poweroff(). Date: Wed, 6 Feb 2019 15:07:21 +0800 Message-Id: <20190206070721.19185-1-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On my Yeeloong 8089, I noticed the machine fails to shutdown properly, and often, the function mach_prepare_reboot() is unexpectedly executed, thus the machine reboots instead. A wait loop is needed to ensure the system is in a well-defined state before going down. In commit 997e93d4df16 ("MIPS: Hang more efficiently on halt/powerdown/restart"), a general superset of the wait loop for all platforms is already provided, so we don't need to implement our own. This commit simply removes the unreachable() compiler marco after mach_prepare_reboot(), thus allowing the execution of machine_hang(). My test shows that the machine is now able to shutdown successfully. Please note that there are two different bugs preventing the machine from shutting down, another work-in-progress commit is needed to fix a lockup in cpufreq / i8259 driver, please read Reference, this commit does not fix that bug. Reference: https://lkml.org/lkml/2019/2/5/908 Signed-off-by: Yifeng Li --- arch/mips/loongson64/common/reset.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/mips/loongson64/common/reset.c b/arch/mips/loongson64/common/reset.c index a60715e11306..b26892ce871c 100644 --- a/arch/mips/loongson64/common/reset.c +++ b/arch/mips/loongson64/common/reset.c @@ -59,7 +59,12 @@ static void loongson_poweroff(void) { #ifndef CONFIG_LEFI_FIRMWARE_INTERFACE mach_prepare_shutdown(); - unreachable(); + + /* + * It needs a wait loop here, but mips/kernel/reset.c already calls + * a generic delay loop, machine_hang(), so simply return. + */ + return; #else void (*fw_poweroff)(void) = (void *)loongson_sysconf.poweroff_addr;