From patchwork Tue Jun 13 23:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 107611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp891167vqr; Tue, 13 Jun 2023 16:41:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RiKvZiCssF1Gkc64MkaGrMx86YeB/cMRjOz5f8+I6TK0xVf17ZXEO3OX08Hv8rSpeXzbR X-Received: by 2002:a17:906:dc94:b0:966:634d:9d84 with SMTP id cs20-20020a170906dc9400b00966634d9d84mr16920764ejc.20.1686699677806; Tue, 13 Jun 2023 16:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686699677; cv=none; d=google.com; s=arc-20160816; b=zLCFiT34tv6B8T0bAlK4SISZSuoYnzH5sgodwKpyDoKr0KSLSoo3SDOb1xan+xVfGc ZabjCM9I/jPEXDK1G/CsKeTWs+h2CSDc8hUBTObs+QClXxFr7NX4bO++PlDGeRn+TJtT 7A6F1VB1XEAoQc8NHwvA1626nDYIUu0B4vxO7bHqJ9ASTMVVGHdNb3w4/9zkpEtJ6k28 y2bPRC4VSK/OkrCWyiXxDNc3Ibbgcjd7S3gUHT9l/uNPLW5yhbqQXvKnH/pLqcWgJeKU nxDJtIxtCYq1PcQ7IgH0E1PsyrbYGT+NNyGZtpDrsR6e9o0HD4zHX5Q2ASYFxuXVM6X/ copQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=77AqRKQdSjaQjDGx40OLahyRXrEjSKh/Zvl13xpUqBI=; b=rpoKGOBRITSmUe6T3RtK8khR+Fp4Ah+3P2kUF12GwXfbgDsTyAb4E9iETjAeSMkFQY qmbACc/L3vXhkt2mZNJ6l4nn4WH7RRjaGTZy+PoDZbSsNYzHlLpYOuMU+OiBTueYlPvc wKC5KNTMiOHHDwHypBU52wa1wke9iddYjK+TFCdtj2VxqdZpDjZh4arfmlOlf1ySN8fW bN3WMiqF37V7uVHZ0pb1fn6JGLMIksM7TeAAyPcoupyQUZ25adjGv59AKNSOWmxx50X6 QxH/BGoUymoy61z/QWpmGLRG82RBmN/C1uB29CB9KqFumkGcaOmA/FJ1gFZzWxeXLefU oVTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fnjAlb4b; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=NcUHkxGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a17090690d900b009745654e184si7355288ejw.924.2023.06.13.16.40.53; Tue, 13 Jun 2023 16:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fnjAlb4b; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=NcUHkxGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238699AbjFMXj2 (ORCPT + 99 others); Tue, 13 Jun 2023 19:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238536AbjFMXj0 (ORCPT ); Tue, 13 Jun 2023 19:39:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3DC199B; Tue, 13 Jun 2023 16:39:24 -0700 (PDT) Message-ID: <20230613224544.957805717@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686699563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=77AqRKQdSjaQjDGx40OLahyRXrEjSKh/Zvl13xpUqBI=; b=fnjAlb4buqGgk+rgrSCls7XVVnssMKtlFn2wVkNKc0rXqkoKriukti4plpA4B3XFF4TzZK HkCGTHa0kgSQScvJzMGd5ndETRmA+U3bEX7DbZ4/2do4EQ0DxEh5OrT0lEol4VvMYfuRS9 HynlSeJlhLILNeJrnp5YyETdHndPSJ7O/5rI4vnEKgJp3QTTCjnHyKycf9vdAFNWo8H2rb OTqiVuHCxtKC1JhOpK0UDZj/7iiiakYdsll7mDRVfp6DDuS0PUAl8a0YNpVsMMsx4052en gUZVODYB997wOJEzzkrsE7bLzpx5hqFiHqP0cAfvYOr6EwF5Zzytu+rPbxhCmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686699563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=77AqRKQdSjaQjDGx40OLahyRXrEjSKh/Zvl13xpUqBI=; b=NcUHkxGs2yX0+eW1fJGry5eTvk3bMCTGxKXUguMEnkfcS6GFg9bNcY/6dOYm0SDEPQHUZn lMvSic4+i4tjOCAw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Nikolay Borisov , "Ahmed S. Darwish" , Arnd Bergmann , Russell King , linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, Huacai Chen , WANG Xuerui , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Thomas Bogendoerfer , linux-mips@vger.kernel.org, Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-sh@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Richard Henderson , "James E.J. Bottomley" , Michael Ellerman , Chris Zankel , Tom Lendacky Subject: [patch 01/17] init: Provide arch_cpu_finalize_init() References: <20230613223827.532680283@linutronix.de> MIME-Version: 1.0 Date: Wed, 14 Jun 2023 01:39:22 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768632801505020981?= X-GMAIL-MSGID: =?utf-8?q?1768632801505020981?= check_bugs() has become a dump ground for all sorts of activities to finalize the CPU initialization before running the rest of the init code. Most are empty, a few do actual bug checks, some do alternative patching and some cobble a CPU advertisment string together.... Aside of that the current implementation requires duplicated function declaration and mostly empty header files for them. Provide a new function arch_cpu_finalize_init(). Provide a generic declaration if CONFIG_ARCH_HAS_CPU_FINALIZE_INIT is selected and a stub inline otherwise. This requires a temporary #ifdef in start_kernel() which will be removed along with check_bugs() once the architectures are converted over. Signed-off-by: Thomas Gleixner --- arch/Kconfig | 3 +++ include/linux/cpu.h | 6 ++++++ init/main.c | 4 ++++ 3 files changed, 13 insertions(+) --- a/arch/Kconfig +++ b/arch/Kconfig @@ -285,6 +285,9 @@ config ARCH_HAS_DMA_SET_UNCACHED config ARCH_HAS_DMA_CLEAR_UNCACHED bool +config ARCH_HAS_CPU_FINALIZE_INIT + bool + # Select if arch init_task must go in the __init_task_data section config ARCH_TASK_STRUCT_ON_STACK bool --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -184,6 +184,12 @@ void arch_cpu_idle_enter(void); void arch_cpu_idle_exit(void); void __noreturn arch_cpu_idle_dead(void); +#ifdef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT +void arch_cpu_finalize_init(void); +#else +static inline void arch_cpu_finalize_init(void) { } +#endif + int cpu_report_state(int cpu); int cpu_check_up_prepare(int cpu); void cpu_set_state_online(int cpu); --- a/init/main.c +++ b/init/main.c @@ -1078,7 +1078,11 @@ asmlinkage __visible void __init __no_sa taskstats_init_early(); delayacct_init(); + arch_cpu_finalize_init(); + /* Temporary conditional until everything has been converted */ +#ifndef CONFIG_ARCH_HAS_CPU_FINALIZE_INIT check_bugs(); +#endif acpi_subsystem_init(); arch_post_acpi_subsys_init();