linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: <xen-devel@lists.xensource.com>
Cc: <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <will.deacon@arm.com>,
	<arnd@arndb.de>, <nicolas.pitre@linaro.org>,
	<Stefano.Stabellini@eu.citrix.com>, <rob.herring@calxeda.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v6 4/4] xen/arm: introduce xen_early_init, use PSCI on xen
Date: Fri, 5 Apr 2013 14:11:35 +0100	[thread overview]
Message-ID: <1365167495-18508-4-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1304031239550.5078@kaball.uk.xensource.com>

Split xen_guest_init in two functions, one of them (xen_early_init) is
going to be called very early from setup_arch.

Change machine_desc->smp_init to xen_smp_init if Xen is present on the
platform. xen_smp_init just sets smp_ops to psci_smp_ops.

XEN selects ARM_PSCI.

Changes in v6:
- xen_smp_init: call smp_set_ops only ifdef CONFIG_SMP;
- move more of the initialization to xen_guest_init;
- select ARM_PSCI if XEN.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/Kconfig                      |    1 +
 arch/arm/include/asm/xen/hypervisor.h |    6 +++++
 arch/arm/kernel/setup.c               |    3 ++
 arch/arm/xen/enlighten.c              |   36 +++++++++++++++++++++++++-------
 4 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2c3bdce..344e299 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1892,6 +1892,7 @@ config XEN
 	depends on ARM && AEABI && OF
 	depends on CPU_V7 && !CPU_V6
 	depends on !GENERIC_ATOMIC64
+	select ARM_PSCI
 	help
 	  Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
 
diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
index d7ab99a..17b3ea2 100644
--- a/arch/arm/include/asm/xen/hypervisor.h
+++ b/arch/arm/include/asm/xen/hypervisor.h
@@ -16,4 +16,10 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
 	return PARAVIRT_LAZY_NONE;
 }
 
+#ifdef CONFIG_XEN
+void xen_early_init(void);
+#else
+static inline void xen_early_init(void) { return; }
+#endif
+
 #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 2f738cb..336305e 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -55,6 +55,8 @@
 #include <asm/unwind.h>
 #include <asm/memblock.h>
 #include <asm/virt.h>
+#include <asm/xen/hypervisor.h>
+#include <xen/xen.h>
 
 #include "atags.h"
 #include "tcm.h"
@@ -768,6 +770,7 @@ void __init setup_arch(char **cmdline_p)
 
 	arm_dt_init_cpu_maps();
 	psci_init();
+	xen_early_init();
 #ifdef CONFIG_SMP
 	if (is_smp()) {
 		if (mdesc->smp_init)
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index b002822..fc1bc2a 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -11,6 +11,8 @@
 #include <xen/xenbus.h>
 #include <xen/page.h>
 #include <xen/xen-ops.h>
+#include <asm/mach/arch.h>
+#include <asm/psci.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 #include <linux/interrupt.h>
@@ -176,11 +178,33 @@ static int __init xen_secondary_init(unsigned int cpu)
 	return 0;
 }
 
+static void __init xen_smp_init(void)
+{
+#ifdef CONFIG_SMP
+	if (psci_smp_available())
+		smp_set_ops(&psci_smp_ops);
+#endif
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
  */
 #define GRANT_TABLE_PHYSADDR 0
+void __init xen_early_init(void)
+{
+	struct device_node *node;
+
+	node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!node) {
+		pr_debug("No Xen support\n");
+		return;
+	}
+
+	xen_domain_type = XEN_HVM_DOMAIN;
+	machine_desc->smp_init = xen_smp_init;
+}
+
 static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
@@ -194,25 +218,21 @@ static int __init xen_guest_init(void)
 	int i;
 
 	node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!node) {
-		pr_debug("No Xen support\n");
-		return 0;
-	}
+
 	s = of_get_property(node, "compatible", &len);
 	if (strlen(xen_prefix) + 3  < len &&
 			!strncmp(xen_prefix, s, strlen(xen_prefix)))
 		version = s + strlen(xen_prefix);
 	if (version == NULL) {
-		pr_debug("Xen version not found\n");
-		return 0;
+		pr_warn("Xen version not found\n");
+		return -EINVAL;
 	}
 	if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res))
-		return 0;
+		return -EINVAL;
 	xen_hvm_resume_frames = res.start >> PAGE_SHIFT;
 	xen_events_irq = irq_of_parse_and_map(node, 0);
 	pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n",
 			version, xen_events_irq, xen_hvm_resume_frames);
-	xen_domain_type = XEN_HVM_DOMAIN;
 
 	xen_setup_features();
 	if (xen_feature(XENFEAT_dom0))
-- 
1.7.2.5


  parent reply	other threads:[~2013-04-05 13:12 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 13:10 [PATCH 0/4 v6] arm: introduce psci_smp_ops and use them on Xen Stefano Stabellini
2013-04-05 13:11 ` [PATCH v6 1/4] arm: introduce psci_smp_ops Stefano Stabellini
2013-04-18 16:13   ` Russell King - ARM Linux
2013-04-18 16:20     ` Stefano Stabellini
2013-04-18 16:35       ` Nicolas Pitre
2013-04-18 16:49         ` Stefano Stabellini
2013-04-18 17:40           ` Nicolas Pitre
2013-04-22 14:23           ` Russell King - ARM Linux
2013-04-22 14:20         ` Russell King - ARM Linux
2013-04-18 16:40       ` Nicolas Pitre
2013-04-18 17:01         ` Stefano Stabellini
2013-04-18 17:38           ` Nicolas Pitre
2013-04-19  9:40             ` Stefano Stabellini
2013-04-19 15:47               ` Nicolas Pitre
2013-04-19 16:16                 ` [Xen-devel] " Ian Campbell
2013-04-19 16:33                   ` Nicolas Pitre
2013-04-19 17:06                     ` Stefano Stabellini
2013-04-22 15:21                       ` Ian Campbell
2013-04-22 16:07                         ` Nicolas Pitre
2013-04-24 18:13                           ` Stefano Stabellini
2013-04-25  7:48                           ` Ian Campbell
2013-04-19  9:52             ` Ian Campbell
2013-04-22 14:06       ` Russell King - ARM Linux
2013-04-24 18:25         ` Stefano Stabellini
2013-04-05 13:11 ` [PATCH v6 2/4] arm: prefer psci_smp_ops over mdesc->smp Stefano Stabellini
2013-04-05 16:15   ` Nicolas Pitre
2013-04-05 13:11 ` [PATCH v6 3/4] ARM: Enable selection of SMP operations at boot time Stefano Stabellini
2013-04-09 20:03   ` Nicolas Pitre
2013-04-05 13:11 ` Stefano Stabellini [this message]
2013-04-05 16:22   ` [PATCH v6 4/4] xen/arm: introduce xen_early_init, use PSCI on xen Nicolas Pitre
2013-04-05 17:16     ` Stefano Stabellini
2013-04-05 17:34       ` Stefano Stabellini
2013-04-05 19:41         ` Nicolas Pitre
2013-04-05 19:36       ` Nicolas Pitre
2013-04-05 20:50         ` Rob Herring
2013-04-05 21:21           ` Nicolas Pitre
2013-04-05 23:20             ` Stefano Stabellini
2013-04-06  0:15               ` Nicolas Pitre
2013-04-05 23:15           ` Stefano Stabellini
2013-04-05 16:01 ` [PATCH 0/4 v6] arm: introduce psci_smp_ops and use them on Xen Stefano Stabellini
2013-04-08 11:05 ` Stefano Stabellini
2013-04-11  8:25   ` Olof Johansson
2013-04-11 20:16     ` Rob Herring
2013-04-12  8:57       ` Will Deacon
2013-04-12 10:58         ` Stefano Stabellini
2013-04-12 14:13         ` Rob Herring

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=1365167495-18508-4-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=rob.herring@calxeda.com \
    --cc=will.deacon@arm.com \
    --cc=xen-devel@lists.xensource.com \
    /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).