From patchwork Wed Aug 9 19:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 133451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3030968vqr; Wed, 9 Aug 2023 12:40:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFj0OEJgmR7/IP4ga/UKL1hfEj7JyJcViMqlIixB8AGK4vDEJ/W9PcNeXX1cqx2Z2fCJbKi X-Received: by 2002:a17:906:208f:b0:965:9602:1f07 with SMTP id 15-20020a170906208f00b0096596021f07mr74317ejq.39.1691610018502; Wed, 09 Aug 2023 12:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610018; cv=none; d=google.com; s=arc-20160816; b=azYhOdS48XM0HHp3ddRnnbTNFllRPUmn4ltDjiNPpSnr2nODRosvZqWmWTUUnKDTDB fwQ+eq/aCjses51f7uX3hhU50ZpX6Ir44Bezy7HIOU0EBPnPk0OsqquKMvCkaYAcSC0V 7B/41di4RXsdFdzfo+aAvym28yOm9lxo4PZHlXF1lb77IUZCxIr9R4hcXCPNCM/inwkM 03kUdP9fwzfAUlamgCh4bUOs/5Vb2ED7Ixwjk4Jo78cCph+e5DoVym0ROopwzdFKiCTP yi7xvCELeu2ulYW+eDv07p4VnvBs6IcRNJpqwb7ii5klewibSqDuT8uLXAUbPDYVSoDN 84Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=ZOOnlytwjdniYUrv8HLfKwwBshoQq0BLjDC3lVUi74U=; fh=jBwjuriIPWA1lnCf5oMMiNAPpgGE0iGPmBzZMsd85oQ=; b=xi5Ll2ImKwCHQ0o2gKWQMoAbcLtvpn95ZlPkhInKZ/3P1wLBx/B7leqPIZZCFWYSS1 3KKuoPmpol0WGPOgTx8Qoe77OX3+3vhaRWOxasnK3vv3eMMctXriOHx71DnVL7PxD0+z PQTib+Tfo3W7K+wDw1r79BnQDqNEWpocLAkWr74pWBdAoNfTGUmBZ1xiC6Suvt09WsUz OQA5uPgluvPWhPUBG0OQPEsfvNUq4eia3Men33J+tbML9AqJrBM/Pi/aOCKecWpiMxsY PV/prsVOpbrzrj8XmTynK58Sqfp3ALzZGQ9E+aX78RovMk2Zx3+CIhsO3U/fp31nyXQP ZKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aM8go1BW; dkim=neutral (no key) header.i=@linutronix.de; 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 ja2-20020a170907988200b0099caf921b0bsi7713986ejc.493.2023.08.09.12.39.55; Wed, 09 Aug 2023 12:40:18 -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=aM8go1BW; dkim=neutral (no key) header.i=@linutronix.de; 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 S233324AbjHITNk (ORCPT + 99 others); Wed, 9 Aug 2023 15:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232152AbjHITM7 (ORCPT ); Wed, 9 Aug 2023 15:12:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B58F5210B; Wed, 9 Aug 2023 12:12:36 -0700 (PDT) Date: Wed, 09 Aug 2023 19:12:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691608345; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZOOnlytwjdniYUrv8HLfKwwBshoQq0BLjDC3lVUi74U=; b=aM8go1BW0LBb2/TPETRHj/3sN/Az2fBDIIJ8NIg3mQvLg0XVSGLqIu9pZcV6e7Pf8hJpNo 4SP0VjTB3vKcr2aNdax/pLjMTqMG9K2SzpqnNgMFXOsHLG7GhnS4VJ4f/v898WTgqHLj90 /tmkacAKkrKW3yUSbdw3XaMiK/oa6Qqgin0tJQuNusINWBhuUpEWtMfDdXuIESh3uJ+c7j h+VBTBQFut0auN4ndodihoULfcuOKuid4rVFkIPPFJYgTGMQXXfl7lSKFzlTRkBSiRywal Gxh/qIKESVoSHQ7p1gbIyUmZnOaeCsS8VZRQn15B3o9Oxc4088wGy+4GuLxtKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691608345; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZOOnlytwjdniYUrv8HLfKwwBshoQq0BLjDC3lVUi74U=; b=XnLhBDbIbJE2aj+MS6VHOZHIKmUfeWPrBbuEtpzn+pgJa8Q9Q6wUWTnI+KiT/8+GFi7ktY UatcB0R9hknw6KAQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/apic: Make some APIC init functions bool Cc: Thomas Gleixner , Dave Hansen , "Peter Zijlstra (Intel)" , Michael Kelley , Sohil Mehta , Juergen Gross , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169160834490.27769.7553485649731661081.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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,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: INBOX X-GMAIL-THRID: 1773779923495901923 X-GMAIL-MSGID: 1773781666891705377 The following commit has been merged into the x86/apic branch of tip: Commit-ID: 1751adedbd601d6a9da35de0c1e2592ac980fdfe Gitweb: https://git.kernel.org/tip/1751adedbd601d6a9da35de0c1e2592ac980fdfe Author: Thomas Gleixner AuthorDate: Tue, 08 Aug 2023 15:03:48 -07:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 11:58:20 -07:00 x86/apic: Make some APIC init functions bool 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 Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) Tested-by: Michael Kelley Tested-by: Sohil Mehta Tested-by: Juergen Gross # Xen PV (dom0 and unpriv. guest) --- 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(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 108fdc2..35d236b 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -135,12 +135,12 @@ extern void setup_secondary_APIC_clock(void); 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); diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 32275ca..d0f4cca 100644 --- 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 long addr) /* * 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(); diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 8f94eb6..87d38f1 100644 --- 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);