Skip to contentSkip to conversation

idle patch queue for Linux 3.1

PATCH In review Len Brown 4 participants 24 messages Aug 3, 2011 – Aug 5, 2011

Subsystems (7)
Documentation Arm (32-bit) x86 ACPI +3 more subsystems
lore
Share & tools
lore

Len Brown

author reviewer
#0 lore raw

Here 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

author reviewer
#1 lore raw

PATCH 1/5 mrst_pmu: driver for Intel Moorestown Power Management Unit

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.

---
 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
index 187282d..d37b387 100644
@@ -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
index f61ccdd..1ea3877 100644
@@ -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
author reviewer
#2 lore raw

PATCH 1/5 mrst_pmu: driver for Intel Moorestown Power Management Unit

In reply to 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.

---
 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
index 187282d..d37b387 100644
@@ -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
index f61ccdd..1ea3877 100644
@@ -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
reviewer Acked-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] mrst_pmu: driver for Intel Moorestown Power Management Unit

Quoted 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.

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

reviewer Acked-by on v1 1/5
#4 lore raw

Re: [PATCH 1/5] mrst_pmu: driver for Intel Moorestown Power Management Unit

In reply to Len Brown
Quoted 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.

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

author reviewer
#5 lore raw

PATCH 2/5 cpuidle: create bootparam "cpuidle.off=1"

In reply to Len Brown

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
index aa47be7..9b8e62d 100644
@@ -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
index bf50924..faae2c3 100644
@@ -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
index 33e50d5..38c3fd8 100644
@@ -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
index fd1601e..3f7e3ce 100644
@@ -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
index 724c164..ea2f8e7 100644
@@ -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
author reviewer
#6 lore raw

PATCH 2/5 cpuidle: create bootparam "cpuidle.off=1"

In reply to Len Brown

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
index aa47be7..9b8e62d 100644
@@ -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
index bf50924..faae2c3 100644
@@ -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
index 33e50d5..38c3fd8 100644
@@ -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
index fd1601e..3f7e3ce 100644
@@ -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
index 724c164..ea2f8e7 100644
@@ -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
author reviewer
#7 lore raw

PATCH 3/5 cpuidle: replace xen access to x86 pm_idle and default_idle

In reply to 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_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
index 60aeeb5..a9627e2 100644
@@ -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
index faae2c3..041df0b 100644
@@ -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
index 36719ea..b89f67d 100644
@@ -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
reviewer Acked-by on v1 3/5
#8 lore raw

Re: [PATCH 3/5] cpuidle: replace xen access to x86 pm_idle and default_idle

Quoted 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_idle and access default_idle, have it simply disable_cpuidle() so acpi_idle will not load and architecture default HLT will be used.

Quoted 9 lines
---
 arch/x86/xen/setup.c      |    3 ++-
 drivers/cpuidle/cpuidle.c |    4 ++++
 include/linux/cpuidle.h   |    2 ++
 3 files changed, 8 insertions(+), 1 deletions(-)
reviewer Acked-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] cpuidle: replace xen access to x86 pm_idle and default_idle

In reply to Len Brown
Quoted 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_idle and access default_idle, have it simply disable_cpuidle() so acpi_idle will not load and architecture default HLT will be used.

Quoted 9 lines
---
 arch/x86/xen/setup.c      |    3 ++-
 drivers/cpuidle/cpuidle.c |    4 ++++
 include/linux/cpuidle.h   |    2 ++
 3 files changed, 8 insertions(+), 1 deletions(-)
author reviewer
#10 lore raw

PATCH 3/5 cpuidle: replace xen access to x86 pm_idle and default_idle

In reply to 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_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
index 60aeeb5..a9627e2 100644
@@ -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
index faae2c3..041df0b 100644
@@ -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
index 36719ea..b89f67d 100644
@@ -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
author reviewer
#11 lore raw

PATCH 4/5 x86 idle: move mwait_idle_with_hints() to where it is used

In reply to Len Brown

From: 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
index 2193715..0d1171c 100644
@@ -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
index 5812404..f50e7fb 100644
@@ -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 *)&current_thread_info()->flags);
+
+		__monitor((void *)&current_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
index e1ba8cb..e7e3b01 100644
@@ -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 *)&current_thread_info()->flags);
-
-		__monitor((void *)&current_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
author reviewer
#12 lore raw

PATCH 4/5 x86 idle: move mwait_idle_with_hints() to where it is used

In reply to Len Brown

From: 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
index 2193715..0d1171c 100644
@@ -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
index 5812404..f50e7fb 100644
@@ -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 *)&current_thread_info()->flags);
+
+		__monitor((void *)&current_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
index e1ba8cb..e7e3b01 100644
@@ -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 *)&current_thread_info()->flags);
-
-		__monitor((void *)&current_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
reviewer Acked-by on v1 4/5
#13 lore raw

Re: [PATCH 4/5] x86 idle: move mwait_idle_with_hints() to where it is used

Quoted 6 lines · Len Brown

From: Len Brown <[email protected]>

...and make it static

no functional change

Quoted 8 lines
---
 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(-)
reviewer Acked-by on v1 4/5
#14 lore raw

Re: [PATCH 4/5] x86 idle: move mwait_idle_with_hints() to where it is used

In reply to Len Brown
Quoted 6 lines · Len Brown

From: Len Brown <[email protected]>

...and make it static

no functional change

Quoted 8 lines
---
 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(-)
author reviewer
#15 lore raw

PATCH 5/5 cpuidle: stop depending on pm_idle

In reply to 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();
---
 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
index 5e1e541..d7ee0d4 100644
@@ -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
index 425d604..9c7099e 100644
@@ -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
index a3d0dc5..7a3b651 100644
@@ -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
index ca6f7ab..f693e44 100644
@@ -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
index 041df0b..d4c5423 100644
@@ -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
index b89f67d..b51629e 100644
@@ -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
author reviewer
#16 lore raw

PATCH 5/5 cpuidle: stop depending on pm_idle

In reply to 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();
---
 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
index 5e1e541..d7ee0d4 100644
@@ -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
index 425d604..9c7099e 100644
@@ -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
index a3d0dc5..7a3b651 100644
@@ -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
index ca6f7ab..f693e44 100644
@@ -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
index 041df0b..d4c5423 100644
@@ -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
index b89f67d..b51629e 100644
@@ -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
reviewer Acked-by on v1 5/5
#17 lore raw

Re: [PATCH 5/5] cpuidle: stop depending on pm_idle

Quoted 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();
reviewer Acked-by on v1 5/5
#18 lore raw

Re: [PATCH 5/5] cpuidle: stop depending on pm_idle

In reply to Len Brown
Quoted 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();
#19 lore raw

Re: [PATCH 5/5] cpuidle: stop depending on pm_idle

In reply to Len Brown
Quoted 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();
---
 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
index 5e1e541..d7ee0d4 100644
@@ -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_idle

arch/sh/kernel/idle.c +2 -1
index 425d604..9c7099e 100644
@@ -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
index a3d0dc5..7a3b651 100644
@@ -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
index ca6f7ab..f693e44 100644
@@ -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
index 041df0b..d4c5423 100644
@@ -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(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 */
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
index b89f67d..b51629e 100644
@@ -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

#20 lore raw

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

#21 lore raw

Re: [linux-pm] [PATCH 5/5] cpuidle: stop depending on pm_idle

In reply to Trinabh Gupta

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

#22 lore raw

Re: [PATCH 5/5] cpuidle: stop depending on pm_idle --build break

In reply to Len Brown

Following 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
Index: linux/arch/arm/kernel/process.c
===================================================================
@@ -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
Index: linux/arch/sh/kernel/idle.c
===================================================================
@@ -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
#23 lore raw

Re: [linux-pm] [PATCH 5/5] cpuidle: stop depending on pm_idle --build break

In reply to Len Brown

Following 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
Index: linux/arch/arm/kernel/process.c
===================================================================
@@ -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
Index: linux/arch/sh/kernel/idle.c
===================================================================
@@ -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