aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-03-23 17:16:23 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-03-23 17:16:23 -0400
commitfb3600cc50302c9577b76838fcac1ee78828007d (patch)
treeb5a2fe372bfe582525b165c55a3c0034bfe02665 /virt
parent134fac3f457f3dd753ecdb25e6da3e5f6629f696 (diff)
KVM: Use syscore_ops instead of sysdev class and sysdev
KVM uses a sysdev class and a sysdev for executing kvm_suspend() after interrupts have been turned off on the boot CPU (during system suspend) and for executing kvm_resume() before turning on interrupts on the boot CPU (during system resume). However, since both of these functions ignore their arguments, the entire mechanism may be replaced with a struct syscore_ops object which is simpler. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1fa0d292119a..24444527f422 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -30,7 +30,7 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/highmem.h> 31#include <linux/highmem.h>
32#include <linux/file.h> 32#include <linux/file.h>
33#include <linux/sysdev.h> 33#include <linux/syscore_ops.h>
34#include <linux/cpu.h> 34#include <linux/cpu.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/cpumask.h> 36#include <linux/cpumask.h>
@@ -2447,33 +2447,26 @@ static void kvm_exit_debug(void)
2447 debugfs_remove(kvm_debugfs_dir); 2447 debugfs_remove(kvm_debugfs_dir);
2448} 2448}
2449 2449
2450static int kvm_suspend(struct sys_device *dev, pm_message_t state) 2450static int kvm_suspend(void)
2451{ 2451{
2452 if (kvm_usage_count) 2452 if (kvm_usage_count)
2453 hardware_disable_nolock(NULL); 2453 hardware_disable_nolock(NULL);
2454 return 0; 2454 return 0;
2455} 2455}
2456 2456
2457static int kvm_resume(struct sys_device *dev) 2457static void kvm_resume(void)
2458{ 2458{
2459 if (kvm_usage_count) { 2459 if (kvm_usage_count) {
2460 WARN_ON(raw_spin_is_locked(&kvm_lock)); 2460 WARN_ON(raw_spin_is_locked(&kvm_lock));
2461 hardware_enable_nolock(NULL); 2461 hardware_enable_nolock(NULL);
2462 } 2462 }
2463 return 0;
2464} 2463}
2465 2464
2466static struct sysdev_class kvm_sysdev_class = { 2465static struct syscore_ops kvm_syscore_ops = {
2467 .name = "kvm",
2468 .suspend = kvm_suspend, 2466 .suspend = kvm_suspend,
2469 .resume = kvm_resume, 2467 .resume = kvm_resume,
2470}; 2468};
2471 2469
2472static struct sys_device kvm_sysdev = {
2473 .id = 0,
2474 .cls = &kvm_sysdev_class,
2475};
2476
2477struct page *bad_page; 2470struct page *bad_page;
2478pfn_t bad_pfn; 2471pfn_t bad_pfn;
2479 2472
@@ -2557,14 +2550,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
2557 goto out_free_2; 2550 goto out_free_2;
2558 register_reboot_notifier(&kvm_reboot_notifier); 2551 register_reboot_notifier(&kvm_reboot_notifier);
2559 2552
2560 r = sysdev_class_register(&kvm_sysdev_class);
2561 if (r)
2562 goto out_free_3;
2563
2564 r = sysdev_register(&kvm_sysdev);
2565 if (r)
2566 goto out_free_4;
2567
2568 /* A kmem cache lets us meet the alignment requirements of fx_save. */ 2553 /* A kmem cache lets us meet the alignment requirements of fx_save. */
2569 if (!vcpu_align) 2554 if (!vcpu_align)
2570 vcpu_align = __alignof__(struct kvm_vcpu); 2555 vcpu_align = __alignof__(struct kvm_vcpu);
@@ -2572,7 +2557,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
2572 0, NULL); 2557 0, NULL);
2573 if (!kvm_vcpu_cache) { 2558 if (!kvm_vcpu_cache) {
2574 r = -ENOMEM; 2559 r = -ENOMEM;
2575 goto out_free_5; 2560 goto out_free_3;
2576 } 2561 }
2577 2562
2578 r = kvm_async_pf_init(); 2563 r = kvm_async_pf_init();
@@ -2589,6 +2574,8 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
2589 goto out_unreg; 2574 goto out_unreg;
2590 } 2575 }
2591 2576
2577 register_syscore_ops(&kvm_syscore_ops);
2578
2592 kvm_preempt_ops.sched_in = kvm_sched_in; 2579 kvm_preempt_ops.sched_in = kvm_sched_in;
2593 kvm_preempt_ops.sched_out = kvm_sched_out; 2580 kvm_preempt_ops.sched_out = kvm_sched_out;
2594 2581
@@ -2600,10 +2587,6 @@ out_unreg:
2600 kvm_async_pf_deinit(); 2587 kvm_async_pf_deinit();
2601out_free: 2588out_free:
2602 kmem_cache_destroy(kvm_vcpu_cache); 2589 kmem_cache_destroy(kvm_vcpu_cache);
2603out_free_5:
2604 sysdev_unregister(&kvm_sysdev);
2605out_free_4:
2606 sysdev_class_unregister(&kvm_sysdev_class);
2607out_free_3: 2590out_free_3:
2608 unregister_reboot_notifier(&kvm_reboot_notifier); 2591 unregister_reboot_notifier(&kvm_reboot_notifier);
2609 unregister_cpu_notifier(&kvm_cpu_notifier); 2592 unregister_cpu_notifier(&kvm_cpu_notifier);
@@ -2631,8 +2614,7 @@ void kvm_exit(void)
2631 misc_deregister(&kvm_dev); 2614 misc_deregister(&kvm_dev);
2632 kmem_cache_destroy(kvm_vcpu_cache); 2615 kmem_cache_destroy(kvm_vcpu_cache);
2633 kvm_async_pf_deinit(); 2616 kvm_async_pf_deinit();
2634 sysdev_unregister(&kvm_sysdev); 2617 unregister_syscore_ops(&kvm_syscore_ops);
2635 sysdev_class_unregister(&kvm_sysdev_class);
2636 unregister_reboot_notifier(&kvm_reboot_notifier); 2618 unregister_reboot_notifier(&kvm_reboot_notifier);
2637 unregister_cpu_notifier(&kvm_cpu_notifier); 2619 unregister_cpu_notifier(&kvm_cpu_notifier);
2638 on_each_cpu(hardware_disable_nolock, NULL, 1); 2620 on_each_cpu(hardware_disable_nolock, NULL, 1);