Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1 | #include <linux/types.h> |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 2 | #include <linux/clockchips.h> |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 3 | |
| 4 | #include <xen/interface/xen.h> |
| 5 | #include <xen/grant_table.h> |
| 6 | #include <xen/events.h> |
| 7 | |
| 8 | #include <asm/xen/hypercall.h> |
| 9 | #include <asm/xen/page.h> |
Ingo Molnar | 99d0000 | 2009-01-23 11:09:15 +0100 | [diff] [blame] | 10 | #include <asm/fixmap.h> |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 11 | |
| 12 | #include "xen-ops.h" |
| 13 | #include "mmu.h" |
| 14 | |
Ian Campbell | 03c8142 | 2011-02-17 11:04:20 +0000 | [diff] [blame] | 15 | void xen_arch_pre_suspend(void) |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 16 | { |
| 17 | xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn); |
| 18 | xen_start_info->console.domU.mfn = |
| 19 | mfn_to_pfn(xen_start_info->console.domU.mfn); |
| 20 | |
| 21 | BUG_ON(!irqs_disabled()); |
| 22 | |
| 23 | HYPERVISOR_shared_info = &xen_dummy_shared_info; |
| 24 | if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP), |
| 25 | __pte_ma(0), 0)) |
| 26 | BUG(); |
| 27 | } |
| 28 | |
Ian Campbell | 03c8142 | 2011-02-17 11:04:20 +0000 | [diff] [blame] | 29 | void xen_arch_hvm_post_suspend(int suspend_cancelled) |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 30 | { |
Stefano Stabellini | e057a4b | 2011-02-11 17:55:13 +0000 | [diff] [blame] | 31 | #ifdef CONFIG_XEN_PVHVM |
Stefano Stabellini | 409771d | 2010-05-14 12:48:19 +0100 | [diff] [blame] | 32 | int cpu; |
Konrad Rzeszutek Wilk | e9daff2 | 2013-02-14 21:29:31 -0500 | [diff] [blame] | 33 | xen_hvm_init_shared_info(); |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 34 | xen_callback_vector(); |
Stefano Stabellini | 512b109 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 35 | xen_unplug_emulated_devices(); |
Stefano Stabellini | 409771d | 2010-05-14 12:48:19 +0100 | [diff] [blame] | 36 | if (xen_feature(XENFEAT_hvm_safe_pvclock)) { |
| 37 | for_each_online_cpu(cpu) { |
| 38 | xen_setup_runstate_info(cpu); |
| 39 | } |
| 40 | } |
Stefano Stabellini | e057a4b | 2011-02-11 17:55:13 +0000 | [diff] [blame] | 41 | #endif |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 42 | } |
| 43 | |
Ian Campbell | 03c8142 | 2011-02-17 11:04:20 +0000 | [diff] [blame] | 44 | void xen_arch_post_suspend(int suspend_cancelled) |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 45 | { |
Ian Campbell | fa24ba6 | 2009-11-21 11:32:49 +0000 | [diff] [blame] | 46 | xen_build_mfn_list_list(); |
| 47 | |
Jeremy Fitzhardinge | 9c7a794 | 2008-05-31 01:33:02 +0100 | [diff] [blame] | 48 | xen_setup_shared_info(); |
| 49 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 50 | if (suspend_cancelled) { |
| 51 | xen_start_info->store_mfn = |
| 52 | pfn_to_mfn(xen_start_info->store_mfn); |
| 53 | xen_start_info->console.domU.mfn = |
| 54 | pfn_to_mfn(xen_start_info->console.domU.mfn); |
| 55 | } else { |
| 56 | #ifdef CONFIG_SMP |
Mike Travis | b78936e | 2008-12-16 17:33:57 -0800 | [diff] [blame] | 57 | BUG_ON(xen_cpu_initialized_map == NULL); |
| 58 | cpumask_copy(xen_cpu_initialized_map, cpu_online_mask); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 59 | #endif |
Jeremy Fitzhardinge | 9c7a794 | 2008-05-31 01:33:02 +0100 | [diff] [blame] | 60 | xen_vcpu_restore(); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 61 | } |
| 62 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 63 | } |
| 64 | |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 65 | static void xen_vcpu_notify_restore(void *data) |
| 66 | { |
| 67 | unsigned long reason = (unsigned long)data; |
| 68 | |
| 69 | /* Boot processor notified via generic timekeeping_resume() */ |
| 70 | if ( smp_processor_id() == 0) |
| 71 | return; |
| 72 | |
| 73 | clockevents_notify(reason, NULL); |
| 74 | } |
| 75 | |
Isaku Yamahata | ad55db9 | 2008-07-08 15:06:32 -0700 | [diff] [blame] | 76 | void xen_arch_resume(void) |
| 77 | { |
Ian Campbell | cd52e17 | 2010-05-19 16:19:25 +0100 | [diff] [blame] | 78 | on_each_cpu(xen_vcpu_notify_restore, |
| 79 | (void *)CLOCK_EVT_NOTIFY_RESUME, 1); |
Isaku Yamahata | ad55db9 | 2008-07-08 15:06:32 -0700 | [diff] [blame] | 80 | } |