ia64/xen-unstable
changeset 14784:ed4311db1cf6
PV-on-HVM: Fixes for save/restore. Also gets rid of separate modules
reboot.ko and xenbus.ko. These are now part of xen-platform-pci.ko.
Signed-off-by: Keir Fraser <keir@xensource.com>
reboot.ko and xenbus.ko. These are now part of xen-platform-pci.ko.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Tue Apr 10 15:31:53 2007 +0100 (2007-04-10) |
parents | 099593da38cb |
children | 3e1181a913c9 |
files | linux-2.6-xen-sparse/drivers/xen/core/reboot.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/include/xen/xenbus.h unmodified_drivers/linux-2.6/Makefile unmodified_drivers/linux-2.6/mkbuildtree unmodified_drivers/linux-2.6/platform-pci/Kbuild unmodified_drivers/linux-2.6/platform-pci/evtchn.c unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c unmodified_drivers/linux-2.6/platform-pci/platform-pci.c unmodified_drivers/linux-2.6/platform-pci/platform-pci.h unmodified_drivers/linux-2.6/util/Kbuild unmodified_drivers/linux-2.6/util/Makefile unmodified_drivers/linux-2.6/xenbus/Kbuild unmodified_drivers/linux-2.6/xenbus/Makefile unmodified_drivers/linux-2.6/xenbus/empty_directory |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Tue Apr 10 13:46:28 2007 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c Tue Apr 10 15:31:53 2007 +0100 1.3 @@ -34,28 +34,7 @@ static int fast_suspend; 1.4 static void __shutdown_handler(void *unused); 1.5 static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL); 1.6 1.7 -#ifdef CONFIG_XEN 1.8 int __xen_suspend(int fast_suspend); 1.9 -#else 1.10 -extern void xenbus_suspend(void); 1.11 -extern void xenbus_resume(void); 1.12 -extern void platform_pci_suspend(void); 1.13 -extern void platform_pci_resume(void); 1.14 -int __xen_suspend(int fast_suspend) 1.15 -{ 1.16 - xenbus_suspend(); 1.17 - platform_pci_suspend(); 1.18 - 1.19 - /* pvdrv sleep in this hyper-call when save */ 1.20 - HYPERVISOR_shutdown(SHUTDOWN_suspend); 1.21 - 1.22 - platform_pci_resume(); 1.23 - xenbus_resume(); 1.24 - printk("PV stuff on HVM resume successfully!\n"); 1.25 - 1.26 - return 0; 1.27 -} 1.28 -#endif 1.29 1.30 static int shutdown_process(void *__unused) 1.31 { 1.32 @@ -210,13 +189,11 @@ static struct xenbus_watch shutdown_watc 1.33 }; 1.34 1.35 static struct xenbus_watch sysrq_watch = { 1.36 - .node ="control/sysrq", 1.37 + .node = "control/sysrq", 1.38 .callback = sysrq_handler 1.39 }; 1.40 1.41 -static int setup_shutdown_watcher(struct notifier_block *notifier, 1.42 - unsigned long event, 1.43 - void *data) 1.44 +static int setup_shutdown_watcher(void) 1.45 { 1.46 int err; 1.47 1.48 @@ -225,17 +202,29 @@ static int setup_shutdown_watcher(struct 1.49 "%d", &fast_suspend); 1.50 1.51 err = register_xenbus_watch(&shutdown_watch); 1.52 - if (err) 1.53 + if (err) { 1.54 printk(KERN_ERR "Failed to set shutdown watcher\n"); 1.55 - else 1.56 - xenbus_write(XBT_NIL, "control", "feature-reboot", "1"); 1.57 + return err; 1.58 + } 1.59 + xenbus_write(XBT_NIL, "control", "feature-reboot", "1"); 1.60 1.61 err = register_xenbus_watch(&sysrq_watch); 1.62 - if (err) 1.63 + if (err) { 1.64 printk(KERN_ERR "Failed to set sysrq watcher\n"); 1.65 - else 1.66 - xenbus_write(XBT_NIL, "control", "feature-sysrq", "1"); 1.67 + return err; 1.68 + } 1.69 + xenbus_write(XBT_NIL, "control", "feature-sysrq", "1"); 1.70 + 1.71 + return 0; 1.72 +} 1.73 1.74 +#ifdef CONFIG_XEN 1.75 + 1.76 +static int shutdown_event(struct notifier_block *notifier, 1.77 + unsigned long event, 1.78 + void *data) 1.79 +{ 1.80 + setup_shutdown_watcher(); 1.81 return NOTIFY_DONE; 1.82 } 1.83 1.84 @@ -250,3 +239,12 @@ static int __init setup_shutdown_event(v 1.85 } 1.86 1.87 subsys_initcall(setup_shutdown_event); 1.88 + 1.89 +#else /* !defined(CONFIG_XEN) */ 1.90 + 1.91 +int xen_reboot_init(void) 1.92 +{ 1.93 + return setup_shutdown_watcher(); 1.94 +} 1.95 + 1.96 +#endif /* !defined(CONFIG_XEN) */
2.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Tue Apr 10 13:46:28 2007 +0100 2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c Tue Apr 10 15:31:53 2007 +0100 2.3 @@ -394,8 +394,7 @@ static const struct file_operations xenb 2.4 .poll = xenbus_dev_poll, 2.5 }; 2.6 2.7 -int __init 2.8 -xenbus_dev_init(void) 2.9 +int xenbus_dev_init(void) 2.10 { 2.11 xenbus_dev_intf = create_xen_proc_entry("xenbus", 0400); 2.12 if (xenbus_dev_intf)
3.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Apr 10 13:46:28 2007 +0100 3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c Tue Apr 10 15:31:53 2007 +0100 3.3 @@ -863,7 +863,7 @@ static int xsd_port_read(char *page, cha 3.4 } 3.5 #endif 3.6 3.7 -static int __init xenbus_probe_init(void) 3.8 +static int xenbus_probe_init(void) 3.9 { 3.10 int err = 0; 3.11 unsigned long page = 0; 3.12 @@ -978,10 +978,15 @@ static int __init xenbus_probe_init(void 3.13 return err; 3.14 } 3.15 3.16 +#ifdef CONFIG_XEN 3.17 postcore_initcall(xenbus_probe_init); 3.18 - 3.19 MODULE_LICENSE("Dual BSD/GPL"); 3.20 - 3.21 +#else 3.22 +int xenbus_init(void) 3.23 +{ 3.24 + return xenbus_probe_init(); 3.25 +} 3.26 +#endif 3.27 3.28 static int is_disconnected_device(struct device *dev, void *data) 3.29 {
4.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h Tue Apr 10 13:46:28 2007 +0100 4.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Tue Apr 10 15:31:53 2007 +0100 4.3 @@ -293,7 +293,7 @@ void xenbus_dev_error(struct xenbus_devi 4.4 void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, 4.5 ...); 4.6 4.7 -int __init xenbus_dev_init(void); 4.8 +int xenbus_dev_init(void); 4.9 4.10 const char *xenbus_strstate(enum xenbus_state state); 4.11 int xenbus_dev_is_online(struct xenbus_device *dev);
5.1 --- a/unmodified_drivers/linux-2.6/Makefile Tue Apr 10 13:46:28 2007 +0100 5.2 +++ b/unmodified_drivers/linux-2.6/Makefile Tue Apr 10 15:31:53 2007 +0100 5.3 @@ -1,8 +1,6 @@ 5.4 include $(M)/overrides.mk 5.5 5.6 obj-m += platform-pci/ 5.7 -obj-m += xenbus/ 5.8 obj-m += balloon/ 5.9 obj-m += blkfront/ 5.10 obj-m += netfront/ 5.11 -obj-m += util/
6.1 --- a/unmodified_drivers/linux-2.6/mkbuildtree Tue Apr 10 13:46:28 2007 +0100 6.2 +++ b/unmodified_drivers/linux-2.6/mkbuildtree Tue Apr 10 15:31:53 2007 +0100 6.3 @@ -25,7 +25,7 @@ done 6.4 ln -sf ${XL}/drivers/xen/core/gnttab.c platform-pci 6.5 ln -sf ${XL}/drivers/xen/core/features.c platform-pci 6.6 ln -sf ${XL}/drivers/xen/core/xen_proc.c xenbus 6.7 -ln -sf ${XL}/drivers/xen/core/reboot.c util 6.8 +ln -sf ${XL}/drivers/xen/core/reboot.c platform-pci 6.9 6.10 mkdir -p include/asm include/xen 6.11
7.1 --- a/unmodified_drivers/linux-2.6/platform-pci/Kbuild Tue Apr 10 13:46:28 2007 +0100 7.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/Kbuild Tue Apr 10 15:31:53 2007 +0100 7.3 @@ -4,7 +4,16 @@ obj-m := xen-platform-pci.o 7.4 7.5 EXTRA_CFLAGS += -I$(M)/platform-pci 7.6 7.7 -xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o features.o platform-compat.o 7.8 +xen-platform-pci-objs := evtchn.o platform-pci.o gnttab.o xen_support.o 7.9 +xen-platform-pci-objs += features.o platform-compat.o 7.10 +xen-platform-pci-objs += reboot.o machine_reboot.o 7.11 + 7.12 +xen-platform-pci-objs += ../xenbus/xenbus_comms.o 7.13 +xen-platform-pci-objs += ../xenbus/xenbus_xs.o 7.14 +xen-platform-pci-objs += ../xenbus/xenbus_probe.o 7.15 +xen-platform-pci-objs += ../xenbus/xenbus_dev.o 7.16 +xen-platform-pci-objs += ../xenbus/xenbus_client.o 7.17 +xen-platform-pci-objs += ../xenbus/xen_proc.o 7.18 7.19 # Can we do better ? 7.20 ifeq ($(ARCH),ia64)
8.1 --- a/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Tue Apr 10 13:46:28 2007 +0100 8.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/evtchn.c Tue Apr 10 15:31:53 2007 +0100 8.3 @@ -41,16 +41,42 @@ 8.4 8.5 void *shared_info_area; 8.6 8.7 -#define MAX_EVTCHN 256 8.8 +static DEFINE_MUTEX(irq_evtchn_mutex); 8.9 + 8.10 +#define is_valid_evtchn(x) ((x) != 0) 8.11 +#define evtchn_from_irq(x) (irq_evtchn[irq].evtchn) 8.12 + 8.13 static struct { 8.14 irqreturn_t(*handler) (int, void *, struct pt_regs *); 8.15 void *dev_id; 8.16 - int close; /* close on unbind_from_irqhandler()? */ 8.17 -} evtchns[MAX_EVTCHN]; 8.18 + int evtchn; 8.19 + int close:1; /* close on unbind_from_irqhandler()? */ 8.20 + int inuse:1; 8.21 +} irq_evtchn[256]; 8.22 +static int evtchn_to_irq[NR_EVENT_CHANNELS] = { 8.23 + [0 ... NR_EVENT_CHANNELS-1] = -1 }; 8.24 + 8.25 +static int find_unbound_irq(void) 8.26 +{ 8.27 + static int warned; 8.28 + int irq; 8.29 + 8.30 + for (irq = 0; irq < ARRAY_SIZE(irq_evtchn); irq++) 8.31 + if (!irq_evtchn[irq].inuse) 8.32 + return irq; 8.33 + 8.34 + if (!warned) { 8.35 + warned = 1; 8.36 + printk(KERN_WARNING "No available IRQ to bind to: " 8.37 + "increase irq_evtchn[] size in evtchn.c.\n"); 8.38 + } 8.39 + 8.40 + return -ENOSPC; 8.41 +} 8.42 8.43 int irq_to_evtchn_port(int irq) 8.44 { 8.45 - return irq; 8.46 + return irq_evtchn[irq].evtchn; 8.47 } 8.48 EXPORT_SYMBOL(irq_to_evtchn_port); 8.49 8.50 @@ -107,21 +133,37 @@ int bind_listening_port_to_irqhandler( 8.51 void *dev_id) 8.52 { 8.53 struct evtchn_alloc_unbound alloc_unbound; 8.54 - int err; 8.55 + int err, irq; 8.56 + 8.57 + mutex_lock(&irq_evtchn_mutex); 8.58 + 8.59 + irq = find_unbound_irq(); 8.60 + if (irq < 0) { 8.61 + mutex_unlock(&irq_evtchn_mutex); 8.62 + return irq; 8.63 + } 8.64 8.65 alloc_unbound.dom = DOMID_SELF; 8.66 alloc_unbound.remote_dom = remote_domain; 8.67 - 8.68 err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, 8.69 &alloc_unbound); 8.70 - if (err) 8.71 + if (err) { 8.72 + mutex_unlock(&irq_evtchn_mutex); 8.73 return err; 8.74 + } 8.75 8.76 - evtchns[alloc_unbound.port].handler = handler; 8.77 - evtchns[alloc_unbound.port].dev_id = dev_id; 8.78 - evtchns[alloc_unbound.port].close = 1; 8.79 + irq_evtchn[irq].handler = handler; 8.80 + irq_evtchn[irq].dev_id = dev_id; 8.81 + irq_evtchn[irq].evtchn = alloc_unbound.port; 8.82 + irq_evtchn[irq].close = 1; 8.83 + irq_evtchn[irq].inuse = 1; 8.84 + 8.85 + evtchn_to_irq[alloc_unbound.port] = irq; 8.86 + 8.87 unmask_evtchn(alloc_unbound.port); 8.88 - return alloc_unbound.port; 8.89 + 8.90 + mutex_unlock(&irq_evtchn_mutex); 8.91 + return irq; 8.92 } 8.93 EXPORT_SYMBOL(bind_listening_port_to_irqhandler); 8.94 8.95 @@ -132,35 +174,59 @@ int bind_caller_port_to_irqhandler( 8.96 const char *devname, 8.97 void *dev_id) 8.98 { 8.99 - if (caller_port >= MAX_EVTCHN) 8.100 - return -EINVAL; 8.101 - evtchns[caller_port].handler = handler; 8.102 - evtchns[caller_port].dev_id = dev_id; 8.103 - evtchns[caller_port].close = 0; 8.104 + int irq; 8.105 + 8.106 + mutex_lock(&irq_evtchn_mutex); 8.107 + 8.108 + irq = find_unbound_irq(); 8.109 + if (irq < 0) { 8.110 + mutex_unlock(&irq_evtchn_mutex); 8.111 + return irq; 8.112 + } 8.113 + 8.114 + irq_evtchn[irq].handler = handler; 8.115 + irq_evtchn[irq].dev_id = dev_id; 8.116 + irq_evtchn[irq].evtchn = caller_port; 8.117 + irq_evtchn[irq].close = 0; 8.118 + irq_evtchn[irq].inuse = 1; 8.119 + 8.120 + evtchn_to_irq[caller_port] = irq; 8.121 + 8.122 unmask_evtchn(caller_port); 8.123 - return caller_port; 8.124 + 8.125 + mutex_unlock(&irq_evtchn_mutex); 8.126 + return irq; 8.127 } 8.128 EXPORT_SYMBOL(bind_caller_port_to_irqhandler); 8.129 8.130 -void unbind_from_irqhandler(unsigned int evtchn, void *dev_id) 8.131 +void unbind_from_irqhandler(unsigned int irq, void *dev_id) 8.132 { 8.133 - if (evtchn >= MAX_EVTCHN) 8.134 - return; 8.135 + int evtchn = evtchn_from_irq(irq); 8.136 + 8.137 + mutex_lock(&irq_evtchn_mutex); 8.138 8.139 - mask_evtchn(evtchn); 8.140 - evtchns[evtchn].handler = NULL; 8.141 + if (is_valid_evtchn(evtchn)) { 8.142 + evtchn_to_irq[irq] = -1; 8.143 + mask_evtchn(evtchn); 8.144 + if (irq_evtchn[irq].close) { 8.145 + struct evtchn_close close = { .port = evtchn }; 8.146 + HYPERVISOR_event_channel_op(EVTCHNOP_close, &close); 8.147 + } 8.148 + } 8.149 8.150 - if (evtchns[evtchn].close) { 8.151 - struct evtchn_close close = { .port = evtchn }; 8.152 - HYPERVISOR_event_channel_op(EVTCHNOP_close, &close); 8.153 - } 8.154 + irq_evtchn[irq].handler = NULL; 8.155 + irq_evtchn[irq].evtchn = 0; 8.156 + irq_evtchn[irq].inuse = 0; 8.157 + 8.158 + mutex_unlock(&irq_evtchn_mutex); 8.159 } 8.160 EXPORT_SYMBOL(unbind_from_irqhandler); 8.161 8.162 void notify_remote_via_irq(int irq) 8.163 { 8.164 - int evtchn = irq; 8.165 - notify_remote_via_evtchn(evtchn); 8.166 + int evtchn = evtchn_from_irq(irq); 8.167 + if (is_valid_evtchn(evtchn)) 8.168 + notify_remote_via_evtchn(evtchn); 8.169 } 8.170 EXPORT_SYMBOL(notify_remote_via_irq); 8.171 8.172 @@ -183,9 +249,10 @@ irqreturn_t evtchn_interrupt(int irq, vo 8.173 while ((l2 = s->evtchn_pending[l1i] & ~s->evtchn_mask[l1i])) { 8.174 port = (l1i * BITS_PER_LONG) + __ffs(l2); 8.175 synch_clear_bit(port, &s->evtchn_pending[0]); 8.176 - if ((handler = evtchns[port].handler) != NULL) 8.177 - handler(port, evtchns[port].dev_id, 8.178 - regs); 8.179 + irq = evtchn_to_irq[port]; 8.180 + if ((irq >= 0) && 8.181 + ((handler = irq_evtchn[irq].handler) != NULL)) 8.182 + handler(irq, irq_evtchn[irq].dev_id, regs); 8.183 else 8.184 printk(KERN_WARNING "unexpected event channel " 8.185 "upcall on port %d!\n", port); 8.186 @@ -200,3 +267,28 @@ void force_evtchn_callback(void) 8.187 (void)HYPERVISOR_xen_version(0, NULL); 8.188 } 8.189 EXPORT_SYMBOL(force_evtchn_callback); 8.190 + 8.191 +void irq_suspend(void) 8.192 +{ 8.193 + mutex_lock(&irq_evtchn_mutex); 8.194 +} 8.195 + 8.196 +void irq_suspend_cancel(void) 8.197 +{ 8.198 + mutex_unlock(&irq_evtchn_mutex); 8.199 +} 8.200 + 8.201 +void irq_resume(void) 8.202 +{ 8.203 + int evtchn, irq; 8.204 + 8.205 + for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++) { 8.206 + mask_evtchn(evtchn); 8.207 + evtchn_to_irq[evtchn] = -1; 8.208 + } 8.209 + 8.210 + for (irq = 0; irq < ARRAY_SIZE(irq_evtchn); irq++) 8.211 + irq_evtchn[irq].evtchn = 0; 8.212 + 8.213 + mutex_unlock(&irq_evtchn_mutex); 8.214 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c Tue Apr 10 15:31:53 2007 +0100 9.3 @@ -0,0 +1,24 @@ 9.4 +#include <linux/config.h> 9.5 +#include <xen/xenbus.h> 9.6 +#include "platform-pci.h" 9.7 +#include <asm/hypervisor.h> 9.8 + 9.9 +int __xen_suspend(int fast_suspend) 9.10 +{ 9.11 + int suspend_cancelled; 9.12 + 9.13 + xenbus_suspend(); 9.14 + platform_pci_suspend(); 9.15 + 9.16 + suspend_cancelled = HYPERVISOR_shutdown(SHUTDOWN_suspend); 9.17 + 9.18 + if (suspend_cancelled) { 9.19 + platform_pci_suspend_cancel(); 9.20 + xenbus_suspend_cancel(); 9.21 + } else { 9.22 + platform_pci_resume(); 9.23 + xenbus_resume(); 9.24 + } 9.25 + 9.26 + return 0; 9.27 +}
10.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Tue Apr 10 13:46:28 2007 +0100 10.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c Tue Apr 10 15:31:53 2007 +0100 10.3 @@ -1,7 +1,9 @@ 10.4 /****************************************************************************** 10.5 * platform-pci.c 10.6 + * 10.7 * Xen platform PCI device driver 10.8 - * Copyright (C) 2005, Intel Corporation. 10.9 + * Copyright (c) 2005, Intel Corporation. 10.10 + * Copyright (c) 2007, XenSource Inc. 10.11 * 10.12 * This program is free software; you can redistribute it and/or modify it 10.13 * under the terms and conditions of the GNU General Public License, 10.14 @@ -35,7 +37,9 @@ 10.15 #include <asm/hypervisor.h> 10.16 #include <asm/pgtable.h> 10.17 #include <xen/interface/memory.h> 10.18 +#include <xen/interface/hvm/params.h> 10.19 #include <xen/features.h> 10.20 +#include <xen/evtchn.h> 10.21 #include <xen/gnttab.h> 10.22 #ifdef __ia64__ 10.23 #include <asm/xen/xencomm.h> 10.24 @@ -54,14 +58,10 @@ 10.25 char *hypercall_stubs; 10.26 EXPORT_SYMBOL(hypercall_stubs); 10.27 10.28 -// Used to be xiaofeng.ling@intel.com 10.29 MODULE_AUTHOR("ssmith@xensource.com"); 10.30 MODULE_DESCRIPTION("Xen platform PCI device"); 10.31 MODULE_LICENSE("GPL"); 10.32 10.33 -unsigned long *phys_to_machine_mapping; 10.34 -EXPORT_SYMBOL(phys_to_machine_mapping); 10.35 - 10.36 static unsigned long shared_info_frame; 10.37 static uint64_t callback_via; 10.38 10.39 @@ -89,30 +89,11 @@ static int __devinit init_xen_info(void) 10.40 if (shared_info_area == NULL) 10.41 panic("can't map shared info\n"); 10.42 10.43 - phys_to_machine_mapping = NULL; 10.44 - 10.45 gnttab_init(); 10.46 10.47 return 0; 10.48 } 10.49 10.50 -static void __devexit platform_pci_remove(struct pci_dev *pdev) 10.51 -{ 10.52 - long ioaddr, iolen; 10.53 - long mmio_addr, mmio_len; 10.54 - 10.55 - ioaddr = pci_resource_start(pdev, 0); 10.56 - iolen = pci_resource_len(pdev, 0); 10.57 - mmio_addr = pci_resource_start(pdev, 1); 10.58 - mmio_len = pci_resource_len(pdev, 1); 10.59 - 10.60 - release_region(ioaddr, iolen); 10.61 - release_mem_region(mmio_addr, mmio_len); 10.62 - 10.63 - pci_set_drvdata(pdev, NULL); 10.64 - free_irq(pdev->irq, pdev); 10.65 -} 10.66 - 10.67 static unsigned long platform_mmio; 10.68 static unsigned long platform_mmio_alloc; 10.69 static unsigned long platform_mmiolen; 10.70 @@ -208,6 +189,19 @@ static uint64_t get_callback_via(struct 10.71 ((uint64_t)(pin - 1) & 3)); 10.72 } 10.73 10.74 +static int set_callback_via(uint64_t via) 10.75 +{ 10.76 + struct xen_hvm_param a; 10.77 + 10.78 + a.domid = DOMID_SELF; 10.79 + a.index = HVM_PARAM_CALLBACK_IRQ; 10.80 + a.value = via; 10.81 + return HYPERVISOR_hvm_op(HVMOP_set_param, &a); 10.82 +} 10.83 + 10.84 +int xenbus_init(void); 10.85 +int xen_reboot_init(void); 10.86 + 10.87 static int __devinit platform_pci_init(struct pci_dev *pdev, 10.88 const struct pci_device_id *ent) 10.89 { 10.90 @@ -232,15 +226,13 @@ static int __devinit platform_pci_init(s 10.91 return -ENOENT; 10.92 } 10.93 10.94 - if (request_mem_region(mmio_addr, mmio_len, DRV_NAME) == NULL) 10.95 - { 10.96 + if (request_mem_region(mmio_addr, mmio_len, DRV_NAME) == NULL) { 10.97 printk(KERN_ERR ":MEM I/O resource 0x%lx @ 0x%lx busy\n", 10.98 mmio_addr, mmio_len); 10.99 return -EBUSY; 10.100 } 10.101 10.102 - if (request_region(ioaddr, iolen, DRV_NAME) == NULL) 10.103 - { 10.104 + if (request_region(ioaddr, iolen, DRV_NAME) == NULL) { 10.105 printk(KERN_ERR DRV_NAME ":I/O resource 0x%lx @ 0x%lx busy\n", 10.106 iolen, ioaddr); 10.107 release_mem_region(mmio_addr, mmio_len); 10.108 @@ -265,6 +257,12 @@ static int __devinit platform_pci_init(s 10.109 if ((ret = set_callback_via(callback_via))) 10.110 goto out; 10.111 10.112 + if ((ret = xenbus_init())) 10.113 + goto out; 10.114 + 10.115 + if ((ret = xen_reboot_init())) 10.116 + goto out; 10.117 + 10.118 out: 10.119 if (ret) { 10.120 release_mem_region(mmio_addr, mmio_len); 10.121 @@ -289,7 +287,6 @@ MODULE_DEVICE_TABLE(pci, platform_pci_tb 10.122 static struct pci_driver platform_driver = { 10.123 name: DRV_NAME, 10.124 probe: platform_pci_init, 10.125 - remove: __devexit_p(platform_pci_remove), 10.126 id_table: platform_pci_tbl, 10.127 }; 10.128 10.129 @@ -298,13 +295,18 @@ static int pci_device_registered; 10.130 void platform_pci_suspend(void) 10.131 { 10.132 gnttab_suspend(); 10.133 + irq_suspend(); 10.134 } 10.135 -EXPORT_SYMBOL_GPL(platform_pci_suspend); 10.136 + 10.137 +void platform_pci_suspend_cancel(void) 10.138 +{ 10.139 + irq_suspend_cancel(); 10.140 + gnttab_resume(); 10.141 +} 10.142 10.143 void platform_pci_resume(void) 10.144 { 10.145 struct xen_add_to_physmap xatp; 10.146 - phys_to_machine_mapping = NULL; 10.147 10.148 /* do 2 things for PV driver restore on HVM 10.149 * 1: rebuild share info 10.150 @@ -317,34 +319,27 @@ void platform_pci_resume(void) 10.151 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) 10.152 BUG(); 10.153 10.154 - if (( set_callback_via(callback_via))) 10.155 + irq_resume(); 10.156 + 10.157 + if (set_callback_via(callback_via)) 10.158 printk("platform_pci_resume failure!\n"); 10.159 10.160 gnttab_resume(); 10.161 } 10.162 -EXPORT_SYMBOL_GPL(platform_pci_resume); 10.163 10.164 static int __init platform_pci_module_init(void) 10.165 { 10.166 int rc; 10.167 10.168 rc = pci_module_init(&platform_driver); 10.169 - if (rc) 10.170 - printk(KERN_INFO DRV_NAME ":No platform pci device model found\n"); 10.171 - else 10.172 - pci_device_registered = 1; 10.173 - 10.174 - return rc; 10.175 -} 10.176 + if (rc) { 10.177 + printk(KERN_INFO DRV_NAME 10.178 + ": No platform pci device model found\n"); 10.179 + return rc; 10.180 + } 10.181 10.182 -static void __exit platform_pci_module_cleanup(void) 10.183 -{ 10.184 - printk(KERN_INFO DRV_NAME ":Do platform module cleanup\n"); 10.185 - /* disable hypervisor for callback irq */ 10.186 - set_callback_via(0); 10.187 - if (pci_device_registered) 10.188 - pci_unregister_driver(&platform_driver); 10.189 + pci_device_registered = 1; 10.190 + return 0; 10.191 } 10.192 10.193 module_init(platform_pci_module_init); 10.194 -module_exit(platform_pci_module_cleanup);
11.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h Tue Apr 10 13:46:28 2007 +0100 11.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.h Tue Apr 10 15:31:53 2007 +0100 11.3 @@ -1,7 +1,9 @@ 11.4 /****************************************************************************** 11.5 - * evtchn-pci.h 11.6 - * module driver support in unmodified Linux 11.7 - * Copyright (C) 2004, Intel Corporation. <xiaofeng.ling@intel.com> 11.8 + * platform-pci.h 11.9 + * 11.10 + * Xen platform PCI device driver 11.11 + * Copyright (c) 2004, Intel Corporation. <xiaofeng.ling@intel.com> 11.12 + * Copyright (c) 2007, XenSource Inc. 11.13 * 11.14 * This program is free software; you can redistribute it and/or modify it 11.15 * under the terms and conditions of the GNU General Public License, 11.16 @@ -15,31 +17,21 @@ 11.17 * You should have received a copy of the GNU General Public License along with 11.18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 11.19 * Place - Suite 330, Boston, MA 02111-1307 USA. 11.20 - * 11.21 */ 11.22 11.23 -#ifndef __XEN_SUPPORT_H 11.24 -#define __XEN_SUPPORT_H 11.25 -#include <linux/version.h> 11.26 -#include <linux/interrupt.h> 11.27 -#include <xen/interface/hvm/params.h> 11.28 +#ifndef _XEN_PLATFORM_PCI_H 11.29 +#define _XEN_PLATFORM_PCI_H 11.30 11.31 -static inline int set_callback_via(uint64_t via) 11.32 -{ 11.33 - struct xen_hvm_param a; 11.34 - 11.35 - a.domid = DOMID_SELF; 11.36 - a.index = HVM_PARAM_CALLBACK_IRQ; 11.37 - a.value = via; 11.38 - return HYPERVISOR_hvm_op(HVMOP_set_param, &a); 11.39 -} 11.40 +#include <linux/interrupt.h> 11.41 11.42 unsigned long alloc_xen_mmio(unsigned long len); 11.43 - 11.44 int gnttab_init(void); 11.45 +irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs); 11.46 +void irq_suspend(void); 11.47 +void irq_suspend_cancel(void); 11.48 11.49 -void setup_xen_features(void); 11.50 +void platform_pci_suspend(void); 11.51 +void platform_pci_suspend_cancel(void); 11.52 +void platform_pci_resume(void); 11.53 11.54 -irqreturn_t evtchn_interrupt(int irq, void *dev_id, struct pt_regs *regs); 11.55 - 11.56 -#endif 11.57 +#endif /* _XEN_PLATFORM_PCI_H */
12.1 --- a/unmodified_drivers/linux-2.6/util/Kbuild Tue Apr 10 13:46:28 2007 +0100 12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 12.3 @@ -1,3 +0,0 @@ 12.4 -include $(M)/overrides.mk 12.5 - 12.6 -obj-m := reboot.o
13.1 --- a/unmodified_drivers/linux-2.6/util/Makefile Tue Apr 10 13:46:28 2007 +0100 13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 13.3 @@ -1,3 +0,0 @@ 13.4 -ifneq ($(KERNELRELEASE),) 13.5 -include $(src)/Kbuild 13.6 -endif
14.1 --- a/unmodified_drivers/linux-2.6/xenbus/Kbuild Tue Apr 10 13:46:28 2007 +0100 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,10 +0,0 @@ 14.4 -include $(M)/overrides.mk 14.5 - 14.6 -obj-m += xenbus.o 14.7 -xenbus-objs = 14.8 -xenbus-objs += xenbus_comms.o 14.9 -xenbus-objs += xenbus_xs.o 14.10 -xenbus-objs += xenbus_probe.o 14.11 -xenbus-objs += xenbus_dev.o 14.12 -xenbus-objs += xenbus_client.o 14.13 -xenbus-objs += xen_proc.o