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: 7635151 Return-Path: X-Original-To: patchwork-linux-arm@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 4B59F9F1D3 for ; Tue, 17 Nov 2015 10:19:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69EE0204E0 for ; Tue, 17 Nov 2015 10:19:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65702203C0 for ; Tue, 17 Nov 2015 10:19:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZydJu-0004B7-Cp; Tue, 17 Nov 2015 10:17:02 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZycpX-00009z-3F for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:45:47 +0000 Received: by wmec201 with SMTP id c201so217997337wme.0 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=ZBt+YaspIghru0PxTiIW25lvXRSfb7t+SaFhotWz/jeYvRGcRSaj3mttvwbQrRtekE UkZKIe7uWVNEf716AhVHltRnDReRNvoxHMZxbT2AdQKCHODxq8B5pGrsg/DLQdbddU5f kSbQU0dNwrssIIwXcLdMmsGm8dNcpVLf/EHACK8Vyn0SGxCDWaLHmeSsBuzeKYyYOdwK Yixnvsym8Fdl2xMi9B4ws2LPcTSUCmPkhdtl+0GCmbcRmsXCP6X07g5Nz69jsSNHOaGN fAn6btAuhB24IzP+5WJOgvQJhnHC7E+PbCqSoOLaAZmTWiKWpRPBv7o34XtIE6FDzACI fcjA== X-Gm-Message-State: ALoCoQnymUoBIo/czyRGiWC4nTZLkx/r1S4l7phTQlR9ty1l8FQdVdXSqqNzPRRX69QtTZu7nWjw 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 Subject: [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_014540_165774_1EA289B6 X-CRM114-Status: GOOD ( 15.30 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 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(-) 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) {