Add suspend\resume support for PV on HVM guests.
Subsystems (3)
PATCH 7/11 Add suspend\resume support for PV on HVM guests.
Signed-off-by Stefano Stabellini <[email protected]>
--- arch/x86/xen/enlighten.c | 9 ++-- drivers/xen/manage.c | 103 +++++++++++++++++++++++++++++++++++-- drivers/xen/platform-pci.c | 29 ++++++++++- drivers/xen/xenbus/xenbus_probe.c | 29 ++++++++++ include/xen/platform_pci.h | 6 ++ include/xen/xen-ops.h | 2 + 6 files changed, 169 insertions(+), 9 deletions(-)
arch/x86/xen/enlighten.c +5 -4
@@ -1248,12 +1248,13 @@ static int init_hvm_pv_info(int *major, int *minor)return 0 ; } -static void __init init_shared_info (void ) +static void init_shared_info (void ) {struct xen_add_to_physmap xatp; -struct shared_info *shared_info_page; +static struct shared_info *shared_info_page =0 ; - shared_info_page = (struct shared_info *)alloc_bootmem_pages (PAGE_SIZE ); +if (!shared_info_page) + shared_info_page = (struct shared_info *)alloc_bootmem_pages (PAGE_SIZE ); xatp.domid =DOMID_SELF ; xatp.idx =0 ; xatp.space = XENMAPSPACE_shared_info;
@@ -1283,7 +1284,7 @@ void do_hvm_pv_evtchn_intr(void)xen_hvm_evtchn_do_upcall (get_irq_regs ()); } -void __init xen_guest_init (void ) +void xen_guest_init (void ) {int r;int major, minor;
drivers/xen/manage.c +99 -4
148 lines not on this page · raw message
drivers/xen/platform-pci.c +28 -1
@@ -33,6 +33,7 @@#include <xen/xenbus.h> #include <xen/events.h> #include <xen/hvm.h> +#include <xen/xen-ops.h> #define DRV_NAME "xen-platform-pci"
@@ -43,6 +44,8 @@ MODULE_LICENSE("GPL");static unsigned long platform_mmio;static unsigned long platform_mmio_alloc;static unsigned long platform_mmiolen; +static uint64_t callback_via; +struct pci_dev *xen_platform_pdev;unsigned long alloc_xen_mmio (unsigned long len) {
@@ -87,13 +90,33 @@ static int xen_allocate_irq(struct pci_dev *pdev) "xen-platform-pci", pdev); } +void platform_pci_disable_irq (void ) +{ +printk (KERN_DEBUG "platform_pci_disable_irq\n" ); +disable_irq (xen_platform_pdev->irq); +} + +void platform_pci_enable_irq (void ) +{ +printk (KERN_DEBUG "platform_pci_enable_irq\n" ); +enable_irq (xen_platform_pdev->irq); +} + +void platform_pci_resume (void ) +{ +if (!xen_have_vector_callback &&xen_set_callback_via (callback_via)) { +printk ("platform_pci_resume failure!\n" ); +return ; + } +} +static int __devinit platform_pci_init (struct pci_dev *pdev,const struct pci_device_id *ent) {int i, ret;long ioaddr, iolen;long mmio_addr, mmio_len; -uint64_t callback_via; + xen_platform_pdev = pdev; i =pci_enable_device (pdev);if (i)
@@ -152,6 +175,10 @@ static int __devinit platform_pci_init(struct pci_dev *pdev, ret =xenbus_probe_init ();if (ret) goto out; + ret =xen_setup_shutdown_event (); +if (ret) + goto out; + out:if (ret) {
drivers/xen/xenbus/xenbus_probe.c +29 -0
@@ -743,6 +743,35 @@ static int xenbus_dev_resume(struct device *dev)return 0 ; } +static int dev_suspend (struct device *dev,void *data) +{ +return xenbus_dev_suspend (dev,PMSG_SUSPEND ); +} + +void xenbus_suspend (void ) +{ +DPRINTK ("" ); + +bus_for_each_dev (&xenbus_frontend.bus,NULL ,NULL , dev_suspend); +xs_suspend (); +} +EXPORT_SYMBOL_GPL (xenbus_suspend); + +static int dev_resume (struct device *dev,void *data) +{ +return xenbus_dev_resume (dev); +} + +void xenbus_resume (void ) +{ +DPRINTK ("" ); + +xs_resume (); +bus_for_each_dev (&xenbus_frontend.bus,NULL ,NULL , dev_resume); +} +EXPORT_SYMBOL_GPL (xenbus_resume); + +/* A flag to determine if xenstored is 'ready' (i.e. has started) */ int xenstored_ready =0 ;
include/xen/platform_pci.h +6 -0
@@ -31,11 +31,17 @@#ifdef CONFIG_XEN_PLATFORM_PCI unsigned long alloc_xen_mmio (unsigned long len); +void platform_pci_resume (void ); +void platform_pci_disable_irq (void ); +void platform_pci_enable_irq (void );#else static inline unsigned long alloc_xen_mmio (unsigned long len) {return ~0UL ; } +static inline void platform_pci_resume (void ) {} +static inline void platform_pci_disable_irq (void ) {} +static inline void platform_pci_enable_irq (void ) {}#endif #endif /* _XEN_PLATFORM_PCI_H */
include/xen/xen-ops.h +2 -0
@@ -14,4 +14,6 @@ void xen_mm_unpin_all(void);void xen_timer_resume (void );void xen_arch_resume (void ); +int xen_setup_shutdown_event (void ); +#endif /* INCLUDE_XEN_OPS_H */
Signature · 1 line
1.5.4.3