From patchwork Mon Mar 21 23:37:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 650661 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2LNf5Kr022058 for ; Mon, 21 Mar 2011 23:41:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932262Ab1CUXkH (ORCPT ); Mon, 21 Mar 2011 19:40:07 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:51875 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932227Ab1CUXjE (ORCPT ); Mon, 21 Mar 2011 19:39:04 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 7E6CE1A5EE1; Tue, 22 Mar 2011 00:23:38 +0100 (CET) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22103-07; Tue, 22 Mar 2011 00:23:16 +0100 (CET) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id 9ACEF1A8B0B; Tue, 22 Mar 2011 00:23:07 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM mailing list Subject: [PATCH 4/6] KVM: Use syscore_ops instead of sysdev class and sysdev Date: Tue, 22 Mar 2011 00:37:06 +0100 User-Agent: KMail/1.13.6 (Linux/2.6.38+; KDE/4.6.0; x86_64; ; ) Cc: LKML , Greg KH , Kay Sievers , Jesse Barnes , "H. Peter Anvin" , mingo@redhat.com, tglx@linutronix.de, Dave Jones , Alan Stern , Avi Kivity , David Woodhouse , kvm@vger.kernel.org, iommu@lists.linux-foundation.org, cpufreq@vger.kernel.org References: <201103100131.58206.rjw@sisk.pl> <201103122212.40828.rjw@sisk.pl> <201103220031.22729.rjw@sisk.pl> In-Reply-To: <201103220031.22729.rjw@sisk.pl> MIME-Version: 1.0 Message-Id: <201103220037.06465.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 21 Mar 2011 23:41:05 +0000 (UTC) Index: linux-2.6/virt/kvm/kvm_main.c =================================================================== --- linux-2.6.orig/virt/kvm/kvm_main.c +++ linux-2.6/virt/kvm/kvm_main.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -2447,33 +2447,26 @@ static void kvm_exit_debug(void) debugfs_remove(kvm_debugfs_dir); } -static int kvm_suspend(struct sys_device *dev, pm_message_t state) +static int kvm_suspend(void) { if (kvm_usage_count) hardware_disable_nolock(NULL); return 0; } -static int kvm_resume(struct sys_device *dev) +static void kvm_resume(void) { if (kvm_usage_count) { WARN_ON(raw_spin_is_locked(&kvm_lock)); hardware_enable_nolock(NULL); } - return 0; } -static struct sysdev_class kvm_sysdev_class = { - .name = "kvm", +static struct syscore_ops kvm_syscore_ops = { .suspend = kvm_suspend, .resume = kvm_resume, }; -static struct sys_device kvm_sysdev = { - .id = 0, - .cls = &kvm_sysdev_class, -}; - struct page *bad_page; pfn_t bad_pfn; @@ -2557,14 +2550,6 @@ int kvm_init(void *opaque, unsigned vcpu goto out_free_2; register_reboot_notifier(&kvm_reboot_notifier); - r = sysdev_class_register(&kvm_sysdev_class); - if (r) - goto out_free_3; - - r = sysdev_register(&kvm_sysdev); - if (r) - goto out_free_4; - /* A kmem cache lets us meet the alignment requirements of fx_save. */ if (!vcpu_align) vcpu_align = __alignof__(struct kvm_vcpu); @@ -2572,7 +2557,7 @@ int kvm_init(void *opaque, unsigned vcpu 0, NULL); if (!kvm_vcpu_cache) { r = -ENOMEM; - goto out_free_5; + goto out_free_3; } r = kvm_async_pf_init(); @@ -2589,6 +2574,8 @@ int kvm_init(void *opaque, unsigned vcpu goto out_unreg; } + register_syscore_ops(&kvm_syscore_ops); + kvm_preempt_ops.sched_in = kvm_sched_in; kvm_preempt_ops.sched_out = kvm_sched_out; @@ -2600,10 +2587,6 @@ out_unreg: kvm_async_pf_deinit(); out_free: kmem_cache_destroy(kvm_vcpu_cache); -out_free_5: - sysdev_unregister(&kvm_sysdev); -out_free_4: - sysdev_class_unregister(&kvm_sysdev_class); out_free_3: unregister_reboot_notifier(&kvm_reboot_notifier); unregister_cpu_notifier(&kvm_cpu_notifier); @@ -2631,8 +2614,7 @@ void kvm_exit(void) misc_deregister(&kvm_dev); kmem_cache_destroy(kvm_vcpu_cache); kvm_async_pf_deinit(); - sysdev_unregister(&kvm_sysdev); - sysdev_class_unregister(&kvm_sysdev_class); + unregister_syscore_ops(&kvm_syscore_ops); unregister_reboot_notifier(&kvm_reboot_notifier); unregister_cpu_notifier(&kvm_cpu_notifier); on_each_cpu(hardware_disable_nolock, NULL, 1);