From 60555e371d56a1e410d9fb6fc68f4e953f8f4109 Mon Sep 17 00:00:00 2001 From: "len.brown@intel.com" Date: Mon, 19 Nov 2007 22:22:37 -0500 Subject: ACPI: CONFIG_CPU_IDLE=ACPI by default In Linux-2.6.24, CPU_IDLE went upstream, default =n. For Linux-2.6.25, enable it by default on ACPI systems. For Linux-2.6.26, we plan to enable it always on ACPI systems. Signed-off-by: Len Brown --- drivers/cpuidle/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/cpuidle') diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index 3bed4127d4ad..7dbc4a83c45c 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -1,13 +1,13 @@ config CPU_IDLE bool "CPU idle PM support" + default ACPI help CPU idle is a generic framework for supporting software-controlled idle processor power management. It includes modular cross-platform governors that can be swapped during runtime. - If you're using a mobile platform that supports CPU idle PM (e.g. - an ACPI-capable notebook), you should say Y here. + If you're using an ACPI-enabled platform, you should say Y here. config CPU_IDLE_GOV_LADDER bool -- cgit v1.2.3 From f757397097d0713c949af76dccabb65a2785782e Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Thu, 31 Jan 2008 17:28:18 -0800 Subject: cpuidle: build fix for non-x86 Convert cpu_idle_wait() to cpuidle_kick_cpus() macro which is SMP-only, and gives error on non supported CPU. Signed-off-by: Kevin Hilman Acked-by: Venkatesh Pallipadi Acked-by: Rafael J. Wysocki Signed-off-by: Len Brown --- arch/x86/Kconfig | 3 +++ drivers/cpuidle/cpuidle.c | 2 +- include/linux/cpuidle.h | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'drivers/cpuidle') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 368864dfe6eb..37d1297e6787 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -105,6 +105,9 @@ config ARCH_HAS_ILOG2_U32 config ARCH_HAS_ILOG2_U64 def_bool n +config ARCH_HAS_CPU_IDLE_WAIT + def_bool y + config GENERIC_CALIBRATE_DELAY def_bool y diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index d2fabe7863a9..794962d9f48b 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -82,7 +82,7 @@ void cpuidle_uninstall_idle_handler(void) { if (enabled_devices && (pm_idle != pm_idle_old)) { pm_idle = pm_idle_old; - cpu_idle_wait(); + cpuidle_kick_cpus(); } } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 16a51546db44..cb95f5a9075a 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -72,6 +72,19 @@ cpuidle_set_statedata(struct cpuidle_state *state, void *data) state->driver_data = data; } +#ifdef CONFIG_SMP +#ifdef CONFIG_ARCH_HAS_CPU_IDLE_WAIT +static inline void cpuidle_kick_cpus(void) +{ + cpu_idle_wait(); +} +#else /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT */ +#error "Arch needs cpu_idle_wait() equivalent here" +#endif /* !CONFIG_ARCH_HAS_CPU_IDLE_WAIT */ +#else /* !CONFIG_SMP */ +static inline void cpuidle_kick_cpus(void) {} +#endif /* !CONFIG_SMP */ + struct cpuidle_state_kobj { struct cpuidle_state *state; struct completion kobj_unregister; -- cgit v1.2.3 From 9a0b841586c3c6c846effdbe75885c2ebc0031b0 Mon Sep 17 00:00:00 2001 From: "venkatesh.pallipadi@intel.com" Date: Thu, 31 Jan 2008 17:35:06 -0800 Subject: cpuidle: Add a poll_idle method Add a default poll idle state with 0 latency. Provides an option to users to use poll_idle by using 0 as the latency requirement. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- arch/x86/Kconfig | 3 +++ drivers/acpi/processor_idle.c | 4 +++- drivers/cpuidle/cpuidle.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/cpuidle.h | 13 ++++++++++--- 4 files changed, 57 insertions(+), 4 deletions(-) (limited to 'drivers/cpuidle') diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e6728bd61cc1..fd4265007053 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -105,6 +105,9 @@ config GENERIC_TIME_VSYSCALL bool default X86_64 +config ARCH_HAS_CPU_RELAX + def_bool y + config HAVE_SETUP_PER_CPU_AREA def_bool X86_64 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index fea71597b40a..32488e6f76ab 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1628,7 +1628,7 @@ struct cpuidle_driver acpi_idle_driver = { */ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) { - int i, count = 0; + int i, count = CPUIDLE_DRIVER_STATE_START; struct acpi_processor_cx *cx; struct cpuidle_state *state; struct cpuidle_device *dev = &pr->power.dev; @@ -1687,6 +1687,8 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) } count++; + if (count == CPUIDLE_STATE_MAX) + break; } dev->state_count = count; diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 2a98d99cbd46..2c4b2d47973e 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "cpuidle.h" @@ -180,6 +181,44 @@ void cpuidle_disable_device(struct cpuidle_device *dev) EXPORT_SYMBOL_GPL(cpuidle_disable_device); +#ifdef CONFIG_ARCH_HAS_CPU_RELAX +static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st) +{ + ktime_t t1, t2; + s64 diff; + int ret; + + t1 = ktime_get(); + local_irq_enable(); + while (!need_resched()) + cpu_relax(); + + t2 = ktime_get(); + diff = ktime_to_us(ktime_sub(t2, t1)); + if (diff > INT_MAX) + diff = INT_MAX; + + ret = (int) diff; + return ret; +} + +static void poll_idle_init(struct cpuidle_device *dev) +{ + struct cpuidle_state *state = &dev->states[0]; + + cpuidle_set_statedata(state, NULL); + + snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)"); + state->exit_latency = 0; + state->target_residency = 0; + state->power_usage = -1; + state->flags = CPUIDLE_FLAG_POLL | CPUIDLE_FLAG_TIME_VALID; + state->enter = poll_idle; +} +#else +static void poll_idle_init(struct cpuidle_device *dev) {} +#endif /* CONFIG_ARCH_HAS_CPU_RELAX */ + /** * cpuidle_register_device - registers a CPU's idle PM feature * @dev: the cpu @@ -198,6 +237,8 @@ int cpuidle_register_device(struct cpuidle_device *dev) mutex_lock(&cpuidle_lock); + poll_idle_init(dev); + per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); if ((ret = cpuidle_add_sysfs(sys_dev))) { diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index b0fd85ab9efb..385d45b616db 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -46,9 +46,10 @@ struct cpuidle_state { /* Idle State Flags */ #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ #define CPUIDLE_FLAG_CHECK_BM (0x02) /* BM activity will exit state */ -#define CPUIDLE_FLAG_SHALLOW (0x10) /* low latency, minimal savings */ -#define CPUIDLE_FLAG_BALANCED (0x20) /* medium latency, moderate savings */ -#define CPUIDLE_FLAG_DEEP (0x40) /* high latency, large savings */ +#define CPUIDLE_FLAG_POLL (0x10) /* no latency, no savings */ +#define CPUIDLE_FLAG_SHALLOW (0x20) /* low latency, minimal savings */ +#define CPUIDLE_FLAG_BALANCED (0x40) /* medium latency, moderate savings */ +#define CPUIDLE_FLAG_DEEP (0x80) /* high latency, large savings */ #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) @@ -178,4 +179,10 @@ static inline void cpuidle_unregister_governor(struct cpuidle_governor *gov) { } #endif +#ifdef CONFIG_ARCH_HAS_CPU_RELAX +#define CPUIDLE_DRIVER_STATE_START 1 +#else +#define CPUIDLE_DRIVER_STATE_START 0 +#endif + #endif /* _LINUX_CPUIDLE_H */ -- cgit v1.2.3