From patchwork Thu Aug 22 10:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13773184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D52F3C3DA4A for ; Thu, 22 Aug 2024 10:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5yJWjHy3h+j3jWPB9kwv/t9wg4XGBgFpVIth36p0MlE=; b=wjV6Rlo2rW3iybu5d5WwFPjrl1 GIOmWi0B91uC2H18jJspqhSkpDui0DiDC6WOCosOTXWNQ3hxcpDqR+ed5IUUFIsPk+x8zQDXbnO0C vfpYh3mg7E7actiupKwsfn+WovpDsI+AP6lzOq3CBOXLGt3c2RuHBED6ViWlIMeKwl3elec+8lQ34 qfpGD3hZQ0EfTyeLqRHsRdEUm5Zin1vGQ1FpaXnK4Zb+aVz9vlLyoUZMLVajX2lFqxtp+8yEUz4+f IzgkusQsdu2z7mSn8o2Ut2jzLCMmH3RucqYSNCYoR50OeH6OCGIDaQeAG1nuu5lbJGnX0EsB1+vQ/ 9ltRttXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4tv-0000000COkH-1e6s; Thu, 22 Aug 2024 10:18:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4qi-0000000COJl-0dQv for linux-arm-kernel@bombadil.infradead.org; Thu, 22 Aug 2024 10:15:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5yJWjHy3h+j3jWPB9kwv/t9wg4XGBgFpVIth36p0MlE=; b=Un2HBoqkmOtsw5h18C1YRa4Ef7 AFkf6ncRSvjfnlu7QMAHU3Ef0dA0Q7qsyNlLvOW2SZGeuBEKDOihoc6DCPlENLd8OB2KKLTUcwRr2 GRTonQS2rQmj+o/ideZ4IGjmnuiVHgCU7jinHOlMCYAdJAMqumzceDB73jo789mb/ztkAfmz6z2t5 GBdNr8e8We9pb8AY1+mQcqZOY5GK7c0IPppcESMyNZ5kyD5CC7sXQuAD5wAhnlncIkPeaa2KAwAH9 8QQZvQjAktAau+fvrgMN7pwBzFsGyiYkHYskP4O9wPImkEM3Mlwktxh6FVrKjnSxFUJlMTGsWXLAY JtJZ9wGA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh4qe-00000009u6r-1m9P for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 10:15:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3FC4F1595; Thu, 22 Aug 2024 03:15:44 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C399F3F66E; Thu, 22 Aug 2024 03:15:16 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akos.denke@arm.com, andre.przywara@arm.com, luca.fancellu@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [BOOT-WRAPPER v3 08/10] Simplify spin logic Date: Thu, 22 Aug 2024 11:14:39 +0100 Message-Id: <20240822101441.251184-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240822101441.251184-1-mark.rutland@arm.com> References: <20240822101441.251184-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240822_111520_882436_D6FB59AD X-CRM114-Status: GOOD ( 14.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The logic for initial boot is more complicated than it needs to be, with both first_spin() having a special case for CPU0 that requires an additional argument to be passed to spin(). Simplify this by moving the special-case logic for CPU0 into first_spin(). This removes the need to provide a dummy mailbox for CPU0 to spin on, simplfiies callers of first_spin() and spin(), which no longer need to pass a dummy mailbox or 'is_entry' for CPU0. Signed-off-by: Mark Rutland Acked-by: Marc Zyngier Reviewed-by: Andre Przywara Cc: Akos Denke Cc: Luca Fancellu --- arch/aarch64/spin.S | 16 +--------------- common/boot.c | 20 ++++++++------------ common/psci.c | 2 +- include/boot.h | 2 +- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S index 375f732..6597ca1 100644 --- a/arch/aarch64/spin.S +++ b/arch/aarch64/spin.S @@ -18,20 +18,6 @@ ASM_FUNC(cpu_init_bootmethod) ASM_FUNC(start_bootmethod) cpuid x0, x1 bl find_logical_id - - /* - * Primary CPU (x0 = 0) jumps to kernel, the other ones wait for an - * address to appear in mbox - */ - adr x3, mbox - adr x4, kernel_address - cmp x0, #0 - csel x1, x3, x4, ne + adr x1, mbox mov x2, #0 bl first_spin - - .align 3 -kernel_address: - .long 0 - - .ltorg diff --git a/common/boot.c b/common/boot.c index 29d53a4..4417649 100644 --- a/common/boot.c +++ b/common/boot.c @@ -27,7 +27,7 @@ const unsigned long id_table[] = { CPU_IDS }; * @invalid: value of an invalid address, 0 or -1 depending on the boot method * @is_entry: when true, pass boot parameters to the kernel, instead of 0 */ -void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry) +void __noreturn spin(unsigned long *mbox, unsigned long invalid) { unsigned long addr = invalid; @@ -36,13 +36,6 @@ void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry) addr = *mbox; } - if (is_entry) -#ifdef KERNEL_32 - jump_kernel(addr, 0, ~0, (unsigned long)&dtb, 0); -#else - jump_kernel(addr, (unsigned long)&dtb, 0, 0, 0); -#endif - jump_kernel(addr, 0, 0, 0, 0); unreachable(); @@ -60,12 +53,15 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, unsigned long invalid) { if (cpu == 0) { - *mbox = (unsigned long)&entrypoint; - sevl(); - spin(mbox, invalid, 1); + unsigned long addr = (unsigned long)&entrypoint; +#ifdef KERNEL_32 + jump_kernel(addr, 0, ~0, (unsigned long)&dtb, 0); +#else + jump_kernel(addr, (unsigned long)&dtb, 0, 0, 0); +#endif } else { *mbox = invalid; - spin(mbox, invalid, 0); + spin(mbox, invalid); } unreachable(); diff --git a/common/psci.c b/common/psci.c index 5ae4255..19cc315 100644 --- a/common/psci.c +++ b/common/psci.c @@ -57,7 +57,7 @@ static int psci_cpu_off(void) branch_table[cpu] = PSCI_ADDR_INVALID; - spin(branch_table + cpu, PSCI_ADDR_INVALID, 0); + spin(branch_table + cpu, PSCI_ADDR_INVALID); unreachable(); } diff --git a/include/boot.h b/include/boot.h index 459d1d5..18b805d 100644 --- a/include/boot.h +++ b/include/boot.h @@ -12,7 +12,7 @@ #include #include -void __noreturn spin(unsigned long *mbox, unsigned long invalid, int is_entry); +void __noreturn spin(unsigned long *mbox, unsigned long invalid); void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, unsigned long invalid_addr);