Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3131286rwo; Mon, 24 Jul 2023 06:47:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbAyolIWh9Do/KTyLdEKTlvjQfc/HpxNiQcUZ1APOHK2jJeYZFM97LrRnKCHir568J3Rk+ X-Received: by 2002:a17:906:76c7:b0:994:1805:1fad with SMTP id q7-20020a17090676c700b0099418051fadmr10098265ejn.10.1690206428685; Mon, 24 Jul 2023 06:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690206428; cv=none; d=google.com; s=arc-20160816; b=SbPqgld1V4ZVNTfsVEHma5oOD2jjMumKQY710dkhbtvpkTXMCwnhu24Ny1fRZMiqWL FCynokZcCHTuM/DJIUoNH1NnCaUg0gh0mmDIBP7jti4xX4Tvgv8g+eLu6mXtQd4rNaXG 3/iMIjxg7N4Dj+zmLKmBtG/AYnMsBYr7fxrZW5YaxeUVglVNTmE13m301m8XShjxXBCu PwxQzT+ginoxehuEwNq/g1Ywoa0aXd3x9lWMzUHmFqc2XrWebclSHiilFuUYM2MKr9BS 3Ret3O6Qvd/1OMJeZXtTTDFs7BubgL3Vh8x+OwsRd+c937fO9vT484mjrjk8O9fVx6ww jKGw== 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=ny7Fxu7g7PBQMTLhRl8hSl0RLxzChrJ0DtIsWugH0fI=; fh=mE3iieUIZLcDfOLIULj9X6/p0bMDPZGFSVRsnyRUnTc=; b=W20qpjJtWRD0CXOvn9bxZRHSN6Nr63s2BuIJWdjgDMYayfAd+KTABNEJZVPr5SbzqF J7Eh6UTJhzwEAuTN4DgaBc5ooWydGYuYTIVr/rXX7130znqjAFicVPbdCLTeamr5rCw+ t3Cpoiwdz8ZoTgtJ1YLvTaJmIU+XtrnKuSwSNG5F9IuMn24xhvY+cn/TeuC9W0Ar/LFz MiUhlxHmR90qnUY2NxRX4MTNEZxSQz4i9yUvVBVbzffp+mGsZB+Npu9P2ASmlWAQU2Kl oNBypf0YhOqN5JFJgjDpdo4xEESEPYFkFnhzc7qx2DwlXg4sJX/E8AN4R41sP7Ia3QmJ hXLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UYKFq2eV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a170906850900b009933071fdd7si6543560ejx.680.2023.07.24.06.46.32; Mon, 24 Jul 2023 06:47:08 -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=UYKFq2eV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231463AbjGXNer (ORCPT + 99 others); Mon, 24 Jul 2023 09:34:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbjGXNea (ORCPT ); Mon, 24 Jul 2023 09:34:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B6221BCD for ; Mon, 24 Jul 2023 06:34:08 -0700 (PDT) Message-ID: <20230724132045.361461564@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690205647; 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=ny7Fxu7g7PBQMTLhRl8hSl0RLxzChrJ0DtIsWugH0fI=; b=UYKFq2eVSj6AOmPTSVltR0cAd7r1HY4xZMlg7KasidxrQeHBZT/+kyYoKHIgmneHZsb01q 7t029ehZZUBnkIhz19oNda3IV4mkrkZkNbPleGevUsTQLpsQMFS8KmW5SskjSQLz04Yf0o sIWWfE3+Hpil2wCXH2j6xEzqmBDKA+zwh5H4jnxnByWrDUaB8mhPNDEkijB/OgWT7tPoPr 3/bvtM+buu4oruNkwgtnqp9oDkdaxG0TRq1+sLLU4AwB0RdXhry6/QR/NFjIbzgny9m3Ad O0OEl5oAGZVVAxRyB/tYPrqEE1Zx8tf/XFNDRw+ijRN4NyOQr94IM5Di+PrZdQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690205647; 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=ny7Fxu7g7PBQMTLhRl8hSl0RLxzChrJ0DtIsWugH0fI=; b=HLzz1DJCmQ830YC+0xiySYwEqQszPcXyt3grCF9HHtD+uTsrzrrDMG8jqywzDpsoVFidja RbO45lgaWF8vzZBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross , Michael Kelley , Peter Keresztes Schmidt , "Peter Zijlstra (Intel)" Subject: [patch V2 13/58] x86/apic: Make some APIC init functions bool References: <20230724131206.500814398@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 24 Jul 2023 15:34:06 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Quite some APIC init functions are pure boolean, but use the success = 0, fail < 0 model. That's confusing as hell when reading through the code. Convert them to boolean. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/apic.h | 6 +++--- arch/x86/kernel/apic/apic.c | 36 ++++++++++++++++++------------------ arch/x86/kernel/devicetree.c | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -135,12 +135,12 @@ extern void setup_secondary_APIC_clock(v extern void lapic_update_tsc_freq(void); #ifdef CONFIG_X86_64 -static inline int apic_force_enable(unsigned long addr) +static inline bool apic_force_enable(unsigned long addr) { - return -1; + return false; } #else -extern int apic_force_enable(unsigned long addr); +extern bool apic_force_enable(unsigned long addr); #endif extern void apic_ap_setup(void); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2000,19 +2000,19 @@ void __init enable_IR_x2apic(void) * On AMD64 we trust the BIOS - if it says no APIC it is likely * not correctly set up (usually the APIC timer won't work etc.) */ -static int __init detect_init_APIC(void) +static bool __init detect_init_APIC(void) { if (!boot_cpu_has(X86_FEATURE_APIC)) { pr_info("No local APIC present\n"); - return -1; + return false; } mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; - return 0; + return true; } #else -static int __init apic_verify(void) +static bool __init apic_verify(void) { u32 features, h, l; @@ -2023,7 +2023,7 @@ static int __init apic_verify(void) features = cpuid_edx(1); if (!(features & (1 << X86_FEATURE_APIC))) { pr_warn("Could not enable APIC!\n"); - return -1; + return false; } set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; @@ -2036,15 +2036,15 @@ static int __init apic_verify(void) } pr_info("Found and enabled local APIC!\n"); - return 0; + return true; } -int __init apic_force_enable(unsigned long addr) +bool __init apic_force_enable(unsigned long addr) { u32 h, l; if (apic_is_disabled) - return -1; + return false; /* * Some BIOSes disable the local APIC in the APIC_BASE @@ -2067,11 +2067,11 @@ int __init apic_force_enable(unsigned lo /* * Detect and initialize APIC */ -static int __init detect_init_APIC(void) +static bool __init detect_init_APIC(void) { /* Disabled by kernel option? */ if (apic_is_disabled) - return -1; + return false; switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_AMD: @@ -2098,22 +2098,22 @@ static int __init detect_init_APIC(void) if (!force_enable_local_apic) { pr_info("Local APIC disabled by BIOS -- " "you can enable it with \"lapic\"\n"); - return -1; + return false; } - if (apic_force_enable(APIC_DEFAULT_PHYS_BASE)) - return -1; + if (!apic_force_enable(APIC_DEFAULT_PHYS_BASE)) + return false; } else { - if (apic_verify()) - return -1; + if (!apic_verify()) + return false; } apic_pm_activate(); - return 0; + return true; no_apic: pr_info("No local APIC present or hardware disabled\n"); - return -1; + return false; } #endif @@ -2129,7 +2129,7 @@ void __init init_apic_mappings(void) return; /* If no local APIC can be found return early */ - if (!smp_found_config && detect_init_APIC()) { + if (!smp_found_config && !detect_init_APIC()) { /* lets NOP'ify apic operations */ pr_info("APIC: disable apic facility\n"); apic_disable(); --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -158,7 +158,7 @@ static void __init dtb_lapic_setup(void) /* Did the boot loader setup the local APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC)) { /* Try force enabling, which registers the APIC address */ - if (apic_force_enable(lapic_addr)) + if (!apic_force_enable(lapic_addr)) return; } else { register_lapic_address(lapic_addr);