From patchwork Mon Jul 3 11:07:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dou Liyang X-Patchwork-Id: 9822517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 91D1D60246 for ; Mon, 3 Jul 2017 11:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8303A2817F for ; Mon, 3 Jul 2017 11:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7664B283AD; Mon, 3 Jul 2017 11:10:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F4482817F for ; Mon, 3 Jul 2017 11:10:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRzCy-0005of-Gq; Mon, 03 Jul 2017 11:08:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRzCx-0005kD-EV for xen-devel@lists.xenproject.org; Mon, 03 Jul 2017 11:07:59 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 3F/EC-03704-F852A595; Mon, 03 Jul 2017 11:07:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRWlGSWpSXmKPExsViPb2gRbdPNSr SYN8pDYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWP1wsvMBb8VK/qnX2VqYHwu08XIySEh4Cex Z/YrRhBbSKBWYvvEFUxdjFxA9kpGiWXPm1kgnGOMEjc/PGcGqWIT0JE40/yAHcQWEQiXWLu2m w2kiFngGaPEp58/wEYJC0RLbDhylwXEZhFQkZj9dgEbiM0rEC+xfflbZojVchLbtuwBq+cUsJ WY1HKZBeIMG4k7rc2MEPWCEidnPgGLMwtISBx88QKqV0ni9boDLBC2rsSfT2eh4poS21afY4O wzSSO7PzPCmELSux8foFtAqPILCRjZyEZu4CRaRWjRnFqUVlqka6RsV5SUWZ6RkluYmaOrqGB mV5uanFxYnpqTmJSsV5yfu4mRmCoMwDBDsY/8wMPMUpyMCmJ8rrejIwU4kvKT6nMSCzOiC8qz UktPsQow8GhJMH7TTkqUkiwKDU9tSItMwcYdTBpCQ4eJRHeA/eAWnmLCxJzizPTIVKnGI05Nq xe/4WJ49WE/9+YhFjy8vNSpcR52VWAJgmAlGaU5sENgiWDS4yyUsK8jECnCfEUpBblZpagyr9 iFOdgVBLm/QRyD09mXgncvldApzABndLQEwFySkkiQkqqgbEws+ab3PxPH74LTKxTymYVuRDI xsPHc8bTO4JnRZCQx/T74SxJ74wevnC9PiVbz+bs3r/sOc/dFj2zfhjilH20z2Fq4GfVJoW/z pOSJ6Wvnn+Dd/kuPutsxo2t/yYH/X5u7mNi3fJSyiNx9TWj4jimFay33vHoaS2MkHiZed1X8i fnO4Unv5VYijMSDbWYi4oTAcS9+igBAwAA X-Env-Sender: douly.fnst@cn.fujitsu.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1499080068!52448529!3 X-Originating-IP: [59.151.112.132] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3381 invoked from network); 3 Jul 2017 11:07:57 -0000 Received: from cn.fujitsu.com (HELO heian.cn.fujitsu.com) (59.151.112.132) by server-15.tower-27.messagelabs.com with SMTP; 3 Jul 2017 11:07:57 -0000 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="20783665" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Jul 2017 19:07:57 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 3176847F64E0; Mon, 3 Jul 2017 19:07:55 +0800 (CST) Received: from localhost.localdomain.localdomain (10.167.226.106) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 3 Jul 2017 19:07:59 +0800 From: Dou Liyang To: , , Date: Mon, 3 Jul 2017 19:07:26 +0800 Message-ID: <50ba4f18ec4371c0cd393dd121f81836adde7c89.1499074567.git.douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 3176847F64E0.A0AEB X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Cc: Dou Liyang , bhe@redhat.com, peterz@infradead.org, mingo@kernel.org, ebiederm@xmission.com, hpa@zytor.com, izumi.taku@jp.fujitsu.com, boris.ostrovsky@oracle.com, tglx@linutronix.de Subject: [Xen-devel] [PATCH v6 06/12] x86/apic: Mark the apic_intr_mode extern for sanity check cleanup X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Calling native_smp_prepare_cpus() to prepare for SMP bootup, does some sanity checking, enables APIC mode and disables SMP feature. Now, APIC mode setup has been unified to apic_intr_mode_init(), some sanity checks are redundant and need to be cleanup. Mark the apic_intr_mode extern to refine the switch and remove the redundant sanity check. Signed-off-by: Dou Liyang --- arch/x86/include/asm/apic.h | 9 +++++++ arch/x86/kernel/apic/apic.c | 12 ++++------ arch/x86/kernel/smpboot.c | 57 +++++++-------------------------------------- 3 files changed, 22 insertions(+), 56 deletions(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index c3bedbd..bfbf715 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -53,6 +53,15 @@ extern int local_apic_timer_c2_ok; extern int disable_apic; extern unsigned int lapic_timer_frequency; +extern enum apic_intr_mode_id apic_intr_mode; +enum apic_intr_mode_id { + APIC_PIC, + APIC_VIRTUAL_WIRE, + APIC_VIRTUAL_WIRE_NO_CONFIG, + APIC_SYMMETRIC_IO, + APIC_SYMMETRIC_IO_NO_ROUTING +}; + #ifdef CONFIG_SMP extern void __inquire_remote_apic(int apicid); #else /* CONFIG_SMP */ diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 4e24aaf..8cae32c 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1157,13 +1157,7 @@ void __init sync_Arb_IDs(void) APIC_INT_LEVELTRIG | APIC_DM_INIT); } -enum apic_intr_mode { - APIC_PIC, - APIC_VIRTUAL_WIRE, - APIC_VIRTUAL_WIRE_NO_CONFIG, - APIC_SYMMETRIC_IO, - APIC_SYMMETRIC_IO_NO_ROUTING, -}; +enum apic_intr_mode_id apic_intr_mode; static int __init apic_intr_mode_select(void) { @@ -1289,7 +1283,9 @@ void __init apic_intr_mode_init(void) { bool upmode = false; - switch (apic_intr_mode_select()) { + apic_intr_mode = apic_intr_mode_select(); + + switch (apic_intr_mode) { case APIC_PIC: pr_info("APIC: keep in PIC mode(8259)\n"); return; diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index a4b072d..b40cf59 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1183,17 +1183,10 @@ static __init void disable_smp(void) cpumask_set_cpu(0, topology_core_cpumask(0)); } -enum { - SMP_OK, - SMP_NO_CONFIG, - SMP_NO_APIC, - SMP_FORCE_UP, -}; - /* * Various sanity checks. */ -static int __init smp_sanity_check(unsigned max_cpus) +static void __init smp_sanity_check(void) { preempt_disable(); @@ -1231,16 +1224,6 @@ static int __init smp_sanity_check(unsigned max_cpus) } /* - * If we couldn't find an SMP configuration at boot time, - * get out of here now! - */ - if (!smp_found_config && !acpi_lapic) { - preempt_enable(); - pr_notice("SMP motherboard not detected\n"); - return SMP_NO_CONFIG; - } - - /* * Should not be necessary because the MP table should list the boot * CPU too, but we do it for the sake of robustness anyway. */ @@ -1250,29 +1233,6 @@ static int __init smp_sanity_check(unsigned max_cpus) physid_set(hard_smp_processor_id(), phys_cpu_present_map); } preempt_enable(); - - /* - * If we couldn't find a local APIC, then get out of here now! - */ - if (APIC_INTEGRATED(boot_cpu_apic_version) && - !boot_cpu_has(X86_FEATURE_APIC)) { - if (!disable_apic) { - pr_err("BIOS bug, local APIC #%d not detected!...\n", - boot_cpu_physical_apicid); - pr_err("... forcing use of dummy APIC emulation (tell your hw vendor)\n"); - } - return SMP_NO_APIC; - } - - /* - * If SMP should be disabled, then really disable it! - */ - if (!max_cpus) { - pr_info("SMP mode deactivated\n"); - return SMP_FORCE_UP; - } - - return SMP_OK; } static void __init smp_cpu_index_default(void) @@ -1331,19 +1291,20 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) apic_intr_mode_init(); - switch (smp_sanity_check(max_cpus)) { - case SMP_NO_CONFIG: - disable_smp(); - return; - case SMP_NO_APIC: + smp_sanity_check(); + + switch (apic_intr_mode) { + case APIC_PIC: + case APIC_VIRTUAL_WIRE_NO_CONFIG: disable_smp(); return; - case SMP_FORCE_UP: + case APIC_SYMMETRIC_IO_NO_ROUTING: disable_smp(); /* Setup local timer */ x86_init.timers.setup_percpu_clockev(); return; - case SMP_OK: + case APIC_VIRTUAL_WIRE: + case APIC_SYMMETRIC_IO: break; }