All of lore.kernel.org
 help / color / mirror / Atom feed
* [V3 patch 00/19] cpuidle: code consolidation
@ 2013-04-12 12:35 ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

This patchset series provide some code consolidation across the different
cpuidle drivers. It contains two parts, the first one is the removal of
the time keeping flag and the second one, is a common initialization routine.

All the drivers use the en_core_tk_irqen flag, which means it is not necessary
to make the time computation optional. We can remove this flag and assume the
cpuidle framework always manage this operation.

The cpuidle code initialization is duplicated across the different drivers in
the same manner.

The repeating pattern is:

SMP:

cpuidle_register_driver(drv);
for_each_possible_cpu(cpu) {
        dev = per_cpu(cpuidle_device, cpu);
        cpuidle_register_device(dev);
}

UP:

cpuidle_register_driver(drv);
cpuidle_register_device(dev);

As on a UP machine the macro 'for_each_cpu' is a one iteration loop, using the
initialization loop from SMP to UP works.

The patchset does some cleanup for different drivers in order to make the init
code the same. Then it introduces a generic function:

  cpuidle_register(struct cpuidle_driver *drv, struct cpumask *cpumask)

The cpumask is for the coupled idle states.

The drivers are then modified to take into account this new function and
to remove the duplicated code.

The benefit is observable in the diffstat: 332 lines of code removed.

Changelog:

 - V3:
   * folded patch 5/19 into 19/19, they were:
     * ARM: imx: cpuidle: use init/exit common routine
     * ARM: imx: cpuidle: create separate drivers for imx5/imx6
   * removed rule to make cpuidle.o in the imx's Makefile
   * splitted patch 1/19 into two, they are:
     * [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi
     * [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype

 - V2:
   * fixed cpumask NULL test for coupled state in cpuidle_register 
   * added comment about structure copy
   * changed printk by pr_err
   * folded splitted message
   * fixed return code in cpuidle_register
   * updated Documentation/cpuidle/drivers.txt
   * added in the changelog dev->state_count is filled by cpuidle_enable_device
   * fixed tag for tegra in the first line patch description
   * fixed tegra2 removed tegra_tear_down_cpu = tegra20_tear_down_cpu;

 - V1: Initial post

Tested-on: u8500
Tested-on: at91
Tested-on: intel i5
Tested-on: OMAP4

Compiled with and without CPU_IDLE for:
 u8500, at91, davinci, exynos, imx5, imx6, kirkwood, multi_v7 (for calxeda),
 omap2plus, s3c64, tegra1, tegra2, tegra3

Daniel Lezcano (19):
  ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
  ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  ARM: OMAP3: remove cpuidle_wrap_enter
  cpuidle: remove en_core_tk_irqen flag
  ARM: ux500: cpuidle: replace for_each_online_cpu by
    for_each_possible_cpu
  cpuidle: make a single register function for all
  ARM: ux500: cpuidle: use init/exit common routine
  ARM: at91: cpuidle: use init/exit common routine
  ARM: OMAP3: cpuidle: use init/exit common routine
  ARM: s3c64xx: cpuidle: use init/exit common routine
  ARM: tegra: cpuidle: use init/exit common routine
  ARM: shmobile: cpuidle: use init/exit common routine
  ARM: OMAP4: cpuidle: use init/exit common routine
  ARM: tegra: cpuidle: use init/exit common routine for tegra2
  ARM: tegra: cpuidle: use init/exit common routine for tegra3
  ARM: calxeda: cpuidle: use init/exit common routine
  ARM: kirkwood: cpuidle: use init/exit common routine
  ARM: davinci: cpuidle: use init/exit common routine
  ARM: imx: cpuidle: use init/exit common routine

 Documentation/cpuidle/driver.txt                |    6 +
 arch/arm/mach-at91/cpuidle.c                    |   18 +--
 arch/arm/mach-davinci/cpuidle.c                 |   21 +---
 arch/arm/mach-exynos/cpuidle.c                  |    1 -
 arch/arm/mach-imx/Makefile                      |    2 +-
 arch/arm/mach-imx/cpuidle-imx5.c                |   40 +++++++
 arch/arm/mach-imx/cpuidle-imx6q.c               |    3 +-
 arch/arm/mach-imx/cpuidle.c                     |   80 -------------
 arch/arm/mach-imx/cpuidle.h                     |   10 +-
 arch/arm/mach-imx/pm-imx5.c                     |   30 +----
 arch/arm/mach-omap2/cpuidle34xx.c               |   49 ++------
 arch/arm/mach-omap2/cpuidle44xx.c               |   23 +---
 arch/arm/mach-s3c64xx/cpuidle.c                 |   15 +--
 arch/arm/mach-shmobile/cpuidle.c                |   11 +-
 arch/arm/mach-shmobile/include/mach/common.h    |    3 -
 arch/arm/mach-shmobile/pm-sh7372.c              |    2 -
 arch/arm/mach-tegra/cpuidle-tegra114.c          |   27 +----
 arch/arm/mach-tegra/cpuidle-tegra20.c           |   31 +----
 arch/arm/mach-tegra/cpuidle-tegra30.c           |   28 +----
 arch/arm/mach-ux500/cpuidle.c                   |   33 +-----
 arch/powerpc/platforms/pseries/processor_idle.c |    1 -
 arch/sh/kernel/cpu/shmobile/cpuidle.c           |    1 -
 arch/x86/kernel/apm_32.c                        |    1 -
 drivers/acpi/processor_idle.c                   |    1 -
 drivers/cpuidle/cpuidle-calxeda.c               |   53 +--------
 drivers/cpuidle/cpuidle-kirkwood.c              |   18 +--
 drivers/cpuidle/cpuidle.c                       |  144 ++++++++++++++---------
 drivers/idle/intel_idle.c                       |    1 -
 include/linux/cpuidle.h                         |   20 ++--
 29 files changed, 175 insertions(+), 498 deletions(-)
 create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
 delete mode 100644 arch/arm/mach-imx/cpuidle.c

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 00/19] cpuidle: code consolidation
@ 2013-04-12 12:35 ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

This patchset series provide some code consolidation across the different
cpuidle drivers. It contains two parts, the first one is the removal of
the time keeping flag and the second one, is a common initialization routine.

All the drivers use the en_core_tk_irqen flag, which means it is not necessary
to make the time computation optional. We can remove this flag and assume the
cpuidle framework always manage this operation.

The cpuidle code initialization is duplicated across the different drivers in
the same manner.

The repeating pattern is:

SMP:

cpuidle_register_driver(drv);
for_each_possible_cpu(cpu) {
        dev = per_cpu(cpuidle_device, cpu);
        cpuidle_register_device(dev);
}

UP:

cpuidle_register_driver(drv);
cpuidle_register_device(dev);

As on a UP machine the macro 'for_each_cpu' is a one iteration loop, using the
initialization loop from SMP to UP works.

The patchset does some cleanup for different drivers in order to make the init
code the same. Then it introduces a generic function:

  cpuidle_register(struct cpuidle_driver *drv, struct cpumask *cpumask)

The cpumask is for the coupled idle states.

The drivers are then modified to take into account this new function and
to remove the duplicated code.

The benefit is observable in the diffstat: 332 lines of code removed.

Changelog:

 - V3:
   * folded patch 5/19 into 19/19, they were:
     * ARM: imx: cpuidle: use init/exit common routine
     * ARM: imx: cpuidle: create separate drivers for imx5/imx6
   * removed rule to make cpuidle.o in the imx's Makefile
   * splitted patch 1/19 into two, they are:
     * [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi
     * [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype

 - V2:
   * fixed cpumask NULL test for coupled state in cpuidle_register 
   * added comment about structure copy
   * changed printk by pr_err
   * folded splitted message
   * fixed return code in cpuidle_register
   * updated Documentation/cpuidle/drivers.txt
   * added in the changelog dev->state_count is filled by cpuidle_enable_device
   * fixed tag for tegra in the first line patch description
   * fixed tegra2 removed tegra_tear_down_cpu = tegra20_tear_down_cpu;

 - V1: Initial post

Tested-on: u8500
Tested-on: at91
Tested-on: intel i5
Tested-on: OMAP4

Compiled with and without CPU_IDLE for:
 u8500, at91, davinci, exynos, imx5, imx6, kirkwood, multi_v7 (for calxeda),
 omap2plus, s3c64, tegra1, tegra2, tegra3

Daniel Lezcano (19):
  ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
  ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  ARM: OMAP3: remove cpuidle_wrap_enter
  cpuidle: remove en_core_tk_irqen flag
  ARM: ux500: cpuidle: replace for_each_online_cpu by
    for_each_possible_cpu
  cpuidle: make a single register function for all
  ARM: ux500: cpuidle: use init/exit common routine
  ARM: at91: cpuidle: use init/exit common routine
  ARM: OMAP3: cpuidle: use init/exit common routine
  ARM: s3c64xx: cpuidle: use init/exit common routine
  ARM: tegra: cpuidle: use init/exit common routine
  ARM: shmobile: cpuidle: use init/exit common routine
  ARM: OMAP4: cpuidle: use init/exit common routine
  ARM: tegra: cpuidle: use init/exit common routine for tegra2
  ARM: tegra: cpuidle: use init/exit common routine for tegra3
  ARM: calxeda: cpuidle: use init/exit common routine
  ARM: kirkwood: cpuidle: use init/exit common routine
  ARM: davinci: cpuidle: use init/exit common routine
  ARM: imx: cpuidle: use init/exit common routine

 Documentation/cpuidle/driver.txt                |    6 +
 arch/arm/mach-at91/cpuidle.c                    |   18 +--
 arch/arm/mach-davinci/cpuidle.c                 |   21 +---
 arch/arm/mach-exynos/cpuidle.c                  |    1 -
 arch/arm/mach-imx/Makefile                      |    2 +-
 arch/arm/mach-imx/cpuidle-imx5.c                |   40 +++++++
 arch/arm/mach-imx/cpuidle-imx6q.c               |    3 +-
 arch/arm/mach-imx/cpuidle.c                     |   80 -------------
 arch/arm/mach-imx/cpuidle.h                     |   10 +-
 arch/arm/mach-imx/pm-imx5.c                     |   30 +----
 arch/arm/mach-omap2/cpuidle34xx.c               |   49 ++------
 arch/arm/mach-omap2/cpuidle44xx.c               |   23 +---
 arch/arm/mach-s3c64xx/cpuidle.c                 |   15 +--
 arch/arm/mach-shmobile/cpuidle.c                |   11 +-
 arch/arm/mach-shmobile/include/mach/common.h    |    3 -
 arch/arm/mach-shmobile/pm-sh7372.c              |    2 -
 arch/arm/mach-tegra/cpuidle-tegra114.c          |   27 +----
 arch/arm/mach-tegra/cpuidle-tegra20.c           |   31 +----
 arch/arm/mach-tegra/cpuidle-tegra30.c           |   28 +----
 arch/arm/mach-ux500/cpuidle.c                   |   33 +-----
 arch/powerpc/platforms/pseries/processor_idle.c |    1 -
 arch/sh/kernel/cpu/shmobile/cpuidle.c           |    1 -
 arch/x86/kernel/apm_32.c                        |    1 -
 drivers/acpi/processor_idle.c                   |    1 -
 drivers/cpuidle/cpuidle-calxeda.c               |   53 +--------
 drivers/cpuidle/cpuidle-kirkwood.c              |   18 +--
 drivers/cpuidle/cpuidle.c                       |  144 ++++++++++++++---------
 drivers/idle/intel_idle.c                       |    1 -
 include/linux/cpuidle.h                         |   20 ++--
 29 files changed, 175 insertions(+), 498 deletions(-)
 create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
 delete mode 100644 arch/arm/mach-imx/cpuidle.c

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the shmobile_enter_wfi function which is the same as the
common WFI enter function from the arm cpuidle driver defined
with the ARM_CPUIDLE_WFI_STATE macro.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-shmobile/pm-sh7372.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index f6b14ca..fbef7b9 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -414,7 +414,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
 	.state_count		= 5,
 	.safe_state_index	= 0, /* C1 */
 	.states[0] = ARM_CPUIDLE_WFI_STATE,
-	.states[0].enter = shmobile_enter_wfi,
 	.states[1] = {
 		.name = "C2",
 		.desc = "Core Standby Mode",
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the shmobile_enter_wfi function which is the same as the
common WFI enter function from the arm cpuidle driver defined
with the ARM_CPUIDLE_WFI_STATE macro.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-shmobile/pm-sh7372.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index f6b14ca..fbef7b9 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -414,7 +414,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
 	.state_count		= 5,
 	.safe_state_index	= 0, /* C1 */
 	.states[0] = ARM_CPUIDLE_WFI_STATE,
-	.states[0].enter = shmobile_enter_wfi,
 	.states[1] = {
 		.name = "C2",
 		.desc = "Core Standby Mode",
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
'shmobile_enter_wfi' but we forgot to remove the definition in the header file.

Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
function callback prototype which already exists with the default WFI state
and the arm_simple_enter function.

Remove the function prototype.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-shmobile/include/mach/common.h |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e48606d..362f9b2 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -13,9 +13,6 @@ extern int shmobile_clk_init(void);
 extern void shmobile_handle_irq_intc(struct pt_regs *);
 extern struct platform_suspend_ops shmobile_suspend_ops;
 struct cpuidle_driver;
-struct cpuidle_device;
-extern int shmobile_enter_wfi(struct cpuidle_device *dev,
-			      struct cpuidle_driver *drv, int index);
 extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv);
 
 extern void sh7372_init_irq(void);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
'shmobile_enter_wfi' but we forgot to remove the definition in the header file.

Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
function callback prototype which already exists with the default WFI state
and the arm_simple_enter function.

Remove the function prototype.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-shmobile/include/mach/common.h |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e48606d..362f9b2 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -13,9 +13,6 @@ extern int shmobile_clk_init(void);
 extern void shmobile_handle_irq_intc(struct pt_regs *);
 extern struct platform_suspend_ops shmobile_suspend_ops;
 struct cpuidle_driver;
-struct cpuidle_device;
-extern int shmobile_enter_wfi(struct cpuidle_device *dev,
-			      struct cpuidle_driver *drv, int index);
 extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv);
 
 extern void sh7372_init_irq(void);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

In a previous commit the en_core_tk_irqen flag has been added but we missed
the cpuidle_wrap_enter which was doing the job to measure the time for the
'omap3_enter_idle' function.

Actually, I don't see any reason to use this wrapper in the code. In the better
case, the time computation is not correctly done because of the different
operations done in omap3_enter_idle_bm which were not taken into account
before the en_core_tk_irqen flag was set.

As the time is reflected for the state overridden by the omap3_enter_idle_bm,
using the wrapper is pointless now, so removing it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 4f67a5b..a56310a 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
 	},
 };
 
-/* Private functions */
-
-static int __omap3_enter_idle(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv,
-				int index)
+/**
+ * omap3_enter_idle - Programs OMAP3 to enter the specified state
+ * @dev: cpuidle device
+ * @drv: cpuidle driver
+ * @index: the index of state to be entered
+ */
+static int omap3_enter_idle(struct cpuidle_device *dev,
+			    struct cpuidle_driver *drv,
+			    int index)
 {
 	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
 
@@ -149,22 +153,6 @@ return_sleep_time:
 }
 
 /**
- * omap3_enter_idle - Programs OMAP3 to enter the specified state
- * @dev: cpuidle device
- * @drv: cpuidle driver
- * @index: the index of state to be entered
- *
- * Called from the CPUidle framework to program the device to the
- * specified target state selected by the governor.
- */
-static inline int omap3_enter_idle(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv,
-				int index)
-{
-	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
-}
-
-/**
  * next_valid_state - Find next valid C-state
  * @dev: cpuidle device
  * @drv: cpuidle driver
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

In a previous commit the en_core_tk_irqen flag has been added but we missed
the cpuidle_wrap_enter which was doing the job to measure the time for the
'omap3_enter_idle' function.

Actually, I don't see any reason to use this wrapper in the code. In the better
case, the time computation is not correctly done because of the different
operations done in omap3_enter_idle_bm which were not taken into account
before the en_core_tk_irqen flag was set.

As the time is reflected for the state overridden by the omap3_enter_idle_bm,
using the wrapper is pointless now, so removing it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 4f67a5b..a56310a 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
 	},
 };
 
-/* Private functions */
-
-static int __omap3_enter_idle(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv,
-				int index)
+/**
+ * omap3_enter_idle - Programs OMAP3 to enter the specified state
+ * @dev: cpuidle device
+ * @drv: cpuidle driver
+ * @index: the index of state to be entered
+ */
+static int omap3_enter_idle(struct cpuidle_device *dev,
+			    struct cpuidle_driver *drv,
+			    int index)
 {
 	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
 
@@ -149,22 +153,6 @@ return_sleep_time:
 }
 
 /**
- * omap3_enter_idle - Programs OMAP3 to enter the specified state
- * @dev: cpuidle device
- * @drv: cpuidle driver
- * @index: the index of state to be entered
- *
- * Called from the CPUidle framework to program the device to the
- * specified target state selected by the governor.
- */
-static inline int omap3_enter_idle(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv,
-				int index)
-{
-	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
-}
-
-/**
  * next_valid_state - Find next valid C-state
  * @dev: cpuidle device
  * @drv: cpuidle driver
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 04/19] cpuidle: remove en_core_tk_irqen flag
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

The en_core_tk_irqen flag is set in all the cpuidle driver which
means it is not necessary to specify this flag.

Remove the flag and the code related to it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-at91/cpuidle.c                    |    1 -
 arch/arm/mach-davinci/cpuidle.c                 |    1 -
 arch/arm/mach-exynos/cpuidle.c                  |    1 -
 arch/arm/mach-imx/cpuidle-imx6q.c               |    1 -
 arch/arm/mach-imx/pm-imx5.c                     |    1 -
 arch/arm/mach-omap2/cpuidle34xx.c               |    1 -
 arch/arm/mach-omap2/cpuidle44xx.c               |    1 -
 arch/arm/mach-s3c64xx/cpuidle.c                 |    1 -
 arch/arm/mach-shmobile/cpuidle.c                |    1 -
 arch/arm/mach-shmobile/pm-sh7372.c              |    1 -
 arch/arm/mach-tegra/cpuidle-tegra114.c          |    1 -
 arch/arm/mach-tegra/cpuidle-tegra20.c           |    1 -
 arch/arm/mach-tegra/cpuidle-tegra30.c           |    1 -
 arch/arm/mach-ux500/cpuidle.c                   |    1 -
 arch/powerpc/platforms/pseries/processor_idle.c |    1 -
 arch/sh/kernel/cpu/shmobile/cpuidle.c           |    1 -
 arch/x86/kernel/apm_32.c                        |    1 -
 drivers/acpi/processor_idle.c                   |    1 -
 drivers/cpuidle/cpuidle-calxeda.c               |    1 -
 drivers/cpuidle/cpuidle-kirkwood.c              |    1 -
 drivers/cpuidle/cpuidle.c                       |   72 ++++++-----------------
 drivers/idle/intel_idle.c                       |    1 -
 include/linux/cpuidle.h                         |   11 ----
 23 files changed, 18 insertions(+), 86 deletions(-)

diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 0c63815..0130df7 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -47,7 +47,6 @@ static int at91_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver at91_idle_driver = {
 	.name			= "at91_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= at91_enter_idle,
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index 22d6d4a..c2887c5 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -62,7 +62,6 @@ static int davinci_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver davinci_idle_driver = {
 	.name			= "cpuidle-davinci",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= davinci_enter_idle,
diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c
index fcfe025..498a7a2 100644
--- a/arch/arm/mach-exynos/cpuidle.c
+++ b/arch/arm/mach-exynos/cpuidle.c
@@ -58,7 +58,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device);
 static struct cpuidle_driver exynos4_idle_driver = {
 	.name			= "exynos4_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 };
 
 /* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index a783a63..e2739ad 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -45,7 +45,6 @@ done:
 static struct cpuidle_driver imx6q_cpuidle_driver = {
 	.name = "imx6q_cpuidle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		/* WFI */
 		ARM_CPUIDLE_WFI_STATE,
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index f67fd7e..4b52b3e 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -164,7 +164,6 @@ static int imx5_cpuidle_enter(struct cpuidle_device *dev,
 static struct cpuidle_driver imx5_cpuidle_driver = {
 	.name			= "imx5_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]	= {
 		.enter			= imx5_cpuidle_enter,
 		.exit_latency		= 2,
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index a56310a..027a787 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -264,7 +264,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 static struct cpuidle_driver omap3_idle_driver = {
 	.name             = "omap3_idle",
 	.owner            = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{
 			.enter		  = omap3_enter_idle_bm,
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index f4b1b23..cd188de 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -162,7 +162,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
 static struct cpuidle_driver omap4_idle_driver = {
 	.name				= "omap4_idle",
 	.owner				= THIS_MODULE,
-	.en_core_tk_irqen		= 1,
 	.states = {
 		{
 			/* C1 - CPU0 ON + CPU1 ON + MPU ON */
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index ead5fab..852ff16 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -45,7 +45,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
 static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 	.name	= "s3c64xx_cpuidle",
 	.owner  = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{
 			.enter            = s3c64xx_enter_idle,
diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
index c872ae8..d671ae9 100644
--- a/arch/arm/mach-shmobile/cpuidle.c
+++ b/arch/arm/mach-shmobile/cpuidle.c
@@ -20,7 +20,6 @@ static struct cpuidle_device shmobile_cpuidle_dev;
 static struct cpuidle_driver shmobile_cpuidle_default_driver = {
 	.name			= "shmobile_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.safe_state_index	= 0, /* C1 */
 	.state_count		= 1,
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index fbef7b9..dec9293 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -410,7 +410,6 @@ static int sh7372_enter_a4s(struct cpuidle_device *dev,
 static struct cpuidle_driver sh7372_cpuidle_driver = {
 	.name			= "sh7372_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.state_count		= 5,
 	.safe_state_index	= 0, /* C1 */
 	.states[0] = ARM_CPUIDLE_WFI_STATE,
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index c527cff..c5fadf9 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -23,7 +23,6 @@
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.state_count = 1,
 	.states = {
 		[0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index b94d76a..f1f6ac4 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -51,7 +51,6 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE_PWR(600),
 #ifdef CONFIG_PM_SLEEP
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index c4e01fe..f6a0c72 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -43,7 +43,6 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev,
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 #ifdef CONFIG_PM_SLEEP
 	.state_count = 2,
 #else
diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index 1b16d9e..c29c1bf 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -94,7 +94,6 @@ out:
 static struct cpuidle_driver ux500_idle_driver = {
 	.name = "ux500_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE,
 		{
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index a197120..4644efa0 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -25,7 +25,6 @@
 struct cpuidle_driver pseries_idle_driver = {
 	.name             = "pseries_idle",
 	.owner            = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 
 #define MAX_IDLE_STATE_COUNT	2
diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c
index 1ddc876..0986f21 100644
--- a/arch/sh/kernel/cpu/shmobile/cpuidle.c
+++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c
@@ -55,7 +55,6 @@ static struct cpuidle_device cpuidle_dev;
 static struct cpuidle_driver cpuidle_driver = {
 	.name			= "sh_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 };
 
 void sh_mobile_setup_cpuidle(void)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 66b5faf..53a4e27 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -373,7 +373,6 @@ static int apm_cpu_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver apm_idle_driver = {
 	.name = "apm_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{ /* entry 0 is for polling */ },
 		{ /* entry 1 is for APM idle */
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index ee255c6..f0df2c9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -918,7 +918,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 struct cpuidle_driver acpi_idle_driver = {
 	.name =		"acpi_idle",
 	.owner =	THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 
 /**
diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index e1aab38..a3b56f5 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -100,7 +100,6 @@ static void calxeda_idle_cpuidle_devices_uninit(void)
 
 static struct cpuidle_driver calxeda_idle_driver = {
 	.name = "calxeda_idle",
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE,
 		{
diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 53aad73..6f31524 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -41,7 +41,6 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver kirkwood_idle_driver = {
 	.name			= "kirkwood_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= kirkwood_enter_idle,
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index c500370..0da795b 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -43,24 +43,6 @@ void disable_cpuidle(void)
 
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
-static inline int cpuidle_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index)
-{
-	struct cpuidle_state *target_state = &drv->states[index];
-	return target_state->enter(dev, drv, index);
-}
-
-static inline int cpuidle_enter_tk(struct cpuidle_device *dev,
-			       struct cpuidle_driver *drv, int index)
-{
-	return cpuidle_wrap_enter(dev, drv, index, cpuidle_enter);
-}
-
-typedef int (*cpuidle_enter_t)(struct cpuidle_device *dev,
-			       struct cpuidle_driver *drv, int index);
-
-static cpuidle_enter_t cpuidle_enter_ops;
-
 /**
  * cpuidle_play_dead - cpu off-lining
  *
@@ -90,11 +72,27 @@ int cpuidle_play_dead(void)
  * @next_state: index into drv->states of the state to enter
  */
 int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
-		int next_state)
+			int index)
 {
 	int entered_state;
 
-	entered_state = cpuidle_enter_ops(dev, drv, next_state);
+	struct cpuidle_state *target_state = &drv->states[index];
+	ktime_t time_start, time_end;
+	s64 diff;
+
+	time_start = ktime_get();
+
+	entered_state = target_state->enter(dev, drv, index);
+
+	time_end = ktime_get();
+
+	local_irq_enable();
+
+	diff = ktime_to_us(ktime_sub(time_end, time_start));
+	if (diff > INT_MAX)
+		diff = INT_MAX;
+
+	dev->last_residency = (int) diff;
 
 	if (entered_state >= 0) {
 		/* Update cpuidle counters */
@@ -231,37 +229,6 @@ void cpuidle_resume(void)
 	mutex_unlock(&cpuidle_lock);
 }
 
-/**
- * cpuidle_wrap_enter - performs timekeeping and irqen around enter function
- * @dev: pointer to a valid cpuidle_device object
- * @drv: pointer to a valid cpuidle_driver object
- * @index: index of the target cpuidle state.
- */
-int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index))
-{
-	ktime_t time_start, time_end;
-	s64 diff;
-
-	time_start = ktime_get();
-
-	index = enter(dev, drv, index);
-
-	time_end = ktime_get();
-
-	local_irq_enable();
-
-	diff = ktime_to_us(ktime_sub(time_end, time_start));
-	if (diff > INT_MAX)
-		diff = INT_MAX;
-
-	dev->last_residency = (int) diff;
-
-	return index;
-}
-
 #ifdef CONFIG_ARCH_HAS_CPU_RELAX
 static int poll_idle(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int index)
@@ -333,9 +300,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 			return ret;
 	}
 
-	cpuidle_enter_ops = drv->en_core_tk_irqen ?
-		cpuidle_enter_tk : cpuidle_enter;
-
 	poll_idle_init(drv);
 
 	ret = cpuidle_add_device_sysfs(dev);
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 5d66750..48d7584 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -71,7 +71,6 @@
 static struct cpuidle_driver intel_idle_driver = {
 	.name = "intel_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 /* intel_idle.max_cstate=0 disables driver */
 static int max_cstate = CPUIDLE_STATE_MAX - 1;
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index fc3e580..79e3811 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -105,8 +105,6 @@ struct cpuidle_driver {
 	struct module 		*owner;
 	int                     refcnt;
 
-	/* set to 1 to use the core cpuidle time keeping (for all states). */
-	unsigned int		en_core_tk_irqen:1;
         /* used by the cpuidle framework to setup the broadcast timer */
 	unsigned int            bctimer:1;
 	/* states array must be ordered in decreasing power consumption */
@@ -132,10 +130,6 @@ extern void cpuidle_pause(void);
 extern void cpuidle_resume(void);
 extern int cpuidle_enable_device(struct cpuidle_device *dev);
 extern void cpuidle_disable_device(struct cpuidle_device *dev);
-extern int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index));
 extern int cpuidle_play_dead(void);
 
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
@@ -162,11 +156,6 @@ static inline void cpuidle_resume(void) { }
 static inline int cpuidle_enable_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
-static inline int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index))
-{ return -ENODEV; }
 static inline int cpuidle_play_dead(void) {return -ENODEV; }
 #endif
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 04/19] cpuidle: remove en_core_tk_irqen flag
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

The en_core_tk_irqen flag is set in all the cpuidle driver which
means it is not necessary to specify this flag.

Remove the flag and the code related to it.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-at91/cpuidle.c                    |    1 -
 arch/arm/mach-davinci/cpuidle.c                 |    1 -
 arch/arm/mach-exynos/cpuidle.c                  |    1 -
 arch/arm/mach-imx/cpuidle-imx6q.c               |    1 -
 arch/arm/mach-imx/pm-imx5.c                     |    1 -
 arch/arm/mach-omap2/cpuidle34xx.c               |    1 -
 arch/arm/mach-omap2/cpuidle44xx.c               |    1 -
 arch/arm/mach-s3c64xx/cpuidle.c                 |    1 -
 arch/arm/mach-shmobile/cpuidle.c                |    1 -
 arch/arm/mach-shmobile/pm-sh7372.c              |    1 -
 arch/arm/mach-tegra/cpuidle-tegra114.c          |    1 -
 arch/arm/mach-tegra/cpuidle-tegra20.c           |    1 -
 arch/arm/mach-tegra/cpuidle-tegra30.c           |    1 -
 arch/arm/mach-ux500/cpuidle.c                   |    1 -
 arch/powerpc/platforms/pseries/processor_idle.c |    1 -
 arch/sh/kernel/cpu/shmobile/cpuidle.c           |    1 -
 arch/x86/kernel/apm_32.c                        |    1 -
 drivers/acpi/processor_idle.c                   |    1 -
 drivers/cpuidle/cpuidle-calxeda.c               |    1 -
 drivers/cpuidle/cpuidle-kirkwood.c              |    1 -
 drivers/cpuidle/cpuidle.c                       |   72 ++++++-----------------
 drivers/idle/intel_idle.c                       |    1 -
 include/linux/cpuidle.h                         |   11 ----
 23 files changed, 18 insertions(+), 86 deletions(-)

diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 0c63815..0130df7 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -47,7 +47,6 @@ static int at91_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver at91_idle_driver = {
 	.name			= "at91_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= at91_enter_idle,
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index 22d6d4a..c2887c5 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -62,7 +62,6 @@ static int davinci_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver davinci_idle_driver = {
 	.name			= "cpuidle-davinci",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= davinci_enter_idle,
diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c
index fcfe025..498a7a2 100644
--- a/arch/arm/mach-exynos/cpuidle.c
+++ b/arch/arm/mach-exynos/cpuidle.c
@@ -58,7 +58,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device);
 static struct cpuidle_driver exynos4_idle_driver = {
 	.name			= "exynos4_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 };
 
 /* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index a783a63..e2739ad 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -45,7 +45,6 @@ done:
 static struct cpuidle_driver imx6q_cpuidle_driver = {
 	.name = "imx6q_cpuidle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		/* WFI */
 		ARM_CPUIDLE_WFI_STATE,
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index f67fd7e..4b52b3e 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -164,7 +164,6 @@ static int imx5_cpuidle_enter(struct cpuidle_device *dev,
 static struct cpuidle_driver imx5_cpuidle_driver = {
 	.name			= "imx5_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]	= {
 		.enter			= imx5_cpuidle_enter,
 		.exit_latency		= 2,
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index a56310a..027a787 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -264,7 +264,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 static struct cpuidle_driver omap3_idle_driver = {
 	.name             = "omap3_idle",
 	.owner            = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{
 			.enter		  = omap3_enter_idle_bm,
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index f4b1b23..cd188de 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -162,7 +162,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
 static struct cpuidle_driver omap4_idle_driver = {
 	.name				= "omap4_idle",
 	.owner				= THIS_MODULE,
-	.en_core_tk_irqen		= 1,
 	.states = {
 		{
 			/* C1 - CPU0 ON + CPU1 ON + MPU ON */
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index ead5fab..852ff16 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -45,7 +45,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
 static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 	.name	= "s3c64xx_cpuidle",
 	.owner  = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{
 			.enter            = s3c64xx_enter_idle,
diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
index c872ae8..d671ae9 100644
--- a/arch/arm/mach-shmobile/cpuidle.c
+++ b/arch/arm/mach-shmobile/cpuidle.c
@@ -20,7 +20,6 @@ static struct cpuidle_device shmobile_cpuidle_dev;
 static struct cpuidle_driver shmobile_cpuidle_default_driver = {
 	.name			= "shmobile_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.safe_state_index	= 0, /* C1 */
 	.state_count		= 1,
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index fbef7b9..dec9293 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -410,7 +410,6 @@ static int sh7372_enter_a4s(struct cpuidle_device *dev,
 static struct cpuidle_driver sh7372_cpuidle_driver = {
 	.name			= "sh7372_cpuidle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.state_count		= 5,
 	.safe_state_index	= 0, /* C1 */
 	.states[0] = ARM_CPUIDLE_WFI_STATE,
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index c527cff..c5fadf9 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -23,7 +23,6 @@
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.state_count = 1,
 	.states = {
 		[0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index b94d76a..f1f6ac4 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -51,7 +51,6 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE_PWR(600),
 #ifdef CONFIG_PM_SLEEP
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index c4e01fe..f6a0c72 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -43,7 +43,6 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev,
 static struct cpuidle_driver tegra_idle_driver = {
 	.name = "tegra_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 #ifdef CONFIG_PM_SLEEP
 	.state_count = 2,
 #else
diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index 1b16d9e..c29c1bf 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -94,7 +94,6 @@ out:
 static struct cpuidle_driver ux500_idle_driver = {
 	.name = "ux500_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE,
 		{
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index a197120..4644efa0 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -25,7 +25,6 @@
 struct cpuidle_driver pseries_idle_driver = {
 	.name             = "pseries_idle",
 	.owner            = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 
 #define MAX_IDLE_STATE_COUNT	2
diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c
index 1ddc876..0986f21 100644
--- a/arch/sh/kernel/cpu/shmobile/cpuidle.c
+++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c
@@ -55,7 +55,6 @@ static struct cpuidle_device cpuidle_dev;
 static struct cpuidle_driver cpuidle_driver = {
 	.name			= "sh_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 };
 
 void sh_mobile_setup_cpuidle(void)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 66b5faf..53a4e27 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -373,7 +373,6 @@ static int apm_cpu_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver apm_idle_driver = {
 	.name = "apm_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 	.states = {
 		{ /* entry 0 is for polling */ },
 		{ /* entry 1 is for APM idle */
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index ee255c6..f0df2c9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -918,7 +918,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
 struct cpuidle_driver acpi_idle_driver = {
 	.name =		"acpi_idle",
 	.owner =	THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 
 /**
diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index e1aab38..a3b56f5 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -100,7 +100,6 @@ static void calxeda_idle_cpuidle_devices_uninit(void)
 
 static struct cpuidle_driver calxeda_idle_driver = {
 	.name = "calxeda_idle",
-	.en_core_tk_irqen = 1,
 	.states = {
 		ARM_CPUIDLE_WFI_STATE,
 		{
diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 53aad73..6f31524 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -41,7 +41,6 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,
 static struct cpuidle_driver kirkwood_idle_driver = {
 	.name			= "kirkwood_idle",
 	.owner			= THIS_MODULE,
-	.en_core_tk_irqen	= 1,
 	.states[0]		= ARM_CPUIDLE_WFI_STATE,
 	.states[1]		= {
 		.enter			= kirkwood_enter_idle,
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index c500370..0da795b 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -43,24 +43,6 @@ void disable_cpuidle(void)
 
 static int __cpuidle_register_device(struct cpuidle_device *dev);
 
-static inline int cpuidle_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index)
-{
-	struct cpuidle_state *target_state = &drv->states[index];
-	return target_state->enter(dev, drv, index);
-}
-
-static inline int cpuidle_enter_tk(struct cpuidle_device *dev,
-			       struct cpuidle_driver *drv, int index)
-{
-	return cpuidle_wrap_enter(dev, drv, index, cpuidle_enter);
-}
-
-typedef int (*cpuidle_enter_t)(struct cpuidle_device *dev,
-			       struct cpuidle_driver *drv, int index);
-
-static cpuidle_enter_t cpuidle_enter_ops;
-
 /**
  * cpuidle_play_dead - cpu off-lining
  *
@@ -90,11 +72,27 @@ int cpuidle_play_dead(void)
  * @next_state: index into drv->states of the state to enter
  */
 int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
-		int next_state)
+			int index)
 {
 	int entered_state;
 
-	entered_state = cpuidle_enter_ops(dev, drv, next_state);
+	struct cpuidle_state *target_state = &drv->states[index];
+	ktime_t time_start, time_end;
+	s64 diff;
+
+	time_start = ktime_get();
+
+	entered_state = target_state->enter(dev, drv, index);
+
+	time_end = ktime_get();
+
+	local_irq_enable();
+
+	diff = ktime_to_us(ktime_sub(time_end, time_start));
+	if (diff > INT_MAX)
+		diff = INT_MAX;
+
+	dev->last_residency = (int) diff;
 
 	if (entered_state >= 0) {
 		/* Update cpuidle counters */
@@ -231,37 +229,6 @@ void cpuidle_resume(void)
 	mutex_unlock(&cpuidle_lock);
 }
 
-/**
- * cpuidle_wrap_enter - performs timekeeping and irqen around enter function
- * @dev: pointer to a valid cpuidle_device object
- * @drv: pointer to a valid cpuidle_driver object
- * @index: index of the target cpuidle state.
- */
-int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index))
-{
-	ktime_t time_start, time_end;
-	s64 diff;
-
-	time_start = ktime_get();
-
-	index = enter(dev, drv, index);
-
-	time_end = ktime_get();
-
-	local_irq_enable();
-
-	diff = ktime_to_us(ktime_sub(time_end, time_start));
-	if (diff > INT_MAX)
-		diff = INT_MAX;
-
-	dev->last_residency = (int) diff;
-
-	return index;
-}
-
 #ifdef CONFIG_ARCH_HAS_CPU_RELAX
 static int poll_idle(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int index)
@@ -333,9 +300,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 			return ret;
 	}
 
-	cpuidle_enter_ops = drv->en_core_tk_irqen ?
-		cpuidle_enter_tk : cpuidle_enter;
-
 	poll_idle_init(drv);
 
 	ret = cpuidle_add_device_sysfs(dev);
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 5d66750..48d7584 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -71,7 +71,6 @@
 static struct cpuidle_driver intel_idle_driver = {
 	.name = "intel_idle",
 	.owner = THIS_MODULE,
-	.en_core_tk_irqen = 1,
 };
 /* intel_idle.max_cstate=0 disables driver */
 static int max_cstate = CPUIDLE_STATE_MAX - 1;
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index fc3e580..79e3811 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -105,8 +105,6 @@ struct cpuidle_driver {
 	struct module 		*owner;
 	int                     refcnt;
 
-	/* set to 1 to use the core cpuidle time keeping (for all states). */
-	unsigned int		en_core_tk_irqen:1;
         /* used by the cpuidle framework to setup the broadcast timer */
 	unsigned int            bctimer:1;
 	/* states array must be ordered in decreasing power consumption */
@@ -132,10 +130,6 @@ extern void cpuidle_pause(void);
 extern void cpuidle_resume(void);
 extern int cpuidle_enable_device(struct cpuidle_device *dev);
 extern void cpuidle_disable_device(struct cpuidle_device *dev);
-extern int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index));
 extern int cpuidle_play_dead(void);
 
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
@@ -162,11 +156,6 @@ static inline void cpuidle_resume(void) { }
 static inline int cpuidle_enable_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
-static inline int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index))
-{ return -ENODEV; }
 static inline int cpuidle_play_dead(void) {return -ENODEV; }
 #endif
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

All the drivers are using, in their initialization function, the
for_each_possible_cpu macro.

Using for_each_online_cpu means the driver must handle the initialization
of the cpuidle device when a cpu is up which is not the case here.

Change the macro to for_each_possible_cpu as that fix the hotplug
initialization and make the initialization routine consistent with the
rest of the code in the different drivers.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-ux500/cpuidle.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index c29c1bf..5657d4a 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -125,7 +125,7 @@ int __init ux500_idle_init(void)
 		return ret;
 	}
 
-	for_each_online_cpu(cpu) {
+	for_each_possible(cpu) {
 		device = &per_cpu(ux500_cpuidle_device, cpu);
 		device->cpu = cpu;
 		ret = cpuidle_register_device(device);
@@ -139,7 +139,7 @@ out:
 	return ret;
 
 out_unregister:
-	for_each_online_cpu(cpu) {
+	for_each_possible_cpu(cpu) {
 		device = &per_cpu(ux500_cpuidle_device, cpu);
 		cpuidle_unregister_device(device);
 	}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

All the drivers are using, in their initialization function, the
for_each_possible_cpu macro.

Using for_each_online_cpu means the driver must handle the initialization
of the cpuidle device when a cpu is up which is not the case here.

Change the macro to for_each_possible_cpu as that fix the hotplug
initialization and make the initialization routine consistent with the
rest of the code in the different drivers.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-ux500/cpuidle.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index c29c1bf..5657d4a 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -125,7 +125,7 @@ int __init ux500_idle_init(void)
 		return ret;
 	}
 
-	for_each_online_cpu(cpu) {
+	for_each_possible(cpu) {
 		device = &per_cpu(ux500_cpuidle_device, cpu);
 		device->cpu = cpu;
 		ret = cpuidle_register_device(device);
@@ -139,7 +139,7 @@ out:
 	return ret;
 
 out_unregister:
-	for_each_online_cpu(cpu) {
+	for_each_possible_cpu(cpu) {
 		device = &per_cpu(ux500_cpuidle_device, cpu);
 		cpuidle_unregister_device(device);
 	}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

The usual scheme to initialize a cpuidle driver on a SMP is:

	cpuidle_register_driver(drv);
	for_each_possible_cpu(cpu) {
		device = &per_cpu(cpuidle_dev, cpu);
		cpuidle_register_device(device);
	}

This code is duplicated in each cpuidle driver.

On UP systems, it is done this way:

	cpuidle_register_driver(drv);
	device = &per_cpu(cpuidle_dev, cpu);
	cpuidle_register_device(device);

On UP, the macro 'for_each_cpu' does one iteration:

#define for_each_cpu(cpu, mask)                 \
        for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)

Hence, the initialization loop is the same for UP than SMP.

Beside, we saw different bugs / mis-initialization / return code unchecked in
the different drivers, the code is duplicated including bugs. After fixing all
these ones, it appears the initialization pattern is the same for everyone.

Please note, some drivers are doing dev->state_count = drv->state_count. This is
not necessary because it is done by the cpuidle_enable_device function in the
cpuidle framework. This is true, until you have the same states for all your
devices. Otherwise, the 'low level' API should be used instead with the specific
initialization for the driver.

Let's add a wrapper function doing this initialization with a cpumask parameter
for the coupled idle states and use it for all the drivers.

That will save a lot of LOC, consolidate the code, and the modifications in the
future could be done in a single place. Another benefit is the consolidation of
the cpuidle_device variable which is now in the cpuidle framework and no longer
spread accross the different arch specific drivers.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 Documentation/cpuidle/driver.txt |    6 ++++
 drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
 include/linux/cpuidle.h          |    9 +++--
 3 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
index 7a9e09e..1b0d81d 100644
--- a/Documentation/cpuidle/driver.txt
+++ b/Documentation/cpuidle/driver.txt
@@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
 cpuidle driver initializes the cpuidle_device structure for each CPU device
 and registers with cpuidle using cpuidle_register_device.
 
+If all the idle states are the same, the wrapper function cpuidle_register
+could be used instead.
+
 It can also support the dynamic changes (like battery <-> AC), by using
 cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
 cpuidle_resume_and_unlock.
 
 Interfaces:
+extern int cpuidle_register(struct cpuidle_driver *drv,
+                            const struct cpumask *const coupled_cpus);
+extern int cpuidle_unregister(struct cpuidle_driver *drv);
 extern int cpuidle_register_driver(struct cpuidle_driver *drv);
 extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
 extern int cpuidle_register_device(struct cpuidle_device *dev);
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0da795b..49e8d30 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -24,6 +24,7 @@
 #include "cpuidle.h"
 
 DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
+DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
 
 DEFINE_MUTEX(cpuidle_lock);
 LIST_HEAD(cpuidle_detected_devices);
@@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
 
 EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
 
+/*
+ * cpuidle_unregister: unregister a driver and the devices. This function
+ * can be used only if the driver has been previously registered through
+ * the cpuidle_register function.
+ *
+ * @drv: a valid pointer to a struct cpuidle_driver
+ */
+void cpuidle_unregister(struct cpuidle_driver *drv)
+{
+	int cpu;
+	struct cpuidle_device *device;
+
+	for_each_possible_cpu(cpu) {
+		device = &per_cpu(cpuidle_dev, cpu);
+		cpuidle_unregister_device(device);
+	}
+
+	cpuidle_unregister_driver(drv);
+}
+EXPORT_SYMBOL_GPL(cpuidle_unregister);
+
+/**
+ * cpuidle_register: registers the driver and the cpu devices with the
+ * coupled_cpus passed as parameter. This function is used for all common
+ * initialization pattern there are in the arch specific drivers. The
+ * devices is globally defined in this file.
+ *
+ * @drv         : a valid pointer to a struct cpuidle_driver
+ * @coupled_cpus: a cpumask for the coupled states
+ *
+ * Returns 0 on success, < 0 otherwise
+ */
+int cpuidle_register(struct cpuidle_driver *drv,
+		     const struct cpumask *const coupled_cpus)
+{
+	int ret, cpu;
+	struct cpuidle_device *device;
+
+	ret = cpuidle_register_driver(drv);
+	if (ret) {
+		pr_err("failed to register cpuidle driver\n");
+		return ret;
+	}
+
+	for_each_possible_cpu(cpu) {
+		device = &per_cpu(cpuidle_dev, cpu);
+		device->cpu = cpu;
+
+#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
+		/*
+		 * On multiplatform for ARM, the coupled idle states could
+		 * enabled in the kernel even if the cpuidle driver does not
+		 * use it. Note, coupled_cpus is a struct copy.
+		 */
+		if (coupled_cpus)
+			device->coupled_cpus = *coupled_cpus;
+#endif
+		ret = cpuidle_register_device(device);
+		if (!ret)
+			continue;
+
+		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
+
+		cpuidle_unregister(drv);
+		break;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cpuidle_register);
+
 #ifdef CONFIG_SMP
 
 static void smp_callback(void *v)
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 79e3811..3c86faa 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
 extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
 extern int cpuidle_register_device(struct cpuidle_device *dev);
 extern void cpuidle_unregister_device(struct cpuidle_device *dev);
-
+extern int cpuidle_register(struct cpuidle_driver *drv,
+			    const struct cpumask *const coupled_cpus);
+extern void cpuidle_unregister(struct cpuidle_driver *drv);
 extern void cpuidle_pause_and_lock(void);
 extern void cpuidle_resume_and_unlock(void);
 extern void cpuidle_pause(void);
@@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
 static inline int cpuidle_register_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
-
+static inline int cpuidle_register(struct cpuidle_driver *drv,
+				   const struct cpumask *const coupled_cpus)
+{return -ENODEV; }
+static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
 static inline void cpuidle_pause_and_lock(void) { }
 static inline void cpuidle_resume_and_unlock(void) { }
 static inline void cpuidle_pause(void) { }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

The usual scheme to initialize a cpuidle driver on a SMP is:

	cpuidle_register_driver(drv);
	for_each_possible_cpu(cpu) {
		device = &per_cpu(cpuidle_dev, cpu);
		cpuidle_register_device(device);
	}

This code is duplicated in each cpuidle driver.

On UP systems, it is done this way:

	cpuidle_register_driver(drv);
	device = &per_cpu(cpuidle_dev, cpu);
	cpuidle_register_device(device);

On UP, the macro 'for_each_cpu' does one iteration:

#define for_each_cpu(cpu, mask)                 \
        for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)

Hence, the initialization loop is the same for UP than SMP.

Beside, we saw different bugs / mis-initialization / return code unchecked in
the different drivers, the code is duplicated including bugs. After fixing all
these ones, it appears the initialization pattern is the same for everyone.

Please note, some drivers are doing dev->state_count = drv->state_count. This is
not necessary because it is done by the cpuidle_enable_device function in the
cpuidle framework. This is true, until you have the same states for all your
devices. Otherwise, the 'low level' API should be used instead with the specific
initialization for the driver.

Let's add a wrapper function doing this initialization with a cpumask parameter
for the coupled idle states and use it for all the drivers.

That will save a lot of LOC, consolidate the code, and the modifications in the
future could be done in a single place. Another benefit is the consolidation of
the cpuidle_device variable which is now in the cpuidle framework and no longer
spread accross the different arch specific drivers.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 Documentation/cpuidle/driver.txt |    6 ++++
 drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
 include/linux/cpuidle.h          |    9 +++--
 3 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
index 7a9e09e..1b0d81d 100644
--- a/Documentation/cpuidle/driver.txt
+++ b/Documentation/cpuidle/driver.txt
@@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
 cpuidle driver initializes the cpuidle_device structure for each CPU device
 and registers with cpuidle using cpuidle_register_device.
 
+If all the idle states are the same, the wrapper function cpuidle_register
+could be used instead.
+
 It can also support the dynamic changes (like battery <-> AC), by using
 cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
 cpuidle_resume_and_unlock.
 
 Interfaces:
+extern int cpuidle_register(struct cpuidle_driver *drv,
+                            const struct cpumask *const coupled_cpus);
+extern int cpuidle_unregister(struct cpuidle_driver *drv);
 extern int cpuidle_register_driver(struct cpuidle_driver *drv);
 extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
 extern int cpuidle_register_device(struct cpuidle_device *dev);
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0da795b..49e8d30 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -24,6 +24,7 @@
 #include "cpuidle.h"
 
 DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
+DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
 
 DEFINE_MUTEX(cpuidle_lock);
 LIST_HEAD(cpuidle_detected_devices);
@@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
 
 EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
 
+/*
+ * cpuidle_unregister: unregister a driver and the devices. This function
+ * can be used only if the driver has been previously registered through
+ * the cpuidle_register function.
+ *
+ * @drv: a valid pointer to a struct cpuidle_driver
+ */
+void cpuidle_unregister(struct cpuidle_driver *drv)
+{
+	int cpu;
+	struct cpuidle_device *device;
+
+	for_each_possible_cpu(cpu) {
+		device = &per_cpu(cpuidle_dev, cpu);
+		cpuidle_unregister_device(device);
+	}
+
+	cpuidle_unregister_driver(drv);
+}
+EXPORT_SYMBOL_GPL(cpuidle_unregister);
+
+/**
+ * cpuidle_register: registers the driver and the cpu devices with the
+ * coupled_cpus passed as parameter. This function is used for all common
+ * initialization pattern there are in the arch specific drivers. The
+ * devices is globally defined in this file.
+ *
+ * @drv         : a valid pointer to a struct cpuidle_driver
+ * @coupled_cpus: a cpumask for the coupled states
+ *
+ * Returns 0 on success, < 0 otherwise
+ */
+int cpuidle_register(struct cpuidle_driver *drv,
+		     const struct cpumask *const coupled_cpus)
+{
+	int ret, cpu;
+	struct cpuidle_device *device;
+
+	ret = cpuidle_register_driver(drv);
+	if (ret) {
+		pr_err("failed to register cpuidle driver\n");
+		return ret;
+	}
+
+	for_each_possible_cpu(cpu) {
+		device = &per_cpu(cpuidle_dev, cpu);
+		device->cpu = cpu;
+
+#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
+		/*
+		 * On multiplatform for ARM, the coupled idle states could
+		 * enabled in the kernel even if the cpuidle driver does not
+		 * use it. Note, coupled_cpus is a struct copy.
+		 */
+		if (coupled_cpus)
+			device->coupled_cpus = *coupled_cpus;
+#endif
+		ret = cpuidle_register_device(device);
+		if (!ret)
+			continue;
+
+		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
+
+		cpuidle_unregister(drv);
+		break;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cpuidle_register);
+
 #ifdef CONFIG_SMP
 
 static void smp_callback(void *v)
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 79e3811..3c86faa 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
 extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
 extern int cpuidle_register_device(struct cpuidle_device *dev);
 extern void cpuidle_unregister_device(struct cpuidle_device *dev);
-
+extern int cpuidle_register(struct cpuidle_driver *drv,
+			    const struct cpumask *const coupled_cpus);
+extern void cpuidle_unregister(struct cpuidle_driver *drv);
 extern void cpuidle_pause_and_lock(void);
 extern void cpuidle_resume_and_unlock(void);
 extern void cpuidle_pause(void);
@@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
 static inline int cpuidle_register_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
-
+static inline int cpuidle_register(struct cpuidle_driver *drv,
+				   const struct cpumask *const coupled_cpus)
+{return -ENODEV; }
+static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
 static inline void cpuidle_pause_and_lock(void) { }
 static inline void cpuidle_resume_and_unlock(void) { }
 static inline void cpuidle_pause(void) { }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 07/19] ARM: ux500: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicate code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-ux500/cpuidle.c |   32 +-------------------------------
 1 file changed, 1 insertion(+), 31 deletions(-)

diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index 5657d4a..488e074 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -21,7 +21,6 @@
 
 static atomic_t master = ATOMIC_INIT(0);
 static DEFINE_SPINLOCK(master_lock);
-static DEFINE_PER_CPU(struct cpuidle_device, ux500_cpuidle_device);
 
 static inline int ux500_enter_idle(struct cpuidle_device *dev,
 				   struct cpuidle_driver *drv, int index)
@@ -112,40 +111,11 @@ static struct cpuidle_driver ux500_idle_driver = {
 
 int __init ux500_idle_init(void)
 {
-	int ret, cpu;
-	struct cpuidle_device *device;
-
         /* Configure wake up reasons */
 	prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
 			     PRCMU_WAKEUP(ABB));
 
-	ret = cpuidle_register_driver(&ux500_idle_driver);
-	if (ret) {
-		printk(KERN_ERR "failed to register ux500 idle driver\n");
-		return ret;
-	}
-
-	for_each_possible(cpu) {
-		device = &per_cpu(ux500_cpuidle_device, cpu);
-		device->cpu = cpu;
-		ret = cpuidle_register_device(device);
-		if (ret) {
-			printk(KERN_ERR "Failed to register cpuidle "
-			       "device for cpu%d\n", cpu);
-			goto out_unregister;
-		}
-	}
-out:
-	return ret;
-
-out_unregister:
-	for_each_possible_cpu(cpu) {
-		device = &per_cpu(ux500_cpuidle_device, cpu);
-		cpuidle_unregister_device(device);
-	}
-
-	cpuidle_unregister_driver(&ux500_idle_driver);
-	goto out;
+	return cpuidle_register(&ux500_idle_driver, NULL);
 }
 
 device_initcall(ux500_idle_init);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 07/19] ARM: ux500: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicate code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-ux500/cpuidle.c |   32 +-------------------------------
 1 file changed, 1 insertion(+), 31 deletions(-)

diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
index 5657d4a..488e074 100644
--- a/arch/arm/mach-ux500/cpuidle.c
+++ b/arch/arm/mach-ux500/cpuidle.c
@@ -21,7 +21,6 @@
 
 static atomic_t master = ATOMIC_INIT(0);
 static DEFINE_SPINLOCK(master_lock);
-static DEFINE_PER_CPU(struct cpuidle_device, ux500_cpuidle_device);
 
 static inline int ux500_enter_idle(struct cpuidle_device *dev,
 				   struct cpuidle_driver *drv, int index)
@@ -112,40 +111,11 @@ static struct cpuidle_driver ux500_idle_driver = {
 
 int __init ux500_idle_init(void)
 {
-	int ret, cpu;
-	struct cpuidle_device *device;
-
         /* Configure wake up reasons */
 	prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
 			     PRCMU_WAKEUP(ABB));
 
-	ret = cpuidle_register_driver(&ux500_idle_driver);
-	if (ret) {
-		printk(KERN_ERR "failed to register ux500 idle driver\n");
-		return ret;
-	}
-
-	for_each_possible(cpu) {
-		device = &per_cpu(ux500_cpuidle_device, cpu);
-		device->cpu = cpu;
-		ret = cpuidle_register_device(device);
-		if (ret) {
-			printk(KERN_ERR "Failed to register cpuidle "
-			       "device for cpu%d\n", cpu);
-			goto out_unregister;
-		}
-	}
-out:
-	return ret;
-
-out_unregister:
-	for_each_possible_cpu(cpu) {
-		device = &per_cpu(ux500_cpuidle_device, cpu);
-		cpuidle_unregister_device(device);
-	}
-
-	cpuidle_unregister_driver(&ux500_idle_driver);
-	goto out;
+	return cpuidle_register(&ux500_idle_driver, NULL);
 }
 
 device_initcall(ux500_idle_init);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 08/19] ARM: at91: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicate code and use the arm cpuidle driver's common code
for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 arch/arm/mach-at91/cpuidle.c |   17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 0130df7..48f1228 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -27,8 +27,6 @@
 
 #define AT91_MAX_STATES	2
 
-static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device);
-
 /* Actual code that puts the SoC in different idle states */
 static int at91_enter_idle(struct cpuidle_device *dev,
 			struct cpuidle_driver *drv,
@@ -60,20 +58,9 @@ static struct cpuidle_driver at91_idle_driver = {
 };
 
 /* Initialize CPU idle by registering the idle states */
-static int at91_init_cpuidle(void)
+static int __init at91_init_cpuidle(void)
 {
-	struct cpuidle_device *device;
-
-	device = &per_cpu(at91_cpuidle_device, smp_processor_id());
-	device->state_count = AT91_MAX_STATES;
-
-	cpuidle_register_driver(&at91_idle_driver);
-
-	if (cpuidle_register_device(device)) {
-		printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
-		return -EIO;
-	}
-	return 0;
+	return cpuidle_register(&at91_idle_driver, NULL);
 }
 
 device_initcall(at91_init_cpuidle);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 08/19] ARM: at91: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicate code and use the arm cpuidle driver's common code
for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 arch/arm/mach-at91/cpuidle.c |   17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 0130df7..48f1228 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -27,8 +27,6 @@
 
 #define AT91_MAX_STATES	2
 
-static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device);
-
 /* Actual code that puts the SoC in different idle states */
 static int at91_enter_idle(struct cpuidle_device *dev,
 			struct cpuidle_driver *drv,
@@ -60,20 +58,9 @@ static struct cpuidle_driver at91_idle_driver = {
 };
 
 /* Initialize CPU idle by registering the idle states */
-static int at91_init_cpuidle(void)
+static int __init at91_init_cpuidle(void)
 {
-	struct cpuidle_device *device;
-
-	device = &per_cpu(at91_cpuidle_device, smp_processor_id());
-	device->state_count = AT91_MAX_STATES;
-
-	cpuidle_register_driver(&at91_idle_driver);
-
-	if (cpuidle_register_device(device)) {
-		printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
-		return -EIO;
-	}
-	return 0;
+	return cpuidle_register(&at91_idle_driver, NULL);
 }
 
 device_initcall(at91_init_cpuidle);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 027a787..cca045c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -26,6 +26,7 @@
 #include <linux/cpuidle.h>
 #include <linux/export.h>
 #include <linux/cpu_pm.h>
+#include <asm/cpuidle.h>
 
 #include "powerdomain.h"
 #include "clockdomain.h"
@@ -259,8 +260,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 	return ret;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
-
 static struct cpuidle_driver omap3_idle_driver = {
 	.name             = "omap3_idle",
 	.owner            = THIS_MODULE,
@@ -336,8 +335,6 @@ static struct cpuidle_driver omap3_idle_driver = {
  */
 int __init omap3_idle_init(void)
 {
-	struct cpuidle_device *dev;
-
 	mpu_pd = pwrdm_lookup("mpu_pwrdm");
 	core_pd = pwrdm_lookup("core_pwrdm");
 	per_pd = pwrdm_lookup("per_pwrdm");
@@ -346,16 +343,5 @@ int __init omap3_idle_init(void)
 	if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
 		return -ENODEV;
 
-	cpuidle_register_driver(&omap3_idle_driver);
-
-	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
-	dev->cpu = 0;
-
-	if (cpuidle_register_device(dev)) {
-		printk(KERN_ERR "%s: CPUidle register device failed\n",
-		       __func__);
-		return -EIO;
-	}
-
-	return 0;
+	return cpuidle_register(&omap3_idle_driver, NULL);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle34xx.c |   18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 027a787..cca045c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -26,6 +26,7 @@
 #include <linux/cpuidle.h>
 #include <linux/export.h>
 #include <linux/cpu_pm.h>
+#include <asm/cpuidle.h>
 
 #include "powerdomain.h"
 #include "clockdomain.h"
@@ -259,8 +260,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 	return ret;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
-
 static struct cpuidle_driver omap3_idle_driver = {
 	.name             = "omap3_idle",
 	.owner            = THIS_MODULE,
@@ -336,8 +335,6 @@ static struct cpuidle_driver omap3_idle_driver = {
  */
 int __init omap3_idle_init(void)
 {
-	struct cpuidle_device *dev;
-
 	mpu_pd = pwrdm_lookup("mpu_pwrdm");
 	core_pd = pwrdm_lookup("core_pwrdm");
 	per_pd = pwrdm_lookup("per_pwrdm");
@@ -346,16 +343,5 @@ int __init omap3_idle_init(void)
 	if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
 		return -ENODEV;
 
-	cpuidle_register_driver(&omap3_idle_driver);
-
-	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
-	dev->cpu = 0;
-
-	if (cpuidle_register_device(dev)) {
-		printk(KERN_ERR "%s: CPUidle register device failed\n",
-		       __func__);
-		return -EIO;
-	}
-
-	return 0;
+	return cpuidle_register(&omap3_idle_driver, NULL);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 10/19] ARM: s3c64xx: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-s3c64xx/cpuidle.c |   14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index 852ff16..3c8ab07 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -40,8 +40,6 @@ static int s3c64xx_enter_idle(struct cpuidle_device *dev,
 	return index;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
-
 static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 	.name	= "s3c64xx_cpuidle",
 	.owner  = THIS_MODULE,
@@ -60,16 +58,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 
 static int __init s3c64xx_init_cpuidle(void)
 {
-	int ret;
-
-	cpuidle_register_driver(&s3c64xx_cpuidle_driver);
-
-	ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
-	if (ret) {
-		pr_err("Failed to register cpuidle device: %d\n", ret);
-		return ret;
-	}
-
-	return 0;
+	return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
 }
 device_initcall(s3c64xx_init_cpuidle);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 10/19] ARM: s3c64xx: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-s3c64xx/cpuidle.c |   14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index 852ff16..3c8ab07 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -40,8 +40,6 @@ static int s3c64xx_enter_idle(struct cpuidle_device *dev,
 	return index;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
-
 static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 	.name	= "s3c64xx_cpuidle",
 	.owner  = THIS_MODULE,
@@ -60,16 +58,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = {
 
 static int __init s3c64xx_init_cpuidle(void)
 {
-	int ret;
-
-	cpuidle_register_driver(&s3c64xx_cpuidle_driver);
-
-	ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
-	if (ret) {
-		pr_err("Failed to register cpuidle device: %d\n", ret);
-		return ret;
-	}
-
-	return 0;
+	return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
 }
 device_initcall(s3c64xx_init_cpuidle);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 11/19] ARM: tegra: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra114.c |   26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index c5fadf9..1d1c602 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -29,31 +29,7 @@ static struct cpuidle_driver tegra_idle_driver = {
 	},
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 int __init tegra114_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, NULL);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 11/19] ARM: tegra: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra114.c |   26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c
index c5fadf9..1d1c602 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra114.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra114.c
@@ -29,31 +29,7 @@ static struct cpuidle_driver tegra_idle_driver = {
 	},
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 int __init tegra114_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, NULL);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 12/19] ARM: shmobile: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/mach-shmobile/cpuidle.c |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
index d671ae9..0afeb5c 100644
--- a/arch/arm/mach-shmobile/cpuidle.c
+++ b/arch/arm/mach-shmobile/cpuidle.c
@@ -16,7 +16,6 @@
 #include <asm/cpuidle.h>
 #include <asm/io.h>
 
-static struct cpuidle_device shmobile_cpuidle_dev;
 static struct cpuidle_driver shmobile_cpuidle_default_driver = {
 	.name			= "shmobile_cpuidle",
 	.owner			= THIS_MODULE,
@@ -34,12 +33,5 @@ void __init shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
 
 int __init shmobile_cpuidle_init(void)
 {
-	struct cpuidle_device *dev = &shmobile_cpuidle_dev;
-
-	cpuidle_register_driver(cpuidle_drv);
-
-	dev->state_count = cpuidle_drv->state_count;
-	cpuidle_register_device(dev);
-
-	return 0;
+	return cpuidle_register(cpuidle_drv, NULL);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 12/19] ARM: shmobile: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
---
 arch/arm/mach-shmobile/cpuidle.c |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
index d671ae9..0afeb5c 100644
--- a/arch/arm/mach-shmobile/cpuidle.c
+++ b/arch/arm/mach-shmobile/cpuidle.c
@@ -16,7 +16,6 @@
 #include <asm/cpuidle.h>
 #include <asm/io.h>
 
-static struct cpuidle_device shmobile_cpuidle_dev;
 static struct cpuidle_driver shmobile_cpuidle_default_driver = {
 	.name			= "shmobile_cpuidle",
 	.owner			= THIS_MODULE,
@@ -34,12 +33,5 @@ void __init shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
 
 int __init shmobile_cpuidle_init(void)
 {
-	struct cpuidle_device *dev = &shmobile_cpuidle_dev;
-
-	cpuidle_register_driver(cpuidle_drv);
-
-	dev->state_count = cpuidle_drv->state_count;
-	cpuidle_register_device(dev);
-
-	return 0;
+	return cpuidle_register(cpuidle_drv, NULL);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:35   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle44xx.c |   22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index cd188de..861dd90 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -15,6 +15,7 @@
 #include <linux/cpu_pm.h>
 #include <linux/export.h>
 
+#include <asm/cpuidle.h>
 #include <asm/proc-fns.h>
 
 #include "common.h"
@@ -157,8 +158,6 @@ fail:
 	return index;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
-
 static struct cpuidle_driver omap4_idle_driver = {
 	.name				= "omap4_idle",
 	.owner				= THIS_MODULE,
@@ -207,9 +206,6 @@ static struct cpuidle_driver omap4_idle_driver = {
  */
 int __init omap4_idle_init(void)
 {
-	struct cpuidle_device *dev;
-	unsigned int cpu_id = 0;
-
 	mpu_pd = pwrdm_lookup("mpu_pwrdm");
 	cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm");
 	cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm");
@@ -221,19 +217,5 @@ int __init omap4_idle_init(void)
 	if (!cpu_clkdm[0] || !cpu_clkdm[1])
 		return -ENODEV;
 
-	for_each_cpu(cpu_id, cpu_online_mask) {
-		dev = &per_cpu(omap4_idle_dev, cpu_id);
-		dev->cpu = cpu_id;
-#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
-		dev->coupled_cpus = *cpu_online_mask;
-#endif
-		cpuidle_register_driver(&omap4_idle_driver);
-
-		if (cpuidle_register_device(dev)) {
-			pr_err("%s: CPUidle register failed\n", __func__);
-			return -EIO;
-		}
-	}
-
-	return 0;
+	return cpuidle_register(&omap4_idle_driver, cpu_online_mask);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
@ 2013-04-12 12:35   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:35 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-omap2/cpuidle44xx.c |   22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index cd188de..861dd90 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -15,6 +15,7 @@
 #include <linux/cpu_pm.h>
 #include <linux/export.h>
 
+#include <asm/cpuidle.h>
 #include <asm/proc-fns.h>
 
 #include "common.h"
@@ -157,8 +158,6 @@ fail:
 	return index;
 }
 
-static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
-
 static struct cpuidle_driver omap4_idle_driver = {
 	.name				= "omap4_idle",
 	.owner				= THIS_MODULE,
@@ -207,9 +206,6 @@ static struct cpuidle_driver omap4_idle_driver = {
  */
 int __init omap4_idle_init(void)
 {
-	struct cpuidle_device *dev;
-	unsigned int cpu_id = 0;
-
 	mpu_pd = pwrdm_lookup("mpu_pwrdm");
 	cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm");
 	cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm");
@@ -221,19 +217,5 @@ int __init omap4_idle_init(void)
 	if (!cpu_clkdm[0] || !cpu_clkdm[1])
 		return -ENODEV;
 
-	for_each_cpu(cpu_id, cpu_online_mask) {
-		dev = &per_cpu(omap4_idle_dev, cpu_id);
-		dev->cpu = cpu_id;
-#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
-		dev->coupled_cpus = *cpu_online_mask;
-#endif
-		cpuidle_register_driver(&omap4_idle_driver);
-
-		if (cpuidle_register_device(dev)) {
-			pr_err("%s: CPUidle register failed\n", __func__);
-			return -EIO;
-		}
-	}
-
-	return 0;
+	return cpuidle_register(&omap4_idle_driver, cpu_online_mask);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 14/19] ARM: tegra: cpuidle: use init/exit common routine for tegra2
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra20.c |   30 +-----------------------------
 1 file changed, 1 insertion(+), 29 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index f1f6ac4..590ec25 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -70,8 +70,6 @@ static struct cpuidle_driver tegra_idle_driver = {
 	.safe_state_index = 0,
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 #ifdef CONFIG_PM_SLEEP
 #ifdef CONFIG_SMP
 static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -220,34 +218,8 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
 
 int __init tegra20_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
 #ifdef CONFIG_PM_SLEEP
 	tegra_tear_down_cpu = tegra20_tear_down_cpu;
 #endif
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
-		dev->coupled_cpus = *cpu_possible_mask;
-#endif
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, cpu_possible_mask);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 14/19] ARM: tegra: cpuidle: use init/exit common routine for tegra2
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra20.c |   30 +-----------------------------
 1 file changed, 1 insertion(+), 29 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index f1f6ac4..590ec25 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -70,8 +70,6 @@ static struct cpuidle_driver tegra_idle_driver = {
 	.safe_state_index = 0,
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 #ifdef CONFIG_PM_SLEEP
 #ifdef CONFIG_SMP
 static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -220,34 +218,8 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
 
 int __init tegra20_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
 #ifdef CONFIG_PM_SLEEP
 	tegra_tear_down_cpu = tegra20_tear_down_cpu;
 #endif
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
-		dev->coupled_cpus = *cpu_possible_mask;
-#endif
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, cpu_possible_mask);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 15/19] ARM: tegra: cpuidle: use init/exit common routine for tegra3
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra30.c |   27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index f6a0c72..36dc2be 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -64,8 +64,6 @@ static struct cpuidle_driver tegra_idle_driver = {
 	},
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 #ifdef CONFIG_PM_SLEEP
 static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev,
 					   struct cpuidle_driver *drv,
@@ -156,31 +154,8 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev,
 
 int __init tegra30_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
 #ifdef CONFIG_PM_SLEEP
 	tegra_tear_down_cpu = tegra30_tear_down_cpu;
 #endif
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, NULL);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 15/19] ARM: tegra: cpuidle: use init/exit common routine for tegra3
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/cpuidle-tegra30.c |   27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index f6a0c72..36dc2be 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -64,8 +64,6 @@ static struct cpuidle_driver tegra_idle_driver = {
 	},
 };
 
-static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
-
 #ifdef CONFIG_PM_SLEEP
 static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev,
 					   struct cpuidle_driver *drv,
@@ -156,31 +154,8 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev,
 
 int __init tegra30_cpuidle_init(void)
 {
-	int ret;
-	unsigned int cpu;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &tegra_idle_driver;
-
 #ifdef CONFIG_PM_SLEEP
 	tegra_tear_down_cpu = tegra30_tear_down_cpu;
 #endif
-
-	ret = cpuidle_register_driver(&tegra_idle_driver);
-	if (ret) {
-		pr_err("CPUidle driver registration failed\n");
-		return ret;
-	}
-
-	for_each_possible_cpu(cpu) {
-		dev = &per_cpu(tegra_idle_device, cpu);
-		dev->cpu = cpu;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("CPU%u: CPUidle device registration failed\n",
-				cpu);
-			return ret;
-		}
-	}
-	return 0;
+	return cpuidle_register(&tegra_idle_driver, NULL);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 16/19] ARM: calxeda: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/cpuidle/cpuidle-calxeda.c |   52 +------------------------------------
 1 file changed, 1 insertion(+), 51 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index a3b56f5..e344b56 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -35,8 +35,6 @@
 extern void highbank_set_cpu_jump(int cpu, void *jump_addr);
 extern void *scu_base_addr;
 
-static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices;
-
 static inline unsigned int get_auxcr(void)
 {
 	unsigned int val;
@@ -85,19 +83,6 @@ static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
 	return index;
 }
 
-static void calxeda_idle_cpuidle_devices_uninit(void)
-{
-	int i;
-	struct cpuidle_device *dev;
-
-	for_each_possible_cpu(i) {
-		dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, i);
-		cpuidle_unregister_device(dev);
-	}
-
-	free_percpu(calxeda_idle_cpuidle_devices);
-}
-
 static struct cpuidle_driver calxeda_idle_driver = {
 	.name = "calxeda_idle",
 	.states = {
@@ -117,44 +102,9 @@ static struct cpuidle_driver calxeda_idle_driver = {
 
 static int __init calxeda_cpuidle_init(void)
 {
-	int cpu_id;
-	int ret;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &calxeda_idle_driver;
-
 	if (!of_machine_is_compatible("calxeda,highbank"))
 		return -ENODEV;
 
-	ret = cpuidle_register_driver(drv);
-	if (ret)
-		return ret;
-
-	calxeda_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-	if (calxeda_idle_cpuidle_devices == NULL) {
-		ret = -ENOMEM;
-		goto unregister_drv;
-	}
-
-	/* initialize state data for each cpuidle_device */
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, cpu_id);
-		dev->cpu = cpu_id;
-		dev->state_count = drv->state_count;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("Failed to register cpu %u, error: %d\n",
-			       cpu_id, ret);
-			goto uninit;
-		}
-	}
-
-	return 0;
-
-uninit:
-	calxeda_idle_cpuidle_devices_uninit();
-unregister_drv:
-	cpuidle_unregister_driver(drv);
-	return ret;
+	return cpuidle_register(&calxeda_idle_driver, NULL);
 }
 module_init(calxeda_cpuidle_init);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 16/19] ARM: calxeda: cpuidle: use init/exit common routine
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/cpuidle/cpuidle-calxeda.c |   52 +------------------------------------
 1 file changed, 1 insertion(+), 51 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c
index a3b56f5..e344b56 100644
--- a/drivers/cpuidle/cpuidle-calxeda.c
+++ b/drivers/cpuidle/cpuidle-calxeda.c
@@ -35,8 +35,6 @@
 extern void highbank_set_cpu_jump(int cpu, void *jump_addr);
 extern void *scu_base_addr;
 
-static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices;
-
 static inline unsigned int get_auxcr(void)
 {
 	unsigned int val;
@@ -85,19 +83,6 @@ static int calxeda_pwrdown_idle(struct cpuidle_device *dev,
 	return index;
 }
 
-static void calxeda_idle_cpuidle_devices_uninit(void)
-{
-	int i;
-	struct cpuidle_device *dev;
-
-	for_each_possible_cpu(i) {
-		dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, i);
-		cpuidle_unregister_device(dev);
-	}
-
-	free_percpu(calxeda_idle_cpuidle_devices);
-}
-
 static struct cpuidle_driver calxeda_idle_driver = {
 	.name = "calxeda_idle",
 	.states = {
@@ -117,44 +102,9 @@ static struct cpuidle_driver calxeda_idle_driver = {
 
 static int __init calxeda_cpuidle_init(void)
 {
-	int cpu_id;
-	int ret;
-	struct cpuidle_device *dev;
-	struct cpuidle_driver *drv = &calxeda_idle_driver;
-
 	if (!of_machine_is_compatible("calxeda,highbank"))
 		return -ENODEV;
 
-	ret = cpuidle_register_driver(drv);
-	if (ret)
-		return ret;
-
-	calxeda_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-	if (calxeda_idle_cpuidle_devices == NULL) {
-		ret = -ENOMEM;
-		goto unregister_drv;
-	}
-
-	/* initialize state data for each cpuidle_device */
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, cpu_id);
-		dev->cpu = cpu_id;
-		dev->state_count = drv->state_count;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("Failed to register cpu %u, error: %d\n",
-			       cpu_id, ret);
-			goto uninit;
-		}
-	}
-
-	return 0;
-
-uninit:
-	calxeda_idle_cpuidle_devices_uninit();
-unregister_drv:
-	cpuidle_unregister_driver(drv);
-	return ret;
+	return cpuidle_register(&calxeda_idle_driver, NULL);
 }
 module_init(calxeda_cpuidle_init);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/cpuidle-kirkwood.c |   17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 6f31524..53290e1 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -52,9 +52,6 @@ static struct cpuidle_driver kirkwood_idle_driver = {
 	},
 	.state_count = KIRKWOOD_MAX_STATES,
 };
-static struct cpuidle_device *device;
-
-static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);
 
 /* Initialize CPU idle by registering the idle states */
 static int kirkwood_cpuidle_probe(struct platform_device *pdev)
@@ -69,22 +66,12 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
 	if (IS_ERR(ddr_operation_base))
 		return PTR_ERR(ddr_operation_base);
 
-	device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id());
-	device->state_count = KIRKWOOD_MAX_STATES;
-
-	cpuidle_register_driver(&kirkwood_idle_driver);
-	if (cpuidle_register_device(device)) {
-		pr_err("kirkwood_init_cpuidle: Failed registering\n");
-		return -EIO;
-	}
-	return 0;
+	return cpuidle_register(&kirkwood_idle_driver, NULL);
 }
 
 int kirkwood_cpuidle_remove(struct platform_device *pdev)
 {
-	cpuidle_unregister_device(device);
-	cpuidle_unregister_driver(&kirkwood_idle_driver);
-
+	cpuidle_unregister(&kirkwood_idle_driver);
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/cpuidle-kirkwood.c |   17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 6f31524..53290e1 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -52,9 +52,6 @@ static struct cpuidle_driver kirkwood_idle_driver = {
 	},
 	.state_count = KIRKWOOD_MAX_STATES,
 };
-static struct cpuidle_device *device;
-
-static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);
 
 /* Initialize CPU idle by registering the idle states */
 static int kirkwood_cpuidle_probe(struct platform_device *pdev)
@@ -69,22 +66,12 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
 	if (IS_ERR(ddr_operation_base))
 		return PTR_ERR(ddr_operation_base);
 
-	device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id());
-	device->state_count = KIRKWOOD_MAX_STATES;
-
-	cpuidle_register_driver(&kirkwood_idle_driver);
-	if (cpuidle_register_device(device)) {
-		pr_err("kirkwood_init_cpuidle: Failed registering\n");
-		return -EIO;
-	}
-	return 0;
+	return cpuidle_register(&kirkwood_idle_driver, NULL);
 }
 
 int kirkwood_cpuidle_remove(struct platform_device *pdev)
 {
-	cpuidle_unregister_device(device);
-	cpuidle_unregister_driver(&kirkwood_idle_driver);
-
+	cpuidle_unregister(&kirkwood_idle_driver);
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 18/19] ARM: davinci: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-davinci/cpuidle.c |   20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index c2887c5..36aef3a 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -25,7 +25,6 @@
 
 #define DAVINCI_CPUIDLE_MAX_STATES	2
 
-static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
 static void __iomem *ddr2_reg_base;
 static bool ddr2_pdown;
 
@@ -76,12 +75,8 @@ static struct cpuidle_driver davinci_idle_driver = {
 
 static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 {
-	int ret;
-	struct cpuidle_device *device;
 	struct davinci_cpuidle_config *pdata = pdev->dev.platform_data;
 
-	device = &per_cpu(davinci_cpuidle_device, smp_processor_id());
-
 	if (!pdata) {
 		dev_err(&pdev->dev, "cannot get platform data\n");
 		return -ENOENT;
@@ -91,20 +86,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 
 	ddr2_pdown = pdata->ddr2_pdown;
 
-	ret = cpuidle_register_driver(&davinci_idle_driver);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register driver\n");
-		return ret;
-	}
-
-	ret = cpuidle_register_device(device);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register device\n");
-		cpuidle_unregister_driver(&davinci_idle_driver);
-		return ret;
-	}
-
-	return 0;
+	return cpuidle_register(&davinci_idle_driver, NULL);
 }
 
 static struct platform_driver davinci_cpuidle_driver = {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 18/19] ARM: davinci: cpuidle: use init/exit common routine
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

Remove the duplicated code and use the cpuidle common code for initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-davinci/cpuidle.c |   20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index c2887c5..36aef3a 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -25,7 +25,6 @@
 
 #define DAVINCI_CPUIDLE_MAX_STATES	2
 
-static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
 static void __iomem *ddr2_reg_base;
 static bool ddr2_pdown;
 
@@ -76,12 +75,8 @@ static struct cpuidle_driver davinci_idle_driver = {
 
 static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 {
-	int ret;
-	struct cpuidle_device *device;
 	struct davinci_cpuidle_config *pdata = pdev->dev.platform_data;
 
-	device = &per_cpu(davinci_cpuidle_device, smp_processor_id());
-
 	if (!pdata) {
 		dev_err(&pdev->dev, "cannot get platform data\n");
 		return -ENOENT;
@@ -91,20 +86,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)
 
 	ddr2_pdown = pdata->ddr2_pdown;
 
-	ret = cpuidle_register_driver(&davinci_idle_driver);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register driver\n");
-		return ret;
-	}
-
-	ret = cpuidle_register_device(device);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to register device\n");
-		cpuidle_unregister_driver(&davinci_idle_driver);
-		return ret;
-	}
-
-	return 0;
+	return cpuidle_register(&davinci_idle_driver, NULL);
 }
 
 static struct platform_driver davinci_cpuidle_driver = {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-12 12:36   ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: rjw
  Cc: linus.walleij, jason, andrew, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

The code intializes the cpuidle driver at different places.
The cpuidle driver for :
  * imx5 : is in the pm-imx5.c, the init function is in cpuidle.c
  * imx6 : is in cpuidle-imx6q.c, the init function is in cpuidle.c
           and cpuidle-imx6q.c

Instead of having the cpuidle code spread across different files,
let's create a driver for each SoC and use the common register function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-imx/Makefile        |    2 +-
 arch/arm/mach-imx/cpuidle-imx5.c  |   40 +++++++++++++++++++
 arch/arm/mach-imx/cpuidle-imx6q.c |    2 +-
 arch/arm/mach-imx/cpuidle.c       |   80 -------------------------------------
 arch/arm/mach-imx/cpuidle.h       |   10 ++---
 arch/arm/mach-imx/pm-imx5.c       |   29 +-------------
 6 files changed, 47 insertions(+), 116 deletions(-)
 create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
 delete mode 100644 arch/arm/mach-imx/cpuidle.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index c4ce090..cb70961 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
 obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
 
 ifeq ($(CONFIG_CPU_IDLE),y)
-obj-y += cpuidle.o
+obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
 obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
 endif
 
diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
new file mode 100644
index 0000000..ba4565f
--- /dev/null
+++ b/arch/arm/mach-imx/cpuidle-imx5.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/cpuidle.h>
+#include <linux/module.h>
+#include <asm/system_misc.h>
+#include <asm/proc-fns.h>
+
+#include "hardware.h"
+
+static int imx5_cpuidle_enter(struct cpuidle_device *dev,
+			      struct cpuidle_driver *drv, int index)
+{
+	arm_pm_idle();
+	return index;
+}
+
+static struct cpuidle_driver imx5_cpuidle_driver = {
+	.name             = "imx5_cpuidle",
+	.owner            = THIS_MODULE,
+	.states[0] = {
+		.enter            = imx5_cpuidle_enter,
+		.exit_latency     = 2,
+		.target_residency = 1,
+		.flags            = CPUIDLE_FLAG_TIME_VALID,
+		.name             = "IMX5 SRPG",
+		.desc             = "CPU state retained,powered off",
+	},
+	.state_count = 1,
+};
+
+int __init imx5_cpuidle_init(void)
+{
+	return cpuidle_register(&imx5_cpuidle_driver, NULL);
+}
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index e2739ad..23ddfb6 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
 	/* Set chicken bit to get a reliable WAIT mode support */
 	imx6q_set_chicken_bit();
 
-	return imx_cpuidle_init(&imx6q_cpuidle_driver);
+	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
 }
diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
deleted file mode 100644
index d4cb511..0000000
--- a/arch/arm/mach-imx/cpuidle.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2012 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/cpuidle.h>
-#include <linux/err.h>
-#include <linux/hrtimer.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-
-static struct cpuidle_device __percpu * imx_cpuidle_devices;
-
-static void __init imx_cpuidle_devices_uninit(void)
-{
-	int cpu_id;
-	struct cpuidle_device *dev;
-
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
-		cpuidle_unregister_device(dev);
-	}
-
-	free_percpu(imx_cpuidle_devices);
-}
-
-int __init imx_cpuidle_init(struct cpuidle_driver *drv)
-{
-	struct cpuidle_device *dev;
-	int cpu_id, ret;
-
-	if (drv->state_count > CPUIDLE_STATE_MAX) {
-		pr_err("%s: state_count exceeds maximum\n", __func__);
-		return -EINVAL;
-	}
-
-	ret = cpuidle_register_driver(drv);
-	if (ret) {
-		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
-			 __func__, ret);
-		return ret;
-	}
-
-	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-	if (imx_cpuidle_devices == NULL) {
-		ret = -ENOMEM;
-		goto unregister_drv;
-	}
-
-	/* initialize state data for each cpuidle_device */
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
-		dev->cpu = cpu_id;
-		dev->state_count = drv->state_count;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("%s: Failed to register cpu %u, error: %d\n",
-				__func__, cpu_id, ret);
-			goto uninit;
-		}
-	}
-
-	return 0;
-
-uninit:
-	imx_cpuidle_devices_uninit();
-
-unregister_drv:
-	cpuidle_unregister_driver(drv);
-	return ret;
-}
diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
index e092d13..786f98e 100644
--- a/arch/arm/mach-imx/cpuidle.h
+++ b/arch/arm/mach-imx/cpuidle.h
@@ -10,18 +10,16 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
-#include <linux/cpuidle.h>
-
 #ifdef CONFIG_CPU_IDLE
-extern int imx_cpuidle_init(struct cpuidle_driver *drv);
+extern int imx5_cpuidle_init(void);
 extern int imx6q_cpuidle_init(void);
 #else
-static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
+static inline int imx5_cpuidle_init(void)
 {
-	return -ENODEV;
+	return 0;
 }
 static inline int imx6q_cpuidle_init(void)
 {
-	return -ENODEV;
+	return 0;
 }
 #endif
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index 4b52b3e..82e79c6 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
 	imx5_cpu_do_idle();
 }
 
-static int imx5_cpuidle_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int idx)
-{
-	int ret;
-
-	ret = imx5_cpu_do_idle();
-	if (ret < 0)
-		return ret;
-
-	return idx;
-}
-
-static struct cpuidle_driver imx5_cpuidle_driver = {
-	.name			= "imx5_cpuidle",
-	.owner			= THIS_MODULE,
-	.states[0]	= {
-		.enter			= imx5_cpuidle_enter,
-		.exit_latency		= 2,
-		.target_residency	= 1,
-		.flags			= CPUIDLE_FLAG_TIME_VALID,
-		.name			= "IMX5 SRPG",
-		.desc			= "CPU state retained,powered off",
-	},
-	.state_count		= 1,
-};
-
 static int __init imx5_pm_common_init(void)
 {
 	int ret;
@@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
 	/* Set the registers to the default cpu idle state. */
 	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
 
-	imx_cpuidle_init(&imx5_cpuidle_driver);
-	return 0;
+	return imx5_cpuidle_init();
 }
 
 void __init imx51_pm_init(void)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
@ 2013-04-12 12:36   ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-12 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

The code intializes the cpuidle driver at different places.
The cpuidle driver for :
  * imx5 : is in the pm-imx5.c, the init function is in cpuidle.c
  * imx6 : is in cpuidle-imx6q.c, the init function is in cpuidle.c
           and cpuidle-imx6q.c

Instead of having the cpuidle code spread across different files,
let's create a driver for each SoC and use the common register function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 arch/arm/mach-imx/Makefile        |    2 +-
 arch/arm/mach-imx/cpuidle-imx5.c  |   40 +++++++++++++++++++
 arch/arm/mach-imx/cpuidle-imx6q.c |    2 +-
 arch/arm/mach-imx/cpuidle.c       |   80 -------------------------------------
 arch/arm/mach-imx/cpuidle.h       |   10 ++---
 arch/arm/mach-imx/pm-imx5.c       |   29 +-------------
 6 files changed, 47 insertions(+), 116 deletions(-)
 create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
 delete mode 100644 arch/arm/mach-imx/cpuidle.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index c4ce090..cb70961 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
 obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
 
 ifeq ($(CONFIG_CPU_IDLE),y)
-obj-y += cpuidle.o
+obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
 obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
 endif
 
diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
new file mode 100644
index 0000000..ba4565f
--- /dev/null
+++ b/arch/arm/mach-imx/cpuidle-imx5.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/cpuidle.h>
+#include <linux/module.h>
+#include <asm/system_misc.h>
+#include <asm/proc-fns.h>
+
+#include "hardware.h"
+
+static int imx5_cpuidle_enter(struct cpuidle_device *dev,
+			      struct cpuidle_driver *drv, int index)
+{
+	arm_pm_idle();
+	return index;
+}
+
+static struct cpuidle_driver imx5_cpuidle_driver = {
+	.name             = "imx5_cpuidle",
+	.owner            = THIS_MODULE,
+	.states[0] = {
+		.enter            = imx5_cpuidle_enter,
+		.exit_latency     = 2,
+		.target_residency = 1,
+		.flags            = CPUIDLE_FLAG_TIME_VALID,
+		.name             = "IMX5 SRPG",
+		.desc             = "CPU state retained,powered off",
+	},
+	.state_count = 1,
+};
+
+int __init imx5_cpuidle_init(void)
+{
+	return cpuidle_register(&imx5_cpuidle_driver, NULL);
+}
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index e2739ad..23ddfb6 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
 	/* Set chicken bit to get a reliable WAIT mode support */
 	imx6q_set_chicken_bit();
 
-	return imx_cpuidle_init(&imx6q_cpuidle_driver);
+	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
 }
diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
deleted file mode 100644
index d4cb511..0000000
--- a/arch/arm/mach-imx/cpuidle.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2012 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/cpuidle.h>
-#include <linux/err.h>
-#include <linux/hrtimer.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-
-static struct cpuidle_device __percpu * imx_cpuidle_devices;
-
-static void __init imx_cpuidle_devices_uninit(void)
-{
-	int cpu_id;
-	struct cpuidle_device *dev;
-
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
-		cpuidle_unregister_device(dev);
-	}
-
-	free_percpu(imx_cpuidle_devices);
-}
-
-int __init imx_cpuidle_init(struct cpuidle_driver *drv)
-{
-	struct cpuidle_device *dev;
-	int cpu_id, ret;
-
-	if (drv->state_count > CPUIDLE_STATE_MAX) {
-		pr_err("%s: state_count exceeds maximum\n", __func__);
-		return -EINVAL;
-	}
-
-	ret = cpuidle_register_driver(drv);
-	if (ret) {
-		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
-			 __func__, ret);
-		return ret;
-	}
-
-	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-	if (imx_cpuidle_devices == NULL) {
-		ret = -ENOMEM;
-		goto unregister_drv;
-	}
-
-	/* initialize state data for each cpuidle_device */
-	for_each_possible_cpu(cpu_id) {
-		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
-		dev->cpu = cpu_id;
-		dev->state_count = drv->state_count;
-
-		ret = cpuidle_register_device(dev);
-		if (ret) {
-			pr_err("%s: Failed to register cpu %u, error: %d\n",
-				__func__, cpu_id, ret);
-			goto uninit;
-		}
-	}
-
-	return 0;
-
-uninit:
-	imx_cpuidle_devices_uninit();
-
-unregister_drv:
-	cpuidle_unregister_driver(drv);
-	return ret;
-}
diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
index e092d13..786f98e 100644
--- a/arch/arm/mach-imx/cpuidle.h
+++ b/arch/arm/mach-imx/cpuidle.h
@@ -10,18 +10,16 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
-#include <linux/cpuidle.h>
-
 #ifdef CONFIG_CPU_IDLE
-extern int imx_cpuidle_init(struct cpuidle_driver *drv);
+extern int imx5_cpuidle_init(void);
 extern int imx6q_cpuidle_init(void);
 #else
-static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
+static inline int imx5_cpuidle_init(void)
 {
-	return -ENODEV;
+	return 0;
 }
 static inline int imx6q_cpuidle_init(void)
 {
-	return -ENODEV;
+	return 0;
 }
 #endif
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index 4b52b3e..82e79c6 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
 	imx5_cpu_do_idle();
 }
 
-static int imx5_cpuidle_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int idx)
-{
-	int ret;
-
-	ret = imx5_cpu_do_idle();
-	if (ret < 0)
-		return ret;
-
-	return idx;
-}
-
-static struct cpuidle_driver imx5_cpuidle_driver = {
-	.name			= "imx5_cpuidle",
-	.owner			= THIS_MODULE,
-	.states[0]	= {
-		.enter			= imx5_cpuidle_enter,
-		.exit_latency		= 2,
-		.target_residency	= 1,
-		.flags			= CPUIDLE_FLAG_TIME_VALID,
-		.name			= "IMX5 SRPG",
-		.desc			= "CPU state retained,powered off",
-	},
-	.state_count		= 1,
-};
-
 static int __init imx5_pm_common_init(void)
 {
 	int ret;
@@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
 	/* Set the registers to the default cpu idle state. */
 	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
 
-	imx_cpuidle_init(&imx5_cpuidle_driver);
-	return 0;
+	return imx5_cpuidle_init();
 }
 
 void __init imx51_pm_init(void)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 114+ messages in thread

* Re: [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-12 12:36   ` Daniel Lezcano
@ 2013-04-14 15:14     ` Andrew Lunn
  -1 siblings, 0 replies; 114+ messages in thread
From: Andrew Lunn @ 2013-04-14 15:14 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On Fri, Apr 12, 2013 at 02:36:03PM +0200, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/cpuidle/cpuidle-kirkwood.c |   17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
> index 6f31524..53290e1 100644
> --- a/drivers/cpuidle/cpuidle-kirkwood.c
> +++ b/drivers/cpuidle/cpuidle-kirkwood.c
> @@ -52,9 +52,6 @@ static struct cpuidle_driver kirkwood_idle_driver = {
>  	},
>  	.state_count = KIRKWOOD_MAX_STATES,
>  };
> -static struct cpuidle_device *device;
> -
> -static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);
>  
>  /* Initialize CPU idle by registering the idle states */
>  static int kirkwood_cpuidle_probe(struct platform_device *pdev)
> @@ -69,22 +66,12 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
>  	if (IS_ERR(ddr_operation_base))
>  		return PTR_ERR(ddr_operation_base);
>  
> -	device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id());
> -	device->state_count = KIRKWOOD_MAX_STATES;
> -
> -	cpuidle_register_driver(&kirkwood_idle_driver);
> -	if (cpuidle_register_device(device)) {
> -		pr_err("kirkwood_init_cpuidle: Failed registering\n");
> -		return -EIO;
> -	}
> -	return 0;
> +	return cpuidle_register(&kirkwood_idle_driver, NULL);
>  }
>  
>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>  {
> -	cpuidle_unregister_device(device);
> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> -
> +	cpuidle_unregister(&kirkwood_idle_driver);
>  	return 0;
>  }
>  
> -- 
> 1.7.9.5
> 

Tested-by: Andrew Lunn <andrew@lunn.ch>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-14 15:14     ` Andrew Lunn
  0 siblings, 0 replies; 114+ messages in thread
From: Andrew Lunn @ 2013-04-14 15:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 12, 2013 at 02:36:03PM +0200, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/cpuidle/cpuidle-kirkwood.c |   17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
> index 6f31524..53290e1 100644
> --- a/drivers/cpuidle/cpuidle-kirkwood.c
> +++ b/drivers/cpuidle/cpuidle-kirkwood.c
> @@ -52,9 +52,6 @@ static struct cpuidle_driver kirkwood_idle_driver = {
>  	},
>  	.state_count = KIRKWOOD_MAX_STATES,
>  };
> -static struct cpuidle_device *device;
> -
> -static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);
>  
>  /* Initialize CPU idle by registering the idle states */
>  static int kirkwood_cpuidle_probe(struct platform_device *pdev)
> @@ -69,22 +66,12 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
>  	if (IS_ERR(ddr_operation_base))
>  		return PTR_ERR(ddr_operation_base);
>  
> -	device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id());
> -	device->state_count = KIRKWOOD_MAX_STATES;
> -
> -	cpuidle_register_driver(&kirkwood_idle_driver);
> -	if (cpuidle_register_device(device)) {
> -		pr_err("kirkwood_init_cpuidle: Failed registering\n");
> -		return -EIO;
> -	}
> -	return 0;
> +	return cpuidle_register(&kirkwood_idle_driver, NULL);
>  }
>  
>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>  {
> -	cpuidle_unregister_device(device);
> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> -
> +	cpuidle_unregister(&kirkwood_idle_driver);
>  	return 0;
>  }
>  
> -- 
> 1.7.9.5
> 

Tested-by: Andrew Lunn <andrew@lunn.ch>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-14 15:14     ` Andrew Lunn
@ 2013-04-14 20:22       ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-14 20:22 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: rjw, linus.walleij, jason, kernel, swarren, santosh.shilimkar,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On 04/14/2013 05:14 PM, Andrew Lunn wrote:
> On Fri, Apr 12, 2013 at 02:36:03PM +0200, Daniel Lezcano wrote:
>> Remove the duplicated code and use the cpuidle common code for initialization.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---

[ ... ]

> Tested-by: Andrew Lunn <andrew@lunn.ch>

Thanks Andrew for testing.

  -- Daniel



-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-14 20:22       ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-14 20:22 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/14/2013 05:14 PM, Andrew Lunn wrote:
> On Fri, Apr 12, 2013 at 02:36:03PM +0200, Daniel Lezcano wrote:
>> Remove the duplicated code and use the cpuidle common code for initialization.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---

[ ... ]

> Tested-by: Andrew Lunn <andrew@lunn.ch>

Thanks Andrew for testing.

  -- Daniel



-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-15  3:56     ` Simon Horman
  -1 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On Fri, Apr 12, 2013 at 02:35:47PM +0200, Daniel Lezcano wrote:
> Remove the shmobile_enter_wfi function which is the same as the
> common WFI enter function from the arm cpuidle driver defined
> with the ARM_CPUIDLE_WFI_STATE macro.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  arch/arm/mach-shmobile/pm-sh7372.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
> index f6b14ca..fbef7b9 100644
> --- a/arch/arm/mach-shmobile/pm-sh7372.c
> +++ b/arch/arm/mach-shmobile/pm-sh7372.c
> @@ -414,7 +414,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
>  	.state_count		= 5,
>  	.safe_state_index	= 0, /* C1 */
>  	.states[0] = ARM_CPUIDLE_WFI_STATE,
> -	.states[0].enter = shmobile_enter_wfi,
>  	.states[1] = {
>  		.name = "C2",
>  		.desc = "Core Standby Mode",
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
@ 2013-04-15  3:56     ` Simon Horman
  0 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 12, 2013 at 02:35:47PM +0200, Daniel Lezcano wrote:
> Remove the shmobile_enter_wfi function which is the same as the
> common WFI enter function from the arm cpuidle driver defined
> with the ARM_CPUIDLE_WFI_STATE macro.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  arch/arm/mach-shmobile/pm-sh7372.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
> index f6b14ca..fbef7b9 100644
> --- a/arch/arm/mach-shmobile/pm-sh7372.c
> +++ b/arch/arm/mach-shmobile/pm-sh7372.c
> @@ -414,7 +414,6 @@ static struct cpuidle_driver sh7372_cpuidle_driver = {
>  	.state_count		= 5,
>  	.safe_state_index	= 0, /* C1 */
>  	.states[0] = ARM_CPUIDLE_WFI_STATE,
> -	.states[0].enter = shmobile_enter_wfi,
>  	.states[1] = {
>  		.name = "C2",
>  		.desc = "Core Standby Mode",
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-15  3:56     ` Simon Horman
  -1 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On Fri, Apr 12, 2013 at 02:35:48PM +0200, Daniel Lezcano wrote:
> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
> 
> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
> function callback prototype which already exists with the default WFI state
> and the arm_simple_enter function.
> 
> Remove the function prototype.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  arch/arm/mach-shmobile/include/mach/common.h |    3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index e48606d..362f9b2 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -13,9 +13,6 @@ extern int shmobile_clk_init(void);
>  extern void shmobile_handle_irq_intc(struct pt_regs *);
>  extern struct platform_suspend_ops shmobile_suspend_ops;
>  struct cpuidle_driver;
> -struct cpuidle_device;
> -extern int shmobile_enter_wfi(struct cpuidle_device *dev,
> -			      struct cpuidle_driver *drv, int index);
>  extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv);
>  
>  extern void sh7372_init_irq(void);
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
@ 2013-04-15  3:56     ` Simon Horman
  0 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 12, 2013 at 02:35:48PM +0200, Daniel Lezcano wrote:
> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
> 
> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
> function callback prototype which already exists with the default WFI state
> and the arm_simple_enter function.
> 
> Remove the function prototype.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  arch/arm/mach-shmobile/include/mach/common.h |    3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index e48606d..362f9b2 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -13,9 +13,6 @@ extern int shmobile_clk_init(void);
>  extern void shmobile_handle_irq_intc(struct pt_regs *);
>  extern struct platform_suspend_ops shmobile_suspend_ops;
>  struct cpuidle_driver;
> -struct cpuidle_device;
> -extern int shmobile_enter_wfi(struct cpuidle_device *dev,
> -			      struct cpuidle_driver *drv, int index);
>  extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv);
>  
>  extern void sh7372_init_irq(void);
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 12/19] ARM: shmobile: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-15  3:56     ` Simon Horman
  -1 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On Fri, Apr 12, 2013 at 02:35:58PM +0200, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
>  arch/arm/mach-shmobile/cpuidle.c |   10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
> index d671ae9..0afeb5c 100644
> --- a/arch/arm/mach-shmobile/cpuidle.c
> +++ b/arch/arm/mach-shmobile/cpuidle.c
> @@ -16,7 +16,6 @@
>  #include <asm/cpuidle.h>
>  #include <asm/io.h>
>  
> -static struct cpuidle_device shmobile_cpuidle_dev;
>  static struct cpuidle_driver shmobile_cpuidle_default_driver = {
>  	.name			= "shmobile_cpuidle",
>  	.owner			= THIS_MODULE,
> @@ -34,12 +33,5 @@ void __init shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
>  
>  int __init shmobile_cpuidle_init(void)
>  {
> -	struct cpuidle_device *dev = &shmobile_cpuidle_dev;
> -
> -	cpuidle_register_driver(cpuidle_drv);
> -
> -	dev->state_count = cpuidle_drv->state_count;
> -	cpuidle_register_device(dev);
> -
> -	return 0;
> +	return cpuidle_register(cpuidle_drv, NULL);
>  }
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 12/19] ARM: shmobile: cpuidle: use init/exit common routine
@ 2013-04-15  3:56     ` Simon Horman
  0 siblings, 0 replies; 114+ messages in thread
From: Simon Horman @ 2013-04-15  3:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 12, 2013 at 02:35:58PM +0200, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
>  arch/arm/mach-shmobile/cpuidle.c |   10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c
> index d671ae9..0afeb5c 100644
> --- a/arch/arm/mach-shmobile/cpuidle.c
> +++ b/arch/arm/mach-shmobile/cpuidle.c
> @@ -16,7 +16,6 @@
>  #include <asm/cpuidle.h>
>  #include <asm/io.h>
>  
> -static struct cpuidle_device shmobile_cpuidle_dev;
>  static struct cpuidle_driver shmobile_cpuidle_default_driver = {
>  	.name			= "shmobile_cpuidle",
>  	.owner			= THIS_MODULE,
> @@ -34,12 +33,5 @@ void __init shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
>  
>  int __init shmobile_cpuidle_init(void)
>  {
> -	struct cpuidle_device *dev = &shmobile_cpuidle_dev;
> -
> -	cpuidle_register_driver(cpuidle_drv);
> -
> -	dev->state_count = cpuidle_drv->state_count;
> -	cpuidle_register_device(dev);
> -
> -	return 0;
> +	return cpuidle_register(cpuidle_drv, NULL);
>  }
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-15 22:55     ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-15 22:55 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
>
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
>
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Kevin Hilman <khilman@linaro.org>

If this doesn't make it for v3.10 (since Rafael is travelling), it should
probably be queued for v3.10-rc.

Kevin

> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
>  1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 4f67a5b..a56310a 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
>  	},
>  };
>  
> -/* Private functions */
> -
> -static int __omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> +/**
> + * omap3_enter_idle - Programs OMAP3 to enter the specified state
> + * @dev: cpuidle device
> + * @drv: cpuidle driver
> + * @index: the index of state to be entered
> + */
> +static int omap3_enter_idle(struct cpuidle_device *dev,
> +			    struct cpuidle_driver *drv,
> +			    int index)
>  {
>  	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
>  
> @@ -149,22 +153,6 @@ return_sleep_time:
>  }
>  
>  /**
> - * omap3_enter_idle - Programs OMAP3 to enter the specified state
> - * @dev: cpuidle device
> - * @drv: cpuidle driver
> - * @index: the index of state to be entered
> - *
> - * Called from the CPUidle framework to program the device to the
> - * specified target state selected by the governor.
> - */
> -static inline int omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> -{
> -	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
> -}
> -
> -/**
>   * next_valid_state - Find next valid C-state
>   * @dev: cpuidle device
>   * @drv: cpuidle driver

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
@ 2013-04-15 22:55     ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-15 22:55 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
>
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
>
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Kevin Hilman <khilman@linaro.org>

If this doesn't make it for v3.10 (since Rafael is travelling), it should
probably be queued for v3.10-rc.

Kevin

> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
>  1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 4f67a5b..a56310a 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
>  	},
>  };
>  
> -/* Private functions */
> -
> -static int __omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> +/**
> + * omap3_enter_idle - Programs OMAP3 to enter the specified state
> + * @dev: cpuidle device
> + * @drv: cpuidle driver
> + * @index: the index of state to be entered
> + */
> +static int omap3_enter_idle(struct cpuidle_device *dev,
> +			    struct cpuidle_driver *drv,
> +			    int index)
>  {
>  	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
>  
> @@ -149,22 +153,6 @@ return_sleep_time:
>  }
>  
>  /**
> - * omap3_enter_idle - Programs OMAP3 to enter the specified state
> - * @dev: cpuidle device
> - * @drv: cpuidle driver
> - * @index: the index of state to be entered
> - *
> - * Called from the CPUidle framework to program the device to the
> - * specified target state selected by the governor.
> - */
> -static inline int omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> -{
> -	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
> -}
> -
> -/**
>   * next_valid_state - Find next valid C-state
>   * @dev: cpuidle device
>   * @drv: cpuidle driver

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 00/19] cpuidle: code consolidation
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-15 23:03   ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-15 23:03 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Hi Daniel,

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> This patchset series provide some code consolidation across the different
> cpuidle drivers. It contains two parts, the first one is the removal of
> the time keeping flag and the second one, is a common initialization routine.

Do you have this series in a branch somewhere (preferrable on top of
Rafael's linux-next) for ease of testing?

Thanks,

Kevin

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 00/19] cpuidle: code consolidation
@ 2013-04-15 23:03   ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-15 23:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Daniel,

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> This patchset series provide some code consolidation across the different
> cpuidle drivers. It contains two parts, the first one is the removal of
> the time keeping flag and the second one, is a common initialization routine.

Do you have this series in a branch somewhere (preferrable on top of
Rafael's linux-next) for ease of testing?

Thanks,

Kevin

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 18/19] ARM: davinci: cpuidle: use init/exit common routine
  2013-04-12 12:36   ` Daniel Lezcano
@ 2013-04-16  8:30     ` Sekhar Nori
  -1 siblings, 0 replies; 114+ messages in thread
From: Sekhar Nori @ 2013-04-16  8:30 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

On 4/12/2013 6:06 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Tested on DA850 EVM.

Acked-by: Sekhar Nori <nsekhar@ti.com>

Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 18/19] ARM: davinci: cpuidle: use init/exit common routine
@ 2013-04-16  8:30     ` Sekhar Nori
  0 siblings, 0 replies; 114+ messages in thread
From: Sekhar Nori @ 2013-04-16  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 4/12/2013 6:06 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Tested on DA850 EVM.

Acked-by: Sekhar Nori <nsekhar@ti.com>

Thanks,
Sekhar

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 00/19] cpuidle: code consolidation
  2013-04-15 23:03   ` Kevin Hilman
@ 2013-04-16  8:42     ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-16  8:42 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

On 04/16/2013 01:03 AM, Kevin Hilman wrote:
> Hi Daniel,
> 
> Daniel Lezcano <daniel.lezcano@linaro.org> writes:
> 
>> This patchset series provide some code consolidation across the different
>> cpuidle drivers. It contains two parts, the first one is the removal of
>> the time keeping flag and the second one, is a common initialization routine.
> 
> Do you have this series in a branch somewhere (preferrable on top of
> Rafael's linux-next) for ease of testing?

Yes, I updated my git tree [1].

Thanks for testing.

  -- Daniel

[1] git://git.linaro.org/people/dlezcano/cpuidle-next.git linux-pm-next

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 00/19] cpuidle: code consolidation
@ 2013-04-16  8:42     ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-16  8:42 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/16/2013 01:03 AM, Kevin Hilman wrote:
> Hi Daniel,
> 
> Daniel Lezcano <daniel.lezcano@linaro.org> writes:
> 
>> This patchset series provide some code consolidation across the different
>> cpuidle drivers. It contains two parts, the first one is the removal of
>> the time keeping flag and the second one, is a common initialization routine.
> 
> Do you have this series in a branch somewhere (preferrable on top of
> Rafael's linux-next) for ease of testing?

Yes, I updated my git tree [1].

Thanks for testing.

  -- Daniel

[1] git://git.linaro.org/people/dlezcano/cpuidle-next.git linux-pm-next

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-16 12:34     ` Linus Walleij
  -1 siblings, 0 replies; 114+ messages in thread
From: Linus Walleij @ 2013-04-16 12:34 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Rafael J. Wysocki, Jason Cooper, Andrew Lunn, Sascha Hauer,
	Stephen Warren, santosh.shilimkar, Nicolas Ferre,
	Jean-Christophe PLAGNIOL-VILLARD, Andrew Victor, Rob Herring,
	Nori, Sekhar, Simon Horman, Magnus Damm, deepthi, Paul Mundt,
	Jiri Kosina, Kukjin Kim, ext Kevin Hilman, ext Tony Lindgren,
	linux-pm, Patch Tracking, linux-arm-kernel@lists.infradead.org

On Fri, Apr 12, 2013 at 2:35 PM, Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:

> All the drivers are using, in their initialization function, the
> for_each_possible_cpu macro.
>
> Using for_each_online_cpu means the driver must handle the initialization
> of the cpuidle device when a cpu is up which is not the case here.
>
> Change the macro to for_each_possible_cpu as that fix the hotplug
> initialization and make the initialization routine consistent with the
> rest of the code in the different drivers.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
@ 2013-04-16 12:34     ` Linus Walleij
  0 siblings, 0 replies; 114+ messages in thread
From: Linus Walleij @ 2013-04-16 12:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 12, 2013 at 2:35 PM, Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:

> All the drivers are using, in their initialization function, the
> for_each_possible_cpu macro.
>
> Using for_each_online_cpu means the driver must handle the initialization
> of the cpuidle device when a cpu is up which is not the case here.
>
> Change the macro to for_each_possible_cpu as that fix the hotplug
> initialization and make the initialization routine consistent with the
> rest of the code in the different drivers.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
  2013-04-12 12:36   ` Daniel Lezcano
@ 2013-04-17  6:24     ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  6:24 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, andrew, khilman, nsekhar, josephl, kgene.kim, patches,
	magnus.damm, tony, plagnioj, linaro-kernel, jason, swarren,
	rob.herring, horms, linux, linux-arm-kernel, deepthi, jkosina,
	linux-pm, lethal, Sascha Hauer, Shawn Guo

On 04/12/2013 02:36 PM, Daniel Lezcano wrote:
> The code intializes the cpuidle driver at different places.
> The cpuidle driver for :
>   * imx5 : is in the pm-imx5.c, the init function is in cpuidle.c
>   * imx6 : is in cpuidle-imx6q.c, the init function is in cpuidle.c
>            and cpuidle-imx6q.c
>
> Instead of having the cpuidle code spread across different files,
> let's create a driver for each SoC and use the common register function.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Hi Sascha, Shawn,

are you ok with this patch ?

Thanks
-- Daniel


>  arch/arm/mach-imx/Makefile        |    2 +-
>  arch/arm/mach-imx/cpuidle-imx5.c  |   40 +++++++++++++++++++
>  arch/arm/mach-imx/cpuidle-imx6q.c |    2 +-
>  arch/arm/mach-imx/cpuidle.c       |   80 -------------------------------------
>  arch/arm/mach-imx/cpuidle.h       |   10 ++---
>  arch/arm/mach-imx/pm-imx5.c       |   29 +-------------
>  6 files changed, 47 insertions(+), 116 deletions(-)
>  create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
>  delete mode 100644 arch/arm/mach-imx/cpuidle.c
>
> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index c4ce090..cb70961 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
>  obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
>  
>  ifeq ($(CONFIG_CPU_IDLE),y)
> -obj-y += cpuidle.o
> +obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
>  obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
>  endif
>  
> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> new file mode 100644
> index 0000000..ba4565f
> --- /dev/null
> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/cpuidle.h>
> +#include <linux/module.h>
> +#include <asm/system_misc.h>
> +#include <asm/proc-fns.h>
> +
> +#include "hardware.h"
> +
> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> +			      struct cpuidle_driver *drv, int index)
> +{
> +	arm_pm_idle();
> +	return index;
> +}
> +
> +static struct cpuidle_driver imx5_cpuidle_driver = {
> +	.name             = "imx5_cpuidle",
> +	.owner            = THIS_MODULE,
> +	.states[0] = {
> +		.enter            = imx5_cpuidle_enter,
> +		.exit_latency     = 2,
> +		.target_residency = 1,
> +		.flags            = CPUIDLE_FLAG_TIME_VALID,
> +		.name             = "IMX5 SRPG",
> +		.desc             = "CPU state retained,powered off",
> +	},
> +	.state_count = 1,
> +};
> +
> +int __init imx5_cpuidle_init(void)
> +{
> +	return cpuidle_register(&imx5_cpuidle_driver, NULL);
> +}
> diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
> index e2739ad..23ddfb6 100644
> --- a/arch/arm/mach-imx/cpuidle-imx6q.c
> +++ b/arch/arm/mach-imx/cpuidle-imx6q.c
> @@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
>  	/* Set chicken bit to get a reliable WAIT mode support */
>  	imx6q_set_chicken_bit();
>  
> -	return imx_cpuidle_init(&imx6q_cpuidle_driver);
> +	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
>  }
> diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
> deleted file mode 100644
> index d4cb511..0000000
> --- a/arch/arm/mach-imx/cpuidle.c
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -/*
> - * Copyright 2012 Freescale Semiconductor, Inc.
> - * Copyright 2012 Linaro Ltd.
> - *
> - * The code contained herein is licensed under the GNU General Public
> - * License. You may obtain a copy of the GNU General Public License
> - * Version 2 or later at the following locations:
> - *
> - * http://www.opensource.org/licenses/gpl-license.html
> - * http://www.gnu.org/copyleft/gpl.html
> - */
> -
> -#include <linux/cpuidle.h>
> -#include <linux/err.h>
> -#include <linux/hrtimer.h>
> -#include <linux/io.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -
> -static struct cpuidle_device __percpu * imx_cpuidle_devices;
> -
> -static void __init imx_cpuidle_devices_uninit(void)
> -{
> -	int cpu_id;
> -	struct cpuidle_device *dev;
> -
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		cpuidle_unregister_device(dev);
> -	}
> -
> -	free_percpu(imx_cpuidle_devices);
> -}
> -
> -int __init imx_cpuidle_init(struct cpuidle_driver *drv)
> -{
> -	struct cpuidle_device *dev;
> -	int cpu_id, ret;
> -
> -	if (drv->state_count > CPUIDLE_STATE_MAX) {
> -		pr_err("%s: state_count exceeds maximum\n", __func__);
> -		return -EINVAL;
> -	}
> -
> -	ret = cpuidle_register_driver(drv);
> -	if (ret) {
> -		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
> -			 __func__, ret);
> -		return ret;
> -	}
> -
> -	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
> -	if (imx_cpuidle_devices == NULL) {
> -		ret = -ENOMEM;
> -		goto unregister_drv;
> -	}
> -
> -	/* initialize state data for each cpuidle_device */
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		dev->cpu = cpu_id;
> -		dev->state_count = drv->state_count;
> -
> -		ret = cpuidle_register_device(dev);
> -		if (ret) {
> -			pr_err("%s: Failed to register cpu %u, error: %d\n",
> -				__func__, cpu_id, ret);
> -			goto uninit;
> -		}
> -	}
> -
> -	return 0;
> -
> -uninit:
> -	imx_cpuidle_devices_uninit();
> -
> -unregister_drv:
> -	cpuidle_unregister_driver(drv);
> -	return ret;
> -}
> diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
> index e092d13..786f98e 100644
> --- a/arch/arm/mach-imx/cpuidle.h
> +++ b/arch/arm/mach-imx/cpuidle.h
> @@ -10,18 +10,16 @@
>   * http://www.gnu.org/copyleft/gpl.html
>   */
>  
> -#include <linux/cpuidle.h>
> -
>  #ifdef CONFIG_CPU_IDLE
> -extern int imx_cpuidle_init(struct cpuidle_driver *drv);
> +extern int imx5_cpuidle_init(void);
>  extern int imx6q_cpuidle_init(void);
>  #else
> -static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
> +static inline int imx5_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  static inline int imx6q_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  #endif
> diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
> index 4b52b3e..82e79c6 100644
> --- a/arch/arm/mach-imx/pm-imx5.c
> +++ b/arch/arm/mach-imx/pm-imx5.c
> @@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
>  	imx5_cpu_do_idle();
>  }
>  
> -static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv, int idx)
> -{
> -	int ret;
> -
> -	ret = imx5_cpu_do_idle();
> -	if (ret < 0)
> -		return ret;
> -
> -	return idx;
> -}
> -
> -static struct cpuidle_driver imx5_cpuidle_driver = {
> -	.name			= "imx5_cpuidle",
> -	.owner			= THIS_MODULE,
> -	.states[0]	= {
> -		.enter			= imx5_cpuidle_enter,
> -		.exit_latency		= 2,
> -		.target_residency	= 1,
> -		.flags			= CPUIDLE_FLAG_TIME_VALID,
> -		.name			= "IMX5 SRPG",
> -		.desc			= "CPU state retained,powered off",
> -	},
> -	.state_count		= 1,
> -};
> -
>  static int __init imx5_pm_common_init(void)
>  {
>  	int ret;
> @@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
>  	/* Set the registers to the default cpu idle state. */
>  	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
>  
> -	imx_cpuidle_init(&imx5_cpuidle_driver);
> -	return 0;
> +	return imx5_cpuidle_init();
>  }
>  
>  void __init imx51_pm_init(void)


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
@ 2013-04-17  6:24     ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  6:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/12/2013 02:36 PM, Daniel Lezcano wrote:
> The code intializes the cpuidle driver at different places.
> The cpuidle driver for :
>   * imx5 : is in the pm-imx5.c, the init function is in cpuidle.c
>   * imx6 : is in cpuidle-imx6q.c, the init function is in cpuidle.c
>            and cpuidle-imx6q.c
>
> Instead of having the cpuidle code spread across different files,
> let's create a driver for each SoC and use the common register function.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Hi Sascha, Shawn,

are you ok with this patch ?

Thanks
-- Daniel


>  arch/arm/mach-imx/Makefile        |    2 +-
>  arch/arm/mach-imx/cpuidle-imx5.c  |   40 +++++++++++++++++++
>  arch/arm/mach-imx/cpuidle-imx6q.c |    2 +-
>  arch/arm/mach-imx/cpuidle.c       |   80 -------------------------------------
>  arch/arm/mach-imx/cpuidle.h       |   10 ++---
>  arch/arm/mach-imx/pm-imx5.c       |   29 +-------------
>  6 files changed, 47 insertions(+), 116 deletions(-)
>  create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c
>  delete mode 100644 arch/arm/mach-imx/cpuidle.c
>
> diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> index c4ce090..cb70961 100644
> --- a/arch/arm/mach-imx/Makefile
> +++ b/arch/arm/mach-imx/Makefile
> @@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
>  obj-$(CONFIG_CPU_FREQ_IMX)    += cpufreq.o
>  
>  ifeq ($(CONFIG_CPU_IDLE),y)
> -obj-y += cpuidle.o
> +obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
>  obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
>  endif
>  
> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> new file mode 100644
> index 0000000..ba4565f
> --- /dev/null
> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/cpuidle.h>
> +#include <linux/module.h>
> +#include <asm/system_misc.h>
> +#include <asm/proc-fns.h>
> +
> +#include "hardware.h"
> +
> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> +			      struct cpuidle_driver *drv, int index)
> +{
> +	arm_pm_idle();
> +	return index;
> +}
> +
> +static struct cpuidle_driver imx5_cpuidle_driver = {
> +	.name             = "imx5_cpuidle",
> +	.owner            = THIS_MODULE,
> +	.states[0] = {
> +		.enter            = imx5_cpuidle_enter,
> +		.exit_latency     = 2,
> +		.target_residency = 1,
> +		.flags            = CPUIDLE_FLAG_TIME_VALID,
> +		.name             = "IMX5 SRPG",
> +		.desc             = "CPU state retained,powered off",
> +	},
> +	.state_count = 1,
> +};
> +
> +int __init imx5_cpuidle_init(void)
> +{
> +	return cpuidle_register(&imx5_cpuidle_driver, NULL);
> +}
> diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
> index e2739ad..23ddfb6 100644
> --- a/arch/arm/mach-imx/cpuidle-imx6q.c
> +++ b/arch/arm/mach-imx/cpuidle-imx6q.c
> @@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
>  	/* Set chicken bit to get a reliable WAIT mode support */
>  	imx6q_set_chicken_bit();
>  
> -	return imx_cpuidle_init(&imx6q_cpuidle_driver);
> +	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
>  }
> diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
> deleted file mode 100644
> index d4cb511..0000000
> --- a/arch/arm/mach-imx/cpuidle.c
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -/*
> - * Copyright 2012 Freescale Semiconductor, Inc.
> - * Copyright 2012 Linaro Ltd.
> - *
> - * The code contained herein is licensed under the GNU General Public
> - * License. You may obtain a copy of the GNU General Public License
> - * Version 2 or later at the following locations:
> - *
> - * http://www.opensource.org/licenses/gpl-license.html
> - * http://www.gnu.org/copyleft/gpl.html
> - */
> -
> -#include <linux/cpuidle.h>
> -#include <linux/err.h>
> -#include <linux/hrtimer.h>
> -#include <linux/io.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -
> -static struct cpuidle_device __percpu * imx_cpuidle_devices;
> -
> -static void __init imx_cpuidle_devices_uninit(void)
> -{
> -	int cpu_id;
> -	struct cpuidle_device *dev;
> -
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		cpuidle_unregister_device(dev);
> -	}
> -
> -	free_percpu(imx_cpuidle_devices);
> -}
> -
> -int __init imx_cpuidle_init(struct cpuidle_driver *drv)
> -{
> -	struct cpuidle_device *dev;
> -	int cpu_id, ret;
> -
> -	if (drv->state_count > CPUIDLE_STATE_MAX) {
> -		pr_err("%s: state_count exceeds maximum\n", __func__);
> -		return -EINVAL;
> -	}
> -
> -	ret = cpuidle_register_driver(drv);
> -	if (ret) {
> -		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
> -			 __func__, ret);
> -		return ret;
> -	}
> -
> -	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
> -	if (imx_cpuidle_devices == NULL) {
> -		ret = -ENOMEM;
> -		goto unregister_drv;
> -	}
> -
> -	/* initialize state data for each cpuidle_device */
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		dev->cpu = cpu_id;
> -		dev->state_count = drv->state_count;
> -
> -		ret = cpuidle_register_device(dev);
> -		if (ret) {
> -			pr_err("%s: Failed to register cpu %u, error: %d\n",
> -				__func__, cpu_id, ret);
> -			goto uninit;
> -		}
> -	}
> -
> -	return 0;
> -
> -uninit:
> -	imx_cpuidle_devices_uninit();
> -
> -unregister_drv:
> -	cpuidle_unregister_driver(drv);
> -	return ret;
> -}
> diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
> index e092d13..786f98e 100644
> --- a/arch/arm/mach-imx/cpuidle.h
> +++ b/arch/arm/mach-imx/cpuidle.h
> @@ -10,18 +10,16 @@
>   * http://www.gnu.org/copyleft/gpl.html
>   */
>  
> -#include <linux/cpuidle.h>
> -
>  #ifdef CONFIG_CPU_IDLE
> -extern int imx_cpuidle_init(struct cpuidle_driver *drv);
> +extern int imx5_cpuidle_init(void);
>  extern int imx6q_cpuidle_init(void);
>  #else
> -static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
> +static inline int imx5_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  static inline int imx6q_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  #endif
> diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
> index 4b52b3e..82e79c6 100644
> --- a/arch/arm/mach-imx/pm-imx5.c
> +++ b/arch/arm/mach-imx/pm-imx5.c
> @@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
>  	imx5_cpu_do_idle();
>  }
>  
> -static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv, int idx)
> -{
> -	int ret;
> -
> -	ret = imx5_cpu_do_idle();
> -	if (ret < 0)
> -		return ret;
> -
> -	return idx;
> -}
> -
> -static struct cpuidle_driver imx5_cpuidle_driver = {
> -	.name			= "imx5_cpuidle",
> -	.owner			= THIS_MODULE,
> -	.states[0]	= {
> -		.enter			= imx5_cpuidle_enter,
> -		.exit_latency		= 2,
> -		.target_residency	= 1,
> -		.flags			= CPUIDLE_FLAG_TIME_VALID,
> -		.name			= "IMX5 SRPG",
> -		.desc			= "CPU state retained,powered off",
> -	},
> -	.state_count		= 1,
> -};
> -
>  static int __init imx5_pm_common_init(void)
>  {
>  	int ret;
> @@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
>  	/* Set the registers to the default cpu idle state. */
>  	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
>  
> -	imx_cpuidle_init(&imx5_cpuidle_driver);
> -	return 0;
> +	return imx5_cpuidle_init();
>  }
>  
>  void __init imx51_pm_init(void)


-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-17  6:28     ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  6:28 UTC (permalink / raw)
  To: andrew, rob.herring
  Cc: rjw, khilman, nsekhar, josephl, kgene.kim, patches, magnus.damm,
	tony, plagnioj, linaro-kernel, jason, swarren, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On 04/12/2013 02:35 PM, Daniel Lezcano wrote:
> The usual scheme to initialize a cpuidle driver on a SMP is:
>
> 	cpuidle_register_driver(drv);
> 	for_each_possible_cpu(cpu) {
> 		device = &per_cpu(cpuidle_dev, cpu);
> 		cpuidle_register_device(device);
> 	}
>
> This code is duplicated in each cpuidle driver.
>
> On UP systems, it is done this way:
>
> 	cpuidle_register_driver(drv);
> 	device = &per_cpu(cpuidle_dev, cpu);
> 	cpuidle_register_device(device);
>
> On UP, the macro 'for_each_cpu' does one iteration:
>
> #define for_each_cpu(cpu, mask)                 \
>         for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
>
> Hence, the initialization loop is the same for UP than SMP.
>
> Beside, we saw different bugs / mis-initialization / return code unchecked in
> the different drivers, the code is duplicated including bugs. After fixing all
> these ones, it appears the initialization pattern is the same for everyone.
>
> Please note, some drivers are doing dev->state_count = drv->state_count. This is
> not necessary because it is done by the cpuidle_enable_device function in the
> cpuidle framework. This is true, until you have the same states for all your
> devices. Otherwise, the 'low level' API should be used instead with the specific
> initialization for the driver.
>
> Let's add a wrapper function doing this initialization with a cpumask parameter
> for the coupled idle states and use it for all the drivers.
>
> That will save a lot of LOC, consolidate the code, and the modifications in the
> future could be done in a single place. Another benefit is the consolidation of
> the cpuidle_device variable which is now in the cpuidle framework and no longer
> spread accross the different arch specific drivers.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Hi Rob, Andrew,

are you ok with this new version ?

Thanks
-- Daniel

>  Documentation/cpuidle/driver.txt |    6 ++++
>  drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
>  include/linux/cpuidle.h          |    9 +++--
>  3 files changed, 85 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
> index 7a9e09e..1b0d81d 100644
> --- a/Documentation/cpuidle/driver.txt
> +++ b/Documentation/cpuidle/driver.txt
> @@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
>  cpuidle driver initializes the cpuidle_device structure for each CPU device
>  and registers with cpuidle using cpuidle_register_device.
>  
> +If all the idle states are the same, the wrapper function cpuidle_register
> +could be used instead.
> +
>  It can also support the dynamic changes (like battery <-> AC), by using
>  cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
>  cpuidle_resume_and_unlock.
>  
>  Interfaces:
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +                            const struct cpumask *const coupled_cpus);
> +extern int cpuidle_unregister(struct cpuidle_driver *drv);
>  extern int cpuidle_register_driver(struct cpuidle_driver *drv);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0da795b..49e8d30 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -24,6 +24,7 @@
>  #include "cpuidle.h"
>  
>  DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
> +DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
>  
>  DEFINE_MUTEX(cpuidle_lock);
>  LIST_HEAD(cpuidle_detected_devices);
> @@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
>  
>  EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
>  
> +/*
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		cpuidle_unregister_device(device);
> +	}
> +
> +	cpuidle_unregister_driver(drv);
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_unregister);
> +
> +/**
> + * cpuidle_register: registers the driver and the cpu devices with the
> + * coupled_cpus passed as parameter. This function is used for all common
> + * initialization pattern there are in the arch specific drivers. The
> + * devices is globally defined in this file.
> + *
> + * @drv         : a valid pointer to a struct cpuidle_driver
> + * @coupled_cpus: a cpumask for the coupled states
> + *
> + * Returns 0 on success, < 0 otherwise
> + */
> +int cpuidle_register(struct cpuidle_driver *drv,
> +		     const struct cpumask *const coupled_cpus)
> +{
> +	int ret, cpu;
> +	struct cpuidle_device *device;
> +
> +	ret = cpuidle_register_driver(drv);
> +	if (ret) {
> +		pr_err("failed to register cpuidle driver\n");
> +		return ret;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		device->cpu = cpu;
> +
> +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> +		/*
> +		 * On multiplatform for ARM, the coupled idle states could
> +		 * enabled in the kernel even if the cpuidle driver does not
> +		 * use it. Note, coupled_cpus is a struct copy.
> +		 */
> +		if (coupled_cpus)
> +			device->coupled_cpus = *coupled_cpus;
> +#endif
> +		ret = cpuidle_register_device(device);
> +		if (!ret)
> +			continue;
> +
> +		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
> +
> +		cpuidle_unregister(drv);
> +		break;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_register);
> +
>  #ifdef CONFIG_SMP
>  
>  static void smp_callback(void *v)
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 79e3811..3c86faa 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
>  extern void cpuidle_unregister_device(struct cpuidle_device *dev);
> -
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +			    const struct cpumask *const coupled_cpus);
> +extern void cpuidle_unregister(struct cpuidle_driver *drv);
>  extern void cpuidle_pause_and_lock(void);
>  extern void cpuidle_resume_and_unlock(void);
>  extern void cpuidle_pause(void);
> @@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
>  static inline int cpuidle_register_device(struct cpuidle_device *dev)
>  {return -ENODEV; }
>  static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
> -
> +static inline int cpuidle_register(struct cpuidle_driver *drv,
> +				   const struct cpumask *const coupled_cpus)
> +{return -ENODEV; }
> +static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
>  static inline void cpuidle_pause_and_lock(void) { }
>  static inline void cpuidle_resume_and_unlock(void) { }
>  static inline void cpuidle_pause(void) { }


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-17  6:28     ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  6:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/12/2013 02:35 PM, Daniel Lezcano wrote:
> The usual scheme to initialize a cpuidle driver on a SMP is:
>
> 	cpuidle_register_driver(drv);
> 	for_each_possible_cpu(cpu) {
> 		device = &per_cpu(cpuidle_dev, cpu);
> 		cpuidle_register_device(device);
> 	}
>
> This code is duplicated in each cpuidle driver.
>
> On UP systems, it is done this way:
>
> 	cpuidle_register_driver(drv);
> 	device = &per_cpu(cpuidle_dev, cpu);
> 	cpuidle_register_device(device);
>
> On UP, the macro 'for_each_cpu' does one iteration:
>
> #define for_each_cpu(cpu, mask)                 \
>         for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
>
> Hence, the initialization loop is the same for UP than SMP.
>
> Beside, we saw different bugs / mis-initialization / return code unchecked in
> the different drivers, the code is duplicated including bugs. After fixing all
> these ones, it appears the initialization pattern is the same for everyone.
>
> Please note, some drivers are doing dev->state_count = drv->state_count. This is
> not necessary because it is done by the cpuidle_enable_device function in the
> cpuidle framework. This is true, until you have the same states for all your
> devices. Otherwise, the 'low level' API should be used instead with the specific
> initialization for the driver.
>
> Let's add a wrapper function doing this initialization with a cpumask parameter
> for the coupled idle states and use it for all the drivers.
>
> That will save a lot of LOC, consolidate the code, and the modifications in the
> future could be done in a single place. Another benefit is the consolidation of
> the cpuidle_device variable which is now in the cpuidle framework and no longer
> spread accross the different arch specific drivers.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Hi Rob, Andrew,

are you ok with this new version ?

Thanks
-- Daniel

>  Documentation/cpuidle/driver.txt |    6 ++++
>  drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
>  include/linux/cpuidle.h          |    9 +++--
>  3 files changed, 85 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
> index 7a9e09e..1b0d81d 100644
> --- a/Documentation/cpuidle/driver.txt
> +++ b/Documentation/cpuidle/driver.txt
> @@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
>  cpuidle driver initializes the cpuidle_device structure for each CPU device
>  and registers with cpuidle using cpuidle_register_device.
>  
> +If all the idle states are the same, the wrapper function cpuidle_register
> +could be used instead.
> +
>  It can also support the dynamic changes (like battery <-> AC), by using
>  cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
>  cpuidle_resume_and_unlock.
>  
>  Interfaces:
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +                            const struct cpumask *const coupled_cpus);
> +extern int cpuidle_unregister(struct cpuidle_driver *drv);
>  extern int cpuidle_register_driver(struct cpuidle_driver *drv);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0da795b..49e8d30 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -24,6 +24,7 @@
>  #include "cpuidle.h"
>  
>  DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
> +DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
>  
>  DEFINE_MUTEX(cpuidle_lock);
>  LIST_HEAD(cpuidle_detected_devices);
> @@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
>  
>  EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
>  
> +/*
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		cpuidle_unregister_device(device);
> +	}
> +
> +	cpuidle_unregister_driver(drv);
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_unregister);
> +
> +/**
> + * cpuidle_register: registers the driver and the cpu devices with the
> + * coupled_cpus passed as parameter. This function is used for all common
> + * initialization pattern there are in the arch specific drivers. The
> + * devices is globally defined in this file.
> + *
> + * @drv         : a valid pointer to a struct cpuidle_driver
> + * @coupled_cpus: a cpumask for the coupled states
> + *
> + * Returns 0 on success, < 0 otherwise
> + */
> +int cpuidle_register(struct cpuidle_driver *drv,
> +		     const struct cpumask *const coupled_cpus)
> +{
> +	int ret, cpu;
> +	struct cpuidle_device *device;
> +
> +	ret = cpuidle_register_driver(drv);
> +	if (ret) {
> +		pr_err("failed to register cpuidle driver\n");
> +		return ret;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		device->cpu = cpu;
> +
> +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> +		/*
> +		 * On multiplatform for ARM, the coupled idle states could
> +		 * enabled in the kernel even if the cpuidle driver does not
> +		 * use it. Note, coupled_cpus is a struct copy.
> +		 */
> +		if (coupled_cpus)
> +			device->coupled_cpus = *coupled_cpus;
> +#endif
> +		ret = cpuidle_register_device(device);
> +		if (!ret)
> +			continue;
> +
> +		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
> +
> +		cpuidle_unregister(drv);
> +		break;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_register);
> +
>  #ifdef CONFIG_SMP
>  
>  static void smp_callback(void *v)
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 79e3811..3c86faa 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
>  extern void cpuidle_unregister_device(struct cpuidle_device *dev);
> -
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +			    const struct cpumask *const coupled_cpus);
> +extern void cpuidle_unregister(struct cpuidle_driver *drv);
>  extern void cpuidle_pause_and_lock(void);
>  extern void cpuidle_resume_and_unlock(void);
>  extern void cpuidle_pause(void);
> @@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
>  static inline int cpuidle_register_device(struct cpuidle_device *dev)
>  {return -ENODEV; }
>  static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
> -
> +static inline int cpuidle_register(struct cpuidle_driver *drv,
> +				   const struct cpumask *const coupled_cpus)
> +{return -ENODEV; }
> +static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
>  static inline void cpuidle_pause_and_lock(void) { }
>  static inline void cpuidle_resume_and_unlock(void) { }
>  static inline void cpuidle_pause(void) { }


-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
  2013-04-12 12:36   ` Daniel Lezcano
@ 2013-04-17  7:15     ` Shawn Guo
  -1 siblings, 0 replies; 114+ messages in thread
From: Shawn Guo @ 2013-04-17  7:15 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

Thanks for working on this, Daniel.

The imx6q change looks good to me.  But I have a comment on imx5 changes
below.

On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> new file mode 100644
> index 0000000..ba4565f
> --- /dev/null
> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/cpuidle.h>
> +#include <linux/module.h>
> +#include <asm/system_misc.h>
> +#include <asm/proc-fns.h>
> +
> +#include "hardware.h"
> +
> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> +			      struct cpuidle_driver *drv, int index)
> +{
> +	arm_pm_idle();

The existing imx5 cpuidle code has an tzic_enable_wake() call before
going to idle.  I think it's there for some reason.

Shawn

> +	return index;
> +}
> +
> +static struct cpuidle_driver imx5_cpuidle_driver = {
> +	.name             = "imx5_cpuidle",
> +	.owner            = THIS_MODULE,
> +	.states[0] = {
> +		.enter            = imx5_cpuidle_enter,
> +		.exit_latency     = 2,
> +		.target_residency = 1,
> +		.flags            = CPUIDLE_FLAG_TIME_VALID,
> +		.name             = "IMX5 SRPG",
> +		.desc             = "CPU state retained,powered off",
> +	},
> +	.state_count = 1,
> +};
> +
> +int __init imx5_cpuidle_init(void)
> +{
> +	return cpuidle_register(&imx5_cpuidle_driver, NULL);
> +}
> diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
> index e2739ad..23ddfb6 100644
> --- a/arch/arm/mach-imx/cpuidle-imx6q.c
> +++ b/arch/arm/mach-imx/cpuidle-imx6q.c
> @@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
>  	/* Set chicken bit to get a reliable WAIT mode support */
>  	imx6q_set_chicken_bit();
>  
> -	return imx_cpuidle_init(&imx6q_cpuidle_driver);
> +	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
>  }
> diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
> deleted file mode 100644
> index d4cb511..0000000
> --- a/arch/arm/mach-imx/cpuidle.c
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -/*
> - * Copyright 2012 Freescale Semiconductor, Inc.
> - * Copyright 2012 Linaro Ltd.
> - *
> - * The code contained herein is licensed under the GNU General Public
> - * License. You may obtain a copy of the GNU General Public License
> - * Version 2 or later at the following locations:
> - *
> - * http://www.opensource.org/licenses/gpl-license.html
> - * http://www.gnu.org/copyleft/gpl.html
> - */
> -
> -#include <linux/cpuidle.h>
> -#include <linux/err.h>
> -#include <linux/hrtimer.h>
> -#include <linux/io.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -
> -static struct cpuidle_device __percpu * imx_cpuidle_devices;
> -
> -static void __init imx_cpuidle_devices_uninit(void)
> -{
> -	int cpu_id;
> -	struct cpuidle_device *dev;
> -
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		cpuidle_unregister_device(dev);
> -	}
> -
> -	free_percpu(imx_cpuidle_devices);
> -}
> -
> -int __init imx_cpuidle_init(struct cpuidle_driver *drv)
> -{
> -	struct cpuidle_device *dev;
> -	int cpu_id, ret;
> -
> -	if (drv->state_count > CPUIDLE_STATE_MAX) {
> -		pr_err("%s: state_count exceeds maximum\n", __func__);
> -		return -EINVAL;
> -	}
> -
> -	ret = cpuidle_register_driver(drv);
> -	if (ret) {
> -		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
> -			 __func__, ret);
> -		return ret;
> -	}
> -
> -	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
> -	if (imx_cpuidle_devices == NULL) {
> -		ret = -ENOMEM;
> -		goto unregister_drv;
> -	}
> -
> -	/* initialize state data for each cpuidle_device */
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		dev->cpu = cpu_id;
> -		dev->state_count = drv->state_count;
> -
> -		ret = cpuidle_register_device(dev);
> -		if (ret) {
> -			pr_err("%s: Failed to register cpu %u, error: %d\n",
> -				__func__, cpu_id, ret);
> -			goto uninit;
> -		}
> -	}
> -
> -	return 0;
> -
> -uninit:
> -	imx_cpuidle_devices_uninit();
> -
> -unregister_drv:
> -	cpuidle_unregister_driver(drv);
> -	return ret;
> -}
> diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
> index e092d13..786f98e 100644
> --- a/arch/arm/mach-imx/cpuidle.h
> +++ b/arch/arm/mach-imx/cpuidle.h
> @@ -10,18 +10,16 @@
>   * http://www.gnu.org/copyleft/gpl.html
>   */
>  
> -#include <linux/cpuidle.h>
> -
>  #ifdef CONFIG_CPU_IDLE
> -extern int imx_cpuidle_init(struct cpuidle_driver *drv);
> +extern int imx5_cpuidle_init(void);
>  extern int imx6q_cpuidle_init(void);
>  #else
> -static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
> +static inline int imx5_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  static inline int imx6q_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  #endif
> diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
> index 4b52b3e..82e79c6 100644
> --- a/arch/arm/mach-imx/pm-imx5.c
> +++ b/arch/arm/mach-imx/pm-imx5.c
> @@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
>  	imx5_cpu_do_idle();
>  }
>  
> -static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv, int idx)
> -{
> -	int ret;
> -
> -	ret = imx5_cpu_do_idle();
> -	if (ret < 0)
> -		return ret;
> -
> -	return idx;
> -}
> -
> -static struct cpuidle_driver imx5_cpuidle_driver = {
> -	.name			= "imx5_cpuidle",
> -	.owner			= THIS_MODULE,
> -	.states[0]	= {
> -		.enter			= imx5_cpuidle_enter,
> -		.exit_latency		= 2,
> -		.target_residency	= 1,
> -		.flags			= CPUIDLE_FLAG_TIME_VALID,
> -		.name			= "IMX5 SRPG",
> -		.desc			= "CPU state retained,powered off",
> -	},
> -	.state_count		= 1,
> -};
> -
>  static int __init imx5_pm_common_init(void)
>  {
>  	int ret;
> @@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
>  	/* Set the registers to the default cpu idle state. */
>  	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
>  
> -	imx_cpuidle_init(&imx5_cpuidle_driver);
> -	return 0;
> +	return imx5_cpuidle_init();
>  }
>  
>  void __init imx51_pm_init(void)
> -- 
> 1.7.9.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
@ 2013-04-17  7:15     ` Shawn Guo
  0 siblings, 0 replies; 114+ messages in thread
From: Shawn Guo @ 2013-04-17  7:15 UTC (permalink / raw)
  To: linux-arm-kernel

Thanks for working on this, Daniel.

The imx6q change looks good to me.  But I have a comment on imx5 changes
below.

On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> new file mode 100644
> index 0000000..ba4565f
> --- /dev/null
> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/cpuidle.h>
> +#include <linux/module.h>
> +#include <asm/system_misc.h>
> +#include <asm/proc-fns.h>
> +
> +#include "hardware.h"
> +
> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> +			      struct cpuidle_driver *drv, int index)
> +{
> +	arm_pm_idle();

The existing imx5 cpuidle code has an tzic_enable_wake() call before
going to idle.  I think it's there for some reason.

Shawn

> +	return index;
> +}
> +
> +static struct cpuidle_driver imx5_cpuidle_driver = {
> +	.name             = "imx5_cpuidle",
> +	.owner            = THIS_MODULE,
> +	.states[0] = {
> +		.enter            = imx5_cpuidle_enter,
> +		.exit_latency     = 2,
> +		.target_residency = 1,
> +		.flags            = CPUIDLE_FLAG_TIME_VALID,
> +		.name             = "IMX5 SRPG",
> +		.desc             = "CPU state retained,powered off",
> +	},
> +	.state_count = 1,
> +};
> +
> +int __init imx5_cpuidle_init(void)
> +{
> +	return cpuidle_register(&imx5_cpuidle_driver, NULL);
> +}
> diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
> index e2739ad..23ddfb6 100644
> --- a/arch/arm/mach-imx/cpuidle-imx6q.c
> +++ b/arch/arm/mach-imx/cpuidle-imx6q.c
> @@ -71,5 +71,5 @@ int __init imx6q_cpuidle_init(void)
>  	/* Set chicken bit to get a reliable WAIT mode support */
>  	imx6q_set_chicken_bit();
>  
> -	return imx_cpuidle_init(&imx6q_cpuidle_driver);
> +	return cpuidle_register(&imx6q_cpuidle_driver, NULL);
>  }
> diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c
> deleted file mode 100644
> index d4cb511..0000000
> --- a/arch/arm/mach-imx/cpuidle.c
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -/*
> - * Copyright 2012 Freescale Semiconductor, Inc.
> - * Copyright 2012 Linaro Ltd.
> - *
> - * The code contained herein is licensed under the GNU General Public
> - * License. You may obtain a copy of the GNU General Public License
> - * Version 2 or later at the following locations:
> - *
> - * http://www.opensource.org/licenses/gpl-license.html
> - * http://www.gnu.org/copyleft/gpl.html
> - */
> -
> -#include <linux/cpuidle.h>
> -#include <linux/err.h>
> -#include <linux/hrtimer.h>
> -#include <linux/io.h>
> -#include <linux/kernel.h>
> -#include <linux/slab.h>
> -
> -static struct cpuidle_device __percpu * imx_cpuidle_devices;
> -
> -static void __init imx_cpuidle_devices_uninit(void)
> -{
> -	int cpu_id;
> -	struct cpuidle_device *dev;
> -
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		cpuidle_unregister_device(dev);
> -	}
> -
> -	free_percpu(imx_cpuidle_devices);
> -}
> -
> -int __init imx_cpuidle_init(struct cpuidle_driver *drv)
> -{
> -	struct cpuidle_device *dev;
> -	int cpu_id, ret;
> -
> -	if (drv->state_count > CPUIDLE_STATE_MAX) {
> -		pr_err("%s: state_count exceeds maximum\n", __func__);
> -		return -EINVAL;
> -	}
> -
> -	ret = cpuidle_register_driver(drv);
> -	if (ret) {
> -		pr_err("%s: Failed to register cpuidle driver with error: %d\n",
> -			 __func__, ret);
> -		return ret;
> -	}
> -
> -	imx_cpuidle_devices = alloc_percpu(struct cpuidle_device);
> -	if (imx_cpuidle_devices == NULL) {
> -		ret = -ENOMEM;
> -		goto unregister_drv;
> -	}
> -
> -	/* initialize state data for each cpuidle_device */
> -	for_each_possible_cpu(cpu_id) {
> -		dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
> -		dev->cpu = cpu_id;
> -		dev->state_count = drv->state_count;
> -
> -		ret = cpuidle_register_device(dev);
> -		if (ret) {
> -			pr_err("%s: Failed to register cpu %u, error: %d\n",
> -				__func__, cpu_id, ret);
> -			goto uninit;
> -		}
> -	}
> -
> -	return 0;
> -
> -uninit:
> -	imx_cpuidle_devices_uninit();
> -
> -unregister_drv:
> -	cpuidle_unregister_driver(drv);
> -	return ret;
> -}
> diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
> index e092d13..786f98e 100644
> --- a/arch/arm/mach-imx/cpuidle.h
> +++ b/arch/arm/mach-imx/cpuidle.h
> @@ -10,18 +10,16 @@
>   * http://www.gnu.org/copyleft/gpl.html
>   */
>  
> -#include <linux/cpuidle.h>
> -
>  #ifdef CONFIG_CPU_IDLE
> -extern int imx_cpuidle_init(struct cpuidle_driver *drv);
> +extern int imx5_cpuidle_init(void);
>  extern int imx6q_cpuidle_init(void);
>  #else
> -static inline int imx_cpuidle_init(struct cpuidle_driver *drv)
> +static inline int imx5_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  static inline int imx6q_cpuidle_init(void)
>  {
> -	return -ENODEV;
> +	return 0;
>  }
>  #endif
> diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
> index 4b52b3e..82e79c6 100644
> --- a/arch/arm/mach-imx/pm-imx5.c
> +++ b/arch/arm/mach-imx/pm-imx5.c
> @@ -149,32 +149,6 @@ static void imx5_pm_idle(void)
>  	imx5_cpu_do_idle();
>  }
>  
> -static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv, int idx)
> -{
> -	int ret;
> -
> -	ret = imx5_cpu_do_idle();
> -	if (ret < 0)
> -		return ret;
> -
> -	return idx;
> -}
> -
> -static struct cpuidle_driver imx5_cpuidle_driver = {
> -	.name			= "imx5_cpuidle",
> -	.owner			= THIS_MODULE,
> -	.states[0]	= {
> -		.enter			= imx5_cpuidle_enter,
> -		.exit_latency		= 2,
> -		.target_residency	= 1,
> -		.flags			= CPUIDLE_FLAG_TIME_VALID,
> -		.name			= "IMX5 SRPG",
> -		.desc			= "CPU state retained,powered off",
> -	},
> -	.state_count		= 1,
> -};
> -
>  static int __init imx5_pm_common_init(void)
>  {
>  	int ret;
> @@ -192,8 +166,7 @@ static int __init imx5_pm_common_init(void)
>  	/* Set the registers to the default cpu idle state. */
>  	mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE);
>  
> -	imx_cpuidle_init(&imx5_cpuidle_driver);
> -	return 0;
> +	return imx5_cpuidle_init();
>  }
>  
>  void __init imx51_pm_init(void)
> -- 
> 1.7.9.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
  2013-04-17  7:15     ` Shawn Guo
@ 2013-04-17  7:23       ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  7:23 UTC (permalink / raw)
  To: Shawn Guo
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On 04/17/2013 09:15 AM, Shawn Guo wrote:
> Thanks for working on this, Daniel.
> 
> The imx6q change looks good to me.  But I have a comment on imx5 changes
> below.
> 
> On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
>> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
>> new file mode 100644
>> index 0000000..ba4565f
>> --- /dev/null
>> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/cpuidle.h>
>> +#include <linux/module.h>
>> +#include <asm/system_misc.h>
>> +#include <asm/proc-fns.h>
>> +
>> +#include "hardware.h"
>> +
>> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
>> +			      struct cpuidle_driver *drv, int index)
>> +{
>> +	arm_pm_idle();
> 
> The existing imx5 cpuidle code has an tzic_enable_wake() call before
> going to idle.  I think it's there for some reason.

The idle function for imx5 is untouched, it is called through
arm_pm_idle instead.

The arm_pm_idle is initialized in imx5_pm_common_init:

arm_pm_idle = imx5_pm_idle;

The imx5_pm_idle function calls imx5_do_pm_idle which in turns calls
tzic_enable_wake and cpu_do_idle.



[ ... ]

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
@ 2013-04-17  7:23       ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-17  7:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/17/2013 09:15 AM, Shawn Guo wrote:
> Thanks for working on this, Daniel.
> 
> The imx6q change looks good to me.  But I have a comment on imx5 changes
> below.
> 
> On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
>> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
>> new file mode 100644
>> index 0000000..ba4565f
>> --- /dev/null
>> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/cpuidle.h>
>> +#include <linux/module.h>
>> +#include <asm/system_misc.h>
>> +#include <asm/proc-fns.h>
>> +
>> +#include "hardware.h"
>> +
>> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
>> +			      struct cpuidle_driver *drv, int index)
>> +{
>> +	arm_pm_idle();
> 
> The existing imx5 cpuidle code has an tzic_enable_wake() call before
> going to idle.  I think it's there for some reason.

The idle function for imx5 is untouched, it is called through
arm_pm_idle instead.

The arm_pm_idle is initialized in imx5_pm_common_init:

arm_pm_idle = imx5_pm_idle;

The imx5_pm_idle function calls imx5_do_pm_idle which in turns calls
tzic_enable_wake and cpu_do_idle.



[ ... ]

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
  2013-04-17  7:23       ` Daniel Lezcano
@ 2013-04-17  7:39         ` Shawn Guo
  -1 siblings, 0 replies; 114+ messages in thread
From: Shawn Guo @ 2013-04-17  7:39 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	khilman, tony, linux-pm, patches, linux-arm-kernel,
	linaro-kernel, josephl

On Wed, Apr 17, 2013 at 09:23:02AM +0200, Daniel Lezcano wrote:
> On 04/17/2013 09:15 AM, Shawn Guo wrote:
> > Thanks for working on this, Daniel.
> > 
> > The imx6q change looks good to me.  But I have a comment on imx5 changes
> > below.
> > 
> > On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
> >> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> >> new file mode 100644
> >> index 0000000..ba4565f
> >> --- /dev/null
> >> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> >> @@ -0,0 +1,40 @@
> >> +/*
> >> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/cpuidle.h>
> >> +#include <linux/module.h>
> >> +#include <asm/system_misc.h>
> >> +#include <asm/proc-fns.h>
> >> +
> >> +#include "hardware.h"

This seems not needed.

> >> +
> >> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> >> +			      struct cpuidle_driver *drv, int index)
> >> +{
> >> +	arm_pm_idle();
> > 
> > The existing imx5 cpuidle code has an tzic_enable_wake() call before
> > going to idle.  I think it's there for some reason.
> 
> The idle function for imx5 is untouched, it is called through
> arm_pm_idle instead.
> 
> The arm_pm_idle is initialized in imx5_pm_common_init:
> 
> arm_pm_idle = imx5_pm_idle;
> 
Ah, yes.  I missed that, sorry.

Acked-by: Shawn Guo <shawn.guo@linaro.org>

> The imx5_pm_idle function calls imx5_do_pm_idle which in turns calls
> tzic_enable_wake and cpu_do_idle.


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 19/19] ARM: imx: cpuidle: use init/exit common routine
@ 2013-04-17  7:39         ` Shawn Guo
  0 siblings, 0 replies; 114+ messages in thread
From: Shawn Guo @ 2013-04-17  7:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 17, 2013 at 09:23:02AM +0200, Daniel Lezcano wrote:
> On 04/17/2013 09:15 AM, Shawn Guo wrote:
> > Thanks for working on this, Daniel.
> > 
> > The imx6q change looks good to me.  But I have a comment on imx5 changes
> > below.
> > 
> > On Fri, Apr 12, 2013 at 02:36:05PM +0200, Daniel Lezcano wrote:
> >> diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c
> >> new file mode 100644
> >> index 0000000..ba4565f
> >> --- /dev/null
> >> +++ b/arch/arm/mach-imx/cpuidle-imx5.c
> >> @@ -0,0 +1,40 @@
> >> +/*
> >> + * Copyright (C) 2012 Freescale Semiconductor, Inc.
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include <linux/cpuidle.h>
> >> +#include <linux/module.h>
> >> +#include <asm/system_misc.h>
> >> +#include <asm/proc-fns.h>
> >> +
> >> +#include "hardware.h"

This seems not needed.

> >> +
> >> +static int imx5_cpuidle_enter(struct cpuidle_device *dev,
> >> +			      struct cpuidle_driver *drv, int index)
> >> +{
> >> +	arm_pm_idle();
> > 
> > The existing imx5 cpuidle code has an tzic_enable_wake() call before
> > going to idle.  I think it's there for some reason.
> 
> The idle function for imx5 is untouched, it is called through
> arm_pm_idle instead.
> 
> The arm_pm_idle is initialized in imx5_pm_common_init:
> 
> arm_pm_idle = imx5_pm_idle;
> 
Ah, yes.  I missed that, sorry.

Acked-by: Shawn Guo <shawn.guo@linaro.org>

> The imx5_pm_idle function calls imx5_do_pm_idle which in turns calls
> tzic_enable_wake and cpu_do_idle.

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:27     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:27 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
> 
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
> 
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
@ 2013-04-18  8:27     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
> 
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
> 
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:28     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:28 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the shmobile_enter_wfi function which is the same as the
> common WFI enter function from the arm cpuidle driver defined
> with the ARM_CPUIDLE_WFI_STATE macro.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function
@ 2013-04-18  8:28     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the shmobile_enter_wfi function which is the same as the
> common WFI enter function from the arm cpuidle driver defined
> with the ARM_CPUIDLE_WFI_STATE macro.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:30     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:30 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
> 
> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
> function callback prototype which already exists with the default WFI state
> and the arm_simple_enter function.
> 
> Remove the function prototype.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
You can actually fold this into 1/19. No strong opinion though.

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
@ 2013-04-18  8:30     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
> 
> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
> function callback prototype which already exists with the default WFI state
> and the arm_simple_enter function.
> 
> Remove the function prototype.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
You can actually fold this into 1/19. No strong opinion though.

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:38     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:38 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> All the drivers are using, in their initialization function, the
> for_each_possible_cpu macro.
> 
> Using for_each_online_cpu means the driver must handle the initialization
> of the cpuidle device when a cpu is up which is not the case here.
> 
> Change the macro to for_each_possible_cpu as that fix the hotplug
> initialization and make the initialization routine consistent with the
> rest of the code in the different drivers.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  arch/arm/mach-ux500/cpuidle.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
> index c29c1bf..5657d4a 100644
> --- a/arch/arm/mach-ux500/cpuidle.c
> +++ b/arch/arm/mach-ux500/cpuidle.c
> @@ -125,7 +125,7 @@ int __init ux500_idle_init(void)
>  		return ret;
>  	}
>  
> -	for_each_online_cpu(cpu) {
> +	for_each_possible(cpu) {
There should no problem with online_cpu() usage
as well as long as one is not limmiting number of
boot CPUs using the max_cpus option.

But I agree making possible_cpu() would take care
of that case as well.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu
@ 2013-04-18  8:38     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> All the drivers are using, in their initialization function, the
> for_each_possible_cpu macro.
> 
> Using for_each_online_cpu means the driver must handle the initialization
> of the cpuidle device when a cpu is up which is not the case here.
> 
> Change the macro to for_each_possible_cpu as that fix the hotplug
> initialization and make the initialization routine consistent with the
> rest of the code in the different drivers.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  arch/arm/mach-ux500/cpuidle.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c
> index c29c1bf..5657d4a 100644
> --- a/arch/arm/mach-ux500/cpuidle.c
> +++ b/arch/arm/mach-ux500/cpuidle.c
> @@ -125,7 +125,7 @@ int __init ux500_idle_init(void)
>  		return ret;
>  	}
>  
> -	for_each_online_cpu(cpu) {
> +	for_each_possible(cpu) {
There should no problem with online_cpu() usage
as well as long as one is not limmiting number of
boot CPUs using the max_cpus option.

But I agree making possible_cpu() would take care
of that case as well.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:48     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:48 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> The usual scheme to initialize a cpuidle driver on a SMP is:
> 
> 	cpuidle_register_driver(drv);
> 	for_each_possible_cpu(cpu) {
> 		device = &per_cpu(cpuidle_dev, cpu);
> 		cpuidle_register_device(device);
> 	}
> 
Not exactly related to $subject patch but the driver should
be registered after all devices has been registered to avoid
devices start using the idle state data as soon as it is
registered. In multi CPU system, this race can easily happen.

Current CPUIDLE core layer is also written with the assumption
that driver will be registered first and then the devices which
is not mandatory as per typical drive/device model.

May be you can fix that part while you are creating this common
wrapper.

> This code is duplicated in each cpuidle driver.
> 
> On UP systems, it is done this way:
> 
> 	cpuidle_register_driver(drv);
> 	device = &per_cpu(cpuidle_dev, cpu);
> 	cpuidle_register_device(device);
> 
> On UP, the macro 'for_each_cpu' does one iteration:
> 
> #define for_each_cpu(cpu, mask)                 \
>         for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
> 
> Hence, the initialization loop is the same for UP than SMP.
> 
> Beside, we saw different bugs / mis-initialization / return code unchecked in
> the different drivers, the code is duplicated including bugs. After fixing all
> these ones, it appears the initialization pattern is the same for everyone.
> 
> Please note, some drivers are doing dev->state_count = drv->state_count. This is
> not necessary because it is done by the cpuidle_enable_device function in the
> cpuidle framework. This is true, until you have the same states for all your
> devices. Otherwise, the 'low level' API should be used instead with the specific
> initialization for the driver.
> 
> Let's add a wrapper function doing this initialization with a cpumask parameter
> for the coupled idle states and use it for all the drivers.
> 
> That will save a lot of LOC, consolidate the code, and the modifications in the
> future could be done in a single place. Another benefit is the consolidation of
> the cpuidle_device variable which is now in the cpuidle framework and no longer
> spread accross the different arch specific drivers.
> 
s/accross/across

> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  Documentation/cpuidle/driver.txt |    6 ++++
>  drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
>  include/linux/cpuidle.h          |    9 +++--
>  3 files changed, 85 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
> index 7a9e09e..1b0d81d 100644
> --- a/Documentation/cpuidle/driver.txt
> +++ b/Documentation/cpuidle/driver.txt
> @@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
>  cpuidle driver initializes the cpuidle_device structure for each CPU device
>  and registers with cpuidle using cpuidle_register_device.
>  
> +If all the idle states are the same, the wrapper function cpuidle_register
> +could be used instead.
> +
>  It can also support the dynamic changes (like battery <-> AC), by using
>  cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
>  cpuidle_resume_and_unlock.
>  
>  Interfaces:
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +                            const struct cpumask *const coupled_cpus);
> +extern int cpuidle_unregister(struct cpuidle_driver *drv);
>  extern int cpuidle_register_driver(struct cpuidle_driver *drv);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0da795b..49e8d30 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -24,6 +24,7 @@
>  #include "cpuidle.h"
>  
>  DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
> +DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
>  
>  DEFINE_MUTEX(cpuidle_lock);
>  LIST_HEAD(cpuidle_detected_devices);
> @@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
>  
>  EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
>  
> +/*
s/*/**
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		cpuidle_unregister_device(device);
> +	}
> +
> +	cpuidle_unregister_driver(drv);
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_unregister);
> +
> +/**
> + * cpuidle_register: registers the driver and the cpu devices with the
> + * coupled_cpus passed as parameter. This function is used for all common
> + * initialization pattern there are in the arch specific drivers. The
> + * devices is globally defined in this file.
> + *
> + * @drv         : a valid pointer to a struct cpuidle_driver
> + * @coupled_cpus: a cpumask for the coupled states
> + *
> + * Returns 0 on success, < 0 otherwise
> + */
> +int cpuidle_register(struct cpuidle_driver *drv,
> +		     const struct cpumask *const coupled_cpus)
> +{
> +	int ret, cpu;
> +	struct cpuidle_device *device;
> +
> +	ret = cpuidle_register_driver(drv);
> +	if (ret) {
> +		pr_err("failed to register cpuidle driver\n");
> +		return ret;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		device->cpu = cpu;
> +
> +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> +		/*
> +		 * On multiplatform for ARM, the coupled idle states could
> +		 * enabled in the kernel even if the cpuidle driver does not
> +		 * use it. Note, coupled_cpus is a struct copy.
> +		 */
> +		if (coupled_cpus)
> +			device->coupled_cpus = *coupled_cpus;
> +#endif
Can we get rid off the need of wrapping the code under CONFIG
marco in middle of function ?

> +		ret = cpuidle_register_device(device);
> +		if (!ret)
> +			continue;
> +
> +		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
> +
> +		cpuidle_unregister(drv);
> +		break;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_register);
> +
>  #ifdef CONFIG_SMP
>  
>  static void smp_callback(void *v)
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 79e3811..3c86faa 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
>  extern void cpuidle_unregister_device(struct cpuidle_device *dev);
> -
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +			    const struct cpumask *const coupled_cpus);
> +extern void cpuidle_unregister(struct cpuidle_driver *drv);
>  extern void cpuidle_pause_and_lock(void);
>  extern void cpuidle_resume_and_unlock(void);
>  extern void cpuidle_pause(void);
> @@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
>  static inline int cpuidle_register_device(struct cpuidle_device *dev)
>  {return -ENODEV; }
>  static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
> -
> +static inline int cpuidle_register(struct cpuidle_driver *drv,
> +				   const struct cpumask *const coupled_cpus)
> +{return -ENODEV; }
> +static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
>  static inline void cpuidle_pause_and_lock(void) { }
>  static inline void cpuidle_resume_and_unlock(void) { }
>  static inline void cpuidle_pause(void) { }
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-18  8:48     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> The usual scheme to initialize a cpuidle driver on a SMP is:
> 
> 	cpuidle_register_driver(drv);
> 	for_each_possible_cpu(cpu) {
> 		device = &per_cpu(cpuidle_dev, cpu);
> 		cpuidle_register_device(device);
> 	}
> 
Not exactly related to $subject patch but the driver should
be registered after all devices has been registered to avoid
devices start using the idle state data as soon as it is
registered. In multi CPU system, this race can easily happen.

Current CPUIDLE core layer is also written with the assumption
that driver will be registered first and then the devices which
is not mandatory as per typical drive/device model.

May be you can fix that part while you are creating this common
wrapper.

> This code is duplicated in each cpuidle driver.
> 
> On UP systems, it is done this way:
> 
> 	cpuidle_register_driver(drv);
> 	device = &per_cpu(cpuidle_dev, cpu);
> 	cpuidle_register_device(device);
> 
> On UP, the macro 'for_each_cpu' does one iteration:
> 
> #define for_each_cpu(cpu, mask)                 \
>         for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
> 
> Hence, the initialization loop is the same for UP than SMP.
> 
> Beside, we saw different bugs / mis-initialization / return code unchecked in
> the different drivers, the code is duplicated including bugs. After fixing all
> these ones, it appears the initialization pattern is the same for everyone.
> 
> Please note, some drivers are doing dev->state_count = drv->state_count. This is
> not necessary because it is done by the cpuidle_enable_device function in the
> cpuidle framework. This is true, until you have the same states for all your
> devices. Otherwise, the 'low level' API should be used instead with the specific
> initialization for the driver.
> 
> Let's add a wrapper function doing this initialization with a cpumask parameter
> for the coupled idle states and use it for all the drivers.
> 
> That will save a lot of LOC, consolidate the code, and the modifications in the
> future could be done in a single place. Another benefit is the consolidation of
> the cpuidle_device variable which is now in the cpuidle framework and no longer
> spread accross the different arch specific drivers.
> 
s/accross/across

> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  Documentation/cpuidle/driver.txt |    6 ++++
>  drivers/cpuidle/cpuidle.c        |   72 ++++++++++++++++++++++++++++++++++++++
>  include/linux/cpuidle.h          |    9 +++--
>  3 files changed, 85 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
> index 7a9e09e..1b0d81d 100644
> --- a/Documentation/cpuidle/driver.txt
> +++ b/Documentation/cpuidle/driver.txt
> @@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states.
>  cpuidle driver initializes the cpuidle_device structure for each CPU device
>  and registers with cpuidle using cpuidle_register_device.
>  
> +If all the idle states are the same, the wrapper function cpuidle_register
> +could be used instead.
> +
>  It can also support the dynamic changes (like battery <-> AC), by using
>  cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
>  cpuidle_resume_and_unlock.
>  
>  Interfaces:
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +                            const struct cpumask *const coupled_cpus);
> +extern int cpuidle_unregister(struct cpuidle_driver *drv);
>  extern int cpuidle_register_driver(struct cpuidle_driver *drv);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0da795b..49e8d30 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -24,6 +24,7 @@
>  #include "cpuidle.h"
>  
>  DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
> +DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev);
>  
>  DEFINE_MUTEX(cpuidle_lock);
>  LIST_HEAD(cpuidle_detected_devices);
> @@ -453,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
>  
>  EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
>  
> +/*
s/*/**
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		cpuidle_unregister_device(device);
> +	}
> +
> +	cpuidle_unregister_driver(drv);
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_unregister);
> +
> +/**
> + * cpuidle_register: registers the driver and the cpu devices with the
> + * coupled_cpus passed as parameter. This function is used for all common
> + * initialization pattern there are in the arch specific drivers. The
> + * devices is globally defined in this file.
> + *
> + * @drv         : a valid pointer to a struct cpuidle_driver
> + * @coupled_cpus: a cpumask for the coupled states
> + *
> + * Returns 0 on success, < 0 otherwise
> + */
> +int cpuidle_register(struct cpuidle_driver *drv,
> +		     const struct cpumask *const coupled_cpus)
> +{
> +	int ret, cpu;
> +	struct cpuidle_device *device;
> +
> +	ret = cpuidle_register_driver(drv);
> +	if (ret) {
> +		pr_err("failed to register cpuidle driver\n");
> +		return ret;
> +	}
> +
> +	for_each_possible_cpu(cpu) {
> +		device = &per_cpu(cpuidle_dev, cpu);
> +		device->cpu = cpu;
> +
> +#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> +		/*
> +		 * On multiplatform for ARM, the coupled idle states could
> +		 * enabled in the kernel even if the cpuidle driver does not
> +		 * use it. Note, coupled_cpus is a struct copy.
> +		 */
> +		if (coupled_cpus)
> +			device->coupled_cpus = *coupled_cpus;
> +#endif
Can we get rid off the need of wrapping the code under CONFIG
marco in middle of function ?

> +		ret = cpuidle_register_device(device);
> +		if (!ret)
> +			continue;
> +
> +		pr_err("Failed to register cpuidle device for cpu%d\n", cpu);
> +
> +		cpuidle_unregister(drv);
> +		break;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_register);
> +
>  #ifdef CONFIG_SMP
>  
>  static void smp_callback(void *v)
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 79e3811..3c86faa 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -123,7 +123,9 @@ extern void cpuidle_driver_unref(void);
>  extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
>  extern int cpuidle_register_device(struct cpuidle_device *dev);
>  extern void cpuidle_unregister_device(struct cpuidle_device *dev);
> -
> +extern int cpuidle_register(struct cpuidle_driver *drv,
> +			    const struct cpumask *const coupled_cpus);
> +extern void cpuidle_unregister(struct cpuidle_driver *drv);
>  extern void cpuidle_pause_and_lock(void);
>  extern void cpuidle_resume_and_unlock(void);
>  extern void cpuidle_pause(void);
> @@ -148,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
>  static inline int cpuidle_register_device(struct cpuidle_device *dev)
>  {return -ENODEV; }
>  static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
> -
> +static inline int cpuidle_register(struct cpuidle_driver *drv,
> +				   const struct cpumask *const coupled_cpus)
> +{return -ENODEV; }
> +static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
>  static inline void cpuidle_pause_and_lock(void) { }
>  static inline void cpuidle_resume_and_unlock(void) { }
>  static inline void cpuidle_pause(void) { }
> 

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:49     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:49 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
@ 2013-04-18  8:49     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-18  8:50     ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:50 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
@ 2013-04-18  8:50     ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-18  8:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
  2013-04-18  8:30     ` Santosh Shilimkar
@ 2013-04-18  8:56       ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-18  8:56 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On 04/18/2013 10:30 AM, Santosh Shilimkar wrote:
> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
>> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
>>
>> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
>> function callback prototype which already exists with the default WFI state
>> and the arm_simple_enter function.
>>
>> Remove the function prototype.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
> You can actually fold this into 1/19. No strong opinion though.

Initially it was folded but Simon wanted to split it in two, thus 1/19
and 2/19.


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype
@ 2013-04-18  8:56       ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-18  8:56 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/18/2013 10:30 AM, Santosh Shilimkar wrote:
> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>> Commit 688036b538974de32ce55be8b0e013b003992abc removed the function
>> 'shmobile_enter_wfi' but we forgot to remove the definition in the header file.
>>
>> Note this function is just an alias to 'cpu_do_idle()' wrapped into a cpuidle
>> function callback prototype which already exists with the default WFI state
>> and the arm_simple_enter function.
>>
>> Remove the function prototype.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
> You can actually fold this into 1/19. No strong opinion though.

Initially it was folded but Simon wanted to split it in two, thus 1/19
and 2/19.


-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-19 22:17     ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:17 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
>
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
>
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

The patch itself is fine, but the changelog is confusing, IMO.

I think you just need to say that since the en_core_tk flag is being
used, the wrapper is duplicating the time measurement already being done
by the core, so it should be removed.

Kevin


> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
>  1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 4f67a5b..a56310a 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
>  	},
>  };
>  
> -/* Private functions */
> -
> -static int __omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> +/**
> + * omap3_enter_idle - Programs OMAP3 to enter the specified state
> + * @dev: cpuidle device
> + * @drv: cpuidle driver
> + * @index: the index of state to be entered
> + */
> +static int omap3_enter_idle(struct cpuidle_device *dev,
> +			    struct cpuidle_driver *drv,
> +			    int index)
>  {
>  	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
>  
> @@ -149,22 +153,6 @@ return_sleep_time:
>  }
>  
>  /**
> - * omap3_enter_idle - Programs OMAP3 to enter the specified state
> - * @dev: cpuidle device
> - * @drv: cpuidle driver
> - * @index: the index of state to be entered
> - *
> - * Called from the CPUidle framework to program the device to the
> - * specified target state selected by the governor.
> - */
> -static inline int omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> -{
> -	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
> -}
> -
> -/**
>   * next_valid_state - Find next valid C-state
>   * @dev: cpuidle device
>   * @drv: cpuidle driver

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter
@ 2013-04-19 22:17     ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:17 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> In a previous commit the en_core_tk_irqen flag has been added but we missed
> the cpuidle_wrap_enter which was doing the job to measure the time for the
> 'omap3_enter_idle' function.
>
> Actually, I don't see any reason to use this wrapper in the code. In the better
> case, the time computation is not correctly done because of the different
> operations done in omap3_enter_idle_bm which were not taken into account
> before the en_core_tk_irqen flag was set.
>
> As the time is reflected for the state overridden by the omap3_enter_idle_bm,
> using the wrapper is pointless now, so removing it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

The patch itself is fine, but the changelog is confusing, IMO.

I think you just need to say that since the en_core_tk flag is being
used, the wrapper is duplicating the time measurement already being done
by the core, so it should be removed.

Kevin


> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   30 +++++++++---------------------
>  1 file changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 4f67a5b..a56310a 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -99,11 +99,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
>  	},
>  };
>  
> -/* Private functions */
> -
> -static int __omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> +/**
> + * omap3_enter_idle - Programs OMAP3 to enter the specified state
> + * @dev: cpuidle device
> + * @drv: cpuidle driver
> + * @index: the index of state to be entered
> + */
> +static int omap3_enter_idle(struct cpuidle_device *dev,
> +			    struct cpuidle_driver *drv,
> +			    int index)
>  {
>  	struct omap3_idle_statedata *cx = &omap3_idle_data[index];
>  
> @@ -149,22 +153,6 @@ return_sleep_time:
>  }
>  
>  /**
> - * omap3_enter_idle - Programs OMAP3 to enter the specified state
> - * @dev: cpuidle device
> - * @drv: cpuidle driver
> - * @index: the index of state to be entered
> - *
> - * Called from the CPUidle framework to program the device to the
> - * specified target state selected by the governor.
> - */
> -static inline int omap3_enter_idle(struct cpuidle_device *dev,
> -				struct cpuidle_driver *drv,
> -				int index)
> -{
> -	return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle);
> -}
> -
> -/**
>   * next_valid_state - Find next valid C-state
>   * @dev: cpuidle device
>   * @drv: cpuidle driver

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-19 22:19     ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:19 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 027a787..cca045c 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -26,6 +26,7 @@
>  #include <linux/cpuidle.h>
>  #include <linux/export.h>
>  #include <linux/cpu_pm.h>
> +#include <asm/cpuidle.h>
>  
>  #include "powerdomain.h"
>  #include "clockdomain.h"
> @@ -259,8 +260,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
>  	return ret;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
> -
>  static struct cpuidle_driver omap3_idle_driver = {
>  	.name             = "omap3_idle",
>  	.owner            = THIS_MODULE,
> @@ -336,8 +335,6 @@ static struct cpuidle_driver omap3_idle_driver = {
>   */
>  int __init omap3_idle_init(void)
>  {
> -	struct cpuidle_device *dev;
> -
>  	mpu_pd = pwrdm_lookup("mpu_pwrdm");
>  	core_pd = pwrdm_lookup("core_pwrdm");
>  	per_pd = pwrdm_lookup("per_pwrdm");
> @@ -346,16 +343,5 @@ int __init omap3_idle_init(void)
>  	if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
>  		return -ENODEV;
>  
> -	cpuidle_register_driver(&omap3_idle_driver);
> -
> -	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
> -	dev->cpu = 0;
> -
> -	if (cpuidle_register_device(dev)) {
> -		printk(KERN_ERR "%s: CPUidle register device failed\n",
> -		       __func__);
> -		return -EIO;
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&omap3_idle_driver, NULL);
>  }

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 09/19] ARM: OMAP3: cpuidle: use init/exit common routine
@ 2013-04-19 22:19     ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:19 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> ---
>  arch/arm/mach-omap2/cpuidle34xx.c |   18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
> index 027a787..cca045c 100644
> --- a/arch/arm/mach-omap2/cpuidle34xx.c
> +++ b/arch/arm/mach-omap2/cpuidle34xx.c
> @@ -26,6 +26,7 @@
>  #include <linux/cpuidle.h>
>  #include <linux/export.h>
>  #include <linux/cpu_pm.h>
> +#include <asm/cpuidle.h>
>  
>  #include "powerdomain.h"
>  #include "clockdomain.h"
> @@ -259,8 +260,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
>  	return ret;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
> -
>  static struct cpuidle_driver omap3_idle_driver = {
>  	.name             = "omap3_idle",
>  	.owner            = THIS_MODULE,
> @@ -336,8 +335,6 @@ static struct cpuidle_driver omap3_idle_driver = {
>   */
>  int __init omap3_idle_init(void)
>  {
> -	struct cpuidle_device *dev;
> -
>  	mpu_pd = pwrdm_lookup("mpu_pwrdm");
>  	core_pd = pwrdm_lookup("core_pwrdm");
>  	per_pd = pwrdm_lookup("per_pwrdm");
> @@ -346,16 +343,5 @@ int __init omap3_idle_init(void)
>  	if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
>  		return -ENODEV;
>  
> -	cpuidle_register_driver(&omap3_idle_driver);
> -
> -	dev = &per_cpu(omap3_idle_dev, smp_processor_id());
> -	dev->cpu = 0;
> -
> -	if (cpuidle_register_device(dev)) {
> -		printk(KERN_ERR "%s: CPUidle register device failed\n",
> -		       __func__);
> -		return -EIO;
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&omap3_idle_driver, NULL);
>  }

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-19 22:19     ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:19 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> ---
>  arch/arm/mach-omap2/cpuidle44xx.c |   22 ++--------------------
>  1 file changed, 2 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
> index cd188de..861dd90 100644
> --- a/arch/arm/mach-omap2/cpuidle44xx.c
> +++ b/arch/arm/mach-omap2/cpuidle44xx.c
> @@ -15,6 +15,7 @@
>  #include <linux/cpu_pm.h>
>  #include <linux/export.h>
>  
> +#include <asm/cpuidle.h>
>  #include <asm/proc-fns.h>
>  
>  #include "common.h"
> @@ -157,8 +158,6 @@ fail:
>  	return index;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
> -
>  static struct cpuidle_driver omap4_idle_driver = {
>  	.name				= "omap4_idle",
>  	.owner				= THIS_MODULE,
> @@ -207,9 +206,6 @@ static struct cpuidle_driver omap4_idle_driver = {
>   */
>  int __init omap4_idle_init(void)
>  {
> -	struct cpuidle_device *dev;
> -	unsigned int cpu_id = 0;
> -
>  	mpu_pd = pwrdm_lookup("mpu_pwrdm");
>  	cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm");
>  	cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm");
> @@ -221,19 +217,5 @@ int __init omap4_idle_init(void)
>  	if (!cpu_clkdm[0] || !cpu_clkdm[1])
>  		return -ENODEV;
>  
> -	for_each_cpu(cpu_id, cpu_online_mask) {
> -		dev = &per_cpu(omap4_idle_dev, cpu_id);
> -		dev->cpu = cpu_id;
> -#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> -		dev->coupled_cpus = *cpu_online_mask;
> -#endif
> -		cpuidle_register_driver(&omap4_idle_driver);
> -
> -		if (cpuidle_register_device(dev)) {
> -			pr_err("%s: CPUidle register failed\n", __func__);
> -			return -EIO;
> -		}
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&omap4_idle_driver, cpu_online_mask);
>  }

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 13/19] ARM: OMAP4: cpuidle: use init/exit common routine
@ 2013-04-19 22:19     ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:19 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Kevin Hilman <khilman@linaro.org>

> ---
>  arch/arm/mach-omap2/cpuidle44xx.c |   22 ++--------------------
>  1 file changed, 2 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
> index cd188de..861dd90 100644
> --- a/arch/arm/mach-omap2/cpuidle44xx.c
> +++ b/arch/arm/mach-omap2/cpuidle44xx.c
> @@ -15,6 +15,7 @@
>  #include <linux/cpu_pm.h>
>  #include <linux/export.h>
>  
> +#include <asm/cpuidle.h>
>  #include <asm/proc-fns.h>
>  
>  #include "common.h"
> @@ -157,8 +158,6 @@ fail:
>  	return index;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
> -
>  static struct cpuidle_driver omap4_idle_driver = {
>  	.name				= "omap4_idle",
>  	.owner				= THIS_MODULE,
> @@ -207,9 +206,6 @@ static struct cpuidle_driver omap4_idle_driver = {
>   */
>  int __init omap4_idle_init(void)
>  {
> -	struct cpuidle_device *dev;
> -	unsigned int cpu_id = 0;
> -
>  	mpu_pd = pwrdm_lookup("mpu_pwrdm");
>  	cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm");
>  	cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm");
> @@ -221,19 +217,5 @@ int __init omap4_idle_init(void)
>  	if (!cpu_clkdm[0] || !cpu_clkdm[1])
>  		return -ENODEV;
>  
> -	for_each_cpu(cpu_id, cpu_online_mask) {
> -		dev = &per_cpu(omap4_idle_dev, cpu_id);
> -		dev->cpu = cpu_id;
> -#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
> -		dev->coupled_cpus = *cpu_online_mask;
> -#endif
> -		cpuidle_register_driver(&omap4_idle_driver);
> -
> -		if (cpuidle_register_device(dev)) {
> -			pr_err("%s: CPUidle register failed\n", __func__);
> -			return -EIO;
> -		}
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&omap4_idle_driver, cpu_online_mask);
>  }

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 04/19] cpuidle: remove en_core_tk_irqen flag
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-19 22:21     ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:21 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> The en_core_tk_irqen flag is set in all the cpuidle driver which
> means it is not necessary to specify this flag.
>
> Remove the flag and the code related to it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Kevin Hilman <khilman@linaro.org>  # for mach-omap2/*

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 04/19] cpuidle: remove en_core_tk_irqen flag
@ 2013-04-19 22:21     ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> The en_core_tk_irqen flag is set in all the cpuidle driver which
> means it is not necessary to specify this flag.
>
> Remove the flag and the code related to it.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Acked-by: Kevin Hilman <khilman@linaro.org>  # for mach-omap2/*

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 00/19] cpuidle: code consolidation
  2013-04-12 12:35 ` Daniel Lezcano
@ 2013-04-19 22:44   ` Kevin Hilman
  -1 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:44 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	santosh.shilimkar, nicolas.ferre, plagnioj, linux, rob.herring,
	nsekhar, horms, magnus.damm, deepthi, lethal, jkosina, kgene.kim,
	tony, linux-pm, patches, linux-arm-kernel, linaro-kernel,
	josephl

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> This patchset series provide some code consolidation across the different
> cpuidle drivers. It contains two parts, the first one is the removal of
> the time keeping flag and the second one, is a common initialization routine.

[...]

> Tested-on: u8500
> Tested-on: at91
> Tested-on: intel i5
> Tested-on: OMAP4

Tested-by: Kevin Hilman <khilman@linaro.org> # OMAP3, OMAP4

Kevin

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 00/19] cpuidle: code consolidation
@ 2013-04-19 22:44   ` Kevin Hilman
  0 siblings, 0 replies; 114+ messages in thread
From: Kevin Hilman @ 2013-04-19 22:44 UTC (permalink / raw)
  To: linux-arm-kernel

Daniel Lezcano <daniel.lezcano@linaro.org> writes:

> This patchset series provide some code consolidation across the different
> cpuidle drivers. It contains two parts, the first one is the removal of
> the time keeping flag and the second one, is a common initialization routine.

[...]

> Tested-on: u8500
> Tested-on: at91
> Tested-on: intel i5
> Tested-on: OMAP4

Tested-by: Kevin Hilman <khilman@linaro.org> # OMAP3, OMAP4

Kevin

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 10/19] ARM: s3c64xx: cpuidle: use init/exit common routine
  2013-04-12 12:35   ` Daniel Lezcano
@ 2013-04-22  6:32     ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22  6:32 UTC (permalink / raw)
  To: kgene.kim, Ben Dooks
  Cc: rjw, Andrew Lunn, khilman, nsekhar, josephl, patches,
	magnus.damm, tony, plagnioj, linaro-kernel, jason, swarren,
	rob.herring, horms, linux, linux-arm-kernel, deepthi, jkosina,
	linux-pm, lethal, kernel

On 04/12/2013 02:35 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Kim, Ben,

is it possible you ack this patch if you are ok with it ?

So it can go into the linux-pm tree before the merge windows [1]

Thanks !

-- Daniel

[1] http://www.spinics.net/lists/linux-acpi/msg43138.html

>  arch/arm/mach-s3c64xx/cpuidle.c |   14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
> index 852ff16..3c8ab07 100644
> --- a/arch/arm/mach-s3c64xx/cpuidle.c
> +++ b/arch/arm/mach-s3c64xx/cpuidle.c
> @@ -40,8 +40,6 @@ static int s3c64xx_enter_idle(struct cpuidle_device *dev,
>  	return index;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
> -
>  static struct cpuidle_driver s3c64xx_cpuidle_driver = {
>  	.name	= "s3c64xx_cpuidle",
>  	.owner  = THIS_MODULE,
> @@ -60,16 +58,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = {
>  
>  static int __init s3c64xx_init_cpuidle(void)
>  {
> -	int ret;
> -
> -	cpuidle_register_driver(&s3c64xx_cpuidle_driver);
> -
> -	ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
> -	if (ret) {
> -		pr_err("Failed to register cpuidle device: %d\n", ret);
> -		return ret;
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
>  }
>  device_initcall(s3c64xx_init_cpuidle);


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 10/19] ARM: s3c64xx: cpuidle: use init/exit common routine
@ 2013-04-22  6:32     ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22  6:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/12/2013 02:35 PM, Daniel Lezcano wrote:
> Remove the duplicated code and use the cpuidle common code for initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Kim, Ben,

is it possible you ack this patch if you are ok with it ?

So it can go into the linux-pm tree before the merge windows [1]

Thanks !

-- Daniel

[1] http://www.spinics.net/lists/linux-acpi/msg43138.html

>  arch/arm/mach-s3c64xx/cpuidle.c |   14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
> index 852ff16..3c8ab07 100644
> --- a/arch/arm/mach-s3c64xx/cpuidle.c
> +++ b/arch/arm/mach-s3c64xx/cpuidle.c
> @@ -40,8 +40,6 @@ static int s3c64xx_enter_idle(struct cpuidle_device *dev,
>  	return index;
>  }
>  
> -static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
> -
>  static struct cpuidle_driver s3c64xx_cpuidle_driver = {
>  	.name	= "s3c64xx_cpuidle",
>  	.owner  = THIS_MODULE,
> @@ -60,16 +58,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = {
>  
>  static int __init s3c64xx_init_cpuidle(void)
>  {
> -	int ret;
> -
> -	cpuidle_register_driver(&s3c64xx_cpuidle_driver);
> -
> -	ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
> -	if (ret) {
> -		pr_err("Failed to register cpuidle device: %d\n", ret);
> -		return ret;
> -	}
> -
> -	return 0;
> +	return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
>  }
>  device_initcall(s3c64xx_init_cpuidle);


-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-14 15:14     ` Andrew Lunn
@ 2013-04-22  7:01       ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22  7:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: khilman, nsekhar, josephl, kgene.kim, patches, magnus.damm, tony,
	plagnioj, linaro-kernel, jason, swarren, rob.herring, rjw, horms,
	linux, linux-arm-kernel, deepthi, jkosina, linux-pm, lethal,
	kernel

On 04/14/2013 05:14 PM, Andrew Lunn wrote:

[ ... ]
>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>  {
> -	cpuidle_unregister_device(device);
> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> -
> +	cpuidle_unregister(&kirkwood_idle_driver);
>  	return 0;
>  }
>  
> -- 
> 1.7.9.5
>
> Tested-by: Andrew Lunn <andrew@lunn.ch>

Hi Andrew,

shall I consider it as acked-by also ?

Thanks
  -- Daniel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-22  7:01       ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22  7:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/14/2013 05:14 PM, Andrew Lunn wrote:

[ ... ]
>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>  {
> -	cpuidle_unregister_device(device);
> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> -
> +	cpuidle_unregister(&kirkwood_idle_driver);
>  	return 0;
>  }
>  
> -- 
> 1.7.9.5
>
> Tested-by: Andrew Lunn <andrew@lunn.ch>

Hi Andrew,

shall I consider it as acked-by also ?

Thanks
  -- Daniel

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-22  7:01       ` Daniel Lezcano
@ 2013-04-22 16:47         ` Andrew Lunn
  -1 siblings, 0 replies; 114+ messages in thread
From: Andrew Lunn @ 2013-04-22 16:47 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Andrew Lunn, swarren, khilman, nsekhar, josephl, kgene.kim,
	linux-pm, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	patches, rob.herring, rjw, horms, linux, linux-arm-kernel,
	deepthi, jkosina, lethal, kernel

On Mon, Apr 22, 2013 at 09:01:10AM +0200, Daniel Lezcano wrote:
> On 04/14/2013 05:14 PM, Andrew Lunn wrote:
> 
> [ ... ]
> >  int kirkwood_cpuidle_remove(struct platform_device *pdev)
> >  {
> > -	cpuidle_unregister_device(device);
> > -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> > -
> > +	cpuidle_unregister(&kirkwood_idle_driver);
> >  	return 0;
> >  }
> >  
> > -- 
> > 1.7.9.5
> >
> > Tested-by: Andrew Lunn <andrew@lunn.ch>
> 
> Hi Andrew,
> 
> shall I consider it as acked-by also ?

Yes, please do.

     Andrew

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-22 16:47         ` Andrew Lunn
  0 siblings, 0 replies; 114+ messages in thread
From: Andrew Lunn @ 2013-04-22 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 22, 2013 at 09:01:10AM +0200, Daniel Lezcano wrote:
> On 04/14/2013 05:14 PM, Andrew Lunn wrote:
> 
> [ ... ]
> >  int kirkwood_cpuidle_remove(struct platform_device *pdev)
> >  {
> > -	cpuidle_unregister_device(device);
> > -	cpuidle_unregister_driver(&kirkwood_idle_driver);
> > -
> > +	cpuidle_unregister(&kirkwood_idle_driver);
> >  	return 0;
> >  }
> >  
> > -- 
> > 1.7.9.5
> >
> > Tested-by: Andrew Lunn <andrew@lunn.ch>
> 
> Hi Andrew,
> 
> shall I consider it as acked-by also ?

Yes, please do.

     Andrew

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
  2013-04-22 16:47         ` Andrew Lunn
@ 2013-04-22 16:54           ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22 16:54 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: khilman, nsekhar, josephl, kgene.kim, patches, magnus.damm, tony,
	plagnioj, linaro-kernel, jason, swarren, rob.herring, rjw, horms,
	linux, linux-arm-kernel, deepthi, jkosina, linux-pm, lethal,
	kernel

On 04/22/2013 06:47 PM, Andrew Lunn wrote:
> On Mon, Apr 22, 2013 at 09:01:10AM +0200, Daniel Lezcano wrote:
>> On 04/14/2013 05:14 PM, Andrew Lunn wrote:
>>
>> [ ... ]
>>>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>>>  {
>>> -	cpuidle_unregister_device(device);
>>> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
>>> -
>>> +	cpuidle_unregister(&kirkwood_idle_driver);
>>>  	return 0;
>>>  }
>>>  
>>> -- 
>>> 1.7.9.5
>>>
>>> Tested-by: Andrew Lunn <andrew@lunn.ch>
>>
>> Hi Andrew,
>>
>> shall I consider it as acked-by also ?
> 
> Yes, please do.

Thanks !

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 17/19] ARM: kirkwood: cpuidle: use init/exit common routine
@ 2013-04-22 16:54           ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-22 16:54 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/22/2013 06:47 PM, Andrew Lunn wrote:
> On Mon, Apr 22, 2013 at 09:01:10AM +0200, Daniel Lezcano wrote:
>> On 04/14/2013 05:14 PM, Andrew Lunn wrote:
>>
>> [ ... ]
>>>  int kirkwood_cpuidle_remove(struct platform_device *pdev)
>>>  {
>>> -	cpuidle_unregister_device(device);
>>> -	cpuidle_unregister_driver(&kirkwood_idle_driver);
>>> -
>>> +	cpuidle_unregister(&kirkwood_idle_driver);
>>>  	return 0;
>>>  }
>>>  
>>> -- 
>>> 1.7.9.5
>>>
>>> Tested-by: Andrew Lunn <andrew@lunn.ch>
>>
>> Hi Andrew,
>>
>> shall I consider it as acked-by also ?
> 
> Yes, please do.

Thanks !

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-18  8:48     ` Santosh Shilimkar
@ 2013-04-23 13:43       ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 13:43 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>
>> 	cpuidle_register_driver(drv);
>> 	for_each_possible_cpu(cpu) {
>> 		device = &per_cpu(cpuidle_dev, cpu);
>> 		cpuidle_register_device(device);
>> 	}
>>
> Not exactly related to $subject patch but the driver should
> be registered after all devices has been registered to avoid
> devices start using the idle state data as soon as it is
> registered. In multi CPU system, this race can easily happen.

Could you elaborate what problems the system will be facing if a cpu
starts using the idle state data as soon as it is registered ?

Is there a bug related to this ?

> Current CPUIDLE core layer is also written with the assumption
> that driver will be registered first and then the devices which
> is not mandatory as per typical drive/device model.

Yes, that's true. The framework assumes cpuidle_register_driver is
called before cpuidle_register_device.

> May be you can fix that part while you are creating this common
> wrapper.

Personally, as that will modify the cpuidle core layer and the changes
are not obvious (because of the design of the code) I prefer to do that
in a separate patchset if it is worth to do it - if there is a bug
related to it, then there is no discussion, we have to do it :)

[ ... ]

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-23 13:43       ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 13:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>
>> 	cpuidle_register_driver(drv);
>> 	for_each_possible_cpu(cpu) {
>> 		device = &per_cpu(cpuidle_dev, cpu);
>> 		cpuidle_register_device(device);
>> 	}
>>
> Not exactly related to $subject patch but the driver should
> be registered after all devices has been registered to avoid
> devices start using the idle state data as soon as it is
> registered. In multi CPU system, this race can easily happen.

Could you elaborate what problems the system will be facing if a cpu
starts using the idle state data as soon as it is registered ?

Is there a bug related to this ?

> Current CPUIDLE core layer is also written with the assumption
> that driver will be registered first and then the devices which
> is not mandatory as per typical drive/device model.

Yes, that's true. The framework assumes cpuidle_register_driver is
called before cpuidle_register_device.

> May be you can fix that part while you are creating this common
> wrapper.

Personally, as that will modify the cpuidle core layer and the changes
are not obvious (because of the design of the code) I prefer to do that
in a separate patchset if it is worth to do it - if there is a bug
related to it, then there is no discussion, we have to do it :)

[ ... ]

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-23 13:43       ` Daniel Lezcano
@ 2013-04-23 13:56         ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-23 13:56 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: andrew, khilman, linus.walleij, nsekhar, josephl, kgene.kim,
	patches, magnus.damm, tony, plagnioj, linaro-kernel, jason,
	swarren, nicolas.ferre, rob.herring, rjw, horms, linux,
	linux-arm-kernel, deepthi, jkosina, linux-pm, lethal, kernel

On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>
>>> 	cpuidle_register_driver(drv);
>>> 	for_each_possible_cpu(cpu) {
>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>> 		cpuidle_register_device(device);
>>> 	}
>>>
>> Not exactly related to $subject patch but the driver should
>> be registered after all devices has been registered to avoid
>> devices start using the idle state data as soon as it is
>> registered. In multi CPU system, this race can easily happen.
> 
> Could you elaborate what problems the system will be facing if a cpu
> starts using the idle state data as soon as it is registered ?
> 
> Is there a bug related to this ?
>
Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
can just lead into unknown issues if all the CPUs are not already part
registered.
 
>> Current CPUIDLE core layer is also written with the assumption
>> that driver will be registered first and then the devices which
>> is not mandatory as per typical drive/device model.
> 
> Yes, that's true. The framework assumes cpuidle_register_driver is
> called before cpuidle_register_device.
> 
>> May be you can fix that part while you are creating this common
>> wrapper.
> 
> Personally, as that will modify the cpuidle core layer and the changes
> are not obvious (because of the design of the code) I prefer to do that
> in a separate patchset if it is worth to do it - if there is a bug
> related to it, then there is no discussion, we have to do it :)
> 
Sure. It would have been nice if you would have clarified that before
posting the next version.

You still need to fix the kernel doc in your v4 though.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-23 13:56         ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-23 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>
>>> 	cpuidle_register_driver(drv);
>>> 	for_each_possible_cpu(cpu) {
>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>> 		cpuidle_register_device(device);
>>> 	}
>>>
>> Not exactly related to $subject patch but the driver should
>> be registered after all devices has been registered to avoid
>> devices start using the idle state data as soon as it is
>> registered. In multi CPU system, this race can easily happen.
> 
> Could you elaborate what problems the system will be facing if a cpu
> starts using the idle state data as soon as it is registered ?
> 
> Is there a bug related to this ?
>
Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
can just lead into unknown issues if all the CPUs are not already part
registered.
 
>> Current CPUIDLE core layer is also written with the assumption
>> that driver will be registered first and then the devices which
>> is not mandatory as per typical drive/device model.
> 
> Yes, that's true. The framework assumes cpuidle_register_driver is
> called before cpuidle_register_device.
> 
>> May be you can fix that part while you are creating this common
>> wrapper.
> 
> Personally, as that will modify the cpuidle core layer and the changes
> are not obvious (because of the design of the code) I prefer to do that
> in a separate patchset if it is worth to do it - if there is a bug
> related to it, then there is no discussion, we have to do it :)
> 
Sure. It would have been nice if you would have clarified that before
posting the next version.

You still need to fix the kernel doc in your v4 though.

Regards,
Santosh

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-23 13:56         ` Santosh Shilimkar
@ 2013-04-23 14:22           ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 14:22 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>
>>>> 	cpuidle_register_driver(drv);
>>>> 	for_each_possible_cpu(cpu) {
>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>> 		cpuidle_register_device(device);
>>>> 	}
>>>>
>>> Not exactly related to $subject patch but the driver should
>>> be registered after all devices has been registered to avoid
>>> devices start using the idle state data as soon as it is
>>> registered. In multi CPU system, this race can easily happen.
>>
>> Could you elaborate what problems the system will be facing if a cpu
>> starts using the idle state data as soon as it is registered ?
>>
>> Is there a bug related to this ?
>>
> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
> can just lead into unknown issues if all the CPUs are not already part
> registered.

Hmm, ok. I don't see a scenario, with the current code, where that could
occurs. The coupled idle state will wait for the other cpus to enter
idle before initiating a shutdown sequence and, so far, the other sync
algorithm (last man standing) are doing the same.

There are some systems with 1024 cpus, and I did not heard problems like
this.

Do you know a system where this problem occurred ? Or is it something
you suspect that can happen ?

That would be interesting to have a system where this race occurs in
order to check the modifications will solve the issue.

>>> Current CPUIDLE core layer is also written with the assumption
>>> that driver will be registered first and then the devices which
>>> is not mandatory as per typical drive/device model.
>>
>> Yes, that's true. The framework assumes cpuidle_register_driver is
>> called before cpuidle_register_device.
>>
>>> May be you can fix that part while you are creating this common
>>> wrapper.
>>
>> Personally, as that will modify the cpuidle core layer and the changes
>> are not obvious (because of the design of the code) I prefer to do that
>> in a separate patchset if it is worth to do it - if there is a bug
>> related to it, then there is no discussion, we have to do it :)
>>
> Sure. It would have been nice if you would have clarified that before
> posting the next version.
> 
> You still need to fix the kernel doc in your v4 though.

Which one ? "s/accross/across" ?

Thanks
  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-23 14:22           ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>
>>>> 	cpuidle_register_driver(drv);
>>>> 	for_each_possible_cpu(cpu) {
>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>> 		cpuidle_register_device(device);
>>>> 	}
>>>>
>>> Not exactly related to $subject patch but the driver should
>>> be registered after all devices has been registered to avoid
>>> devices start using the idle state data as soon as it is
>>> registered. In multi CPU system, this race can easily happen.
>>
>> Could you elaborate what problems the system will be facing if a cpu
>> starts using the idle state data as soon as it is registered ?
>>
>> Is there a bug related to this ?
>>
> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
> can just lead into unknown issues if all the CPUs are not already part
> registered.

Hmm, ok. I don't see a scenario, with the current code, where that could
occurs. The coupled idle state will wait for the other cpus to enter
idle before initiating a shutdown sequence and, so far, the other sync
algorithm (last man standing) are doing the same.

There are some systems with 1024 cpus, and I did not heard problems like
this.

Do you know a system where this problem occurred ? Or is it something
you suspect that can happen ?

That would be interesting to have a system where this race occurs in
order to check the modifications will solve the issue.

>>> Current CPUIDLE core layer is also written with the assumption
>>> that driver will be registered first and then the devices which
>>> is not mandatory as per typical drive/device model.
>>
>> Yes, that's true. The framework assumes cpuidle_register_driver is
>> called before cpuidle_register_device.
>>
>>> May be you can fix that part while you are creating this common
>>> wrapper.
>>
>> Personally, as that will modify the cpuidle core layer and the changes
>> are not obvious (because of the design of the code) I prefer to do that
>> in a separate patchset if it is worth to do it - if there is a bug
>> related to it, then there is no discussion, we have to do it :)
>>
> Sure. It would have been nice if you would have clarified that before
> posting the next version.
> 
> You still need to fix the kernel doc in your v4 though.

Which one ? "s/accross/across" ?

Thanks
  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-23 14:22           ` Daniel Lezcano
@ 2013-04-23 15:07             ` Santosh Shilimkar
  -1 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-23 15:07 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On Tuesday 23 April 2013 07:52 PM, Daniel Lezcano wrote:
> On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
>> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>>
>>>>> 	cpuidle_register_driver(drv);
>>>>> 	for_each_possible_cpu(cpu) {
>>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>>> 		cpuidle_register_device(device);
>>>>> 	}
>>>>>
>>>> Not exactly related to $subject patch but the driver should
>>>> be registered after all devices has been registered to avoid
>>>> devices start using the idle state data as soon as it is
>>>> registered. In multi CPU system, this race can easily happen.
>>>
>>> Could you elaborate what problems the system will be facing if a cpu
>>> starts using the idle state data as soon as it is registered ?
>>>
>>> Is there a bug related to this ?
>>>
>> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
>> can just lead into unknown issues if all the CPUs are not already part
>> registered.
> 
> Hmm, ok. I don't see a scenario, with the current code, where that could
> occurs. The coupled idle state will wait for the other cpus to enter
> idle before initiating a shutdown sequence and, so far, the other sync
> algorithm (last man standing) are doing the same.
> 
Its no just couple idle state usages. CPUs do share power domains, clock
domains, clocks etc. One CPU going ahead and tampering/progarmming
the low power states till the next one isn't registered yet
can lead to issues.

> There are some systems with 1024 cpus, and I did not heard problems like
> this.
> 
That is because todays CPUIDLe core code doesn't let that happen. Once
you fix the ordering issue, there is window where the issue could happen.

> Do you know a system where this problem occurred ? Or is it something
> you suspect that can happen ?
> 
See above. Its more prone to issues true for systems with higher
number of CPUs. Not sure if that was the reason the core code, doesn't
proceed without all the devices are registered ?

> That would be interesting to have a system where this race occurs in
> order to check the modifications will solve the issue.
> 
I haven't see the issue myself but logically it could easily happen
once the core code is fixed.

>>>> Current CPUIDLE core layer is also written with the assumption
>>>> that driver will be registered first and then the devices which
>>>> is not mandatory as per typical drive/device model.
>>>
>>> Yes, that's true. The framework assumes cpuidle_register_driver is
>>> called before cpuidle_register_device.
>>>
>>>> May be you can fix that part while you are creating this common
>>>> wrapper.
>>>
>>> Personally, as that will modify the cpuidle core layer and the changes
>>> are not obvious (because of the design of the code) I prefer to do that
>>> in a separate patchset if it is worth to do it - if there is a bug
>>> related to it, then there is no discussion, we have to do it :)
>>>
>> Sure. It would have been nice if you would have clarified that before
>> posting the next version.
>>
>> You still need to fix the kernel doc in your v4 though.
> 
> Which one ? "s/accross/across" ?
> 
s/*/** below hunk in v4

+/*
+ * cpuidle_unregister: unregister a driver and the devices. This function
+ * can be used only if the driver has been previously registered through
+ * the cpuidle_register function.
+ *
+ * @drv: a valid pointer to a struct cpuidle_driver
+ */
+void cpuidle_unregister(struct cpuidle_driver *drv)
+{
+	int cpu;
+	struct cpuidle_device *device;


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-23 15:07             ` Santosh Shilimkar
  0 siblings, 0 replies; 114+ messages in thread
From: Santosh Shilimkar @ 2013-04-23 15:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 23 April 2013 07:52 PM, Daniel Lezcano wrote:
> On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
>> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>>
>>>>> 	cpuidle_register_driver(drv);
>>>>> 	for_each_possible_cpu(cpu) {
>>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>>> 		cpuidle_register_device(device);
>>>>> 	}
>>>>>
>>>> Not exactly related to $subject patch but the driver should
>>>> be registered after all devices has been registered to avoid
>>>> devices start using the idle state data as soon as it is
>>>> registered. In multi CPU system, this race can easily happen.
>>>
>>> Could you elaborate what problems the system will be facing if a cpu
>>> starts using the idle state data as soon as it is registered ?
>>>
>>> Is there a bug related to this ?
>>>
>> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
>> can just lead into unknown issues if all the CPUs are not already part
>> registered.
> 
> Hmm, ok. I don't see a scenario, with the current code, where that could
> occurs. The coupled idle state will wait for the other cpus to enter
> idle before initiating a shutdown sequence and, so far, the other sync
> algorithm (last man standing) are doing the same.
> 
Its no just couple idle state usages. CPUs do share power domains, clock
domains, clocks etc. One CPU going ahead and tampering/progarmming
the low power states till the next one isn't registered yet
can lead to issues.

> There are some systems with 1024 cpus, and I did not heard problems like
> this.
> 
That is because todays CPUIDLe core code doesn't let that happen. Once
you fix the ordering issue, there is window where the issue could happen.

> Do you know a system where this problem occurred ? Or is it something
> you suspect that can happen ?
> 
See above. Its more prone to issues true for systems with higher
number of CPUs. Not sure if that was the reason the core code, doesn't
proceed without all the devices are registered ?

> That would be interesting to have a system where this race occurs in
> order to check the modifications will solve the issue.
> 
I haven't see the issue myself but logically it could easily happen
once the core code is fixed.

>>>> Current CPUIDLE core layer is also written with the assumption
>>>> that driver will be registered first and then the devices which
>>>> is not mandatory as per typical drive/device model.
>>>
>>> Yes, that's true. The framework assumes cpuidle_register_driver is
>>> called before cpuidle_register_device.
>>>
>>>> May be you can fix that part while you are creating this common
>>>> wrapper.
>>>
>>> Personally, as that will modify the cpuidle core layer and the changes
>>> are not obvious (because of the design of the code) I prefer to do that
>>> in a separate patchset if it is worth to do it - if there is a bug
>>> related to it, then there is no discussion, we have to do it :)
>>>
>> Sure. It would have been nice if you would have clarified that before
>> posting the next version.
>>
>> You still need to fix the kernel doc in your v4 though.
> 
> Which one ? "s/accross/across" ?
> 
s/*/** below hunk in v4

+/*
+ * cpuidle_unregister: unregister a driver and the devices. This function
+ * can be used only if the driver has been previously registered through
+ * the cpuidle_register function.
+ *
+ * @drv: a valid pointer to a struct cpuidle_driver
+ */
+void cpuidle_unregister(struct cpuidle_driver *drv)
+{
+	int cpu;
+	struct cpuidle_device *device;

^ permalink raw reply	[flat|nested] 114+ messages in thread

* Re: [V3 patch 06/19] cpuidle: make a single register function for all
  2013-04-23 15:07             ` Santosh Shilimkar
@ 2013-04-23 15:21               ` Daniel Lezcano
  -1 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 15:21 UTC (permalink / raw)
  To: Santosh Shilimkar
  Cc: rjw, linus.walleij, jason, andrew, kernel, swarren,
	nicolas.ferre, plagnioj, linux, rob.herring, nsekhar, horms,
	magnus.damm, deepthi, lethal, jkosina, kgene.kim, khilman, tony,
	linux-pm, patches, linux-arm-kernel, linaro-kernel, josephl

On 04/23/2013 05:07 PM, Santosh Shilimkar wrote:
> On Tuesday 23 April 2013 07:52 PM, Daniel Lezcano wrote:
>> On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
>>> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>>>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>>>
>>>>>> 	cpuidle_register_driver(drv);
>>>>>> 	for_each_possible_cpu(cpu) {
>>>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>>>> 		cpuidle_register_device(device);
>>>>>> 	}
>>>>>>
>>>>> Not exactly related to $subject patch but the driver should
>>>>> be registered after all devices has been registered to avoid
>>>>> devices start using the idle state data as soon as it is
>>>>> registered. In multi CPU system, this race can easily happen.
>>>>
>>>> Could you elaborate what problems the system will be facing if a cpu
>>>> starts using the idle state data as soon as it is registered ?
>>>>
>>>> Is there a bug related to this ?
>>>>
>>> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
>>> can just lead into unknown issues if all the CPUs are not already part
>>> registered.
>>
>> Hmm, ok. I don't see a scenario, with the current code, where that could
>> occurs. The coupled idle state will wait for the other cpus to enter
>> idle before initiating a shutdown sequence and, so far, the other sync
>> algorithm (last man standing) are doing the same.
>>
> Its no just couple idle state usages. CPUs do share power domains, clock
> domains, clocks etc. One CPU going ahead and tampering/progarmming
> the low power states till the next one isn't registered yet
> can lead to issues.
> 
>> There are some systems with 1024 cpus, and I did not heard problems like
>> this.
>>
> That is because todays CPUIDLe core code doesn't let that happen. Once
> you fix the ordering issue, there is window where the issue could happen.
> 
>> Do you know a system where this problem occurred ? Or is it something
>> you suspect that can happen ?
>>
> See above. Its more prone to issues true for systems with higher
> number of CPUs. Not sure if that was the reason the core code, doesn't
> proceed without all the devices are registered ?
> 
>> That would be interesting to have a system where this race occurs in
>> order to check the modifications will solve the issue.
>>
> I haven't see the issue myself but logically it could easily happen
> once the core code is fixed.
> 
>>>>> Current CPUIDLE core layer is also written with the assumption
>>>>> that driver will be registered first and then the devices which
>>>>> is not mandatory as per typical drive/device model.
>>>>
>>>> Yes, that's true. The framework assumes cpuidle_register_driver is
>>>> called before cpuidle_register_device.
>>>>
>>>>> May be you can fix that part while you are creating this common
>>>>> wrapper.
>>>>
>>>> Personally, as that will modify the cpuidle core layer and the changes
>>>> are not obvious (because of the design of the code) I prefer to do that
>>>> in a separate patchset if it is worth to do it - if there is a bug
>>>> related to it, then there is no discussion, we have to do it :)
>>>>
>>> Sure. It would have been nice if you would have clarified that before
>>> posting the next version.
>>>
>>> You still need to fix the kernel doc in your v4 though.
>>
>> Which one ? "s/accross/across" ?
>>
> s/*/** below hunk in v4
> 
> +/*
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> 

Ah, ok. I thought you were referring to something in 'Documentation'.

I will fix this nit.

Thanks !
  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 114+ messages in thread

* [V3 patch 06/19] cpuidle: make a single register function for all
@ 2013-04-23 15:21               ` Daniel Lezcano
  0 siblings, 0 replies; 114+ messages in thread
From: Daniel Lezcano @ 2013-04-23 15:21 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/23/2013 05:07 PM, Santosh Shilimkar wrote:
> On Tuesday 23 April 2013 07:52 PM, Daniel Lezcano wrote:
>> On 04/23/2013 03:56 PM, Santosh Shilimkar wrote:
>>> On Tuesday 23 April 2013 07:13 PM, Daniel Lezcano wrote:
>>>> On 04/18/2013 10:48 AM, Santosh Shilimkar wrote:
>>>>> On Friday 12 April 2013 06:05 PM, Daniel Lezcano wrote:
>>>>>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>>>>>
>>>>>> 	cpuidle_register_driver(drv);
>>>>>> 	for_each_possible_cpu(cpu) {
>>>>>> 		device = &per_cpu(cpuidle_dev, cpu);
>>>>>> 		cpuidle_register_device(device);
>>>>>> 	}
>>>>>>
>>>>> Not exactly related to $subject patch but the driver should
>>>>> be registered after all devices has been registered to avoid
>>>>> devices start using the idle state data as soon as it is
>>>>> registered. In multi CPU system, this race can easily happen.
>>>>
>>>> Could you elaborate what problems the system will be facing if a cpu
>>>> starts using the idle state data as soon as it is registered ?
>>>>
>>>> Is there a bug related to this ?
>>>>
>>> Ofcouse. In multi-CPU scenario, where CPU C-states needs co-ordination
>>> can just lead into unknown issues if all the CPUs are not already part
>>> registered.
>>
>> Hmm, ok. I don't see a scenario, with the current code, where that could
>> occurs. The coupled idle state will wait for the other cpus to enter
>> idle before initiating a shutdown sequence and, so far, the other sync
>> algorithm (last man standing) are doing the same.
>>
> Its no just couple idle state usages. CPUs do share power domains, clock
> domains, clocks etc. One CPU going ahead and tampering/progarmming
> the low power states till the next one isn't registered yet
> can lead to issues.
> 
>> There are some systems with 1024 cpus, and I did not heard problems like
>> this.
>>
> That is because todays CPUIDLe core code doesn't let that happen. Once
> you fix the ordering issue, there is window where the issue could happen.
> 
>> Do you know a system where this problem occurred ? Or is it something
>> you suspect that can happen ?
>>
> See above. Its more prone to issues true for systems with higher
> number of CPUs. Not sure if that was the reason the core code, doesn't
> proceed without all the devices are registered ?
> 
>> That would be interesting to have a system where this race occurs in
>> order to check the modifications will solve the issue.
>>
> I haven't see the issue myself but logically it could easily happen
> once the core code is fixed.
> 
>>>>> Current CPUIDLE core layer is also written with the assumption
>>>>> that driver will be registered first and then the devices which
>>>>> is not mandatory as per typical drive/device model.
>>>>
>>>> Yes, that's true. The framework assumes cpuidle_register_driver is
>>>> called before cpuidle_register_device.
>>>>
>>>>> May be you can fix that part while you are creating this common
>>>>> wrapper.
>>>>
>>>> Personally, as that will modify the cpuidle core layer and the changes
>>>> are not obvious (because of the design of the code) I prefer to do that
>>>> in a separate patchset if it is worth to do it - if there is a bug
>>>> related to it, then there is no discussion, we have to do it :)
>>>>
>>> Sure. It would have been nice if you would have clarified that before
>>> posting the next version.
>>>
>>> You still need to fix the kernel doc in your v4 though.
>>
>> Which one ? "s/accross/across" ?
>>
> s/*/** below hunk in v4
> 
> +/*
> + * cpuidle_unregister: unregister a driver and the devices. This function
> + * can be used only if the driver has been previously registered through
> + * the cpuidle_register function.
> + *
> + * @drv: a valid pointer to a struct cpuidle_driver
> + */
> +void cpuidle_unregister(struct cpuidle_driver *drv)
> +{
> +	int cpu;
> +	struct cpuidle_device *device;
> 

Ah, ok. I thought you were referring to something in 'Documentation'.

I will fix this nit.

Thanks !
  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 114+ messages in thread

end of thread, other threads:[~2013-04-23 15:21 UTC | newest]

Thread overview: 114+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 12:35 [V3 patch 00/19] cpuidle: code consolidation Daniel Lezcano
2013-04-12 12:35 ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 01/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi function Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-15  3:56   ` Simon Horman
2013-04-15  3:56     ` Simon Horman
2013-04-18  8:28   ` Santosh Shilimkar
2013-04-18  8:28     ` Santosh Shilimkar
2013-04-12 12:35 ` [V3 patch 02/19] ARM: shmobile: cpuidle: remove shmobile_enter_wfi prototype Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-15  3:56   ` Simon Horman
2013-04-15  3:56     ` Simon Horman
2013-04-18  8:30   ` Santosh Shilimkar
2013-04-18  8:30     ` Santosh Shilimkar
2013-04-18  8:56     ` Daniel Lezcano
2013-04-18  8:56       ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 03/19] ARM: OMAP3: remove cpuidle_wrap_enter Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-15 22:55   ` Kevin Hilman
2013-04-15 22:55     ` Kevin Hilman
2013-04-18  8:27   ` Santosh Shilimkar
2013-04-18  8:27     ` Santosh Shilimkar
2013-04-19 22:17   ` Kevin Hilman
2013-04-19 22:17     ` Kevin Hilman
2013-04-12 12:35 ` [V3 patch 04/19] cpuidle: remove en_core_tk_irqen flag Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-19 22:21   ` Kevin Hilman
2013-04-19 22:21     ` Kevin Hilman
2013-04-12 12:35 ` [V3 patch 05/19] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-16 12:34   ` Linus Walleij
2013-04-16 12:34     ` Linus Walleij
2013-04-18  8:38   ` Santosh Shilimkar
2013-04-18  8:38     ` Santosh Shilimkar
2013-04-12 12:35 ` [V3 patch 06/19] cpuidle: make a single register function for all Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-17  6:28   ` Daniel Lezcano
2013-04-17  6:28     ` Daniel Lezcano
2013-04-18  8:48   ` Santosh Shilimkar
2013-04-18  8:48     ` Santosh Shilimkar
2013-04-23 13:43     ` Daniel Lezcano
2013-04-23 13:43       ` Daniel Lezcano
2013-04-23 13:56       ` Santosh Shilimkar
2013-04-23 13:56         ` Santosh Shilimkar
2013-04-23 14:22         ` Daniel Lezcano
2013-04-23 14:22           ` Daniel Lezcano
2013-04-23 15:07           ` Santosh Shilimkar
2013-04-23 15:07             ` Santosh Shilimkar
2013-04-23 15:21             ` Daniel Lezcano
2013-04-23 15:21               ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 07/19] ARM: ux500: cpuidle: use init/exit common routine Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 08/19] ARM: at91: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 09/19] ARM: OMAP3: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-18  8:49   ` Santosh Shilimkar
2013-04-18  8:49     ` Santosh Shilimkar
2013-04-19 22:19   ` Kevin Hilman
2013-04-19 22:19     ` Kevin Hilman
2013-04-12 12:35 ` [V3 patch 10/19] ARM: s3c64xx: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-22  6:32   ` Daniel Lezcano
2013-04-22  6:32     ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 11/19] ARM: tegra: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-12 12:35 ` [V3 patch 12/19] ARM: shmobile: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-15  3:56   ` Simon Horman
2013-04-15  3:56     ` Simon Horman
2013-04-12 12:35 ` [V3 patch 13/19] ARM: OMAP4: " Daniel Lezcano
2013-04-12 12:35   ` Daniel Lezcano
2013-04-18  8:50   ` Santosh Shilimkar
2013-04-18  8:50     ` Santosh Shilimkar
2013-04-19 22:19   ` Kevin Hilman
2013-04-19 22:19     ` Kevin Hilman
2013-04-12 12:36 ` [V3 patch 14/19] ARM: tegra: cpuidle: use init/exit common routine for tegra2 Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-12 12:36 ` [V3 patch 15/19] ARM: tegra: cpuidle: use init/exit common routine for tegra3 Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-12 12:36 ` [V3 patch 16/19] ARM: calxeda: cpuidle: use init/exit common routine Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-12 12:36 ` [V3 patch 17/19] ARM: kirkwood: " Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-14 15:14   ` Andrew Lunn
2013-04-14 15:14     ` Andrew Lunn
2013-04-14 20:22     ` Daniel Lezcano
2013-04-14 20:22       ` Daniel Lezcano
2013-04-22  7:01     ` Daniel Lezcano
2013-04-22  7:01       ` Daniel Lezcano
2013-04-22 16:47       ` Andrew Lunn
2013-04-22 16:47         ` Andrew Lunn
2013-04-22 16:54         ` Daniel Lezcano
2013-04-22 16:54           ` Daniel Lezcano
2013-04-12 12:36 ` [V3 patch 18/19] ARM: davinci: " Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-16  8:30   ` Sekhar Nori
2013-04-16  8:30     ` Sekhar Nori
2013-04-12 12:36 ` [V3 patch 19/19] ARM: imx: " Daniel Lezcano
2013-04-12 12:36   ` Daniel Lezcano
2013-04-17  6:24   ` Daniel Lezcano
2013-04-17  6:24     ` Daniel Lezcano
2013-04-17  7:15   ` Shawn Guo
2013-04-17  7:15     ` Shawn Guo
2013-04-17  7:23     ` Daniel Lezcano
2013-04-17  7:23       ` Daniel Lezcano
2013-04-17  7:39       ` Shawn Guo
2013-04-17  7:39         ` Shawn Guo
2013-04-15 23:03 ` [V3 patch 00/19] cpuidle: code consolidation Kevin Hilman
2013-04-15 23:03   ` Kevin Hilman
2013-04-16  8:42   ` Daniel Lezcano
2013-04-16  8:42     ` Daniel Lezcano
2013-04-19 22:44 ` Kevin Hilman
2013-04-19 22:44   ` Kevin Hilman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.