aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2012-09-14 07:13:12 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-09-17 10:04:04 -0400
commitecc635f90adfe1b7cd5fd354f49edfbf24aa4e3e (patch)
tree541a0ea9d95cf25eb45e2c8d33a3111a623f9ad1
parente58f5b55113b8fd4eb8eb43f5508d87e4862f280 (diff)
xen/arm: compile and run xenbus
bind_evtchn_to_irqhandler can legitimately return 0 (irq 0): it is not an error. If Linux is running as an HVM domain and is running as Dom0, use xenstored_local_init to initialize the xenstore page and event channel. Changes in v4: - do not xs_reset_watches on dom0. Changes in v2: - refactor xenbus_init. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> [v5: Fixed case switch indentations] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--drivers/xen/xenbus/xenbus_comms.c2
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c52
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c3
3 files changed, 41 insertions, 16 deletions
diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c
index 52fe7ad07666..c5aa55c5d371 100644
--- a/drivers/xen/xenbus/xenbus_comms.c
+++ b/drivers/xen/xenbus/xenbus_comms.c
@@ -224,7 +224,7 @@ int xb_init_comms(void)
224 int err; 224 int err;
225 err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting, 225 err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting,
226 0, "xenbus", &xb_waitq); 226 0, "xenbus", &xb_waitq);
227 if (err <= 0) { 227 if (err < 0) {
228 printk(KERN_ERR "XENBUS request irq failed %i\n", err); 228 printk(KERN_ERR "XENBUS request irq failed %i\n", err);
229 return err; 229 return err;
230 } 230 }
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 91d3d6544a7b..038b71dbf03c 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -719,17 +719,47 @@ static int __init xenstored_local_init(void)
719 return err; 719 return err;
720} 720}
721 721
722enum xenstore_init {
723 UNKNOWN,
724 PV,
725 HVM,
726 LOCAL,
727};
722static int __init xenbus_init(void) 728static int __init xenbus_init(void)
723{ 729{
724 int err = 0; 730 int err = 0;
731 enum xenstore_init usage = UNKNOWN;
732 uint64_t v = 0;
725 733
726 if (!xen_domain()) 734 if (!xen_domain())
727 return -ENODEV; 735 return -ENODEV;
728 736
729 xenbus_ring_ops_init(); 737 xenbus_ring_ops_init();
730 738
731 if (xen_hvm_domain()) { 739 if (xen_pv_domain())
732 uint64_t v = 0; 740 usage = PV;
741 if (xen_hvm_domain())
742 usage = HVM;
743 if (xen_hvm_domain() && xen_initial_domain())
744 usage = LOCAL;
745 if (xen_pv_domain() && !xen_start_info->store_evtchn)
746 usage = LOCAL;
747 if (xen_pv_domain() && xen_start_info->store_evtchn)
748 xenstored_ready = 1;
749
750 switch (usage) {
751 case LOCAL:
752 err = xenstored_local_init();
753 if (err)
754 goto out_error;
755 xen_store_interface = mfn_to_virt(xen_store_mfn);
756 break;
757 case PV:
758 xen_store_evtchn = xen_start_info->store_evtchn;
759 xen_store_mfn = xen_start_info->store_mfn;
760 xen_store_interface = mfn_to_virt(xen_store_mfn);
761 break;
762 case HVM:
733 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); 763 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
734 if (err) 764 if (err)
735 goto out_error; 765 goto out_error;
@@ -738,18 +768,12 @@ static int __init xenbus_init(void)
738 if (err) 768 if (err)
739 goto out_error; 769 goto out_error;
740 xen_store_mfn = (unsigned long)v; 770 xen_store_mfn = (unsigned long)v;
741 xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); 771 xen_store_interface =
742 } else { 772 ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
743 xen_store_evtchn = xen_start_info->store_evtchn; 773 break;
744 xen_store_mfn = xen_start_info->store_mfn; 774 default:
745 if (xen_store_evtchn) 775 pr_warn("Xenstore state unknown\n");
746 xenstored_ready = 1; 776 break;
747 else {
748 err = xenstored_local_init();
749 if (err)
750 goto out_error;
751 }
752 xen_store_interface = mfn_to_virt(xen_store_mfn);
753 } 777 }
754 778
755 /* Initialize the interface to xenstore. */ 779 /* Initialize the interface to xenstore. */
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index bce15cf4a8df..131dec04794e 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -44,6 +44,7 @@
44#include <linux/rwsem.h> 44#include <linux/rwsem.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <asm/xen/hypervisor.h>
47#include <xen/xenbus.h> 48#include <xen/xenbus.h>
48#include <xen/xen.h> 49#include <xen/xen.h>
49#include "xenbus_comms.h" 50#include "xenbus_comms.h"
@@ -622,7 +623,7 @@ static void xs_reset_watches(void)
622{ 623{
623 int err, supported = 0; 624 int err, supported = 0;
624 625
625 if (!xen_hvm_domain()) 626 if (!xen_hvm_domain() || xen_initial_domain())
626 return; 627 return;
627 628
628 err = xenbus_scanf(XBT_NIL, "control", 629 err = xenbus_scanf(XBT_NIL, "control",