cpuidle-haltpoll.c (fa86ee90eb1111267de67cb4272b5ce711f18cbb) | cpuidle-haltpoll.c (a1c4423b02b2121108e3ea9580741e0f26309a48) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * cpuidle driver for haltpoll governor. 4 * 5 * Copyright 2019 Red Hat, Inc. and/or its affiliates. 6 * 7 * This work is licensed under the terms of the GNU GPL, version 2. See 8 * the COPYING file in the top-level directory. 9 * 10 * Authors: Marcelo Tosatti <mtosatti@redhat.com> 11 */ 12 13#include <linux/init.h> 14#include <linux/cpuidle.h> 15#include <linux/module.h> 16#include <linux/sched/idle.h> 17#include <linux/kvm_para.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * cpuidle driver for haltpoll governor. 4 * 5 * Copyright 2019 Red Hat, Inc. and/or its affiliates. 6 * 7 * This work is licensed under the terms of the GNU GPL, version 2. See 8 * the COPYING file in the top-level directory. 9 * 10 * Authors: Marcelo Tosatti <mtosatti@redhat.com> 11 */ 12 13#include <linux/init.h> 14#include <linux/cpuidle.h> 15#include <linux/module.h> 16#include <linux/sched/idle.h> 17#include <linux/kvm_para.h> |
18#include <linux/cpuidle_haltpoll.h> |
|
18 19static int default_enter_idle(struct cpuidle_device *dev, 20 struct cpuidle_driver *drv, int index) 21{ 22 if (current_clr_polling_and_test()) { 23 local_irq_enable(); 24 return index; 25 } --- 16 unchanged lines hidden (view full) --- 42 }, 43 }, 44 .safe_state_index = 0, 45 .state_count = 2, 46}; 47 48static int __init haltpoll_init(void) 49{ | 19 20static int default_enter_idle(struct cpuidle_device *dev, 21 struct cpuidle_driver *drv, int index) 22{ 23 if (current_clr_polling_and_test()) { 24 local_irq_enable(); 25 return index; 26 } --- 16 unchanged lines hidden (view full) --- 43 }, 44 }, 45 .safe_state_index = 0, 46 .state_count = 2, 47}; 48 49static int __init haltpoll_init(void) 50{ |
51 int ret; |
|
50 struct cpuidle_driver *drv = &haltpoll_driver; 51 52 cpuidle_poll_state_init(drv); 53 54 if (!kvm_para_available()) 55 return 0; 56 | 52 struct cpuidle_driver *drv = &haltpoll_driver; 53 54 cpuidle_poll_state_init(drv); 55 56 if (!kvm_para_available()) 57 return 0; 58 |
57 return cpuidle_register(&haltpoll_driver, NULL); | 59 ret = cpuidle_register(&haltpoll_driver, NULL); 60 if (ret == 0) 61 arch_haltpoll_enable(); 62 63 return ret; |
58} 59 60static void __exit haltpoll_exit(void) 61{ | 64} 65 66static void __exit haltpoll_exit(void) 67{ |
68 arch_haltpoll_disable(); |
|
62 cpuidle_unregister(&haltpoll_driver); 63} 64 65module_init(haltpoll_init); 66module_exit(haltpoll_exit); 67MODULE_LICENSE("GPL"); 68MODULE_AUTHOR("Marcelo Tosatti <mtosatti@redhat.com>"); | 69 cpuidle_unregister(&haltpoll_driver); 70} 71 72module_init(haltpoll_init); 73module_exit(haltpoll_exit); 74MODULE_LICENSE("GPL"); 75MODULE_AUTHOR("Marcelo Tosatti <mtosatti@redhat.com>"); |