From mboxrd@z Thu Jan 1 00:00:00 1970 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 D5CE4C52D7C for ; Wed, 21 Aug 2024 16:56:28 +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: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ne9eXSZTxxeS0+4Cpvef1GmZAHH3xlYsYYCc8wzr8iY=; b=vxrLYfET4VUEOrHeqIJc6fQEY9 nokPqKobeVitsgXmzw6c4vk+mifPagWGmkFMred3uzju5Of3jf+EfKhGBKUgSj2qGXO+MB4Um1k9G NFfvjpNqpS3jArvvcTI4gcbp+spVCjaV944Ucj4desJapKVOEuAQ5fjUub/Fftp92yKLRKB4Agy+n I7bL2t+tBI4gY5WqPjh2JbFnAXxaXOC/4BpollPiOJx8BJzKKpfgA3At9U01UcFg27XLG37FkODvj CpzJGpDFQddK2Z51NrRCsYGrTr4zqy9NbirgKZg6ucCS5iyQJxw2XlToyuSI0j6mgY19EH9iiBgfp krqPIkMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgod7-00000009pjz-3Bxj; Wed, 21 Aug 2024 16:56:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgocM-00000009pVM-1mbP for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 16:55:31 +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 B526DDA7; Wed, 21 Aug 2024 09:55:55 -0700 (PDT) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AE9203F66E; Wed, 21 Aug 2024 09:55:28 -0700 (PDT) Date: Wed, 21 Aug 2024 17:55:25 +0100 From: Andre Przywara To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, akos.denke@arm.com, luca.fancellu@arm.com, maz@kernel.org Subject: Re: [BOOT-WRAPPER v2 08/10] Simplify spin logic Message-ID: <20240821175525.07cf69b2@donnerap.manchester.arm.com> In-Reply-To: <20240812101555.3558589-9-mark.rutland@arm.com> References: <20240812101555.3558589-1-mark.rutland@arm.com> <20240812101555.3558589-9-mark.rutland@arm.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_095530_585125_79E12B3B X-CRM114-Status: GOOD ( 24.31 ) 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 On Mon, 12 Aug 2024 11:15:53 +0100 Mark Rutland wrote: > 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. Ah, that's a nice one! Indeed this looks much cleaner now. The change looks good to me, just some small thing below: > Signed-off-by: Mark Rutland > Acked-by: Marc Zyngier > Cc: Akos Denke > Cc: Andre Przywara > Cc: Luca Fancellu > --- > arch/aarch64/spin.S | 11 +---------- > common/boot.c | 20 ++++++++------------ > common/psci.c | 2 +- > include/boot.h | 2 +- > 4 files changed, 11 insertions(+), 24 deletions(-) > > diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S > index 375f732..a7879d4 100644 > --- a/arch/aarch64/spin.S > +++ b/arch/aarch64/spin.S > @@ -23,15 +23,6 @@ ASM_FUNC(start_bootmethod) > * Primary CPU (x0 = 0) jumps to kernel, the other ones wait for an > * address to appear in mbox I think this comment is a bit out of place now, either remove it entirely, or hint that first_spin will take care of the difference between mbox and kernel entrypoint. Regardless: Reviewed-by: Andre Przywara Cheers, Andre > */ > - 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);