linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shannon.zhao@linaro.org (shannon.zhao at linaro.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 13/13] ARM: XEN: Move xen_early_init() before efi_init()
Date: Tue, 17 Nov 2015 17:57:11 +0800	[thread overview]
Message-ID: <1447754231-7772-14-git-send-email-shannon.zhao@linaro.org> (raw)
In-Reply-To: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org>

From: Shannon Zhao <shannon.zhao@linaro.org>

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 <shannon.zhao@linaro.org>
---
 arch/arm/xen/enlighten.c  | 62 ++++++++++++++++++++++++++++++++++++-----------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 49 insertions(+), 15 deletions(-)

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 <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -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();
-- 
2.1.0

  parent reply	other threads:[~2015-11-17  9:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17  9:56 [PATCH 00/13] Add ACPI support for Xen Dom0 on ARM64 shannon.zhao at linaro.org
2015-11-17  9:56 ` [PATCH 01/13] Xen : Hide UART used by Xen shannon.zhao at linaro.org
2015-11-20 16:07   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 02/13] xen/grant-table: Move xlated_setup_gnttab_pages to common place shannon.zhao at linaro.org
2015-11-17 16:02   ` [Xen-devel] " David Vrabel
2015-11-18  4:32     ` Shannon Zhao
2015-11-18 10:38       ` David Vrabel
2015-11-18 12:25   ` Julien Grall
2015-11-18 13:34     ` Shannon Zhao
2015-11-17  9:57 ` [PATCH 03/13] arm/xen: Use xlated_setup_gnttab_pages to setup grant table shannon.zhao at linaro.org
2015-11-20 16:19   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 04/13] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio shannon.zhao at linaro.org
2015-11-17 11:16   ` Ard Biesheuvel
2015-11-17  9:57 ` [PATCH 05/13] Xen: ARM: Add support for mapping platform device mmio shannon.zhao at linaro.org
2015-11-17 16:32   ` [Xen-devel] " David Vrabel
2015-11-18  6:11     ` Shannon Zhao
     [not found]   ` <20151117143822.GH3003@char.us.oracle.com>
2015-11-18  5:48     ` Shannon Zhao
2015-11-20 16:30   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 06/13] Xen: ARM: Add support for mapping amba " shannon.zhao at linaro.org
2015-11-17 16:36   ` [Xen-devel] " David Vrabel
     [not found]   ` <20151117144040.GI3003@char.us.oracle.com>
2015-11-18  6:03     ` Shannon Zhao
2015-11-18 12:27       ` Julien Grall
2015-11-18 13:15         ` Shannon Zhao
2015-11-20 16:39   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 07/13] ARM: Xen: Document UEFI support on Xen ARM virtual platforms shannon.zhao at linaro.org
2015-11-17 16:46   ` [Xen-devel] " David Vrabel
2015-11-18  6:33     ` Shannon Zhao
2015-11-20 16:42     ` Stefano Stabellini
2015-11-17 20:44   ` Rob Herring
2015-11-18  6:24     ` Shannon Zhao
2015-11-17  9:57 ` [PATCH 08/13] Xen: EFI: Parse DT parameters for Xen specific UEFI shannon.zhao at linaro.org
2015-11-17 11:25   ` Ard Biesheuvel
2015-11-17 11:37     ` Mark Rutland
2015-11-17 12:17       ` Ard Biesheuvel
2015-11-18  6:26         ` Shannon Zhao
2015-11-20 17:04   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 09/13] ARM: Xen: Initialize Xen specific UEFI runtime services shannon.zhao at linaro.org
2015-11-17 11:28   ` Ard Biesheuvel
2015-11-17 12:17     ` Shannon Zhao
2015-11-20 16:57   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 10/13] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI shannon.zhao at linaro.org
2015-11-20 17:20   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 11/13] xen/hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ shannon.zhao at linaro.org
2015-11-20 17:07   ` Stefano Stabellini
2015-11-20 17:22     ` [Xen-devel] " Andrew Cooper
2015-11-20 17:32       ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 12/13] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI shannon.zhao at linaro.org
2015-11-20 17:11   ` Stefano Stabellini
2015-11-24  3:49     ` Shannon Zhao
2015-11-17  9:57 ` shannon.zhao at linaro.org [this message]
2015-11-20 17:30   ` [PATCH 13/13] ARM: XEN: Move xen_early_init() before efi_init() Stefano Stabellini
2015-11-24  3:50     ` Shannon Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447754231-7772-14-git-send-email-shannon.zhao@linaro.org \
    --to=shannon.zhao@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).