suspend.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include <linux/types.h>
  2. #include <linux/tick.h>
  3. #include <xen/interface/xen.h>
  4. #include <xen/grant_table.h>
  5. #include <xen/events.h>
  6. #include <asm/xen/hypercall.h>
  7. #include <asm/xen/page.h>
  8. #include <asm/fixmap.h>
  9. #include "xen-ops.h"
  10. #include "mmu.h"
  11. #include "pmu.h"
  12. static void xen_pv_pre_suspend(void)
  13. {
  14. xen_mm_pin_all();
  15. xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
  16. xen_start_info->console.domU.mfn =
  17. mfn_to_pfn(xen_start_info->console.domU.mfn);
  18. BUG_ON(!irqs_disabled());
  19. HYPERVISOR_shared_info = &xen_dummy_shared_info;
  20. if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
  21. __pte_ma(0), 0))
  22. BUG();
  23. }
  24. static void xen_hvm_post_suspend(int suspend_cancelled)
  25. {
  26. #ifdef CONFIG_XEN_PVHVM
  27. int cpu;
  28. xen_hvm_init_shared_info();
  29. xen_callback_vector();
  30. xen_unplug_emulated_devices();
  31. if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
  32. for_each_online_cpu(cpu) {
  33. xen_setup_runstate_info(cpu);
  34. }
  35. }
  36. #endif
  37. }
  38. static void xen_pv_post_suspend(int suspend_cancelled)
  39. {
  40. xen_build_mfn_list_list();
  41. xen_setup_shared_info();
  42. if (suspend_cancelled) {
  43. xen_start_info->store_mfn =
  44. pfn_to_mfn(xen_start_info->store_mfn);
  45. xen_start_info->console.domU.mfn =
  46. pfn_to_mfn(xen_start_info->console.domU.mfn);
  47. } else {
  48. #ifdef CONFIG_SMP
  49. BUG_ON(xen_cpu_initialized_map == NULL);
  50. cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
  51. #endif
  52. xen_vcpu_restore();
  53. }
  54. xen_mm_unpin_all();
  55. }
  56. void xen_arch_pre_suspend(void)
  57. {
  58. int cpu;
  59. for_each_online_cpu(cpu)
  60. xen_pmu_finish(cpu);
  61. if (xen_pv_domain())
  62. xen_pv_pre_suspend();
  63. }
  64. void xen_arch_post_suspend(int cancelled)
  65. {
  66. int cpu;
  67. if (xen_pv_domain())
  68. xen_pv_post_suspend(cancelled);
  69. else
  70. xen_hvm_post_suspend(cancelled);
  71. for_each_online_cpu(cpu)
  72. xen_pmu_init(cpu);
  73. }
  74. static void xen_vcpu_notify_restore(void *data)
  75. {
  76. /* Boot processor notified via generic timekeeping_resume() */
  77. if (smp_processor_id() == 0)
  78. return;
  79. tick_resume_local();
  80. }
  81. static void xen_vcpu_notify_suspend(void *data)
  82. {
  83. tick_suspend_local();
  84. }
  85. void xen_arch_resume(void)
  86. {
  87. on_each_cpu(xen_vcpu_notify_restore, NULL, 1);
  88. }
  89. void xen_arch_suspend(void)
  90. {
  91. on_each_cpu(xen_vcpu_notify_suspend, NULL, 1);
  92. }