From patchwork Sat Jan 16 05:01:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 59900 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp932009lbb; Fri, 15 Jan 2016 21:07:54 -0800 (PST) X-Received: by 10.194.116.170 with SMTP id jx10mr13067155wjb.166.1452920873620; Fri, 15 Jan 2016 21:07:53 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id g2si22453032wjb.166.2016.01.15.21.07.53 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jan 2016 21:07:53 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aKJ3p-0007CL-Up; Sat, 16 Jan 2016 05:06:01 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aKJ3o-0007By-LS for xen-devel@lists.xen.org; Sat, 16 Jan 2016 05:06:00 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 68/BA-24494-7BFC9965; Sat, 16 Jan 2016 05:05:59 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1452920754!15939717!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14154 invoked from network); 16 Jan 2016 05:05:58 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jan 2016 05:05:58 -0000 Received: from 172.24.1.51 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DDC66672; Sat, 16 Jan 2016 13:02:24 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Sat, 16 Jan 2016 13:02:14 +0800 From: Shannon Zhao To: Date: Sat, 16 Jan 2016 13:01:09 +0800 Message-ID: <1452920477-13916-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1452920477-13916-1-git-send-email-zhaoshenglong@huawei.com> References: <1452920477-13916-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5699CEE1.001D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2cba635734eaf14b1f10533e1fd47d56 Cc: ian.campbell@citrix.com, peter.huangpeng@huawei.com, julien.grall@citrix.com, stefano.stabellini@citrix.com, shannon.zhao@linaro.org, Jan Beulich Subject: [Xen-devel] [PATCH v4 02/10] ACPI / table: Add new function to get table entries X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Ashwin Chaugule The acpi_table_parse() function has a callback that passes a pointer to a table_header. Add a new function which takes this pointer and parses its entries. This eliminates the need to re-traverse all the tables for each call. e.g. as in acpi_table_parse_madt() which is normally called after acpi_table_parse(). Acked-by: Grant Likely Signed-off-by: Ashwin Chaugule Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo Signed-off-by: Rafael J. Wysocki [Linux commit f08bb472bff3c0397fb7d6f47bc5cec41dad76e3] Signed-off-by: Shannon Zhao --- Cc: Jan Beulich --- xen/drivers/acpi/tables.c | 50 +++++++++++++++++++++++++++++++++++------------ xen/include/xen/acpi.h | 4 ++++ 2 files changed, 42 insertions(+), 12 deletions(-) -- 2.0.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c index 39f1223..4e590de 100644 --- a/xen/drivers/acpi/tables.c +++ b/xen/drivers/acpi/tables.c @@ -199,27 +199,23 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header) int __init -acpi_table_parse_entries(char *id, - unsigned long table_size, - int entry_id, - acpi_table_entry_handler handler, - unsigned int max_entries) +acpi_parse_entries(char *id, unsigned long table_size, + acpi_table_entry_handler handler, + struct acpi_table_header *table_header, + int entry_id, unsigned int max_entries) { - struct acpi_table_header *table_header = NULL; struct acpi_subtable_header *entry; - unsigned int count = 0; + int count = 0; unsigned long table_end; if (acpi_disabled) return -ENODEV; - if (!handler) + if (!id || !handler) return -EINVAL; - if (strncmp(id, ACPI_SIG_MADT, 4) == 0) - acpi_get_table(id, acpi_apic_instance, &table_header); - else - acpi_get_table(id, 0, &table_header); + if (!table_size) + return -EINVAL; if (!table_header) { printk(KERN_WARNING PREFIX "%4.4s not present\n", id); @@ -252,6 +248,7 @@ acpi_table_parse_entries(char *id, entry = (struct acpi_subtable_header *) ((unsigned long)entry + entry->length); } + if (max_entries && count > max_entries) { printk(KERN_WARNING PREFIX "[%4.4s:%#x] ignored %i entries of " "%i found\n", id, entry_id, count - max_entries, count); @@ -261,6 +258,35 @@ acpi_table_parse_entries(char *id, } int __init +acpi_table_parse_entries(char *id, + unsigned long table_size, + int entry_id, + acpi_table_entry_handler handler, + unsigned int max_entries) +{ + struct acpi_table_header *table_header = NULL; + u32 instance = 0; + + if (acpi_disabled) + return -ENODEV; + + if (!id || !handler) + return -EINVAL; + + if (!strncmp(id, ACPI_SIG_MADT, 4)) + instance = acpi_apic_instance; + + acpi_get_table(id, instance, &table_header); + if (!table_header) { + printk(KERN_WARNING PREFIX "%4.4s not present\n", id); + return -ENODEV; + } + + return acpi_parse_entries(id, table_size, handler, table_header, + entry_id, max_entries); +} + +int __init acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries) { diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index 0f1077d..65e53a6 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -64,6 +64,10 @@ void acpi_hest_init(void); int acpi_table_init (void); int acpi_table_parse(char *id, acpi_table_handler handler); +int acpi_parse_entries(char *id, unsigned long table_size, + acpi_table_entry_handler handler, + struct acpi_table_header *table_header, + int entry_id, unsigned int max_entries); int acpi_table_parse_entries(char *id, unsigned long table_size, int entry_id, acpi_table_entry_handler handler, unsigned int max_entries); int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);