From patchwork Sat Aug 31 10:15:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 19650 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8DD2B25E41 for ; Sat, 31 Aug 2013 10:18:10 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id i72sf47998yha.2 for ; Sat, 31 Aug 2013 03:18:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=nub+9jC3j6clTh/Leu16jCj3Vv3qVJetvde+qy6LiBI=; b=nNF+JagNdZtMtftjjCzzAqUIQDYhW1X8+1AxxihrGuDX5ZRk/XkUpMm6ibd6DbcKOX D0MGRdA9vB7Q+nyIGv3jz46FkTEwYUyNSw2ZgWjbv5y+0IEMZ9K4Cl3zz41m9ANGJo96 ARzAAVMxvQUUf7GwS+2i80t+pzu5rZJv6QxFFXie+KoDo723/GxeJvqE9b+DNwGS8Gjh RtLe/8aAvsnhUfW6fjrir9VPsDPmeAzOz4KQafm0uAwAtmvExEwrD22at1N1CWF3N7+U rYrd7W9SomaIIdv3HisFQ5Rcy6VoNJuTDlZ6RQGXWYEAUnxKDq6jVjimOoJwSwe98HW0 Ys8A== X-Received: by 10.224.52.6 with SMTP id f6mr14627401qag.2.1377944290043; Sat, 31 Aug 2013 03:18:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.104.198 with SMTP id gg6ls1711429qeb.89.gmail; Sat, 31 Aug 2013 03:18:09 -0700 (PDT) X-Received: by 10.52.249.102 with SMTP id yt6mr10031663vdc.21.1377944289931; Sat, 31 Aug 2013 03:18:09 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id se9si704081vdc.23.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Aug 2013 03:18:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id hz10so1913763vcb.40 for ; Sat, 31 Aug 2013 03:18:09 -0700 (PDT) X-Gm-Message-State: ALoCoQndW20DxOlbcGgfrsj/MbkAoNjCk4bh2CaYrCV3qBkmqmGtlT7F0fsCn5vBDNL9vEX1khr+ X-Received: by 10.52.92.73 with SMTP id ck9mr9984523vdb.2.1377944289763; Sat, 31 Aug 2013 03:18:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp15996vcz; Sat, 31 Aug 2013 03:18:09 -0700 (PDT) X-Received: by 10.68.76.34 with SMTP id h2mr14904495pbw.20.1377944288714; Sat, 31 Aug 2013 03:18:08 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id ua7si2467961pac.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Aug 2013 03:18:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id kl13so3259579pab.20 for ; Sat, 31 Aug 2013 03:18:08 -0700 (PDT) X-Received: by 10.68.244.2 with SMTP id xc2mr14817288pbc.58.1377944287972; Sat, 31 Aug 2013 03:18:07 -0700 (PDT) Received: from localhost ([218.17.215.175]) by mx.google.com with ESMTPSA id ef10sm3723468pac.1.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 31 Aug 2013 03:18:07 -0700 (PDT) From: Hanjun Guo To: "Rafael J. Wysocki" Cc: Thomas Gleixner , Tony Luck , Ingo Molnar , linux-acpi@vger.kernel.org, x86@kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linaro-acpi@lists.linaro.org, Jiang Liu , Hanjun Guo Subject: [PATCH 1/6] ACPI / processor: Introduce apic_id in struct processor to save parsed APIC id Date: Sat, 31 Aug 2013 18:15:56 +0800 Message-Id: <1377944162-18574-1-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Jiang Liu For cpu hot add, we evaluate _MAT or parse MADT twice to get APIC id, here is the code logic: acpi_processor_add() acpi_processor_get_info() acpi_get_cpuid() will evaluate _MAT or parse MADT; acpi_processor_hotadd_init() acpi_map_lsapic() will evaluate _MAT again; This can be done more effectively, this patch introduces apic_id in struct processor to save parsed APIC id, and then we can use it and remove the duplicated _MAT evaluation. Signed-off-by: Jiang Liu Signed-off-by: Hanjun Guo --- drivers/acpi/acpi_processor.c | 3 ++- drivers/acpi/processor_core.c | 26 +++++++++++++++++++++----- include/acpi/processor.h | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index f29e06e..d5a6c81 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -270,7 +270,8 @@ static int acpi_processor_get_info(struct acpi_device *device) device_declaration = 1; pr->acpi_id = value; } - cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); + pr->apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); + cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); /* Handle UP system running SMP kernel, with no LAPIC in MADT */ if (!cpu0_initialized && (cpu_index == -1) && diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index cf34d90..b3171f3 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -162,16 +162,23 @@ exit: return apic_id; } -int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) +int acpi_get_apicid(acpi_handle handle, int type, u32 acpi_id) { -#ifdef CONFIG_SMP - int i; -#endif - int apic_id = -1; + int apic_id; apic_id = map_mat_entry(handle, type, acpi_id); if (apic_id == -1) apic_id = map_madt_entry(type, acpi_id); + + return apic_id; +} + +int acpi_map_cpuid(int apic_id, u32 acpi_id) +{ +#ifdef CONFIG_SMP + int i; +#endif + if (apic_id == -1) { /* * On UP processor, there is no _MAT or MADT table. @@ -211,6 +218,15 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) #endif return -1; } + +int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) +{ + int apic_id; + + apic_id = acpi_get_apicid(handle, type, acpi_id); + + return acpi_map_cpuid(apic_id, acpi_id); +} EXPORT_SYMBOL_GPL(acpi_get_cpuid); static bool __init processor_physically_present(acpi_handle handle) diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 66096d0..7816e45 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -199,6 +199,7 @@ struct acpi_processor_flags { struct acpi_processor { acpi_handle handle; u32 acpi_id; + u32 apic_id; u32 id; u32 pblk; int performance_platform_limit; @@ -314,6 +315,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) /* in processor_core.c */ void acpi_processor_set_pdc(acpi_handle handle); +int acpi_get_apicid(acpi_handle, int type, u32 acpi_id); +int acpi_map_cpuid(int apic_id, u32 acpi_id); int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); /* in processor_throttling.c */