From: Joao Martins <joao.m.martins@xxxxxxxxxx> Right now kvm_para_has_hint(KVM_HINTS_REALTIME) is x86 only. In pursuit of making cpuidle-haltpoll architecture independent, define arch_haltpoll_supported() which handles the architectural check for enabling haltpoll. Move the (kvm_para_available() && kvm_para_has_hint(KVM_HINTS_REALTIME)) check to the x86 specific arch_haltpoll_supported(). Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx> Signed-off-by: Mihai Carabas <mihai.carabas@xxxxxxxxxx> Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx> --- Changelog: - s/arch_haltpoll_want/arch_haltpoll_supported/ - change the check in haltpoll_want() from: (kvm_para_available() && arch_haltpoll_want()) || force; to arch_haltpoll_supported() || force; Dropped Rafael's acked-by due to these changes. --- arch/x86/include/asm/cpuidle_haltpoll.h | 1 + arch/x86/kernel/kvm.c | 10 ++++++++++ drivers/cpuidle/cpuidle-haltpoll.c | 9 ++------- include/linux/cpuidle_haltpoll.h | 5 +++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/cpuidle_haltpoll.h b/arch/x86/include/asm/cpuidle_haltpoll.h index c8b39c6716ff..43ce79b88662 100644 --- a/arch/x86/include/asm/cpuidle_haltpoll.h +++ b/arch/x86/include/asm/cpuidle_haltpoll.h @@ -4,5 +4,6 @@ void arch_haltpoll_enable(unsigned int cpu); void arch_haltpoll_disable(unsigned int cpu); +bool arch_haltpoll_supported(void); #endif diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 7f0732bc0ccd..e4dcbe9acc07 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1151,4 +1151,14 @@ void arch_haltpoll_disable(unsigned int cpu) smp_call_function_single(cpu, kvm_enable_host_haltpoll, NULL, 1); } EXPORT_SYMBOL_GPL(arch_haltpoll_disable); + +bool arch_haltpoll_supported(void) +{ + /* Do not load haltpoll if idle= is passed */ + if (boot_option_idle_override != IDLE_NO_OVERRIDE) + return false; + + return kvm_para_available() && kvm_para_has_hint(KVM_HINTS_REALTIME); +} +EXPORT_SYMBOL_GPL(arch_haltpoll_supported); #endif diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c index d8515d5c0853..70f585383171 100644 --- a/drivers/cpuidle/cpuidle-haltpoll.c +++ b/drivers/cpuidle/cpuidle-haltpoll.c @@ -15,7 +15,6 @@ #include <linux/cpuidle.h> #include <linux/module.h> #include <linux/sched/idle.h> -#include <linux/kvm_para.h> #include <linux/cpuidle_haltpoll.h> static bool force __read_mostly; @@ -95,7 +94,7 @@ static void haltpoll_uninit(void) static bool haltpoll_want(void) { - return kvm_para_has_hint(KVM_HINTS_REALTIME) || force; + return arch_haltpoll_supported() || force; } static int __init haltpoll_init(void) @@ -103,11 +102,7 @@ static int __init haltpoll_init(void) int ret; struct cpuidle_driver *drv = &haltpoll_driver; - /* Do not load haltpoll if idle= is passed */ - if (boot_option_idle_override != IDLE_NO_OVERRIDE) - return -ENODEV; - - if (!kvm_para_available() || !haltpoll_want()) + if (!haltpoll_want()) return -ENODEV; cpuidle_poll_state_init(drv); diff --git a/include/linux/cpuidle_haltpoll.h b/include/linux/cpuidle_haltpoll.h index d50c1e0411a2..a3caf01d3f0e 100644 --- a/include/linux/cpuidle_haltpoll.h +++ b/include/linux/cpuidle_haltpoll.h @@ -12,5 +12,10 @@ static inline void arch_haltpoll_enable(unsigned int cpu) static inline void arch_haltpoll_disable(unsigned int cpu) { } + +static inline bool arch_haltpoll_supported(void) +{ + return false; +} #endif #endif -- 2.39.3