From patchwork Wed Mar 2 07:34:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 63376 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2242513lbc; Tue, 1 Mar 2016 23:38:12 -0800 (PST) X-Received: by 10.31.5.9 with SMTP id 9mr18747941vkf.109.1456904284990; Tue, 01 Mar 2016 23:38:04 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r21si21609164vke.163.2016.03.01.23.38.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2016 23:38:04 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 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.84) (envelope-from ) id 1ab1LC-0005T1-Au; Wed, 02 Mar 2016 07:37:02 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1ab1LB-0005SL-Fg for xen-devel@lists.xen.org; Wed, 02 Mar 2016 07:37:01 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id F5/E3-13547-C1896D65; Wed, 02 Mar 2016 07:37:00 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1456904214!26168682!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58777 invoked from network); 2 Mar 2016 07:36:59 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-3.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 2 Mar 2016 07:36:59 -0000 Received: from 172.24.1.47 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BXB04027; Wed, 02 Mar 2016 15:35:48 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Wed, 2 Mar 2016 15:35:26 +0800 From: Shannon Zhao To: Date: Wed, 2 Mar 2016 15:34:43 +0800 Message-ID: <1456904083-13168-18-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1456904083-13168-1-git-send-email-zhaoshenglong@huawei.com> References: <1456904083-13168-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.0A090203.56D697D9.00B0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 2601ef3b5f8a04a922a950b45ef120e3 Cc: zhaoshenglong@huawei.com, stefano.stabellini@citrix.com, ian.campbell@citrix.com, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v8 17/17] arm/acpi: Add acpi parameter to enable/disable acpi 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" From: Shannon Zhao Define new command line parameter "acpi" to enable/disable acpi. This implements the following policy to decide whether ACPI should be used to boot the system: - acpi=off: ACPI will not be used to boot the system, even if there is no alternative available (e.g., device tree is empty) - acpi=force: only ACPI will be used to boot the system; if that fails, there will be no fallback to alternative methods (such as device tree) - otherwise, ACPI will be used as a fallback if the device tree turns out to lack a platform description; the heuristic to decide this is whether /chosen is the only node present at depth 1 Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini --- xen/arch/arm/acpi/boot.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index e9321c6..859aa86 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -30,9 +30,11 @@ #include #include #include +#include #include #include +#include /* Processors with enabled flag and sane MPIDR */ static unsigned int enabled_cpus; @@ -174,6 +176,36 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table) return -EINVAL; } +static bool_t __initdata param_acpi_off; +static bool_t __initdata param_acpi_force; + +static void __init parse_acpi_param(char *arg) +{ + if ( !arg ) + return; + + /* Interpret the parameter for use within Xen. */ + if ( !parse_bool(arg) ) + param_acpi_off = true; + else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */ + param_acpi_force = true; +} +custom_param("acpi", parse_acpi_param); + +static int __init dt_scan_depth1_nodes(const void *fdt, int node, + const char *uname, int depth, + u32 address_cells, u32 size_cells, + void *data) +{ + /* + * Return 1 as soon as we encounter a node at depth 1 that is + * not the /chosen node. + */ + if (depth == 1 && (strcmp(uname, "chosen") != 0)) + return 1; + return 0; +} + /* * acpi_boot_table_init() called from setup_arch(), always. * 1. find RSDP and get its address, and then find XSDT @@ -190,6 +222,26 @@ int __init acpi_boot_table_init(void) { int error; + /* + * Enable ACPI instead of device tree unless + * - ACPI has been disabled explicitly (acpi=off), or + * - the device tree is not empty (it has more than just a /chosen node) + * and ACPI has not been force enabled (acpi=force) + */ + if ( param_acpi_off || ( !param_acpi_force + && device_tree_for_each_node(device_tree_flattened, + dt_scan_depth1_nodes, NULL))) + { + disable_acpi(); + return 0; + } + + /* + * ACPI is disabled at this point. Enable it in order to parse + * the ACPI tables. + */ + enable_acpi(); + /* Initialize the ACPI boot-time table parser. */ error = acpi_table_init(); if ( error )