idle patch queue for Linux 3.1
Subsystems (7)
Len Brown
reviewerPATCH 1/5 mrst_pmu: driver for Intel Moorestown Power Management Unit
In reply to Len BrownFrom: Len Brown <[email protected]>
The Moorestown (MRST) Power Management Unit (PMU) driver directs the SOC power states in the "Langwell" south complex (SCU).
It hooks pci_platform_pm_ops[] and thus observes all PCI ".set_state" requests. For devices in the SC, the pmu driver translates those PCI requests into the appropriate commands for the SCU.
The PMU driver helps implement S0i3, a deep system idle power idle state. Entry into S0i3 is via cpuidle, just like regular processor c-states. S0i3 depends on pre-conditions including uni-processor, graphics off, and certain IO devices in the SC must be off. If those pre-conditions are met, then the PMU allows cpuidle to enter S0i3, otherwise such requests are demoted, either to Atom C4 or Atom C6.
This driver is based on prototype work by Bruce Flemming, Illyas Mansoor, Rajeev D. Muralidhar, Vishwesh M. Rudramuni, Hari Seshadri and Sujith Thomas. The current driver also includes contributions from H. Peter Anvin, Arjan van de Ven, Kristen Accardi, and Yong Wang.
Thanks for additional review feedback from Alan Cox and Randy Dunlap.
--- MAINTAINERS | 6 + arch/x86/platform/mrst/Makefile | 1 + arch/x86/platform/mrst/pmu.c | 817 +++++++++++++++++++++++++++++++++++++++ arch/x86/platform/mrst/pmu.h | 234 +++++++++++ 4 files changed, 1058 insertions(+), 0 deletions(-) create mode 100644 arch/x86/platform/mrst/pmu.c create mode 100644 arch/x86/platform/mrst/pmu.h
MAINTAINERS +6 -0
@@ -3344,6 +3344,12 @@ F: drivers/net/ixgb/ F: drivers/net/ixgbe/ F: drivers/net/ixgbevf/ +INTEL MRST PMU DRIVER +M: Len Brown <[email protected]> +L: [email protected] +S: Supported +F: arch/x86/platform/mrst/pmu.* + INTEL PRO/WIRELESS 2100 NETWORK CONNECTION SUPPORT L: [email protected] S: Orphan
arch/x86/platform/mrst/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_X86_MRST) += mrst.o obj-$(CONFIG_X86_MRST) += vrtc.o obj-$(CONFIG_EARLY_PRINTK_MRST) += early_printk_mrst.o +obj-$(CONFIG_X86_MRST) += pmu.o
arch/x86/platform/mrst/pmu.c new file +817 -0
817 lines not on this page · raw message
arch/x86/platform/mrst/pmu.h new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 2/5 cpuidle: create bootparam "cpuidle.off=1"
In reply to Len BrownFrom: Len Brown <[email protected]>
useful for disabling cpuidle to fall back
to architecture-default idle loop
cpuidle drivers and governors will fail to register. on x86 they'll say so:
intel_idle: intel_idle yielding to (null)
ACPI: acpi_idle yielding to (null)
--- Documentation/kernel-parameters.txt | 3 +++ drivers/cpuidle/cpuidle.c | 10 ++++++++++ drivers/cpuidle/cpuidle.h | 1 + drivers/cpuidle/driver.c | 3 +++ drivers/cpuidle/governor.c | 3 +++ 5 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +3 -0
@@ -546,6 +546,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. /proc/<pid>/coredump_filter. See also Documentation/filesystems/proc.txt. + cpuidle.off=1 [CPU_IDLE] + disable the cpuidle sub-system + cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver Format: <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
drivers/cpuidle/cpuidle.c +10 -0
@@ -28,6 +28,12 @@ LIST_HEAD(cpuidle_detected_devices);static void (*pm_idle_old)(void );static int enabled_devices; +static int off__read_mostly ; + +int cpuidle_disabled (void ) +{ +return off; +}#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT )static void cpuidle_kick_cpus (void )
@@ -427,6 +433,9 @@ static int __init cpuidle_init(void) {int ret; +if (cpuidle_disabled ()) +return -ENODEV ; + pm_idle_old = pm_idle; ret =cpuidle_add_class_sysfs (&cpu_sysdev_class);
@@ -438,4 +447,5 @@ static int __init cpuidle_init(void)return 0 ; } +module_param (off, int,0444 );core_initcall (cpuidle_init);
drivers/cpuidle/cpuidle.h +1 -0
@@ -13,6 +13,7 @@ extern struct list_head cpuidle_governors;extern struct list_head cpuidle_detected_devices;extern struct mutex cpuidle_lock;extern spinlock_t cpuidle_driver_lock; +extern int cpuidle_disabled (void );/* idle loop */ extern void cpuidle_install_idle_handler (void );
drivers/cpuidle/driver.c +3 -0
@@ -26,6 +26,9 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)if (!drv)return -EINVAL ; +if (cpuidle_disabled ()) +return -ENODEV ; +spin_lock (&cpuidle_driver_lock);if (cpuidle_curr_driver) {spin_unlock (&cpuidle_driver_lock);
drivers/cpuidle/governor.c +3 -0
@@ -81,6 +81,9 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)if (!gov || !gov->select)return -EINVAL ; +if (cpuidle_disabled ()) +return -ENODEV ; +mutex_lock (&cpuidle_lock);if (__cpuidle_find_governor (gov->name) ==NULL ) { ret =0 ;
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 3/5 cpuidle: replace xen access to x86 pm_idle and default_idle
In reply to Len BrownFrom: Len Brown <[email protected]>
When a Xen Dom0 kernel boots on a hypervisor, it gets access to the raw-hardware ACPI tables. While it parses the idle tables for the hypervisor's beneift, it uses HLT for its own idle.
Rather than have xen scribble on pm_idle and access default_idle, have it simply disable_cpuidle() so acpi_idle will not load and architecture default HLT will be used.
--- arch/x86/xen/setup.c | 3 ++- drivers/cpuidle/cpuidle.c | 4 ++++ include/linux/cpuidle.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/xen/setup.c +2 -1
@@ -9,6 +9,7 @@#include <linux/mm.h> #include <linux/pm.h> #include <linux/memblock.h> +#include <linux/cpuidle.h> #include <asm/elf.h> #include <asm/vdso.h>
@@ -426,7 +427,7 @@ void __init xen_arch_setup(void)#ifdef CONFIG_X86_32 boot_cpu_data.hlt_works_ok =1 ;#endif - pm_idle = default_idle; +disable_cpuidle (); boot_option_idle_override =IDLE_HALT ;fiddle_vdso ();
drivers/cpuidle/cpuidle.c +4 -0
@@ -34,6 +34,10 @@ int cpuidle_disabled(void) {return off; } +void disable_cpuidle (void ) +{ + off =1 ; +}#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT )static void cpuidle_kick_cpus (void )
include/linux/cpuidle.h +2 -0
@@ -122,6 +122,7 @@ struct cpuidle_driver { };#ifdef CONFIG_CPU_IDLE +extern void disable_cpuidle (void );extern int cpuidle_register_driver (struct cpuidle_driver *drv);struct cpuidle_driver *cpuidle_get_driver (void );
@@ -135,6 +136,7 @@ extern int cpuidle_enable_device(struct cpuidle_device *dev);extern void cpuidle_disable_device (struct cpuidle_device *dev);#else +static inline void disable_cpuidle (void ) { }static inline int cpuidle_register_driver (struct cpuidle_driver *drv) {return -ENODEV ; }
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 3/5 cpuidle: replace xen access to x86 pm_idle and default_idle
In reply to Len BrownFrom: Len Brown <[email protected]>
When a Xen Dom0 kernel boots on a hypervisor, it gets access to the raw-hardware ACPI tables. While it parses the idle tables for the hypervisor's beneift, it uses HLT for its own idle.
Rather than have xen scribble on pm_idle and access default_idle, have it simply disable_cpuidle() so acpi_idle will not load and architecture default HLT will be used.
--- arch/x86/xen/setup.c | 3 ++- drivers/cpuidle/cpuidle.c | 4 ++++ include/linux/cpuidle.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletions(-)
arch/x86/xen/setup.c +2 -1
@@ -9,6 +9,7 @@#include <linux/mm.h> #include <linux/pm.h> #include <linux/memblock.h> +#include <linux/cpuidle.h> #include <asm/elf.h> #include <asm/vdso.h>
@@ -426,7 +427,7 @@ void __init xen_arch_setup(void)#ifdef CONFIG_X86_32 boot_cpu_data.hlt_works_ok =1 ;#endif - pm_idle = default_idle; +disable_cpuidle (); boot_option_idle_override =IDLE_HALT ;fiddle_vdso ();
drivers/cpuidle/cpuidle.c +4 -0
@@ -34,6 +34,10 @@ int cpuidle_disabled(void) {return off; } +void disable_cpuidle (void ) +{ + off =1 ; +}#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT )static void cpuidle_kick_cpus (void )
include/linux/cpuidle.h +2 -0
@@ -122,6 +122,7 @@ struct cpuidle_driver { };#ifdef CONFIG_CPU_IDLE +extern void disable_cpuidle (void );extern int cpuidle_register_driver (struct cpuidle_driver *drv);struct cpuidle_driver *cpuidle_get_driver (void );
@@ -135,6 +136,7 @@ extern int cpuidle_enable_device(struct cpuidle_device *dev);extern void cpuidle_disable_device (struct cpuidle_device *dev);#else +static inline void disable_cpuidle (void ) { }static inline int cpuidle_register_driver (struct cpuidle_driver *drv) {return -ENODEV ; }
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 4/5 x86 idle: move mwait_idle_with_hints() to where it is used
In reply to Len BrownFrom: Len Brown <[email protected]>
...and make it static
no functional change
--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/acpi/cstate.c | 23 +++++++++++++++++++++++ arch/x86/kernel/process.c | 23 ----------------------- 3 files changed, 23 insertions(+), 25 deletions(-)
arch/x86/include/asm/processor.h +0 -2
@@ -751,8 +751,6 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx) :: "a" (eax), "c" (ecx)); } -extern void mwait_idle_with_hints (unsigned long eax,unsigned long ecx); -extern void select_idle_routine (const struct cpuinfo_x86 *c);extern void init_amd_e400_c1e_mask (void );
arch/x86/kernel/acpi/cstate.c +23 -0
@@ -149,6 +149,29 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, }EXPORT_SYMBOL_GPL (acpi_processor_ffh_cstate_probe); +/* +* This uses new MONITOR/MWAIT instructions on P4 processors with PNI, +* which can obviate IPI to trigger checking of need_resched. +* We execute MONITOR against need_resched and enter optimized wait state +* through MWAIT. Whenever someone changes need_resched, we would be woken +* up from MWAIT (without an IPI). +* +* New with Core Duo processors, MWAIT can take some hints based on CPU +* capability. +*/ +void mwait_idle_with_hints (unsigned long ax,unsigned long cx) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags); + +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__mwait (ax, cx); + } +} +void acpi_processor_ffh_cstate_enter (struct acpi_processor_cx *cx) {unsigned int cpu =smp_processor_id ();
arch/x86/kernel/process.c +0 -23
@@ -438,29 +438,6 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); -/* -* This uses new MONITOR/MWAIT instructions on P4 processors with PNI, -* which can obviate IPI to trigger checking of need_resched. -* We execute MONITOR against need_resched and enter optimized wait state -* through MWAIT. Whenever someone changes need_resched, we would be woken -* up from MWAIT (without an IPI). -* -* New with Core Duo processors, MWAIT can take some hints based on CPU -* capability. -*/ -void mwait_idle_with_hints (unsigned long ax,unsigned long cx) -{ -if (!need_resched ()) { -if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) -clflush ((void *)¤t_thread_info ()->flags); - -__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); -smp_mb (); -if (!need_resched ()) -__mwait (ax, cx); - } -} -/* Default MONITOR/MWAIT with no hints, used for default C1 state */ static void mwait_idle (void ) {
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 5/5 cpuidle: stop depending on pm_idle
In reply to Len BrownFrom: Len Brown <[email protected]>
cpuidle users should call cpuidle_call_idle() directly rather than via (pm_idle)() function pointer.
Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it:
my_arch_cpu_idle()
... if(cpuidle_call_idle()) pm_idle();
--- arch/arm/kernel/process.c | 4 +++- arch/sh/kernel/idle.c | 6 ++++-- arch/x86/kernel/process_32.c | 4 +++- arch/x86/kernel/process_64.c | 4 +++- drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++-------------------- include/linux/cpuidle.h | 2 ++ 6 files changed, 33 insertions(+), 25 deletions(-)
arch/arm/kernel/process.c +3 -1
@@ -30,6 +30,7 @@#include <linux/uaccess.h> #include <linux/random.h> #include <linux/hw_breakpoint.h> +#include <linux/cpuidle.h> #include <asm/cacheflush.h> #include <asm/leds.h>
@@ -196,7 +197,8 @@ void cpu_idle(void)cpu_relax (); }else {stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ()) +pm_idle ();start_critical_timings ();/* * This will eventually be removed - pm_idle
arch/sh/kernel/idle.c +4 -2
@@ -16,12 +16,13 @@#include <linux/thread_info.h> #include <linux/irqflags.h> #include <linux/smp.h> +#include <linux/cpuidle.h> #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/smp.h> -void (*pm_idle)(void ) =NULL ; +static void (*pm_idle)(void );static int hlt_counter;
@@ -100,7 +101,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ()) +pm_idle ();/* * Sanity check to ensure that pm_idle() returns * with IRQs enabled
arch/x86/kernel/process_32.c +3 -1
@@ -38,6 +38,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/kdebug.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h>
@@ -109,7 +110,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings (); }tick_nohz_restart_sched_tick ();
arch/x86/kernel/process_64.c +3 -1
@@ -37,6 +37,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/ftrace.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h>
@@ -136,7 +137,8 @@ void cpu_idle(void)enter_idle ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings ();/* In many cases the interrupt that ended idle
drivers/cpuidle/cpuidle.c +18 -20
@@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);DEFINE_MUTEX (cpuidle_lock);LIST_HEAD (cpuidle_detected_devices); -static void (*pm_idle_old)(void );static int enabled_devices;static int off__read_mostly ; +static int initialized__read_mostly ;int cpuidle_disabled (void ) {
@@ -56,25 +56,23 @@ static int __cpuidle_register_device(struct cpuidle_device *dev);* cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here +* return non-zero on failure */ -static void cpuidle_idle_call (void ) +int cpuidle_idle_call (void ) {struct cpuidle_device *dev =__this_cpu_read (cpuidle_devices);struct cpuidle_state *target_state;int next_state; +if (off) +return -ENODEV ; + +if (!initialized) +return -ENODEV ; +/* check if the device is ready */ -if (!dev || !dev->enabled) { -if (pm_idle_old) -pm_idle_old (); - else -#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE ) -default_idle (); -#else -local_irq_enable (); -#endif -return ; - } +if (!dev || !dev->enabled) +return -EBUSY ;#if 0 /* shows regressions, re-enable for 2.6.29 */
@@ -99,7 +97,7 @@ static void cpuidle_idle_call(void) next_state = cpuidle_curr_governor->select (dev);if (need_resched ()) {local_irq_enable (); -return ; +return 0 ; } target_state = &dev->states[next_state];
@@ -124,6 +122,8 @@ static void cpuidle_idle_call(void)/* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect (dev); + +return 0 ; }/**
@@ -131,10 +131,10 @@ static void cpuidle_idle_call(void)*/ void cpuidle_install_idle_handler (void ) { -if (enabled_devices && (pm_idle != cpuidle_idle_call)) { +if (enabled_devices) {/* Make sure all changes finished before we switch to new idle */ smp_wmb (); - pm_idle = cpuidle_idle_call; + initialized =1 ; } }
@@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void)*/ void cpuidle_uninstall_idle_handler (void ) { -if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { - pm_idle = pm_idle_old; +if (enabled_devices) { + initialized =0 ;cpuidle_kick_cpus (); } }
@@ -440,8 +440,6 @@ static int __init cpuidle_init(void)if (cpuidle_disabled ())return -ENODEV ; - pm_idle_old = pm_idle; - ret =cpuidle_add_class_sysfs (&cpu_sysdev_class);if (ret)return ret;
include/linux/cpuidle.h +2 -0
@@ -123,6 +123,7 @@ struct cpuidle_driver {#ifdef CONFIG_CPU_IDLE extern void disable_cpuidle (void ); +extern int cpuidle_idle_call (void );extern int cpuidle_register_driver (struct cpuidle_driver *drv);struct cpuidle_driver *cpuidle_get_driver (void );
@@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);#else static inline void disable_cpuidle (void ) { } +static inline int cpuidle_idle_call (void ) {return -ENODEV ; }static inline int cpuidle_register_driver (struct cpuidle_driver *drv) {return -ENODEV ; }
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerHere is the idle patch queue for Linux 3.1
Please let me know if you see troubles with
any of these patches.
thanks,
-Len Brown, Intel Open Source Technology Center
Len Brown
reviewerPATCH 2/5 cpuidle: create bootparam "cpuidle.off=1"
From: Len Brown <[email protected]>
useful for disabling cpuidle to fall back
to architecture-default idle loop
cpuidle drivers and governors will fail to register. on x86 they'll say so:
intel_idle: intel_idle yielding to (null)
ACPI: acpi_idle yielding to (null)
--- Documentation/kernel-parameters.txt | 3 +++ drivers/cpuidle/cpuidle.c | 10 ++++++++++ drivers/cpuidle/cpuidle.h | 1 + drivers/cpuidle/driver.c | 3 +++ drivers/cpuidle/governor.c | 3 +++ 5 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +3 -0
@@ -546,6 +546,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. /proc/<pid>/coredump_filter. See also Documentation/filesystems/proc.txt. + cpuidle.off=1 [CPU_IDLE] + disable the cpuidle sub-system + cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver Format: <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
drivers/cpuidle/cpuidle.c +10 -0
@@ -28,6 +28,12 @@ LIST_HEAD(cpuidle_detected_devices);static void (*pm_idle_old)(void );static int enabled_devices; +static int off__read_mostly ; + +int cpuidle_disabled (void ) +{ +return off; +}#if defined(CONFIG_ARCH_HAS_CPU_IDLE_WAIT )static void cpuidle_kick_cpus (void )
@@ -427,6 +433,9 @@ static int __init cpuidle_init(void) {int ret; +if (cpuidle_disabled ()) +return -ENODEV ; + pm_idle_old = pm_idle; ret =cpuidle_add_class_sysfs (&cpu_sysdev_class);
@@ -438,4 +447,5 @@ static int __init cpuidle_init(void)return 0 ; } +module_param (off, int,0444 );core_initcall (cpuidle_init);
drivers/cpuidle/cpuidle.h +1 -0
@@ -13,6 +13,7 @@ extern struct list_head cpuidle_governors;extern struct list_head cpuidle_detected_devices;extern struct mutex cpuidle_lock;extern spinlock_t cpuidle_driver_lock; +extern int cpuidle_disabled (void );/* idle loop */ extern void cpuidle_install_idle_handler (void );
drivers/cpuidle/driver.c +3 -0
@@ -26,6 +26,9 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)if (!drv)return -EINVAL ; +if (cpuidle_disabled ()) +return -ENODEV ; +spin_lock (&cpuidle_driver_lock);if (cpuidle_curr_driver) {spin_unlock (&cpuidle_driver_lock);
drivers/cpuidle/governor.c +3 -0
@@ -81,6 +81,9 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)if (!gov || !gov->select)return -EINVAL ; +if (cpuidle_disabled ()) +return -ENODEV ; +mutex_lock (&cpuidle_lock);if (__cpuidle_find_governor (gov->name) ==NULL ) { ret =0 ;
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 5/5 cpuidle: stop depending on pm_idle
In reply to Len BrownFrom: Len Brown <[email protected]>
cpuidle users should call cpuidle_call_idle() directly rather than via (pm_idle)() function pointer.
Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it:
my_arch_cpu_idle()
... if(cpuidle_call_idle()) pm_idle();
--- arch/arm/kernel/process.c | 4 +++- arch/sh/kernel/idle.c | 6 ++++-- arch/x86/kernel/process_32.c | 4 +++- arch/x86/kernel/process_64.c | 4 +++- drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++-------------------- include/linux/cpuidle.h | 2 ++ 6 files changed, 33 insertions(+), 25 deletions(-)
arch/arm/kernel/process.c +3 -1
@@ -30,6 +30,7 @@#include <linux/uaccess.h> #include <linux/random.h> #include <linux/hw_breakpoint.h> +#include <linux/cpuidle.h> #include <asm/cacheflush.h> #include <asm/leds.h>
@@ -196,7 +197,8 @@ void cpu_idle(void)cpu_relax (); }else {stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ()) +pm_idle ();start_critical_timings ();/* * This will eventually be removed - pm_idle
arch/sh/kernel/idle.c +4 -2
@@ -16,12 +16,13 @@#include <linux/thread_info.h> #include <linux/irqflags.h> #include <linux/smp.h> +#include <linux/cpuidle.h> #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/smp.h> -void (*pm_idle)(void ) =NULL ; +static void (*pm_idle)(void );static int hlt_counter;
@@ -100,7 +101,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ()) +pm_idle ();/* * Sanity check to ensure that pm_idle() returns * with IRQs enabled
arch/x86/kernel/process_32.c +3 -1
@@ -38,6 +38,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/kdebug.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h>
@@ -109,7 +110,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings (); }tick_nohz_restart_sched_tick ();
arch/x86/kernel/process_64.c +3 -1
@@ -37,6 +37,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/ftrace.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h>
@@ -136,7 +137,8 @@ void cpu_idle(void)enter_idle ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings ();/* In many cases the interrupt that ended idle
drivers/cpuidle/cpuidle.c +18 -20
@@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);DEFINE_MUTEX (cpuidle_lock);LIST_HEAD (cpuidle_detected_devices); -static void (*pm_idle_old)(void );static int enabled_devices;static int off__read_mostly ; +static int initialized__read_mostly ;int cpuidle_disabled (void ) {
@@ -56,25 +56,23 @@ static int __cpuidle_register_device(struct cpuidle_device *dev);* cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here +* return non-zero on failure */ -static void cpuidle_idle_call (void ) +int cpuidle_idle_call (void ) {struct cpuidle_device *dev =__this_cpu_read (cpuidle_devices);struct cpuidle_state *target_state;int next_state; +if (off) +return -ENODEV ; + +if (!initialized) +return -ENODEV ; +/* check if the device is ready */ -if (!dev || !dev->enabled) { -if (pm_idle_old) -pm_idle_old (); - else -#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE ) -default_idle (); -#else -local_irq_enable (); -#endif -return ; - } +if (!dev || !dev->enabled) +return -EBUSY ;#if 0 /* shows regressions, re-enable for 2.6.29 */
@@ -99,7 +97,7 @@ static void cpuidle_idle_call(void) next_state = cpuidle_curr_governor->select (dev);if (need_resched ()) {local_irq_enable (); -return ; +return 0 ; } target_state = &dev->states[next_state];
@@ -124,6 +122,8 @@ static void cpuidle_idle_call(void)/* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect (dev); + +return 0 ; }/**
@@ -131,10 +131,10 @@ static void cpuidle_idle_call(void)*/ void cpuidle_install_idle_handler (void ) { -if (enabled_devices && (pm_idle != cpuidle_idle_call)) { +if (enabled_devices) {/* Make sure all changes finished before we switch to new idle */ smp_wmb (); - pm_idle = cpuidle_idle_call; + initialized =1 ; } }
@@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void)*/ void cpuidle_uninstall_idle_handler (void ) { -if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { - pm_idle = pm_idle_old; +if (enabled_devices) { + initialized =0 ;cpuidle_kick_cpus (); } }
@@ -440,8 +440,6 @@ static int __init cpuidle_init(void)if (cpuidle_disabled ())return -ENODEV ; - pm_idle_old = pm_idle; - ret =cpuidle_add_class_sysfs (&cpu_sysdev_class);if (ret)return ret;
include/linux/cpuidle.h +2 -0
@@ -123,6 +123,7 @@ struct cpuidle_driver {#ifdef CONFIG_CPU_IDLE extern void disable_cpuidle (void ); +extern int cpuidle_idle_call (void );extern int cpuidle_register_driver (struct cpuidle_driver *drv);struct cpuidle_driver *cpuidle_get_driver (void );
@@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);#else static inline void disable_cpuidle (void ) { } +static inline int cpuidle_idle_call (void ) {return -ENODEV ; }static inline int cpuidle_register_driver (struct cpuidle_driver *drv) {return -ENODEV ; }
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 4/5 x86 idle: move mwait_idle_with_hints() to where it is used
In reply to Len BrownFrom: Len Brown <[email protected]>
...and make it static
no functional change
--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/acpi/cstate.c | 23 +++++++++++++++++++++++ arch/x86/kernel/process.c | 23 ----------------------- 3 files changed, 23 insertions(+), 25 deletions(-)
arch/x86/include/asm/processor.h +0 -2
@@ -751,8 +751,6 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx) :: "a" (eax), "c" (ecx)); } -extern void mwait_idle_with_hints (unsigned long eax,unsigned long ecx); -extern void select_idle_routine (const struct cpuinfo_x86 *c);extern void init_amd_e400_c1e_mask (void );
arch/x86/kernel/acpi/cstate.c +23 -0
@@ -149,6 +149,29 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, }EXPORT_SYMBOL_GPL (acpi_processor_ffh_cstate_probe); +/* +* This uses new MONITOR/MWAIT instructions on P4 processors with PNI, +* which can obviate IPI to trigger checking of need_resched. +* We execute MONITOR against need_resched and enter optimized wait state +* through MWAIT. Whenever someone changes need_resched, we would be woken +* up from MWAIT (without an IPI). +* +* New with Core Duo processors, MWAIT can take some hints based on CPU +* capability. +*/ +void mwait_idle_with_hints (unsigned long ax,unsigned long cx) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags); + +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__mwait (ax, cx); + } +} +void acpi_processor_ffh_cstate_enter (struct acpi_processor_cx *cx) {unsigned int cpu =smp_processor_id ();
arch/x86/kernel/process.c +0 -23
@@ -438,29 +438,6 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); -/* -* This uses new MONITOR/MWAIT instructions on P4 processors with PNI, -* which can obviate IPI to trigger checking of need_resched. -* We execute MONITOR against need_resched and enter optimized wait state -* through MWAIT. Whenever someone changes need_resched, we would be woken -* up from MWAIT (without an IPI). -* -* New with Core Duo processors, MWAIT can take some hints based on CPU -* capability. -*/ -void mwait_idle_with_hints (unsigned long ax,unsigned long cx) -{ -if (!need_resched ()) { -if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) -clflush ((void *)¤t_thread_info ()->flags); - -__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); -smp_mb (); -if (!need_resched ()) -__mwait (ax, cx); - } -} -/* Default MONITOR/MWAIT with no hints, used for default C1 state */ static void mwait_idle (void ) {
Signature · 1 line
1.7.6.396.ge0613
Len Brown
reviewerPATCH 1/5 mrst_pmu: driver for Intel Moorestown Power Management Unit
In reply to Len BrownFrom: Len Brown <[email protected]>
The Moorestown (MRST) Power Management Unit (PMU) driver directs the SOC power states in the "Langwell" south complex (SCU).
It hooks pci_platform_pm_ops[] and thus observes all PCI ".set_state" requests. For devices in the SC, the pmu driver translates those PCI requests into the appropriate commands for the SCU.
The PMU driver helps implement S0i3, a deep system idle power idle state. Entry into S0i3 is via cpuidle, just like regular processor c-states. S0i3 depends on pre-conditions including uni-processor, graphics off, and certain IO devices in the SC must be off. If those pre-conditions are met, then the PMU allows cpuidle to enter S0i3, otherwise such requests are demoted, either to Atom C4 or Atom C6.
This driver is based on prototype work by Bruce Flemming, Illyas Mansoor, Rajeev D. Muralidhar, Vishwesh M. Rudramuni, Hari Seshadri and Sujith Thomas. The current driver also includes contributions from H. Peter Anvin, Arjan van de Ven, Kristen Accardi, and Yong Wang.
Thanks for additional review feedback from Alan Cox and Randy Dunlap.
--- MAINTAINERS | 6 + arch/x86/platform/mrst/Makefile | 1 + arch/x86/platform/mrst/pmu.c | 817 +++++++++++++++++++++++++++++++++++++++ arch/x86/platform/mrst/pmu.h | 234 +++++++++++ 4 files changed, 1058 insertions(+), 0 deletions(-) create mode 100644 arch/x86/platform/mrst/pmu.c create mode 100644 arch/x86/platform/mrst/pmu.h
MAINTAINERS +6 -0
@@ -3344,6 +3344,12 @@ F: drivers/net/ixgb/ F: drivers/net/ixgbe/ F: drivers/net/ixgbevf/ +INTEL MRST PMU DRIVER +M: Len Brown <[email protected]> +L: [email protected] +S: Supported +F: arch/x86/platform/mrst/pmu.* + INTEL PRO/WIRELESS 2100 NETWORK CONNECTION SUPPORT L: [email protected] S: Orphan
arch/x86/platform/mrst/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_X86_MRST) += mrst.o obj-$(CONFIG_X86_MRST) += vrtc.o obj-$(CONFIG_EARLY_PRINTK_MRST) += early_printk_mrst.o +obj-$(CONFIG_X86_MRST) += pmu.o
arch/x86/platform/mrst/pmu.c new file +817 -0
817 lines not on this page · raw message
arch/x86/platform/mrst/pmu.h new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
1.7.6.396.ge0613
Re: [PATCH 3/5] cpuidle: replace xen access to x86 pm_idle and default_idle
In reply to Len BrownQuoted 10 lines · Len Brown
From: Len Brown <[email protected]>
When a Xen Dom0 kernel boots on a hypervisor, it gets access to the raw-hardware ACPI tables. While it parses the idle tables for the hypervisor's beneift, it uses HLT for its own idle.
Rather than have xen scribble on
pm_idleand accessdefault_idle, have it simplydisable_cpuidle()soacpi_idlewill not load and architecture default HLT will be used.
Quoted 9 lines
Signed-off-by Len Brown <[email protected]>--- arch/x86/xen/setup.c | 3 ++- drivers/cpuidle/cpuidle.c | 4 ++++ include/linux/cpuidle.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletions(-)
Re: [PATCH 3/5] cpuidle: replace xen access to x86 pm_idle and default_idle
In reply to Len BrownQuoted 10 lines · Len Brown
From: Len Brown <[email protected]>
When a Xen Dom0 kernel boots on a hypervisor, it gets access to the raw-hardware ACPI tables. While it parses the idle tables for the hypervisor's beneift, it uses HLT for its own idle.
Rather than have xen scribble on
pm_idleand accessdefault_idle, have it simplydisable_cpuidle()soacpi_idlewill not load and architecture default HLT will be used.
Quoted 9 lines
Signed-off-by Len Brown <[email protected]>--- arch/x86/xen/setup.c | 3 ++- drivers/cpuidle/cpuidle.c | 4 ++++ include/linux/cpuidle.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletions(-)
Re: [PATCH 4/5] x86 idle: move mwait_idle_with_hints() to where it is used
In reply to Len BrownQuoted 6 lines · Len Brown
From: Len Brown <[email protected]>
...and make it static
no functional change
Quoted 8 lines
Signed-off-by Len Brown <[email protected]>--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/acpi/cstate.c | 23 +++++++++++++++++++++++ arch/x86/kernel/process.c | 23 ----------------------- 3 files changed, 23 insertions(+), 25 deletions(-)
Re: [PATCH 4/5] x86 idle: move mwait_idle_with_hints() to where it is used
In reply to Len BrownQuoted 6 lines · Len Brown
From: Len Brown <[email protected]>
...and make it static
no functional change
Quoted 8 lines
Signed-off-by Len Brown <[email protected]>--- arch/x86/include/asm/processor.h | 2 -- arch/x86/kernel/acpi/cstate.c | 23 +++++++++++++++++++++++ arch/x86/kernel/process.c | 23 ----------------------- 3 files changed, 23 insertions(+), 25 deletions(-)
Re: [PATCH 5/5] cpuidle: stop depending on pm_idle
In reply to Len BrownQuoted 9 lines · Len Brown
From: Len Brown <[email protected]>
cpuidle users should call
cpuidle_call_idle()directly rather than via (pm_idle)() function pointer.Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it:
my_arch_cpu_idle()
Quoted 8 lines
... if(cpuidle_call_idle()) pm_idle();cc Kevin Hilman <[email protected]>cc Paul Mundt <[email protected]>Signed-off-by Len Brown <[email protected]>
Re: [PATCH 5/5] cpuidle: stop depending on pm_idle
In reply to Len BrownQuoted 9 lines · Len Brown
From: Len Brown <[email protected]>
cpuidle users should call
cpuidle_call_idle()directly rather than via (pm_idle)() function pointer.Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it:
my_arch_cpu_idle()
Quoted 8 lines
... if(cpuidle_call_idle()) pm_idle();cc Kevin Hilman <[email protected]>cc Paul Mundt <[email protected]>Signed-off-by Len Brown <[email protected]>
Re: [PATCH 1/5] mrst_pmu: driver for Intel Moorestown Power Management Unit
In reply to Len BrownQuoted 26 lines · Len Brown
From: Len Brown <[email protected]>
The Moorestown (MRST) Power Management Unit (PMU) driver directs the SOC power states in the "Langwell" south complex (SCU).
It hooks pci_platform_pm_ops[] and thus observes all PCI ".set_state" requests. For devices in the SC, the pmu driver translates those PCI requests into the appropriate commands for the SCU.
The PMU driver helps implement S0i3, a deep system idle power idle state. Entry into S0i3 is via cpuidle, just like regular processor c-states. S0i3 depends on pre-conditions including uni-processor, graphics off, and certain IO devices in the SC must be off. If those pre-conditions are met, then the PMU allows cpuidle to enter S0i3, otherwise such requests are demoted, either to Atom C4 or Atom C6.
This driver is based on prototype work by Bruce Flemming, Illyas Mansoor, Rajeev D. Muralidhar, Vishwesh M. Rudramuni, Hari Seshadri and Sujith Thomas. The current driver also includes contributions from H. Peter Anvin, Arjan van de Ven, Kristen Accardi, and Yong Wang.
Thanks for additional review feedback from Alan Cox and Randy Dunlap.
Signed-off-by Len Brown <[email protected]>Acked-by Alan Cox <[email protected]>
Quoted 9 lines
--- MAINTAINERS | 6 + arch/x86/platform/mrst/Makefile | 1 + arch/x86/platform/mrst/pmu.c | 817 +++++++++++++++++++++++++++++++++++++++ arch/x86/platform/mrst/pmu.h | 234 +++++++++++ 4 files changed, 1058 insertions(+), 0 deletions(-) create mode 100644 arch/x86/platform/mrst/pmu.c create mode 100644 arch/x86/platform/mrst/pmu.h
-hpa
Re: [PATCH 1/5] mrst_pmu: driver for Intel Moorestown Power Management Unit
In reply to Len BrownQuoted 26 lines · Len Brown
From: Len Brown <[email protected]>
The Moorestown (MRST) Power Management Unit (PMU) driver directs the SOC power states in the "Langwell" south complex (SCU).
It hooks pci_platform_pm_ops[] and thus observes all PCI ".set_state" requests. For devices in the SC, the pmu driver translates those PCI requests into the appropriate commands for the SCU.
The PMU driver helps implement S0i3, a deep system idle power idle state. Entry into S0i3 is via cpuidle, just like regular processor c-states. S0i3 depends on pre-conditions including uni-processor, graphics off, and certain IO devices in the SC must be off. If those pre-conditions are met, then the PMU allows cpuidle to enter S0i3, otherwise such requests are demoted, either to Atom C4 or Atom C6.
This driver is based on prototype work by Bruce Flemming, Illyas Mansoor, Rajeev D. Muralidhar, Vishwesh M. Rudramuni, Hari Seshadri and Sujith Thomas. The current driver also includes contributions from H. Peter Anvin, Arjan van de Ven, Kristen Accardi, and Yong Wang.
Thanks for additional review feedback from Alan Cox and Randy Dunlap.
Signed-off-by Len Brown <[email protected]>Acked-by Alan Cox <[email protected]>
Quoted 9 lines
--- MAINTAINERS | 6 + arch/x86/platform/mrst/Makefile | 1 + arch/x86/platform/mrst/pmu.c | 817 +++++++++++++++++++++++++++++++++++++++ arch/x86/platform/mrst/pmu.h | 234 +++++++++++ 4 files changed, 1058 insertions(+), 0 deletions(-) create mode 100644 arch/x86/platform/mrst/pmu.c create mode 100644 arch/x86/platform/mrst/pmu.h
-hpa
Re: [PATCH 5/5] cpuidle: stop depending on pm_idle
In reply to Len BrownQuoted 39 lines · Len Brown
From: Len Brown <[email protected]>
cpuidle users should call
cpuidle_call_idle()directly rather than via (pm_idle)() function pointer.Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it:
my_arch_cpu_idle()... if(cpuidle_call_idle()) pm_idle();cc Kevin Hilman <[email protected]>cc Paul Mundt <[email protected]>Signed-off-by Len Brown <[email protected]>--- arch/arm/kernel/process.c | 4 +++- arch/sh/kernel/idle.c | 6 ++++-- arch/x86/kernel/process_32.c | 4 +++- arch/x86/kernel/process_64.c | 4 +++- drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++-------------------- include/linux/cpuidle.h | 2 ++ 6 files changed, 33 insertions(+), 25 deletions(-)arch/arm/kernel/process.c +1
-0@@ -30,6 +30,7 @@#include <linux/uaccess.h> #include <linux/random.h> #include <linux/hw_breakpoint.h> +#include <linux/cpuidle.h> #include <asm/cacheflush.h> #include <asm/leds.h>
arch/arm/kernel/process.c void cpu_idle(void) · line 201
Quoted 6 lines
arch/arm/kernel/process.c +1
-1@@ -196,7 +197,8 @@ void cpu_idle(void)cpu_relax (); }else {stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ())
Hi Len,
This should be cpuidle_idle_call()
Quoted 24 lines
arch/arm/kernel/process.c +1
-0+pm_idle ();start_critical_timings ();/* * This will eventually be removed -
pm_idlearch/sh/kernel/idle.c +2
-1@@ -16,12 +16,13 @@#include <linux/thread_info.h> #include <linux/irqflags.h> #include <linux/smp.h> +#include <linux/cpuidle.h> #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/smp.h> -void (*pm_idle)(void ) =NULL ; +static void (*pm_idle)(void );static int hlt_counter;
arch/sh/kernel/idle.c void cpu_idle(void) · line 105
Quoted 6 lines
arch/sh/kernel/idle.c +1
-1@@ -100,7 +101,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_call_idle ())
Again this should be cpuidle_idle_call()
+ pm_idle();
Quoted 182 lines
arch/sh/kernel/idle.c +0
-0/* * Sanity check to ensure that pm_idle() returns * with IRQs enabled arch/x86/kernel/process_32.c +3
-1@@ -38,6 +38,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/kdebug.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -109,7 +110,8 @@ void cpu_idle(void)local_irq_disable ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings (); }tick_nohz_restart_sched_tick ();arch/x86/kernel/process_64.c +3
-1@@ -37,6 +37,7 @@#include <linux/uaccess.h> #include <linux/io.h> #include <linux/ftrace.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -136,7 +137,8 @@ void cpu_idle(void)enter_idle ();/* Don't trace irqs off for idle */ stop_critical_timings (); -pm_idle (); +if (cpuidle_idle_call ()) +pm_idle ();start_critical_timings ();/* In many cases the interrupt that ended idle drivers/cpuidle/cpuidle.c +1
-1@@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);DEFINE_MUTEX (cpuidle_lock);LIST_HEAD (cpuidle_detected_devices); -static void (*pm_idle_old)(void );static int enabled_devices;static int off__read_mostly ; +static int initialized__read_mostly ;int cpuidle_disabled (void ){
drivers/cpuidle/cpuidle.c +10
-12@@ -56,25 +56,23 @@ static int __cpuidle_register_device(structcpuidle_device *dev); * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here +* return non-zero on failure */ -static void cpuidle_idle_call (void ) +int cpuidle_idle_call (void ) {struct cpuidle_device *dev =__this_cpu_read (cpuidle_devices);struct cpuidle_state *target_state;int next_state; +if (off) +return -ENODEV ; + +if (!initialized) +return -ENODEV ; +/* check if the device is ready */ -if (!dev || !dev->enabled) { -if (pm_idle_old) -pm_idle_old (); - else -#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE ) -default_idle (); -#else -local_irq_enable (); -#endif -return ; - } +if (!dev || !dev->enabled) +return -EBUSY ;#if 0 /* shows regressions, re-enable for 2.6.29 */drivers/cpuidle/cpuidle.c +4
-2@@ -99,7 +97,7 @@ static void cpuidle_idle_call(void) next_state = cpuidle_curr_governor->select (dev);if (need_resched ()) {local_irq_enable (); -return ; +return 0 ; } target_state = &dev->states[next_state];@@ -124,6 +122,8 @@ static void cpuidle_idle_call(void)/* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect (dev); + +return 0 ; }/** @@ -131,10 +131,10 @@ static void cpuidle_idle_call(void)*/ void cpuidle_install_idle_handler (void ) { -if (enabled_devices && (pm_idle != cpuidle_idle_call)) { +if (enabled_devices) {/* Make sure all changes finished before we switch to new idle */
smp_wmb();drivers/cpuidle/cpuidle.c +3
-5- pm_idle = cpuidle_idle_call; + initialized =1 ; } }@@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void)*/ void cpuidle_uninstall_idle_handler (void ) { -if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { - pm_idle = pm_idle_old; +if (enabled_devices) { + initialized =0 ;cpuidle_kick_cpus (); } }@@ -440,8 +440,6 @@ static int __init cpuidle_init(void)if (cpuidle_disabled ())return -ENODEV ; - pm_idle_old = pm_idle; - ret =cpuidle_add_class_sysfs (&cpu_sysdev_class);if (ret)return ret;include/linux/cpuidle.h +2
-0@@ -123,6 +123,7 @@ struct cpuidle_driver {#ifdef CONFIG_CPU_IDLE extern void disable_cpuidle (void ); +extern int cpuidle_idle_call (void );extern int cpuidle_register_driver (struct cpuidle_driver *drv);struct cpuidle_driver *cpuidle_get_driver (void );@@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);#else static inline void disable_cpuidle (void ) { } +static inline int cpuidle_idle_call (void ) {return -ENODEV ; }static inline int cpuidle_register_driver (struct cpuidle_driver *drv){return
-ENODEV; }
--
1.7.6.396.ge0613_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Re: [PATCH 5/5] cpuidle: stop depending on pm_idle
Hi Len,
The following code would not compile on ARM. The patch for this has already been posted by Trinabh earlier on, in the following link.
https://lkml.org/lkml/2011/4/25/54
Quoted 270 lines · Trinabh Gupta
On Wed, Aug 3, 2011 at 12:44 PM, Len Brown <[email protected] <mailto:[email protected]>> wrote:
From: Len Brown <[email protected] <mailto:[email protected]>> cpuidle users should call cpuidle_call_idle() directly rather than via (pm_idle)() function pointer. Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it: my_arch_cpu_idle() ... if(cpuidle_call_idle()) pm_idle(); cc: [email protected] <mailto:[email protected]> cc: Kevin Hilman <[email protected] <mailto:[email protected]>> cc: Paul Mundt <[email protected] <mailto:[email protected]>> Signed-off-by: Len Brown <[email protected] <mailto:[email protected]>> --- arch/arm/kernel/process.c | 4 +++- arch/sh/kernel/idle.c | 6 ++++-- arch/x86/kernel/process_32.c | 4 +++- arch/x86/kernel/process_64.c | 4 +++- drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++-------------------- include/linux/cpuidle.h | 2 ++ 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 5e1e541..d7ee0d4 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -30,6 +30,7 @@ #include <linux/uaccess.h> #include <linux/random.h> #include <linux/hw_breakpoint.h> +#include <linux/cpuidle.h> #include <asm/cacheflush.h> #include <asm/leds.h> @@ -196,7 +197,8 @@ void cpu_idle(void) cpu_relax(); } else { stop_critical_timings(); - pm_idle(); + if (cpuidle_call_idle())Hi Len,
This should be
cpuidle_idle_call()+ pm_idle(); start_critical_timings(); /* * This will eventually be removed - pm_idle diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c index 425d604..9c7099e 100644 --- a/arch/sh/kernel/idle.c +++ b/arch/sh/kernel/idle.c @@ -16,12 +16,13 @@ #include <linux/thread_info.h> #include <linux/irqflags.h> #include <linux/smp.h> +#include <linux/cpuidle.h> #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/smp.h> -void (*pm_idle)(void) = NULL; +static void (*pm_idle)(void); static int hlt_counter; @@ -100,7 +101,8 @@ void cpu_idle(void) local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_call_idle())Again this should be
cpuidle_idle_call()+ pm_idle(); /* * Sanity check to ensure that pm_idle() returns * with IRQs enabled diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index a3d0dc5..7a3b651 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -38,6 +38,7 @@ #include <linux/uaccess.h> #include <linux/io.h> #include <linux/kdebug.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -109,7 +110,8 @@ void cpu_idle(void) local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_idle_call()) + pm_idle(); start_critical_timings(); } tick_nohz_restart_sched_tick(); diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index ca6f7ab..f693e44 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -37,6 +37,7 @@ #include <linux/uaccess.h> #include <linux/io.h> #include <linux/ftrace.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -136,7 +137,8 @@ void cpu_idle(void) enter_idle(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_idle_call()) + pm_idle(); start_critical_timings(); /* In many cases the interrupt that ended idle diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 041df0b..d4c5423 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); DEFINE_MUTEX(cpuidle_lock); LIST_HEAD(cpuidle_detected_devices); -static void (*pm_idle_old)(void); static int enabled_devices; static int off __read_mostly; +static int initialized __read_mostly; int cpuidle_disabled(void) { @@ -56,25 +56,23 @@ static int __cpuidle_register_device(struct cpuidle_device *dev); * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here + * return non-zero on failure */ -static void cpuidle_idle_call(void) +int cpuidle_idle_call(void) { struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_state *target_state; int next_state; + if (off) + return -ENODEV; + + if (!initialized) + return -ENODEV; + /* check if the device is ready */ - if (!dev || !dev->enabled) { - if (pm_idle_old) - pm_idle_old(); - else -#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE) - default_idle(); -#else - local_irq_enable(); -#endif - return; - } + if (!dev || !dev->enabled) + return -EBUSY; #if 0 /* shows regressions, re-enable for 2.6.29 */ @@ -99,7 +97,7 @@ static void cpuidle_idle_call(void) next_state = cpuidle_curr_governor->select(dev); if (need_resched()) { local_irq_enable(); - return; + return 0; } target_state = &dev->states[next_state]; @@ -124,6 +122,8 @@ static void cpuidle_idle_call(void) /* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect(dev); + + return 0; } /** @@ -131,10 +131,10 @@ static void cpuidle_idle_call(void) */ void cpuidle_install_idle_handler(void) { - if (enabled_devices && (pm_idle != cpuidle_idle_call)) { + if (enabled_devices) { /* Make sure all changes finished before we switch to new idle */ smp_wmb(); - pm_idle = cpuidle_idle_call; + initialized = 1; } } @@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void) */ void cpuidle_uninstall_idle_handler(void) { - if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { - pm_idle = pm_idle_old; + if (enabled_devices) { + initialized = 0; cpuidle_kick_cpus(); } } @@ -440,8 +440,6 @@ static int __init cpuidle_init(void) if (cpuidle_disabled()) return -ENODEV; - pm_idle_old = pm_idle; - ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); if (ret) return ret; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index b89f67d..b51629e 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -123,6 +123,7 @@ struct cpuidle_driver { #ifdef CONFIG_CPU_IDLE extern void disable_cpuidle(void); +extern int cpuidle_idle_call(void); extern int cpuidle_register_driver(struct cpuidle_driver *drv); struct cpuidle_driver *cpuidle_get_driver(void); @@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev); #else static inline void disable_cpuidle(void) { } +static inline int cpuidle_idle_call(void) { return -ENODEV; } static inline int cpuidle_register_driver(struct cpuidle_driver *drv) {return -ENODEV; } -- 1.7.6.396.ge0613 _______________________________________________ linux-pm mailing list [email protected] <mailto:[email protected]> https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 4 lines
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Regards,
Deepthi
Re: [linux-pm] [PATCH 5/5] cpuidle: stop depending on pm_idle
In reply to Trinabh GuptaHi Len,
The following code would not compile on ARM. The patch for this has already been posted by Trinabh earlier on, in the following link.
https://lkml.org/lkml/2011/4/25/54
Quoted 270 lines · Trinabh Gupta
On Wed, Aug 3, 2011 at 12:44 PM, Len Brown <[email protected] <mailto:[email protected]>> wrote:
From: Len Brown <[email protected] <mailto:[email protected]>> cpuidle users should call cpuidle_call_idle() directly rather than via (pm_idle)() function pointer. Architecture may choose to continue using (pm_idle)(), but cpuidle need not depend on it: my_arch_cpu_idle() ... if(cpuidle_call_idle()) pm_idle(); cc: [email protected] <mailto:[email protected]> cc: Kevin Hilman <[email protected] <mailto:[email protected]>> cc: Paul Mundt <[email protected] <mailto:[email protected]>> Signed-off-by: Len Brown <[email protected] <mailto:[email protected]>> --- arch/arm/kernel/process.c | 4 +++- arch/sh/kernel/idle.c | 6 ++++-- arch/x86/kernel/process_32.c | 4 +++- arch/x86/kernel/process_64.c | 4 +++- drivers/cpuidle/cpuidle.c | 38 ++++++++++++++++++-------------------- include/linux/cpuidle.h | 2 ++ 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 5e1e541..d7ee0d4 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -30,6 +30,7 @@ #include <linux/uaccess.h> #include <linux/random.h> #include <linux/hw_breakpoint.h> +#include <linux/cpuidle.h> #include <asm/cacheflush.h> #include <asm/leds.h> @@ -196,7 +197,8 @@ void cpu_idle(void) cpu_relax(); } else { stop_critical_timings(); - pm_idle(); + if (cpuidle_call_idle())Hi Len,
This should be
cpuidle_idle_call()+ pm_idle(); start_critical_timings(); /* * This will eventually be removed - pm_idle diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c index 425d604..9c7099e 100644 --- a/arch/sh/kernel/idle.c +++ b/arch/sh/kernel/idle.c @@ -16,12 +16,13 @@ #include <linux/thread_info.h> #include <linux/irqflags.h> #include <linux/smp.h> +#include <linux/cpuidle.h> #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/smp.h> -void (*pm_idle)(void) = NULL; +static void (*pm_idle)(void); static int hlt_counter; @@ -100,7 +101,8 @@ void cpu_idle(void) local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_call_idle())Again this should be
cpuidle_idle_call()+ pm_idle(); /* * Sanity check to ensure that pm_idle() returns * with IRQs enabled diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index a3d0dc5..7a3b651 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -38,6 +38,7 @@ #include <linux/uaccess.h> #include <linux/io.h> #include <linux/kdebug.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -109,7 +110,8 @@ void cpu_idle(void) local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_idle_call()) + pm_idle(); start_critical_timings(); } tick_nohz_restart_sched_tick(); diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index ca6f7ab..f693e44 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -37,6 +37,7 @@ #include <linux/uaccess.h> #include <linux/io.h> #include <linux/ftrace.h> +#include <linux/cpuidle.h> #include <asm/pgtable.h> #include <asm/system.h> @@ -136,7 +137,8 @@ void cpu_idle(void) enter_idle(); /* Don't trace irqs off for idle */ stop_critical_timings(); - pm_idle(); + if (cpuidle_idle_call()) + pm_idle(); start_critical_timings(); /* In many cases the interrupt that ended idle diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 041df0b..d4c5423 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -25,10 +25,10 @@ DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); DEFINE_MUTEX(cpuidle_lock); LIST_HEAD(cpuidle_detected_devices); -static void (*pm_idle_old)(void); static int enabled_devices; static int off __read_mostly; +static int initialized __read_mostly; int cpuidle_disabled(void) { @@ -56,25 +56,23 @@ static int __cpuidle_register_device(struct cpuidle_device *dev); * cpuidle_idle_call - the main idle loop * * NOTE: no locks or semaphores should be used here + * return non-zero on failure */ -static void cpuidle_idle_call(void) +int cpuidle_idle_call(void) { struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); struct cpuidle_state *target_state; int next_state; + if (off) + return -ENODEV; + + if (!initialized) + return -ENODEV; + /* check if the device is ready */ - if (!dev || !dev->enabled) { - if (pm_idle_old) - pm_idle_old(); - else -#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE) - default_idle(); -#else - local_irq_enable(); -#endif - return; - } + if (!dev || !dev->enabled) + return -EBUSY; #if 0 /* shows regressions, re-enable for 2.6.29 */ @@ -99,7 +97,7 @@ static void cpuidle_idle_call(void) next_state = cpuidle_curr_governor->select(dev); if (need_resched()) { local_irq_enable(); - return; + return 0; } target_state = &dev->states[next_state]; @@ -124,6 +122,8 @@ static void cpuidle_idle_call(void) /* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) cpuidle_curr_governor->reflect(dev); + + return 0; } /** @@ -131,10 +131,10 @@ static void cpuidle_idle_call(void) */ void cpuidle_install_idle_handler(void) { - if (enabled_devices && (pm_idle != cpuidle_idle_call)) { + if (enabled_devices) { /* Make sure all changes finished before we switch to new idle */ smp_wmb(); - pm_idle = cpuidle_idle_call; + initialized = 1; } } @@ -143,8 +143,8 @@ void cpuidle_install_idle_handler(void) */ void cpuidle_uninstall_idle_handler(void) { - if (enabled_devices && pm_idle_old && (pm_idle != pm_idle_old)) { - pm_idle = pm_idle_old; + if (enabled_devices) { + initialized = 0; cpuidle_kick_cpus(); } } @@ -440,8 +440,6 @@ static int __init cpuidle_init(void) if (cpuidle_disabled()) return -ENODEV; - pm_idle_old = pm_idle; - ret = cpuidle_add_class_sysfs(&cpu_sysdev_class); if (ret) return ret; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index b89f67d..b51629e 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -123,6 +123,7 @@ struct cpuidle_driver { #ifdef CONFIG_CPU_IDLE extern void disable_cpuidle(void); +extern int cpuidle_idle_call(void); extern int cpuidle_register_driver(struct cpuidle_driver *drv); struct cpuidle_driver *cpuidle_get_driver(void); @@ -137,6 +138,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev); #else static inline void disable_cpuidle(void) { } +static inline int cpuidle_idle_call(void) { return -ENODEV; } static inline int cpuidle_register_driver(struct cpuidle_driver *drv) {return -ENODEV; } -- 1.7.6.396.ge0613 _______________________________________________ linux-pm mailing list [email protected] <mailto:[email protected]> https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 4 lines
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Regards,
Deepthi
Re: [PATCH 5/5] cpuidle: stop depending on pm_idle --build break
In reply to Len BrownFollowing is a patch required to compile on arm
and sh with the latest cpuidle cleanup changes.
arch/arm/kernel/process.c 2011-08-05 11:10:03.000000000 +0000 renamed from arch/arm/kernel/process.c 2011-08-05 11:02:59.000000000 +0000 +1 -1
@@ -197,7 +197,7 @@ cpu_relax(); } else { stop_critical_timings(); - if (cpuidle_call_idle()) + if (cpuidle_idle_call()) pm_idle(); start_critical_timings(); /*
arch/sh/kernel/idle.c 2011-08-05 11:13:23.000000000 +0000 renamed from arch/sh/kernel/idle.c 2011-08-05 11:02:59.000000000 +0000 +1 -1
@@ -101,7 +101,7 @@ local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - if (cpuidle_call_idle()) + if (cpuidle_idle_call()) pm_idle(); /* * Sanity check to ensure that pm_idle() returns
Re: [linux-pm] [PATCH 5/5] cpuidle: stop depending on pm_idle --build break
In reply to Len BrownFollowing is a patch required to compile on arm
and sh with the latest cpuidle cleanup changes.
arch/arm/kernel/process.c 2011-08-05 11:10:03.000000000 +0000 renamed from arch/arm/kernel/process.c 2011-08-05 11:02:59.000000000 +0000 +1 -1
@@ -197,7 +197,7 @@ cpu_relax(); } else { stop_critical_timings(); - if (cpuidle_call_idle()) + if (cpuidle_idle_call()) pm_idle(); start_critical_timings(); /*
arch/sh/kernel/idle.c 2011-08-05 11:13:23.000000000 +0000 renamed from arch/sh/kernel/idle.c 2011-08-05 11:02:59.000000000 +0000 +1 -1
@@ -101,7 +101,7 @@ local_irq_disable(); /* Don't trace irqs off for idle */ stop_critical_timings(); - if (cpuidle_call_idle()) + if (cpuidle_idle_call()) pm_idle(); /* * Sanity check to ensure that pm_idle() returns