From patchwork Fri Jan 20 03:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-Chien Peter Lin X-Patchwork-Id: 1729249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=C6i6xxw3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NyksH2qwBz23gM for ; Fri, 20 Jan 2023 14:05:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JiDSUpSmxtzQzXsR7oUsLiPz8uDVbY2W8Wj2ZmXUv5s=; b=C6i6xxw3jKIr44 JTV7x/Gnz/xmFV62+hp03zmAu4zHvvxOdiD4o/hAA3EOqvVlvW5oLO+8ycYNDTcVwndgmXtQmhLi/ i7rliD6VjaTgTtCHjXblhCDPdaTvAlmmvUwjAL3E9PhKCQGfX0FVsVHiIuAOCwWMlTqGHg7pJo6dS QU0tUaGi6SU2MAime3J15jb5qGaecV5HaHWqUFbu4nzEAyIANCtnQlps5O+Tw9NdNMk6gPyfnKz1N JBgL/kiT9RF6HFYVEbO4rbJKaZo4wSF6K9CuSmPPTn2w0FszfEmgrXeldth9m6EhHJ6bX6wuHr6LI g3tSRjQu0jIw2e/19eDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIhim-008AiU-Jb; Fri, 20 Jan 2023 03:05:40 +0000 Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIhij-008Ah3-AY for opensbi@lists.infradead.org; Fri, 20 Jan 2023 03:05:39 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 30K35URH080397; Fri, 20 Jan 2023 11:05:30 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from atcfdc88.andestech.com (10.0.15.158) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Fri, 20 Jan 2023 11:05:27 +0800 From: Yu Chien Peter Lin To: CC: , , Yu Chien Peter Lin , Andrew Jones , Atish Patra Subject: [PATCH v4 2/6] lib: sbi_hsm: handle failure when hart_stop returns SBI_ENOTSUPP Date: Fri, 20 Jan 2023 11:05:08 +0800 Message-ID: <20230120030512.8778-3-peterlin@andestech.com> X-Mailer: git-send-email 2.38.0.68.ge85701b4af.dirty In-Reply-To: <20230120030512.8778-1-peterlin@andestech.com> References: <20230120030512.8778-1-peterlin@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.158] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 30K35URH080397 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230119_190537_892378_AE92566B X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Make use of generic warm-boot path when platform hart_stop callback returns SBI_ENOTSUPP, in case certain hart can not turn off its power domain, or it detects some error occured in power management u [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 TVD_RCVD_IP Message was received from an IP address -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Make use of generic warm-boot path when platform hart_stop callback returns SBI_ENOTSUPP, in case certain hart can not turn off its power domain, or it detects some error occured in power management unit, it can fall through warm-boot flow and wait for interrupt in sbi_hsm_hart_wait(). Also improves comment in sbi_hsm_hart_wait(). Signed-off-by: Yu Chien Peter Lin Reviewed-by: Andrew Jones Reviewed-by: Atish Patra Reviewed-by: Anup Patel --- include/sbi/sbi_hsm.h | 8 ++++++-- lib/sbi/sbi_hsm.c | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index c2a728a4..1170127b 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -21,8 +21,12 @@ struct sbi_hsm_device { int (*hart_start)(u32 hartid, ulong saddr); /** - * Stop (or power-down) the current hart from running. This call - * doesn't expect to return if success. + * Stop (or power-down) the current hart from running. + * + * Return SBI_ENOTSUPP if the hart does not support platform-specific + * stop actions. + * + * For successful stop, the call won't return. */ int (*hart_stop)(void); diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index c0a55054..d4cce4ac 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -116,7 +116,7 @@ static void sbi_hsm_hart_wait(struct sbi_scratch *scratch, u32 hartid) /* Set MSIE and MEIE bits to receive IPI */ csr_set(CSR_MIE, MIP_MSIP | MIP_MEIP); - /* Wait for hart_add call*/ + /* Wait for state transition requested by sbi_hsm_hart_start() */ while (atomic_read(&hdata->state) != SBI_HSM_STATE_START_PENDING) { wfi(); }; @@ -228,9 +228,8 @@ void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch) goto fail_exit; if (hsm_device_has_hart_hotplug()) { - hsm_device_hart_stop(); - /* It should never reach here */ - goto fail_exit; + if (hsm_device_hart_stop() != SBI_ENOTSUPP) + goto fail_exit; } /**