From patchwork Wed Jan 4 06:29:27 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: 1721254 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=wKda7Zg2; 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 4Nn0Bs4lztz23fc for ; Wed, 4 Jan 2023 17:32:21 +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=zftejIy49KmZlOkiywITCqKACaVg75Ylp67mwm/HIdY=; b=wKda7Zg25jnICN 6uKT2A6aSNNBXhJjLp9ozo7ulbEVXHRz1GDxTJDd8IyHY2tDG7fQ76hqu/qCuBVZ6sn48gMAVLPxX LX89oC0jZY4NyL1ruBtuW99BthSYLgeVOfy+M+zOKs14LQoB4DPECWOODj3RsXK7SvWUl2vzhP/tY //8uBvyO0brAHCTuFmiqgxiEg2BGv0MaX1r3OvRgUuV54RtENjJeFF56wkiPn2JAYkX5aGTi4uJ1J mGF6V933oF0xO7Y5WrnJtYJoohKFAmp9fGvuFQAMmfufW4YFBJkfhRhCPiN5Jonm9qEpA7Z06OM0w kmc20+WIaHRtKCjS8jeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCxJm-007APX-Sq; Wed, 04 Jan 2023 06:32:06 +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 1pCxJc-007ALv-CF for opensbi@lists.infradead.org; Wed, 04 Jan 2023 06:31:58 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 3046VjDp074110 for ; Wed, 4 Jan 2023 14:31:45 +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; Wed, 4 Jan 2023 14:31:43 +0800 From: Yu Chien Peter Lin To: CC: , , , "Yu Chien Peter Lin" Subject: [PATCH 6/6] lib: sbi_hsm: Introduce hart_secondary_boot() callback Date: Wed, 4 Jan 2023 14:29:27 +0800 Message-ID: <20230104062927.15628-7-peterlin@andestech.com> X-Mailer: git-send-email 2.38.0.68.ge85701b4af.dirty In-Reply-To: <20230104062927.15628-1-peterlin@andestech.com> References: <20230104062927.15628-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 3046VjDp074110 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230103_223156_898390_1FFCF804 X-CRM114-Status: GOOD ( 10.55 ) 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: When platform supports hotplug, i.e. both hart_start() and hart_stop() callbacks are provided, the former doesn't need to be performed at the boot-time. Thus, add a callback for the case of secondary [...] 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 When platform supports hotplug, i.e. both hart_start() and hart_stop() callbacks are provided, the former doesn't need to be performed at the boot-time. Thus, add a callback for the case of secondary boot. Signed-off-by: Yu Chien Peter Lin --- include/sbi/sbi_hsm.h | 7 +++++++ lib/sbi/sbi_hsm.c | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index 1e23884..94b3bbb 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -49,6 +49,13 @@ struct sbi_hsm_device { * non-retentive suspend. */ void (*hart_resume)(void); + + /** + * Perform platform-specific actions on non-boot harts at boot-time + * + * For successful secondary boot, the call will return 0. + */ + int (*hart_secondary_boot)(u32 hartid, ulong saddr); }; struct sbi_domain; diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index b89253b..c9ab6a3 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -152,11 +152,18 @@ static bool hsm_device_has_hart_hotplug(void) static bool hsm_device_has_hart_secondary_boot(void) { - if (hsm_dev && hsm_dev->hart_start && !hsm_dev->hart_stop) + if (hsm_dev && hsm_dev->hart_secondary_boot) return true; return false; } +static int hsm_device_hart_secondary_boot(u32 hartid, ulong saddr) +{ + if (hsm_dev && hsm_dev->hart_secondary_boot) + return hsm_dev->hart_secondary_boot(hartid, saddr); + return SBI_ENOTSUPP; +} + static int hsm_device_hart_start(u32 hartid, ulong saddr) { if (hsm_dev && hsm_dev->hart_start) @@ -284,16 +291,13 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, rscratch->next_addr = saddr; rscratch->next_mode = smode; - if (hsm_device_has_hart_hotplug() || - (hsm_device_has_hart_secondary_boot() && !init_count)) { + if (hsm_device_has_hart_secondary_boot() && !init_count) + return hsm_device_hart_secondary_boot(hartid, scratch->warmboot_addr); + + if (hsm_device_has_hart_hotplug() && init_count) return hsm_device_hart_start(hartid, scratch->warmboot_addr); - } else { - int rc = sbi_ipi_raw_send(hartid); - if (rc) - return rc; - } - return 0; + return sbi_ipi_raw_send(hartid); } int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow)