Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932082AbdC2O4A (ORCPT ); Wed, 29 Mar 2017 10:56:00 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:34031 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752538AbdC2Oz6 (ORCPT ); Wed, 29 Mar 2017 10:55:58 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17139553" From: Dou Liyang To: , CC: , , , , , , Dou Liyang Subject: [RFC PATCH 3/6] x86/apic: Extract APIC timer related code from apic_bsp_setup() Date: Wed, 29 Mar 2017 22:55:30 +0800 Message-ID: <1490799333-18242-4-git-send-email-douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1490799333-18242-1-git-send-email-douly.fnst@cn.fujitsu.com> References: <1490799333-18242-1-git-send-email-douly.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 61EFC47EE1E3.A4A40 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3226 Lines: 109 The apic_bsp_setup() contains the APIC timer related code, which leads to hard reuse the local APIC and I/O APIC setup independently. Extract the related code to a single function for setuping APIC in advance. Signed-off-by: Dou Liyang --- arch/x86/include/asm/io_apic.h | 2 ++ arch/x86/kernel/apic/apic.c | 28 +++++++++++++++++++++------- arch/x86/kernel/apic/io_apic.c | 4 +--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h index 6cbf2cf..535ca00 100644 --- a/arch/x86/include/asm/io_apic.h +++ b/arch/x86/include/asm/io_apic.h @@ -189,6 +189,7 @@ static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) return x86_io_apic_ops.read(apic, reg); } +extern void check_timer(void); extern void setup_IO_APIC(void); extern void enable_IO_APIC(void); extern void disable_IO_APIC(void); @@ -230,6 +231,7 @@ static inline void io_apic_init_mappings(void) { } #define native_io_apic_read NULL #define native_disable_io_apic NULL +static inline void check_timer(void) { } static inline void setup_IO_APIC(void) { } static inline void enable_IO_APIC(void) { } static inline void setup_ioapic_dest(void) { } diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index bf4ccd0..0ba8a85 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2324,6 +2324,25 @@ static void __init apic_bsp_up_setup(void) physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); } +/* Setup local APIC timer and get the Id*/ +static int __init apic_bsp_timer_setup(void) +{ + int id; + + if (x2apic_mode) + id = apic_read(APIC_LDR); + else + id = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR)); + + if (!skip_ioapic_setup && nr_ioapics && nr_legacy_irqs()) + check_timer(); + + /* Setup local timer */ + x86_init.timers.setup_percpu_clockev(); + + return id; +} + /** * apic_bsp_setup - Setup function for local apic and io-apic * @upmode: Force UP mode (for APIC_init_uniprocessor) @@ -2340,17 +2359,12 @@ int __init apic_bsp_setup(bool upmode) apic_bsp_up_setup(); setup_local_APIC(); - if (x2apic_mode) - id = apic_read(APIC_LDR); - else - id = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR)); - enable_IO_APIC(); end_local_APIC_setup(); irq_remap_enable_fault_handling(); setup_IO_APIC(); - /* Setup local timer */ - x86_init.timers.setup_percpu_clockev(); + + id = apic_bsp_timer_setup(); return id; } diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 347bb9f..e19b88f 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2047,7 +2047,7 @@ static int mp_alloc_timer_irq(int ioapic, int pin) * * FIXME: really need to revamp this for all platforms. */ -static inline void __init check_timer(void) +void __init check_timer(void) { struct irq_data *irq_data = irq_get_irq_data(0); struct mp_chip_data *data = irq_data->chip_data; @@ -2278,8 +2278,6 @@ void __init setup_IO_APIC(void) sync_Arb_IDs(); setup_IO_APIC_irqs(); init_IO_APIC_traps(); - if (nr_legacy_irqs()) - check_timer(); ioapic_initialized = 1; } -- 2.5.5