From patchwork Tue Nov 17 09:40:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56734 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1826356lbb; Tue, 17 Nov 2015 01:46:28 -0800 (PST) X-Received: by 10.31.21.66 with SMTP id 63mr2450305vkv.129.1447753588538; Tue, 17 Nov 2015 01:46:28 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id x77si2022959vkx.201.2015.11.17.01.46.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Nov 2015 01:46:28 -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; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycpE-0004p8-Fx; Tue, 17 Nov 2015 09:45:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZycpD-0004nq-AU for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:45:19 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 25/B2-01753-E27FA465; Tue, 17 Nov 2015 09:45:18 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-6.tower-31.messagelabs.com!1447753517!4205210!1 X-Originating-IP: [74.125.82.43] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51416 invoked from network); 17 Nov 2015 09:45:18 -0000 Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by server-6.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:45:18 -0000 Received: by wmvv187 with SMTP id v187so217840991wmv.1 for ; Tue, 17 Nov 2015 01:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8pDNdCZJ7bDHyHyn9vz6wTT0pkmd9R80pSzQCRy5/6k=; b=r8gk15czheqkAVsknBiVm24QtrMXSxEMJu0IfRY/bzPNDtvfHTKIaX7v89vPdqUAxw oji/eD/QoG9WFbMIlTfWWAJ6EtxJe8XqSO+2Qx87mijt5AThnDjq/cYCN7OCH/olmhrU nmob2fsymZ1pTuVBTzley8JYXl2U/T5AeRx+xoNwLe/kCV7h34gcteaVn8k3AwW82EWH dUTVBIE37SLJqb44O6t2Is37W01ljb6FRzSKdWu9UgrszWGFRvm/XPdwa06jgAAGLWZK EFNMuLM3xErcgp6VdqIJ7hXgoI4MnFiplF9fFU+ok24t1nEoAU2sTWL1L6YpwkQndTU+ XIjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8pDNdCZJ7bDHyHyn9vz6wTT0pkmd9R80pSzQCRy5/6k=; b=E6pvZpNg92FztJHprYEyFnT+/k1F/G1W2wywlqNvhJhH0GJ6sZmlTQNMauZSOYApj2 yKhbOS+Zc17LKmfq7V4NYabV4aSli/VCiCAXSWa5qa/N+VNxRrUEmFEL5qdYDvyDM0rK HT7K0Gi6E9D8Kk/W1mKk7utHuduIXTm4jni64ow89XUq+ADr8wdULoqSkd+K1G4HSvDL TbuLnTpnSaaH8uRq4h4YsuFwFDju1lkEDJmi5ub3EbY2mqZumTq5tys1VtNj9mUPZ1le 41FpAl3gbA60EhGhlqzH/AJqdV9hCjP7YHajaqjw9psfbfkZE4rN5yKkN1hr++xCHv7c S3cw== X-Gm-Message-State: ALoCoQk2PGBRZtvkU8qMdTUTpqSpWExsa7dt7tJh/uuUfGvWSsqJgoqSO0UQ4H+BAbLa1atDaNPU X-Received: by 10.28.4.212 with SMTP id 203mr1534780wme.89.1447753517734; Tue, 17 Nov 2015 01:45:17 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id 123sm3001555wmt.18.2015.11.17.01.45.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:45:17 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:27 +0800 Message-Id: <1447753261-7552-29-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit 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: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC version filed, it could get GIC version from that. According to the version, call different preinit functions. Signed-off-by: Shannon Zhao --- xen/arch/arm/gic.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 1e1e5ba..ac82588 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) +void __init dt_gic_preinit(void) { int rc; struct dt_device_node *node; @@ -261,6 +260,54 @@ void __init gic_preinit(void) dt_device_set_used_by(node, DOMID_XEN); } +#ifdef CONFIG_ACPI +static void __init acpi_gic_preinit(void) +{ + int rc = 0; + acpi_status status; + struct acpi_table_header *table; + struct acpi_subtable_header * subtable; + struct acpi_madt_generic_distributor *dist; + + status = acpi_get_table(ACPI_SIG_MADT, 0, &table); + if ( ACPI_FAILURE(status) ) + { + const char *msg = acpi_format_exception(status); + + panic("Failed to get MADT table, %s", msg); + } + + subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt), + table, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0); + if ( !subtable ) + panic("No valid GICD entries exists"); + + dist = (struct acpi_madt_generic_distributor *)subtable; + + if ( dist->version == ACPI_MADT_GIC_VERSION_V2 ) + rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2); + else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 ) + rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3); + else + panic("Wrong GIC version or unsupported GIC"); + if ( rc ) + panic("Unable to find compatible GIC in the ACPI table"); +} +#else +static void __init acpi_gic_preinit(void) {} +#endif + +/* Find the interrupt controller and set up the callback to translate + * device tree IRQ. + */ +void __init gic_preinit(void) +{ + if( acpi_disabled ) + dt_gic_preinit(); + else + acpi_gic_preinit(); +} + /* Set up the GIC */ void __init gic_init(void) {