diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-26 00:07:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-26 00:07:59 -0400 |
commit | 16c29dafcc86024048f1dbb8349d31cb22c7c55a (patch) | |
tree | 100c4fd34903adf02c9b8ae7705a3e1f30c8d712 /virt/kvm | |
parent | dc50eddb2f3a0dff365f093b2a93fb4ab4dd4389 (diff) | |
parent | d47d81c0e9abdc3c88653fabff5beae82c949b09 (diff) |
Merge branch 'syscore' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'syscore' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
Introduce ARCH_NO_SYSDEV_OPS config option (v2)
cpufreq: Use syscore_ops for boot CPU suspend/resume (v2)
KVM: Use syscore_ops instead of sysdev class and sysdev
PCI / Intel IOMMU: Use syscore_ops instead of sysdev class and sysdev
timekeeping: Use syscore_ops instead of sysdev class and sysdev
x86: Use syscore_ops instead of sysdev classes and sysdevs
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 7bee6dc8cdb2..556e3efe5325 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> |
@@ -2446,33 +2446,26 @@ static void kvm_exit_debug(void) | |||
2446 | debugfs_remove(kvm_debugfs_dir); | 2446 | debugfs_remove(kvm_debugfs_dir); |
2447 | } | 2447 | } |
2448 | 2448 | ||
2449 | static int kvm_suspend(struct sys_device *dev, pm_message_t state) | 2449 | static int kvm_suspend(void) |
2450 | { | 2450 | { |
2451 | if (kvm_usage_count) | 2451 | if (kvm_usage_count) |
2452 | hardware_disable_nolock(NULL); | 2452 | hardware_disable_nolock(NULL); |
2453 | return 0; | 2453 | return 0; |
2454 | } | 2454 | } |
2455 | 2455 | ||
2456 | static int kvm_resume(struct sys_device *dev) | 2456 | static void kvm_resume(void) |
2457 | { | 2457 | { |
2458 | if (kvm_usage_count) { | 2458 | if (kvm_usage_count) { |
2459 | WARN_ON(raw_spin_is_locked(&kvm_lock)); | 2459 | WARN_ON(raw_spin_is_locked(&kvm_lock)); |
2460 | hardware_enable_nolock(NULL); | 2460 | hardware_enable_nolock(NULL); |
2461 | } | 2461 | } |
2462 | return 0; | ||
2463 | } | 2462 | } |
2464 | 2463 | ||
2465 | static struct sysdev_class kvm_sysdev_class = { | 2464 | static struct syscore_ops kvm_syscore_ops = { |
2466 | .name = "kvm", | ||
2467 | .suspend = kvm_suspend, | 2465 | .suspend = kvm_suspend, |
2468 | .resume = kvm_resume, | 2466 | .resume = kvm_resume, |
2469 | }; | 2467 | }; |
2470 | 2468 | ||
2471 | static struct sys_device kvm_sysdev = { | ||
2472 | .id = 0, | ||
2473 | .cls = &kvm_sysdev_class, | ||
2474 | }; | ||
2475 | |||
2476 | struct page *bad_page; | 2469 | struct page *bad_page; |
2477 | pfn_t bad_pfn; | 2470 | pfn_t bad_pfn; |
2478 | 2471 | ||
@@ -2556,14 +2549,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | |||
2556 | goto out_free_2; | 2549 | goto out_free_2; |
2557 | register_reboot_notifier(&kvm_reboot_notifier); | 2550 | register_reboot_notifier(&kvm_reboot_notifier); |
2558 | 2551 | ||
2559 | r = sysdev_class_register(&kvm_sysdev_class); | ||
2560 | if (r) | ||
2561 | goto out_free_3; | ||
2562 | |||
2563 | r = sysdev_register(&kvm_sysdev); | ||
2564 | if (r) | ||
2565 | goto out_free_4; | ||
2566 | |||
2567 | /* A kmem cache lets us meet the alignment requirements of fx_save. */ | 2552 | /* A kmem cache lets us meet the alignment requirements of fx_save. */ |
2568 | if (!vcpu_align) | 2553 | if (!vcpu_align) |
2569 | vcpu_align = __alignof__(struct kvm_vcpu); | 2554 | vcpu_align = __alignof__(struct kvm_vcpu); |
@@ -2571,7 +2556,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | |||
2571 | 0, NULL); | 2556 | 0, NULL); |
2572 | if (!kvm_vcpu_cache) { | 2557 | if (!kvm_vcpu_cache) { |
2573 | r = -ENOMEM; | 2558 | r = -ENOMEM; |
2574 | goto out_free_5; | 2559 | goto out_free_3; |
2575 | } | 2560 | } |
2576 | 2561 | ||
2577 | r = kvm_async_pf_init(); | 2562 | r = kvm_async_pf_init(); |
@@ -2588,6 +2573,8 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | |||
2588 | goto out_unreg; | 2573 | goto out_unreg; |
2589 | } | 2574 | } |
2590 | 2575 | ||
2576 | register_syscore_ops(&kvm_syscore_ops); | ||
2577 | |||
2591 | kvm_preempt_ops.sched_in = kvm_sched_in; | 2578 | kvm_preempt_ops.sched_in = kvm_sched_in; |
2592 | kvm_preempt_ops.sched_out = kvm_sched_out; | 2579 | kvm_preempt_ops.sched_out = kvm_sched_out; |
2593 | 2580 | ||
@@ -2599,10 +2586,6 @@ out_unreg: | |||
2599 | kvm_async_pf_deinit(); | 2586 | kvm_async_pf_deinit(); |
2600 | out_free: | 2587 | out_free: |
2601 | kmem_cache_destroy(kvm_vcpu_cache); | 2588 | kmem_cache_destroy(kvm_vcpu_cache); |
2602 | out_free_5: | ||
2603 | sysdev_unregister(&kvm_sysdev); | ||
2604 | out_free_4: | ||
2605 | sysdev_class_unregister(&kvm_sysdev_class); | ||
2606 | out_free_3: | 2589 | out_free_3: |
2607 | unregister_reboot_notifier(&kvm_reboot_notifier); | 2590 | unregister_reboot_notifier(&kvm_reboot_notifier); |
2608 | unregister_cpu_notifier(&kvm_cpu_notifier); | 2591 | unregister_cpu_notifier(&kvm_cpu_notifier); |
@@ -2630,8 +2613,7 @@ void kvm_exit(void) | |||
2630 | misc_deregister(&kvm_dev); | 2613 | misc_deregister(&kvm_dev); |
2631 | kmem_cache_destroy(kvm_vcpu_cache); | 2614 | kmem_cache_destroy(kvm_vcpu_cache); |
2632 | kvm_async_pf_deinit(); | 2615 | kvm_async_pf_deinit(); |
2633 | sysdev_unregister(&kvm_sysdev); | 2616 | unregister_syscore_ops(&kvm_syscore_ops); |
2634 | sysdev_class_unregister(&kvm_sysdev_class); | ||
2635 | unregister_reboot_notifier(&kvm_reboot_notifier); | 2617 | unregister_reboot_notifier(&kvm_reboot_notifier); |
2636 | unregister_cpu_notifier(&kvm_cpu_notifier); | 2618 | unregister_cpu_notifier(&kvm_cpu_notifier); |
2637 | on_each_cpu(hardware_disable_nolock, NULL, 1); | 2619 | on_each_cpu(hardware_disable_nolock, NULL, 1); |