From patchwork Tue Nov 17 09:57:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56780 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1831576lbb; Tue, 17 Nov 2015 01:59:17 -0800 (PST) X-Received: by 10.67.22.99 with SMTP id hr3mr61867845pad.10.1447754357665; Tue, 17 Nov 2015 01:59:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rf5si8652772pbc.205.2015.11.17.01.59.17; Tue, 17 Nov 2015 01:59:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753418AbbKQJ7Q (ORCPT + 6 others); Tue, 17 Nov 2015 04:59:16 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:33221 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752726AbbKQJ7L (ORCPT ); Tue, 17 Nov 2015 04:59:11 -0500 Received: by wmec201 with SMTP id c201so218573798wme.0 for ; Tue, 17 Nov 2015 01:59:10 -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=TtoFvU7L4+w9g3Rnm04aToh+WNq7GSEGsSLBs0tLu6k=; b=O/DPtuDAMHoXMTwt5vrsmqatVU1YzzrbS50XAokv8gVII8q4qc7RmMxJupgCn8FZaa 6po3EocVO+sFfjj/chfuvevs8D8t+bGpVurF3StUj5WPR5hB2l33Vp/t4gpJVOR7P1Ej dEdeHBPXwrTg7VDafzVu39ttrTBjdSvbMzv2cizn1wMHmFp+k3p11zuixNI/PHDiu+2J HlGxyQ3AMDStk+Uctps85k+DKuEC8KKB1N5V8hynb0uW0yvXI7ExJoUJz6Dpna0vytvT VT5jGNuKmAr9eoJWOCD3HDkBcqa16yfm7RN0ifHqLvzDCYYS7qzmqwv97/9mo5e8cgcv K8XA== 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=TtoFvU7L4+w9g3Rnm04aToh+WNq7GSEGsSLBs0tLu6k=; b=CzPYBSHajlO1pOhaDzg+7taXFF5kBhjHJNLkDcocm/GMAF6Jt+DOmRKH4TgoqU66/E 2Y2zaUz+2UkOY+PzrTYQjx2s2lMmi+f7yJ/KAyH8aSNdhjFtfFtGvi878b3Xq+0zNDVC bNgcup+7ODMacI5ndNqkhtm1jXSsyNzUrXrj6ykdhL+iW2vDEaJB2Tkt3d/4hUlEHghh ert5B8XPHR/MZxN703RDTDPVx7Fupcp7tEYsbMbqUZs80lbhanviifn+IvpmL+74fP8X jwJBmrZIfXoJoIBaGZ2l8zzbMBlArTByod6yVP2OykzL60jZUy/dqBN/sk9bXFBC1hvI ocIw== X-Gm-Message-State: ALoCoQnU6FkQNe8xfNkFgjvynceQler4AZtQ+0y4VXEPTtjjo1XiMxYN4alO53JUCBZbWzeFb8ge X-Received: by 10.194.91.164 with SMTP id cf4mr41539176wjb.139.1447754350105; Tue, 17 Nov 2015 01:59:10 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id e189sm23135062wma.4.2015.11.17.01.59.07 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:59:09 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, catalin.marinas@arm.com, will.deacon@arm.com, julien.grall@citrix.com, ard.biesheuvel@linaro.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Cc: xen-devel@lists.xen.org, christoffer.dall@linaro.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, peter.huangpeng@huawei.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, hangaohuai@huawei.com Subject: [PATCH 13/13] ARM: XEN: Move xen_early_init() before efi_init() Date: Tue, 17 Nov 2015 17:57:11 +0800 Message-Id: <1447754231-7772-14-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> References: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Shannon Zhao Move xen_early_init() before efi_init(), then when calling efi_init() could initialize Xen specific UEFI. Check if it runs on Xen hypervisor through the flat dts. Signed-off-by: Shannon Zhao --- arch/arm/xen/enlighten.c | 62 ++++++++++++++++++++++++++++++++++++----------- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 49 insertions(+), 15 deletions(-) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index b8e9db8..d4f884c 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -48,8 +49,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata; static __read_mostly unsigned int xen_events_irq; -static __initdata struct device_node *xen_node; - int xen_remap_domain_gfn_array(struct vm_area_struct *vma, unsigned long addr, xen_pfn_t *gfn, int nr, @@ -142,6 +141,34 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) return IRQ_HANDLED; } +struct xen_node_info { + const char *compat; + const char *prefix; + const char *version; + bool found; +}; + +static int __init fdt_find_xen_node(unsigned long node, const char *uname, + int depth, void *data) +{ + struct xen_node_info *info = data; + const void *s = NULL; + int len; + + if (depth != 1 || strcmp(uname, "hypervisor") != 0) + return 0; + + if (of_flat_dt_is_compatible(node, info->compat)) + info->found = true; + + s = of_get_flat_dt_prop(node, "compatible", &len); + if (strlen(info->prefix) + 3 < len && + !strncmp(info->prefix, s, strlen(info->prefix))) + info->version = s + strlen(info->prefix); + + return 0; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -149,26 +176,25 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) #define GRANT_TABLE_PHYSADDR 0 void __init xen_early_init(void) { - int len; - const char *s = NULL; - const char *version = NULL; - const char *xen_prefix = "xen,xen-"; + struct xen_node_info info; + + info.compat = "xen,xen"; + info.prefix = "xen,xen-"; + info.version = NULL; + info.found = false; - xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!xen_node) { + of_scan_flat_dt(fdt_find_xen_node, &info); + if (!info.found) { pr_debug("No Xen support\n"); return; } - s = of_get_property(xen_node, "compatible", &len); - if (strlen(xen_prefix) + 3 < len && - !strncmp(xen_prefix, s, strlen(xen_prefix))) - version = s + strlen(xen_prefix); - if (version == NULL) { + + if (info.version == NULL) { pr_debug("Xen version not found\n"); return; } - pr_info("Xen %s support found\n", version); + pr_info("Xen %s support found\n", info.version); xen_domain_type = XEN_HVM_DOMAIN; @@ -204,6 +230,14 @@ static int __init xen_guest_init(void) } xen_events_irq = a.value & 0xff; } else { + struct device_node *xen_node; + + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { + pr_debug("No Xen support\n"); + return -ENODEV; + } + xen_events_irq = irq_of_parse_and_map(xen_node, 0); if (!xen_events_irq) { pr_err("Xen event channel interrupt not found\n"); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 2322479..ee95593 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -428,6 +428,7 @@ void __init setup_arch(char **cmdline_p) */ local_async_enable(); + xen_early_init(); efi_init(); arm64_memblock_init(); @@ -446,7 +447,6 @@ void __init setup_arch(char **cmdline_p) } else { psci_acpi_init(); } - xen_early_init(); cpu_read_bootcpu_ops(); smp_init_cpus();