From patchwork Sat Jan 23 09:20:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8096311 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 842549F1CC for ; Sat, 23 Jan 2016 09:28:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BFF3205E4 for ; Sat, 23 Jan 2016 09:28:13 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FCA6205E8 for ; Sat, 23 Jan 2016 09:28:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMuSY-0000S6-Ts; Sat, 23 Jan 2016 09:26:18 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aMuSX-0000R9-V2 for xen-devel@lists.xen.org; Sat, 23 Jan 2016 09:26:18 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 92/61-03225-93743A65; Sat, 23 Jan 2016 09:26:17 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1453541162!17621817!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 56348 invoked from network); 23 Jan 2016 09:26:15 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jan 2016 09:26:15 -0000 Received: from 172.24.1.51 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DDP82362; Sat, 23 Jan 2016 17:22:37 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.235.1; Sat, 23 Jan 2016 17:22:26 +0800 From: Shannon Zhao To: Date: Sat, 23 Jan 2016 17:20:13 +0800 Message-ID: <1453540813-15764-22-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1453540813-15764-1-git-send-email-zhaoshenglong@huawei.com> References: <1453540813-15764-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.0A090201.56A3465E.002F, 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: 38e36d34fbf9193ea08b7fe12106468c Cc: ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@citrix.com, stefano.stabellini@citrix.com, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v4 21/21] arm/acpi: Add acpi parameter to enable/disable acpi 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- V4: be consistent with Linux --- 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 c9135f2..8eb6c37 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; @@ -182,6 +184,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 @@ -198,6 +230,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 )