From patchwork Sun Nov 4 15:24:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1694541 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EA99FDF230 for ; Sun, 4 Nov 2012 15:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755023Ab2KDPZn (ORCPT ); Sun, 4 Nov 2012 10:25:43 -0500 Received: from mail-da0-f46.google.com ([209.85.210.46]:40017 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755341Ab2KDPZI (ORCPT ); Sun, 4 Nov 2012 10:25:08 -0500 Received: by mail-da0-f46.google.com with SMTP id n41so2322643dak.19 for ; Sun, 04 Nov 2012 07:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=UXtV4bS8+uySd+RROSTm0Lgensoy1LixovLsYVvMNBc=; b=ESz7DDTSf2si28rseiFh7HRRA+2HeeH7OSe/n3zPC8cu8Qq1fshMH9Ub9E4/zbhRkH 9twiuuVg+0syczKiSBRE80H4MBn6B0bow/Q2E9fMGXcqB/G2xsFN9NDv6opHzbvZ8MO8 EAJX3mN9Ja0YTnAne9PQKTvHvV86aZm4KtIgSVgmqRzPxlk9tVlCzm1vBHLJ/tzBKWUH V+turF3cIX9DgdwvuSTSxlTsh+pBcsQRaJkJdX7oRUKSVwOfS4qc1d1Y79o5tiIcnShp z6GXxvH0gDj7eLPZa1P4Jabj+1Tt3h2KWswxCtP6wbW4kx9kFe3MbLfDlkhvsSHaH+sv Vf2g== Received: by 10.68.225.5 with SMTP id rg5mr22637847pbc.73.1352042708369; Sun, 04 Nov 2012 07:25:08 -0800 (PST) Received: from localhost.localdomain ([120.196.98.117]) by mx.google.com with ESMTPS id nd6sm9020763pbc.68.2012.11.04.07.25.03 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Nov 2012 07:25:07 -0800 (PST) From: Jiang Liu To: "Rafael J . Wysocki" , Yinghai Lu , Tony Luck , Yasuaki Ishimatsu , Wen Congyang , Tang Chen , Taku Izumi , Bjorn Helgaas Cc: Jiang Liu , Kenji Kaneshige , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Yijing Wang , Hanjun Guo , Jiang Liu , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Subject: [ACPIHP PATCH part4 9/9] x86: simplify _acpi_map_lsapic() implementation Date: Sun, 4 Nov 2012 23:24:02 +0800 Message-Id: <1352042642-7306-10-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> References: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Simplify implementation of function _acpi_map_lsapic(). Signed-off-by: Jiang Liu --- arch/x86/include/asm/mpspec.h | 2 +- arch/x86/kernel/acpi/boot.c | 44 +++++++++-------------------------------- arch/x86/kernel/apic/apic.c | 8 +++++--- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h index 3e2f42a..f1d6487 100644 --- a/arch/x86/include/asm/mpspec.h +++ b/arch/x86/include/asm/mpspec.h @@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { } #define default_get_smp_config x86_init_uint_noop #endif -void __cpuinit generic_processor_info(int apicid, int version); +int __cpuinit generic_processor_info(int apicid, int version); #ifdef CONFIG_ACPI extern void mp_register_ioapic(int id, u32 address, u32 gsi_base); extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 5e76952..f354446 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -195,24 +195,24 @@ static int __init acpi_parse_madt(struct acpi_table_header *table) return 0; } -static void __cpuinit acpi_register_lapic(int id, u8 enabled) +static int __cpuinit acpi_register_lapic(int id, u8 enabled) { unsigned int ver = 0; if (id >= (MAX_LOCAL_APIC-1)) { printk(KERN_INFO PREFIX "skipped apicid that is too big\n"); - return; + return -1; } if (!enabled) { ++disabled_cpus; - return; + return -1; } if (boot_cpu_physical_apicid != -1U) ver = apic_version[boot_cpu_physical_apicid]; - generic_processor_info(id, ver); + return generic_processor_info(id, ver); } static int __init @@ -610,44 +610,19 @@ static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) { - cpumask_var_t tmp_map, new_map; int cpu; - int retval = -ENOMEM; - if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL)) - goto out; - - if (!alloc_cpumask_var(&new_map, GFP_KERNEL)) - goto free_tmp_map; - - cpumask_copy(tmp_map, cpu_present_mask); - acpi_register_lapic(physid, ACPI_MADT_ENABLED); - - /* - * If acpi_register_lapic successfully generates a new logical cpu - * number, then the following will get us exactly what was mapped - */ - cpumask_andnot(new_map, cpu_present_mask, tmp_map); - if (cpumask_empty(new_map)) { + cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED); + if (cpu == -1) { printk ("Unable to map lapic to logical cpu number\n"); - retval = -EINVAL; - goto free_new_map; + return -EINVAL; } acpi_processor_set_pdc(handle); - - cpu = cpumask_first(new_map); acpi_map_cpu2node(handle, cpu, physid); - *pcpu = cpu; - retval = 0; - -free_new_map: - free_cpumask_var(new_map); -free_tmp_map: - free_cpumask_var(tmp_map); -out: - return retval; + + return 0; } /* wrapper to silence section mismatch warning */ @@ -665,7 +640,6 @@ int acpi_unmap_lsapic(int cpu) return (0); } - EXPORT_SYMBOL(acpi_unmap_lsapic); #endif /* CONFIG_ACPI_HOTPLUG_CPU */ diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index b17416e..9fdc293 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2030,7 +2030,7 @@ void disconnect_bsp_APIC(int virt_wire_setup) apic_write(APIC_LVT1, value); } -void __cpuinit generic_processor_info(int apicid, int version) +int __cpuinit generic_processor_info(int apicid, int version) { int cpu, max = nr_cpu_ids; bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, @@ -2050,7 +2050,7 @@ void __cpuinit generic_processor_info(int apicid, int version) " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); disabled_cpus++; - return; + return -1; } if (num_processors >= nr_cpu_ids) { @@ -2061,7 +2061,7 @@ void __cpuinit generic_processor_info(int apicid, int version) " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); disabled_cpus++; - return; + return -1; } num_processors++; @@ -2106,6 +2106,8 @@ void __cpuinit generic_processor_info(int apicid, int version) #endif set_cpu_possible(cpu, true); set_cpu_present(cpu, true); + + return cpu; } int hard_smp_processor_id(void)