From patchwork Fri Feb 26 06:22:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 63271 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1578185lbc; Mon, 29 Feb 2016 18:33:07 -0800 (PST) X-Received: by 10.107.129.228 with SMTP id l97mr22290862ioi.76.1456799560752; Mon, 29 Feb 2016 18:32:40 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v87si33619646iov.41.2016.02.29.18.32.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Feb 2016 18:32:40 -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 1aZBpw-0007E7-80; Fri, 26 Feb 2016 06:25:12 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aZBpv-0007Cg-1c for xen-devel@lists.xen.org; Fri, 26 Feb 2016 06:25:11 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id FF/1D-02989-6CFEFC65; Fri, 26 Feb 2016 06:25:10 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1456467904!23095618!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15011 invoked from network); 26 Feb 2016 06:25:08 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-8.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 26 Feb 2016 06:25:08 -0000 Received: from 172.24.1.49 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.49]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DFG21625; Fri, 26 Feb 2016 14:24:13 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Fri, 26 Feb 2016 14:24:00 +0800 From: Shannon Zhao To: Date: Fri, 26 Feb 2016 14:22:53 +0800 Message-ID: <1456467780-8476-16-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1456467780-8476-1-git-send-email-zhaoshenglong@huawei.com> References: <1456467780-8476-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.0A020204.56CFEF8E.0109, 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: cbd22e690fb351971bf522d773f7ba48 Cc: peter.huangpeng@huawei.com, stefano.stabellini@citrix.com, ian.campbell@citrix.com, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v5 15/22] arm/gic: Add ACPI support for GIC preinit 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 Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC version filed, it could get GIC version from that. Then call acpi device initializing function to preinit GIC device. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini --- V5: fix coding style and simplify #else case V4: use ACPI_MADT_GIC_VERSION_V* instead of GICv* --- xen/arch/arm/gic.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 43e6fa2..fbbe37f 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,7 @@ #include #include #include +#include static void gic_restore_pending_irqs(struct vcpu *v); @@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, return 0; } -/* Find the interrupt controller and set up the callback to translate - * device tree IRQ. - */ -void __init gic_preinit(void) +static void __init gic_dt_preinit(void) { int rc; struct dt_device_node *node; @@ -261,6 +260,36 @@ void __init gic_preinit(void) dt_device_set_used_by(node, DOMID_XEN); } +#ifdef CONFIG_ACPI +static void __init gic_acpi_preinit(void) +{ + struct acpi_subtable_header *header; + struct acpi_madt_generic_distributor *dist; + + header = acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0); + if ( !header ) + panic("No valid GICD entries exists"); + + dist = container_of(header, struct acpi_madt_generic_distributor, header); + + if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) ) + panic("Unable to find compatible GIC in the ACPI table"); +} +#else +static void __init gic_acpi_preinit(void) { } +#endif + +/* Find the interrupt controller and set up the callback to translate + * device tree or ACPI IRQ. + */ +void __init gic_preinit(void) +{ + if ( acpi_disabled ) + gic_dt_preinit(); + else + gic_acpi_preinit(); +} + /* Set up the GIC */ void __init gic_init(void) {