Re: Nokia N900: Proper C-states

2016-01-02 Thread Daniel Lezcano

On 01/02/2016 03:26 PM, Pali Rohár wrote:

Hello,

due to this Daniel Lezcano commit (ARM: OMAP3: cpuidle - remove rx51
cpuidle parameters table)

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=231900afba52d6faddfb480cde4132d4edc089bc

we need patch cpuidle34xx.c code to fix commit for Nokia N900. See:

https://github.com/pali/linux-n900/commit/e147fd4b678f1f3d7a5235287910960bd41e04dc

As Nokia N900 code is converting from legacy board code to DST, I would
like to know how to patch correctly omap3_idle_driver in DTS with
correct values measured for Nokia N900. Thanks!


Hi Pali,

the conversion to the DT based arm cpuidle driver could be a bit complex 
with one issue (index 0 != cpu_do_idle()) and one performance regression 
(cpu_pm_enter/exit will be called in retention mode, even if this is not 
needed).


It will result in a PM code only on one side and on the other side, the 
generic cpuidle-arm.c driver will be used instead with the DT 
definition. It is worth to the conversion because the result will be 
nice IMO.


Added Lorenzo who is initially author of the arm generic driver. We 
already discussed in the past about those two issues above and I think 
this is something we should improve.




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

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/11] clocksource: add TI 32.768 Hz counter driver

2015-10-06 Thread Daniel Lezcano

On 10/06/2015 07:02 PM, Felipe Balbi wrote:

Introduce a new clocksource driver for Texas
Instruments 32.768 Hz device which is available
on most OMAP-like devices.

Signed-off-by: Felipe Balbi <ba...@ti.com>


Hi Felipe,

With the couple of nits below fixed, you can my:

Acked-by: Daniel Lezcano <daniel.lezc...@linaro.org>

[ ... ]


+#define OMAP2_32KSYNCNT_REV_OFF0x0
+#define OMAP2_32KSYNCNT_REV_SCHEME (0x3 << 30)
+#define OMAP2_32KSYNCNT_CR_OFF_LOW 0x10
+#define OMAP2_32KSYNCNT_CR_OFF_HIGH0x30
+
+struct ti_32k {
+   void __iomem*base;
+   void __iomem*counter;
+   struct clocksource  cs;
+};
+#define to_ti_32k(cs)  (container_of((cs), struct ti_32k, cs))


Usually a static inline is used instead of a macro for that.


+static cycle_t ti_32k_read_cycles(struct clocksource *cs)
+{
+   struct ti_32k   *ti = to_ti_32k(cs);


format


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

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 09/11] clocksource: add TI 32.768 Hz counter driver

2015-10-01 Thread Daniel Lezcano


Hi Felipe,


On 09/29/2015 10:44 PM, Felipe Balbi wrote:

Introduce a new clocksource driver for Texas
Instruments 32.768 Hz device which is available
on most OMAP-like devices.

Signed-off-by: Felipe Balbi 
---


[ ... ]


+config CLKSRC_TI_32K
+   bool "Texas Instruments 32.768 Hz Clocksource"
+   depends on OF && ARCH_OMAP2PLUS
+   select CLKSRC_OF
+   help
+ This option enables support for Texas Instruments 32.768 Hz 
clocksource
+ available on many OMAP-like platforms.
+


It is the omap's Kconfig which should select the timer, not the user to 
enable the timer.


It should be something like:

config CLKSRC_TI_32K
bool "Texas Instruments 32.768 Hz Clocksource" if COMPILE_TEST
select CLKSRC_OF if OF
help
  This option enables support for Texas Instruments 32.768 Hz
  clocksource available on many OMAP-like platforms.

And in the omap's Kconfig:
select CLKSRC_TI_32K



  config CLKSRC_STM32
bool "Clocksource for STM32 SoCs" if !ARCH_STM32
depends on OF && ARM && (ARCH_STM32 || COMPILE_TEST)
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 5c00863c3e33..749abc3665b3 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_VF_PIT_TIMER)+= vf_pit_timer.o
  obj-$(CONFIG_CLKSRC_QCOM) += qcom-timer.o
  obj-$(CONFIG_MTK_TIMER)   += mtk_timer.o
  obj-$(CONFIG_CLKSRC_PISTACHIO)+= time-pistachio.o
+obj-$(CONFIG_CLKSRC_TI_32K)+= timer-ti-32k.o

  obj-$(CONFIG_ARM_ARCH_TIMER)  += arm_arch_timer.o
  obj-$(CONFIG_ARM_GLOBAL_TIMER)+= arm_global_timer.o
diff --git a/drivers/clocksource/timer-ti-32k.c 
b/drivers/clocksource/timer-ti-32k.c
new file mode 100644
index ..10ccce2eb645
--- /dev/null
+++ b/drivers/clocksource/timer-ti-32k.c
@@ -0,0 +1,121 @@
+/**
+ * timer-ti-32k.c - OMAP2 32k Timer Support
+ *
+ * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 


Can you check all these headers are needed ? I don't think interrupt.h, 
or slab.h or irq.h, etc ... are needed.


A few nits below:


+/* OMAP2_32KSYNCNT_CR_OFF: offset of 32ksync counter register */


I am not sure this comment gives some interesting indication.


+#define OMAP2_32KSYNCNT_REV_OFF0x0
+#define OMAP2_32KSYNCNT_REV_SCHEME (0x3 << 30)
+#define OMAP2_32KSYNCNT_CR_OFF_LOW 0x10
+#define OMAP2_32KSYNCNT_CR_OFF_HIGH0x30
+
+/*
+ * 32KHz clocksource ... always available, on pretty most chips except
+ * OMAP 730 and 1510.  Other timers could be used as clocksources, with
+ * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
+ * but systems won't necessarily want to spend resources that way.
+ */
+static void __iomem *sync32k_cnt_reg;
+
+/**
+ * omap_read_persistent_clock64 -  Return time from a persistent clock.
+ *
+ * Reads the time from a source which isn't disabled during PM, the
+ * 32k sync timer.  Convert the cycles elapsed since last read into
+ * nsecs and adds to a monotonically increasing timespec64.
+ */


This comment above should be moved right before the function it 
describes and in order to comply with the kernel-doc format the 
parameters must be documented also:

...
* @ts:  
...



+static struct timespec64 persistent_ts;
+static cycles_t cycles;
+static unsigned int persistent_mult, persistent_shift;
+
+static u64 notrace omap_32k_read_sched_clock(void)
+{
+   return readl_relaxed(sync32k_cnt_reg);
+}
+
+static void omap_read_persistent_clock64(struct timespec64 *ts)
+{
+   unsigned long long nsecs;
+   cycles_t last_cycles;
+
+   last_cycles = cycles;
+   cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0;


This test is pointless because 'sync32k_cnt_reg' is always different 
from zero regarding the init routine, no ?



+
+   nsecs = clocksource_cyc2ns(cycles - last_cycles,
+   persistent_mult, persistent_shift);
+
+   timespec64_add_ns(_ts, nsecs);
+
+   *ts = persistent_ts;
+}
+
+static void __init ti_32k_timer_init(struct device_node *np)
+{
+   void __iomem *vbase;
+   int ret;
+
+  

Re: [PATCH 08/10] ARM: OMAP5/DRA7: PM: cpuidle MPU CSWR support

2014-09-17 Thread Daniel Lezcano

On 08/22/2014 07:02 AM, Nishanth Menon wrote:

From: Santosh Shilimkar santosh.shilim...@ti.com

Add OMAP5/DRA74/72 CPUIDLE support.

This patch adds MPUSS low power states in cpuidle.

 C1 - CPU0 WFI + CPU1 WFI + MPU ON
 C2 - CPU0 RET + CPU1 RET + MPU CSWR

Tested on DRA74/72-EVM for C1 and C2 states.

NOTE: DRA7 does not do voltage scaling as part of retention transition
and has Mercury which speeds up transition paths - Latency numbers are
based on measurements done by toggling GPIOs.

Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
[ j-keer...@ti.com rework on 3.14]
Signed-off-by: Keerthy j-keer...@ti.com
[n...@ti.com: updates based on profiling, OMAP5 squashed]
Signed-off-by: Nishanth Menon n...@ti.com
---
  arch/arm/mach-omap2/cpuidle44xx.c |   82 -
  arch/arm/mach-omap2/pm44xx.c  |2 +-
  2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 2498ab0..8ad4f44 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,6 +22,7 @@
  #include common.h
  #include pm.h
  #include prm.h
+#include soc.h
  #include clockdomain.h

  #define MAX_CPUS  2
@@ -31,6 +32,7 @@ struct idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
u32 mpu_state;
+   u32 mpu_state_vote;
  };

  static struct idle_statedata omap4_idle_data[] = {
@@ -51,12 +53,26 @@ static struct idle_statedata omap4_idle_data[] = {
},
  };

+static struct idle_statedata dra7_idle_data[] = {
+   {
+   .cpu_state = PWRDM_POWER_ON,
+   .mpu_state = PWRDM_POWER_ON,
+   .mpu_logic_state = PWRDM_POWER_ON,
+   },
+   {
+   .cpu_state = PWRDM_POWER_RET,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+};
+
  static struct powerdomain *mpu_pd, *cpu_pd[MAX_CPUS];
  static struct clockdomain *cpu_clkdm[MAX_CPUS];

  static atomic_t abort_barrier;
  static bool cpu_done[MAX_CPUS];
  static struct idle_statedata *state_ptr = omap4_idle_data[0];
+static DEFINE_RAW_SPINLOCK(mpu_lock);

  /* Private functions */

@@ -78,6 +94,32 @@ static int omap_enter_idle_simple(struct cpuidle_device *dev,
return index;
  }

+static int omap_enter_idle_smp(struct cpuidle_device *dev,
+  struct cpuidle_driver *drv,
+  int index)
+{
+   struct idle_statedata *cx = state_ptr + index;
+   unsigned long flag;
+
+   raw_spin_lock_irqsave(mpu_lock, flag);


Why do you need this spin_lock_irqsave ? Aren't the local irqs already 
disabled ?



+   cx-mpu_state_vote++;
+   if (cx-mpu_state_vote == num_online_cpus()) {
+   pwrdm_set_logic_retst(mpu_pd, cx-mpu_logic_state);
+   omap_set_pwrdm_state(mpu_pd, cx-mpu_state);
+   }
+   raw_spin_unlock_irqrestore(mpu_lock, flag);
+
+   omap4_enter_lowpower(dev-cpu, cx-cpu_state);
+
+   raw_spin_lock_irqsave(mpu_lock, flag);
+   if (cx-mpu_state_vote == num_online_cpus())
+   omap_set_pwrdm_state(mpu_pd, PWRDM_POWER_ON);
+   cx-mpu_state_vote--;
+   raw_spin_unlock_irqrestore(mpu_lock, flag);


I am not sure that will work. What happens if a cpu exits idle and then 
re-enter idle immediately ?


Could you try a long run of this little program:

https://git.linaro.org/power/pm-qa.git/blob/HEAD:/cpuidle/cpuidle_killer.c


+   return index;
+}
+
  static int omap_enter_idle_coupled(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
@@ -224,6 +266,34 @@ static struct cpuidle_driver omap4_idle_driver = {
.safe_state_index = 0,
  };

+static struct cpuidle_driver dra7_idle_driver = {
+   .name   = dra7_idle,
+   .owner  = THIS_MODULE,
+   .states = {
+   {
+   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap_enter_idle_simple,
+   .name = C1,
+   .desc = CPUx WFI, MPUSS ON
+   },
+   {
+   /* C2 - CPU0 RET + CPU1 RET + MPU CSWR */
+   .exit_latency = 48 + 60,
+   .target_residency = 100,
+   .flags = CPUIDLE_FLAG_TIME_VALID
+   | CPUIDLE_FLAG_TIMER_STOP,
+   .enter = omap_enter_idle_smp,
+   .name = C2,
+   .desc = CPUx CSWR, MPUSS CSWR,
+   },
+   },
+   .state_count = ARRAY_SIZE(dra7_idle_data),
+   .safe_state_index = 0,
+};
+
  /* Public functions */

  

Re: [PATCH 08/10] ARM: OMAP5/DRA7: PM: cpuidle MPU CSWR support

2014-09-17 Thread Daniel Lezcano

On 09/17/2014 04:20 PM, Shilimkar, Santosh wrote:

Sorry for the format. Emailing from webmail.



[ ... ]


+static int omap_enter_idle_smp(struct cpuidle_device *dev,
+struct cpuidle_driver *drv,
+int index)
+{
+ struct idle_statedata *cx = state_ptr + index;
+ unsigned long flag;
+
+ raw_spin_lock_irqsave(mpu_lock, flag);


Why do you need this spin_lock_irqsave ? Aren't the local irqs already
disabled ?

[Santosh] Actually at one point of time before the idle consolidation the local
irq disable was inside the idle drivers. Now with that moved to core layer,
I think plain spin_lock/unlock() should work.


ok.


+ cx-mpu_state_vote++;
+ if (cx-mpu_state_vote == num_online_cpus()) {
+ pwrdm_set_logic_retst(mpu_pd, cx-mpu_logic_state);
+ omap_set_pwrdm_state(mpu_pd, cx-mpu_state);
+ }
+ raw_spin_unlock_irqrestore(mpu_lock, flag);
+
+ omap4_enter_lowpower(dev-cpu, cx-cpu_state);
+
+ raw_spin_lock_irqsave(mpu_lock, flag);
+ if (cx-mpu_state_vote == num_online_cpus())
+ omap_set_pwrdm_state(mpu_pd, PWRDM_POWER_ON);
+ cx-mpu_state_vote--;
+ raw_spin_unlock_irqrestore(mpu_lock, flag);


I am not sure that will work. What happens if a cpu exits idle and then
re-enter idle immediately ?

[Santosh] It works and that case is already taken care. CPU exist the idle and 
then votes
out for cluster state and if it reenters with the right targeted state, the 
cluster state would
be picked.


It isn't possible to have one cpu disabling the coherency, while the 
other one is looking for a lock ? Or eg. cpu0 is on WFI then cpu1 is the 
last entering idle. While cpu1 is entering 'lowpower', cpu0 exits the 
wfi check the state vote and set the power domain on. In the meantime 
cpu1 disables the coherency and cpu0 decrease the vote and release the 
lock. Could be possible there is a very small racy window here ?



Could you try a long run of this little program:

https://git.linaro.org/power/pm-qa.git/blob/HEAD:/cpuidle/cpuidle_killer.c

[Santosh] I am sure there will not be any issue with the long run test case 
here.
Lets see if Nishant sees anything otherwise


Ok. Make sure the cpu is effectively entering your C2 state with the 
sleep duration in the test program.



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-27 Thread Daniel Lezcano

On 05/27/2014 11:03 PM, Santosh Shilimkar wrote:

On Tuesday 27 May 2014 04:34 PM, Tony Lindgren wrote:

* Daniel Lezcano daniel.lezc...@linaro.org [140523 13:53]:

On 23 May 2014 20:32, Tony Lindgren t...@atomide.com wrote:


* Tony Lindgren t...@atomide.com [140523 07:45]:

* Tobias Jakobi tjak...@math.uni-bielefeld.de [140519 14:19]:


But even if I don't connect via WiFi at all, just boot and let me

system

run with serial console connected, after some time I get a kernel

'WARNING':

http://www.math.uni-bielefeld.de/~tjakobi/archive/dmesg.1.log


BTW, care to update the bugzilla page with the second warning
in this log?

That's the WARNING: CPU: 1 PID: 0 at kernel/timer.c:1147 that's
at 238 seconds.


Also, with Santosh's fix applied, can you also try disabling one
or more of the idle states for cpuidle and see if that helps?

Something like this patch below. If that helps with the WARNING
above you're getting it narrows down the problem down quite a bit.

Regards,

Tony

--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -44,11 +44,13 @@ static struct idle_statedata omap4_idle_data[] = {
 .mpu_state = PWRDM_POWER_RET,
 .mpu_logic_state = PWRDM_POWER_RET,
 },
+#if 0
 {
 .cpu_state = PWRDM_POWER_OFF,
 .mpu_state = PWRDM_POWER_RET,
 .mpu_logic_state = PWRDM_POWER_OFF,
 },
+#endif



Hmm, I am afraid that will lead to a fault. Safer to set the state_count =
2 instead.


Hmm don't we have state_count = ARRAY_SIZE(omap4_idle_data) or am I
missing something?


I don't think you are missing anything. The change should work.


Oh, yes. Sorry, over-sighted that. I am too used with the other drivers 
assigning the state_count with a number.



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-19 Thread Daniel Lezcano

On 05/16/2014 11:29 PM, Tony Lindgren wrote:

* Santosh Shilimkar santosh.shilim...@ti.com [140516 06:43]:

Tony,

On Thursday 15 May 2014 02:29 PM, Santosh Shilimkar wrote:

On Thursday 15 May 2014 01:54 PM, Santosh Shilimkar wrote:

On Thursday 15 May 2014 01:50 PM, Daniel Lezcano wrote:

On 05/15/2014 07:03 PM, Santosh Shilimkar wrote:


[..]


With above mentioned change, it should work. Other alternatives is OMAP4 driver 
does
its won registration where it can start the timer. The way it was before the
consolidation.

Ofcourse if you have better fix, then great.


What is your suggestion. We *must* fix the regression asap. I think
$subject patch with an update to bctimer start under CPUIDLE_FLAG_COUPLED
seems a good way forward.

Do let me know.


Did you see Alex Shi's email [cc'ed] ? Reverting this change makes the panda ES 
to hang.


The hang is definitely due to the bctimer not started. As I said, I assumed it 
was and
then you corrected saying it is under the flag.


I am not convinced the culprit is this code you are trying to revert.


fair enough. Thats why I said if you have an alternative fix thats great.


For record, below is updated patch with bctimer started which
was missed in earlier version. I haven't tested it though.

Alex,
Please give a try with your test-case and see if you still see the hang.
Am just curious about your issue and hence the request..


Alex tested below patch and he don't see the hang so the patch is
addressing the issue.

If Daniel works out an alternate fix to avoid reverts, that will be great
but if not, we should merge the below patch. I let you take call on it.


Daniel any news on this?

And just to recap, this problem can be reproduced with current
Linux next with omap2plus_defconfig with CONFIG_CPU_IDLE enabled. The
system should hang during the boot at some point.


I can take the time to investigate a bit more but not right now. What is 
your deadline before committing the reverts ?



And for the record, the omap3 hang fix is now posted to the lists as
[PATCH] ARM: OMAP2+: Fix DMA hang after off-idle. This should not
have anything to do with the omap4 cpu_idle hang as omap4 does not
currently lose context during 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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-19 Thread Daniel Lezcano

On 05/19/2014 07:51 PM, Tony Lindgren wrote:

* Santosh Shilimkar santosh.shilim...@ti.com [140519 10:35]:

On Monday 19 May 2014 01:23 PM, Tony Lindgren wrote:

* Daniel Lezcano daniel.lezc...@linaro.org [140519 09:46]:

On 05/16/2014 11:29 PM, Tony Lindgren wrote:


And just to recap, this problem can be reproduced with current
Linux next with omap2plus_defconfig with CONFIG_CPU_IDLE enabled. The
system should hang during the boot at some point.


I can take the time to investigate a bit more but not right now. What is
your deadline before committing the reverts ?


Well we do have several automated build and boot systems failing
because of this with multi_v7_defconfig. And users are complaining,
see this report from Tobias Jakobi:

https://bugzilla.kernel.org/show_bug.cgi?id=75421

It seems that doing the revert is not enough based on the
page above.


Thats not true. The above link used the half patch and not the
updated patch. Updated patch worked for Alex also. As you can
see they saw RCU stalls and they go away after the updated patch.

Can you please point them to try out the updated patch ?


OK good point. I added a link to the updated patch in
bugzilla.


I'd prefer we'd fix this issue properly for sure, it seems that
we're not quite understanding what's going on. And this might
hit other platforms too when they start implementing deeper
PM idle states in the mainline kernel.


I am certain that the updated patch fixed the regression
for sure. The issue is really not generic enough since its related
an OMAP ROM errata which needs that special handling of
interrupt re-trigger etc. You don't need that for other platforms
so they are not likely get affected.


OK makes sense to me considering the ROM code. Daniel, are you OK
with that or do you still want to investigate further?


For the moment I am a bit short in time for some other tasks. So feel 
free to apply the revert and I will look for a proper fix when I will 
have time.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-19 Thread Daniel Lezcano

On 05/19/2014 09:36 PM, Tony Lindgren wrote:

* Daniel Lezcano daniel.lezc...@linaro.org [140519 11:07]:

On 05/19/2014 07:51 PM, Tony Lindgren wrote:

* Santosh Shilimkar santosh.shilim...@ti.com [140519 10:35]:

On Monday 19 May 2014 01:23 PM, Tony Lindgren wrote:

* Daniel Lezcano daniel.lezc...@linaro.org [140519 09:46]:

On 05/16/2014 11:29 PM, Tony Lindgren wrote:


And just to recap, this problem can be reproduced with current
Linux next with omap2plus_defconfig with CONFIG_CPU_IDLE enabled. The
system should hang during the boot at some point.


I can take the time to investigate a bit more but not right now. What is
your deadline before committing the reverts ?


Well we do have several automated build and boot systems failing
because of this with multi_v7_defconfig. And users are complaining,
see this report from Tobias Jakobi:

https://bugzilla.kernel.org/show_bug.cgi?id=75421

It seems that doing the revert is not enough based on the
page above.


Thats not true. The above link used the half patch and not the
updated patch. Updated patch worked for Alex also. As you can
see they saw RCU stalls and they go away after the updated patch.

Can you please point them to try out the updated patch ?


OK good point. I added a link to the updated patch in
bugzilla.


I'd prefer we'd fix this issue properly for sure, it seems that
we're not quite understanding what's going on. And this might
hit other platforms too when they start implementing deeper
PM idle states in the mainline kernel.


I am certain that the updated patch fixed the regression
for sure. The issue is really not generic enough since its related
an OMAP ROM errata which needs that special handling of
interrupt re-trigger etc. You don't need that for other platforms
so they are not likely get affected.


OK makes sense to me considering the ROM code. Daniel, are you OK
with that or do you still want to investigate further?


For the moment I am a bit short in time for some other tasks. So feel free
to apply the revert and I will look for a proper fix when I will have time.


Added Tobias to Cc. At the bugzilla link Tobias is saying
he used the right patch from Santosh to test and it still
fails.


So apparently Santosh, Kevin and Alex say they are not facing the issue 
anymore with the revert. But Tobias is still facing this issue.


There is this simple program [1] which usually makes cpuidle to hang the 
system more quickly when there is a problem somewhere. May be worth to 
check with it.


Hope that helps.

  -- Daniel

[1] 
https://git.linaro.org/power/pm-qa.git/blob/HEAD:/cpuidle/cpuidle_killer.c


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RCU stall on panda

2014-05-15 Thread Daniel Lezcano

On 05/15/2014 10:44 AM, Alex Shi wrote:

On 05/13/2014 11:32 PM, Tony Lindgren wrote:

* Alex Shi alex@linaro.org [140512 23:37]:

On 05/13/2014 05:21 AM, Tony Lindgren wrote:

* Paul E. McKenney paul...@linux.vnet.ibm.com [140505 11:11]:

On Mon, May 05, 2014 at 05:39:43PM +0800, Alex Shi wrote:

I keep seeing the RCU stall problem on panda board from 3.10 kernel to latest 
upstream kernel
and google find some one report it before: https://lkml.org/lkml/2012/9/20/519

Is it the hardware issue or a real software problem?


I cannot distinguish between hardware and software from the trace below,
but given that you are also seeing a soft lockup, either way you do
appear to have a real problem as opposed to an RCU CPU stall warning
false positive.


Looks like you have CPU_IDLE enabled on panda. Hangs with current linux
next with CPU_IDLE are currently being discussed on the linux-omap list
in thread omap4-panda-es boot issues with v3.15-rc4

I've seen occasional system hangs, and I've also noticed that doing
ctrl-a-f h or ctrl-a-f l for sysrq backtrace can unlock the system
producing similar errors to the below.



Thanks a lot for the info.
In fact, the oops keeps in upstream kernel from 3.10 to latest.


Care to test if the revert of commit cb7094 Santosh posted as
[PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled
solves the problem for you?



After enable this patch, system maybe hang in idle. :(


Hi Alex,

do you mean even with this revert applied, the board hangs in 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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-15 Thread Daniel Lezcano

On 05/15/2014 07:03 PM, Santosh Shilimkar wrote:

Daniel,

On Wednesday 14 May 2014 05:18 PM, Santosh Shilimkar wrote:

On Wednesday 14 May 2014 04:02 PM, Daniel Lezcano wrote:

On 05/14/2014 09:50 PM, Santosh Shilimkar wrote:

On Wednesday 14 May 2014 03:44 PM, Daniel Lezcano wrote:

On 05/13/2014 04:39 PM, Santosh Shilimkar wrote:

On OMAP4 panda board, there have been several bug reports about boot
hang and lock-ups with CPU_IDLE enabled. The root cause of the issue
is missing interrupts while in idle state. Commit cb7094e8 {cpuidle / omap4 :
use CPUIDLE_FLAG_TIMER_STOP flag} moved the broadcast notifiers to common
code for right reasons but on OMAP4 which suffers from a nasty ROM code
bug with GIC, commit ff999b8a {ARM: OMAP4460: Workaround for ROM bug ..},
we loose interrupts which leads to issues like lock-up, hangs etc.

Patch reverts commit cb7094 {cpuidle / omap4 : use CPUIDLE_FLAG_TIMER_STOP
flag} to avoid the issue. With this change, OMAP4 panda boards, the mentioned
issues are getting fixed. We no longer loose interrupts which was the cause
of the regression.

Cc: Roger Quadros rog...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: Tony Lindgren t...@atomide.com
Cc: Daniel Lezcano daniel.lezc...@linaro.org
Reported-tested-by: Roger Quadros rog...@ti.com
Reported-tested-by: Kevin Hilman khil...@linaro.org
Tested-by: Tony Lindgren t...@atomide.com
Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
---


[ ... ]



+clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, cpu_id);
+
/*
 * Call idle CPU PM enter notifier chain so that
 * VFP and per CPU interrupt context is saved.
@@ -165,6 +169,8 @@ static int omap_enter_idle_coupled(struct cpuidle_device 
*dev,
if (dev-cpu == 0  mpuss_can_lose_context)
cpu_cluster_pm_exit();

+clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, cpu_id);


[ ... ]



Shouldn't the broadcast timer to be setup with CLOCK_EVT_NOTIFY_BROADCAST_ON 
also ?


Which is already taken care by __cpuidle_register_driver(). Note that setup code
is still used from generic code...


Nope, if the flag CPUIDLE_FLAG_TIMER_STOP is not set, the cpuidle framework 
won't setup the timer.


I see. I assumed it was taken care. So we might have setup the timer too.


static void __cpuidle_driver_init(struct cpuidle_driver *drv)
{

 ...

 for (i = drv-state_count - 1; i = 0 ; i--) {
 if (drv-states[i].flags  CPUIDLE_FLAG_TIMER_STOP) {

May be you should start the bc timer in case 'CPUIDLE_FLAG_TIMER_STOP'
or 'CPUIDLE_FLAG_COUPLED'

 drv-bctimer = 1;
 break;
 }
 }

 ...

}

static int __cpuidle_register_driver(struct cpuidle_driver *drv)
{
 ...

 if (drv-bctimer)
 on_each_cpu_mask(drv-cpumask,
 cpuidle_setup_broadcast_timer,
  (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1);

 ...
}

So the broadcast timer does not operate with this revert. Moreover, I am not 
sure reverting this patch is the right solution.


With above mentioned change, it should work. Other alternatives is OMAP4 driver 
does
its won registration where it can start the timer. The way it was before the
consolidation.

Ofcourse if you have better fix, then great.


What is your suggestion. We *must* fix the regression asap. I think
$subject patch with an update to bctimer start under CPUIDLE_FLAG_COUPLED
seems a good way forward.

Do let me know.


Did you see Alex Shi's email [cc'ed] ? Reverting this change makes the 
panda ES to hang.


I am not convinced the culprit is this code you are trying to revert.

I will try to reproduce the bug on my board.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-14 Thread Daniel Lezcano

On 05/13/2014 04:39 PM, Santosh Shilimkar wrote:

On OMAP4 panda board, there have been several bug reports about boot
hang and lock-ups with CPU_IDLE enabled. The root cause of the issue
is missing interrupts while in idle state. Commit cb7094e8 {cpuidle / omap4 :
use CPUIDLE_FLAG_TIMER_STOP flag} moved the broadcast notifiers to common
code for right reasons but on OMAP4 which suffers from a nasty ROM code
bug with GIC, commit ff999b8a {ARM: OMAP4460: Workaround for ROM bug ..},
we loose interrupts which leads to issues like lock-up, hangs etc.

Patch reverts commit cb7094 {cpuidle / omap4 : use CPUIDLE_FLAG_TIMER_STOP
flag} to avoid the issue. With this change, OMAP4 panda boards, the mentioned
issues are getting fixed. We no longer loose interrupts which was the cause
of the regression.

Cc: Roger Quadros rog...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: Tony Lindgren t...@atomide.com
Cc: Daniel Lezcano daniel.lezc...@linaro.org
Reported-tested-by: Roger Quadros rog...@ti.com
Reported-tested-by: Kevin Hilman khil...@linaro.org
Tested-by: Tony Lindgren t...@atomide.com
Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
---
  arch/arm/mach-omap2/cpuidle44xx.c |   12 
  1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 01fc710..3e169d9 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -14,6 +14,7 @@
  #include linux/cpuidle.h
  #include linux/cpu_pm.h
  #include linux/export.h
+#include linux/clockchips.h

  #include asm/cpuidle.h
  #include asm/proc-fns.h
@@ -83,6 +84,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
  {
struct idle_statedata *cx = state_ptr + index;
u32 mpuss_can_lose_context = 0;
+   int cpu_id = smp_processor_id();

/*
 * CPU0 has to wait and stay ON until CPU1 is OFF state.
@@ -110,6 +112,8 @@ static int omap_enter_idle_coupled(struct cpuidle_device 
*dev,
mpuss_can_lose_context = (cx-mpu_state == PWRDM_POWER_RET) 
 (cx-mpu_logic_state == PWRDM_POWER_OFF);

+   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, cpu_id);
+
/*
 * Call idle CPU PM enter notifier chain so that
 * VFP and per CPU interrupt context is saved.
@@ -165,6 +169,8 @@ static int omap_enter_idle_coupled(struct cpuidle_device 
*dev,
if (dev-cpu == 0  mpuss_can_lose_context)
cpu_cluster_pm_exit();

+   clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, cpu_id);
+
  fail:
cpuidle_coupled_parallel_barrier(dev, abort_barrier);
cpu_done[dev-cpu] = false;
@@ -189,8 +195,7 @@ static struct cpuidle_driver omap4_idle_driver = {
/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
.exit_latency = 328 + 440,
.target_residency = 960,
-   .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED 
|
-CPUIDLE_FLAG_TIMER_STOP,
+   .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED,
.enter = omap_enter_idle_coupled,
.name = C2,
.desc = CPUx OFF, MPUSS CSWR,
@@ -199,8 +204,7 @@ static struct cpuidle_driver omap4_idle_driver = {
/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
.exit_latency = 460 + 518,
.target_residency = 1100,
-   .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED 
|
-CPUIDLE_FLAG_TIMER_STOP,
+   .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED,
.enter = omap_enter_idle_coupled,
.name = C3,
.desc = CPUx OFF, MPUSS OSWR,


Shouldn't the broadcast timer to be setup with 
CLOCK_EVT_NOTIFY_BROADCAST_ON also ?




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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP4: Fix the boot regression with CPU_IDLE enabled

2014-05-14 Thread Daniel Lezcano

On 05/14/2014 09:50 PM, Santosh Shilimkar wrote:

On Wednesday 14 May 2014 03:44 PM, Daniel Lezcano wrote:

On 05/13/2014 04:39 PM, Santosh Shilimkar wrote:

On OMAP4 panda board, there have been several bug reports about boot
hang and lock-ups with CPU_IDLE enabled. The root cause of the issue
is missing interrupts while in idle state. Commit cb7094e8 {cpuidle / omap4 :
use CPUIDLE_FLAG_TIMER_STOP flag} moved the broadcast notifiers to common
code for right reasons but on OMAP4 which suffers from a nasty ROM code
bug with GIC, commit ff999b8a {ARM: OMAP4460: Workaround for ROM bug ..},
we loose interrupts which leads to issues like lock-up, hangs etc.

Patch reverts commit cb7094 {cpuidle / omap4 : use CPUIDLE_FLAG_TIMER_STOP
flag} to avoid the issue. With this change, OMAP4 panda boards, the mentioned
issues are getting fixed. We no longer loose interrupts which was the cause
of the regression.

Cc: Roger Quadros rog...@ti.com
Cc: Kevin Hilman khil...@linaro.org
Cc: Tony Lindgren t...@atomide.com
Cc: Daniel Lezcano daniel.lezc...@linaro.org
Reported-tested-by: Roger Quadros rog...@ti.com
Reported-tested-by: Kevin Hilman khil...@linaro.org
Tested-by: Tony Lindgren t...@atomide.com
Signed-off-by: Santosh Shilimkar santosh.shilim...@ti.com
---


[ ... ]



+clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, cpu_id);
+
   /*
* Call idle CPU PM enter notifier chain so that
* VFP and per CPU interrupt context is saved.
@@ -165,6 +169,8 @@ static int omap_enter_idle_coupled(struct cpuidle_device 
*dev,
   if (dev-cpu == 0  mpuss_can_lose_context)
   cpu_cluster_pm_exit();

+clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, cpu_id);


[ ... ]



Shouldn't the broadcast timer to be setup with CLOCK_EVT_NOTIFY_BROADCAST_ON 
also ?


Which is already taken care by __cpuidle_register_driver(). Note that setup code
is still used from generic code...


Nope, if the flag CPUIDLE_FLAG_TIMER_STOP is not set, the cpuidle 
framework won't setup the timer.


static void __cpuidle_driver_init(struct cpuidle_driver *drv)
{

...

for (i = drv-state_count - 1; i = 0 ; i--) {
if (drv-states[i].flags  CPUIDLE_FLAG_TIMER_STOP) {
drv-bctimer = 1;
break;
}
}

...

}

static int __cpuidle_register_driver(struct cpuidle_driver *drv)
{
...

if (drv-bctimer)
on_each_cpu_mask(drv-cpumask,
cpuidle_setup_broadcast_timer,
 (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1);

...
}

So the broadcast timer does not operate with this revert. Moreover, I am 
not sure reverting this patch is the right solution.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3] cpuidle: Improve governor Kconfig options

2013-06-03 Thread Daniel Lezcano
Each governor is suitable for different kernel configurations: the menu
governor suits better for a tickless system, while the ladder governor fits
better for a periodic timer tick system.

The Kconfig does not allow to [un]select a governor, thus both are compiled in
the kernel but the init order makes the menu governor to be the last one to be
registered, so becoming the default. The only way to switch back to the ladder
governor is to enable the sysfs governor switch in the kernel command line.

Because it seems nobody complained about this, the menu governor is used by
default most of the time on the system, having both governors is not really
necessary on a tickless system but there isn't a config option to disable one
or another governor.

Create a submenu for cpuidle and add a label for each governor, so we can see
the option in the menu config and enable/disable it.

The governors will be enabled depending on the CONFIG_NO_HZ option:
 - If CONFIG_NO_HZ is set, then the menu governor is selected and the ladder
   governor is optional, defaulting to 'yes'
 - If CONFIG_NO_HZ is not set, then the ladder governor is selected and the
   menu governor is optional, defaulting to 'yes'

Before this patch, the ARCH_NEEDS_CPU_IDLE_COUPLED option was wrongly not
depending on the CPU_IDLE and the Kconfig for OMAP / TEGRA was not checking
this dependency when setting the option.

With this patch, the ARCH_NEEDS_CPU_IDLE_COUPLED has been moved under the
CPU_IDLE option. The dependency has been fixed in the relevant arch's Kconfig.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---

V3:
 - Fixed Kconfig dependency between CPU_IDLE and ARCH_NEEDS_CPU_IDLE_COUPLED
V2:
 - Set default values to 'yes' for the governors

 arch/arm/mach-omap2/Kconfig |2 +-
 arch/arm/mach-tegra/Kconfig |2 +-
 drivers/cpuidle/Kconfig |   16 +++-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index f49cd51..831e89e 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -83,7 +83,7 @@ config ARCH_OMAP4
depends on ARCH_OMAP2PLUS
depends on ARCH_MULTI_V7
select ARCH_HAS_OPP
-   select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
+   select ARCH_NEEDS_CPU_IDLE_COUPLED if (SMP  CPU_IDLE)
select ARM_CPU_SUSPEND if PM
select ARM_ERRATA_720789
select ARM_GIC
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 84d72fc..04c6221 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -23,7 +23,7 @@ menu NVIDIA Tegra options
 
 config ARCH_TEGRA_2x_SOC
bool Enable support for Tegra20 family
-   select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
+   select ARCH_NEEDS_CPU_IDLE_COUPLED if (SMP  CPU_IDLE)
select ARM_ERRATA_720789
select ARM_ERRATA_754327 if SMP
select ARM_ERRATA_764369 if SMP
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index c4cc27e..e997f15 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -1,7 +1,9 @@
 
-config CPU_IDLE
+menuconfig CPU_IDLE
bool CPU idle PM support
default y if ACPI || PPC_PSERIES
+   select CPU_IDLE_GOV_LADDER if (!NO_HZ  !NO_HZ_IDLE)
+   select CPU_IDLE_GOV_MENU if (NO_HZ || NO_HZ_IDLE)
help
  CPU idle is a generic framework for supporting software-controlled
  idle processor power management.  It includes modular cross-platform
@@ -9,9 +11,10 @@ config CPU_IDLE
 
  If you're using an ACPI-enabled platform, you should say Y here.
 
+if CPU_IDLE
+
 config CPU_IDLE_MULTIPLE_DRIVERS
 bool Support multiple cpuidle drivers
-depends on CPU_IDLE
 default n
 help
  Allows the cpuidle framework to use different drivers for each CPU.
@@ -19,24 +22,19 @@ config CPU_IDLE_MULTIPLE_DRIVERS
  states. If unsure say N.
 
 config CPU_IDLE_GOV_LADDER
-   bool
-   depends on CPU_IDLE
+   bool Ladder governor (for periodic timer tick)
default y
 
 config CPU_IDLE_GOV_MENU
-   bool
-   depends on CPU_IDLE  NO_HZ
+   bool Menu governor (for tickless system)
default y
 
 config ARCH_NEEDS_CPU_IDLE_COUPLED
def_bool n
 
-if CPU_IDLE
-
 config CPU_IDLE_CALXEDA
bool CPU Idle Driver for Calxeda processors
depends on ARCH_HIGHBANK
help
  Select this to enable cpuidle on Calxeda processors.
-
 endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL 2/5] omap pm clean-up for v3.10 merge window

2013-04-09 Thread Daniel Lezcano
On 04/09/2013 07:36 PM, Kevin Hilman wrote:
 Tony Lindgren t...@atomide.com writes:
 
 * Kevin Hilman khil...@linaro.org [130409 09:43]:
 Arnd Bergmann a...@arndb.de writes:

 On Tuesday 09 April 2013, Tony Lindgren wrote:
 The following changes since commit 
 07961ac7c0ee8b546658717034fe692fd12eefa9:

   Linux 3.9-rc5 (2013-03-31 15:12:43 -0700)

 are available in the git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap 
 tags/omap-for-v3.10/cleanup-pm-signed

 for you to fetch changes up to ca8cdff548da76da01f3783548ceb917139a5ddc:

   Merge tag 'omap-pm-v3.10/cleanup/cpuidle' of
 git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm
 into omap-for-v3.10/cleanup-pm (2013-04-08 09:51:00 -0700)

 

 PM cleanup to prepare for omap5 PM via Kevin Hilman khil...@linaro.org:

 OMAP3/4 CPUidle cleanups for v3.10

 Adding Daniel and Rafael to Cc.

Kevin,

I just want to point you this patch:

https://git.linaro.org/gitweb?p=people/dlezcano/cpuidle-next.git;a=commit;h=e03a37fdf942a25154ccb5539524afd336f130bb

I did not yet send it to Rafael.


 Is this series coordinated with the other cpuidle changes? Please tell me 
 if this
 is good to go into arm-soc.

 Hmm, looks like it's not ready.  There are some minor conflicts with
 what Rafael has queued up from Daniel.

 I will work this out with Daniel to figure out how we should proceed.

 OK it seems that this branch can also be queued by Rafael after
 updating it if there's a dependency. So far it's not conflicting
 with anything else we have queued up for arm soc tree.
 
 Right, I just did a test rebase onto the relevant commit in Rafael
 linux-next branch, and fixed up all the conflicts[1].
 
 If Rafael agrees, it's fine with me if it goes via him.
 
 Rafael, the signed tag for the updated branch is below[1], based on the
 commit in your linux-next branch where you merged the rest of the
 CPUidle changes.  Let me know if you want a different base commit, or an
 official pull request.
 
 Kevin
 
 [1] git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git 
 tags/omap-pm-v3.10/cleanup/cpuidle-v2



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL 2/5] omap pm clean-up for v3.10 merge window

2013-04-09 Thread Daniel Lezcano
On 04/09/2013 11:47 PM, Kevin Hilman wrote:
 Daniel Lezcano daniel.lezc...@linaro.org writes:
 
 [...]
 

 PM cleanup to prepare for omap5 PM via Kevin Hilman 
 khil...@linaro.org:

 OMAP3/4 CPUidle cleanups for v3.10

 Adding Daniel and Rafael to Cc.

 Kevin,

 I just want to point you this patch:

 https://git.linaro.org/gitweb?p=people/dlezcano/cpuidle-next.git;a=commit;h=e03a37fdf942a25154ccb5539524afd336f130bb

 I did not yet send it to Rafael.
 
 I haven't seen that one posted anywhere so it's not in my queue, and
 probably too late for v3.10.
 
 Once it's posted, I'll queue it up, and we can maybe get it in for
 v3.10-rc.

Yes, I just did the fix very recently. It was just a head up. I will
send it to Rafael as soon as the 'bleeding edge' branch is merged with
'linux-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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Question regarding broadcast timer/cpuidle and /proc/interrupts

2013-01-21 Thread Daniel Lezcano

Hi All,

I have a question regarding the behavior of cpuidle on pandaboard.

1. cpuidle is enabled

2. The deep idle states seem to be reach

for i in $(find /sys/devices/system/cpu -name usage); do echo $i :
$(cat $i); done
/sys/devices/system/cpu/cpu0/cpuidle/state0/usage : 7049
/sys/devices/system/cpu/cpu0/cpuidle/state1/usage : 17
/sys/devices/system/cpu/cpu0/cpuidle/state2/usage : 1341
/sys/devices/system/cpu/cpu1/cpuidle/state0/usage : 6318
/sys/devices/system/cpu/cpu1/cpuidle/state1/usage : 17
/sys/devices/system/cpu/cpu1/cpuidle/state2/usage : 1341

3. Regarding the cpuidle driver code : the state1 and state2 are
coupled states where the broadcast timer is used instead of the local
timer. I assume this is because they go down when we reach these idle
states.

4. The content of /proc/interrupts shows no broadcast timer used at all.

...
IPI1:  0  0  Timer broadcast interrupts
...

Shouldn't be the broadcast timer used sometimes ? or did I miss something ?

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Question regarding broadcast timer/cpuidle and /proc/interrupts

2013-01-21 Thread Daniel Lezcano
On 01/21/2013 03:38 PM, Santosh Shilimkar wrote:
 On Monday 21 January 2013 07:47 PM, Daniel Lezcano wrote:

 Hi All,

 I have a question regarding the behavior of cpuidle on pandaboard.

 1. cpuidle is enabled

 2. The deep idle states seem to be reach

 for i in $(find /sys/devices/system/cpu -name usage); do echo $i :
 $(cat $i); done
 /sys/devices/system/cpu/cpu0/cpuidle/state0/usage : 7049
 /sys/devices/system/cpu/cpu0/cpuidle/state1/usage : 17
 /sys/devices/system/cpu/cpu0/cpuidle/state2/usage : 1341
 /sys/devices/system/cpu/cpu1/cpuidle/state0/usage : 6318
 /sys/devices/system/cpu/cpu1/cpuidle/state1/usage : 17
 /sys/devices/system/cpu/cpu1/cpuidle/state2/usage : 1341

 3. Regarding the cpuidle driver code : the state1 and state2 are
 coupled states where the broadcast timer is used instead of the local
 timer. I assume this is because they go down when we reach these idle
 states.

 Thats correct. Local timer are not wakeup capable and hence we switch
 to a wakeup capable broadcast timer.
 
 4. The content of /proc/interrupts shows no broadcast timer used at all.

 ...
 IPI1:  0  0  Timer broadcast interrupts
 ...

 Shouldn't be the broadcast timer used sometimes ? or did I miss
 something ?

 There might be an issue with status updating. Just look for gptimer1
 interrupts. if they are incrementing then, broadcast is being used
 but just the status update isn't happening some how.

Is it the interrupt 69 ?

 29:293395   GIC  twd
 41:  0  0   GIC  l3-dbg-irq
 42:  0  0   GIC  l3-app-irq
 44:  0  0   GIC  DMA
 69: 61  0   GIC  gp_timer
 88:  0  0   GIC  i2c.9
 89:  0  0   GIC  i2c.10
 93:  0  0   GIC  i2c.11
 94:  0  0   GIC  i2c.12
106: 93  0   GIC  OMAP UART2
169:  0  0  PRCM  hwmod_io
IPI0: 0  0  Timer broadcast interrupts
IPI1:  1424   1260  Rescheduling interrupts
IPI2: 0  0  Function call interrupts
IPI3:81 90  Single function call interrupts
IPI4: 0  0  CPU stop interrupts
Err:  0

 
 regards
 santosh
 


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-30 Thread Daniel Lezcano
On 05/30/2012 08:07 PM, Kevin Hilman wrote:
 Daniel Lezcano daniel.lezc...@linaro.org writes:
 
 On 05/14/2012 06:42 AM, Rajendra Nayak wrote:
 On Thursday 10 May 2012 03:32 PM, Daniel Lezcano wrote:
 The current Makefile compiles the cpuidle34xx.c and cpuidle44xx.c files
 even if the cpuidle option is not set in the kernel.

 This patch fixes this by creating a section in the Makefile where these
 files are compiled only if the CONFIG_CPU_IDLE option is set.

 This modification breaks an implicit dependency between CPU_IDLE and
 PM as
 they belong to the same block in the Makefile. This is fixed in the
 Kconfig
 by selecting explicitely PM is CPU_IDLE is set.

 The linux coding style recommend to use no-op functions in the headers
 when the subsystem is disabled instead of adding big section in C files.

 Looks good to me.
 Reviewed-by: Rajendra Nayak rna...@ti.com

 Hi Kevin,

 I think I addressed all the points. Is it possible to consider this
 patch for inclusion ?

 
 Yes.  I'll queue up as a cleanup for v3.6 with the reviewed-by from
 Rajendra.

Cool !

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-29 Thread Daniel Lezcano
On 05/14/2012 06:42 AM, Rajendra Nayak wrote:
 On Thursday 10 May 2012 03:32 PM, Daniel Lezcano wrote:
 The current Makefile compiles the cpuidle34xx.c and cpuidle44xx.c files
 even if the cpuidle option is not set in the kernel.

 This patch fixes this by creating a section in the Makefile where these
 files are compiled only if the CONFIG_CPU_IDLE option is set.

 This modification breaks an implicit dependency between CPU_IDLE and
 PM as
 they belong to the same block in the Makefile. This is fixed in the
 Kconfig
 by selecting explicitely PM is CPU_IDLE is set.

 The linux coding style recommend to use no-op functions in the headers
 when the subsystem is disabled instead of adding big section in C files.
 
 Looks good to me.
 Reviewed-by: Rajendra Nayak rna...@ti.com

Hi Kevin,

I think I addressed all the points. Is it possible to consider this
patch for inclusion ?

Thanks
  -- Daniel

 This patch fix this also.

 Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
 Reviewed-by: Jean Pihetj-pi...@ti.com
 ---
   arch/arm/mach-omap2/Kconfig   |2 ++
   arch/arm/mach-omap2/Makefile  |   11 +++
   arch/arm/mach-omap2/cpuidle34xx.c |8 
   arch/arm/mach-omap2/cpuidle44xx.c |8 
   arch/arm/mach-omap2/pm.h  |   17 +++--
   5 files changed, 24 insertions(+), 22 deletions(-)

 diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
 index 8141b76..42f6b89 100644
 --- a/arch/arm/mach-omap2/Kconfig
 +++ b/arch/arm/mach-omap2/Kconfig
 @@ -34,6 +34,7 @@ config ARCH_OMAP3
   select CPU_V7
   select USB_ARCH_HAS_EHCI if USB_SUPPORT
   select ARCH_HAS_OPP
 +select PM if CPU_IDLE
   select PM_OPP if PM
   select ARM_CPU_SUSPEND if PM
   select MULTI_IRQ_HANDLER
 @@ -51,6 +52,7 @@ config ARCH_OMAP4
   select PL310_ERRATA_727915
   select ARM_ERRATA_720789
   select ARCH_HAS_OPP
 +select PM if CPU_IDLE
   select PM_OPP if PM
   select USB_ARCH_HAS_EHCI if USB_SUPPORT
   select ARM_CPU_SUSPEND if PM
 diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
 index 49f92bc..f46c735 100644
 --- a/arch/arm/mach-omap2/Makefile
 +++ b/arch/arm/mach-omap2/Makefile
 @@ -64,10 +64,8 @@ endif
   ifeq ($(CONFIG_PM),y)
   obj-$(CONFIG_ARCH_OMAP2)+= pm24xx.o
   obj-$(CONFIG_ARCH_OMAP2)+= sleep24xx.o
 -obj-$(CONFIG_ARCH_OMAP3)+= pm34xx.o sleep34xx.o \
 -   cpuidle34xx.o
 -obj-$(CONFIG_ARCH_OMAP4)+= pm44xx.o omap-mpuss-lowpower.o \
 -   cpuidle44xx.o
 +obj-$(CONFIG_ARCH_OMAP3)+= pm34xx.o sleep34xx.o
 +obj-$(CONFIG_ARCH_OMAP4)+= pm44xx.o omap-mpuss-lowpower.o
   obj-$(CONFIG_PM_DEBUG)+= pm-debug.o
   obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
   obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)+= smartreflex-class3.o
 @@ -81,6 +79,11 @@ endif

   endif

 +ifeq ($(CONFIG_CPU_IDLE),y)
 +obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
 +obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
 +endif
 +
   # PRCM
   obj-y+= prm_common.o
   obj-$(CONFIG_ARCH_OMAP2)+= prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
 diff --git a/arch/arm/mach-omap2/cpuidle34xx.c
 b/arch/arm/mach-omap2/cpuidle34xx.c
 index 207bc1c..3134452 100644
 --- a/arch/arm/mach-omap2/cpuidle34xx.c
 +++ b/arch/arm/mach-omap2/cpuidle34xx.c
 @@ -36,8 +36,6 @@
   #include control.h
   #include common.h

 -#ifdef CONFIG_CPU_IDLE
 -
   /* Mach specific information to be recorded in the C-state
 driver_data */
   struct omap3_idle_statedata {
   u32 mpu_state;
 @@ -379,9 +377,3 @@ int __init omap3_idle_init(void)

   return 0;
   }
 -#else
 -int __init omap3_idle_init(void)
 -{
 -return 0;
 -}
 -#endif /* CONFIG_CPU_IDLE */
 diff --git a/arch/arm/mach-omap2/cpuidle44xx.c
 b/arch/arm/mach-omap2/cpuidle44xx.c
 index be1617c..02d15bb 100644
 --- a/arch/arm/mach-omap2/cpuidle44xx.c
 +++ b/arch/arm/mach-omap2/cpuidle44xx.c
 @@ -22,8 +22,6 @@
   #include pm.h
   #include prm.h

 -#ifdef CONFIG_CPU_IDLE
 -
   /* Machine specific information */
   struct omap4_idle_statedata {
   u32 cpu_state;
 @@ -199,9 +197,3 @@ int __init omap4_idle_init(void)

   return 0;
   }
 -#else
 -int __init omap4_idle_init(void)
 -{
 -return 0;
 -}
 -#endif /* CONFIG_CPU_IDLE */
 diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
 index 7856489..ab04d3b 100644
 --- a/arch/arm/mach-omap2/pm.h
 +++ b/arch/arm/mach-omap2/pm.h
 @@ -15,12 +15,25 @@

   #include powerdomain.h

 +#ifdef CONFIG_CPU_IDLE
 +extern int __init omap3_idle_init(void);
 +extern int __init omap4_idle_init(void);
 +#else
 +static inline int omap3_idle_init(void)
 +{
 +return 0;
 +}
 +
 +static inline int omap4_idle_init(void)
 +{
 +return 0;
 +}
 +#endif
 +
   extern void *omap3_secure_ram_storage;
   extern void omap3_pm_off_mode_enable(int);
   extern void omap_sram_idle(void);
   extern int

[PATCH] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-10 Thread Daniel Lezcano
The current Makefile compiles the cpuidle34xx.c and cpuidle44xx.c files
even if the cpuidle option is not set in the kernel.

This patch fixes this by creating a section in the Makefile where these
files are compiled only if the CONFIG_CPU_IDLE option is set.

This modification breaks an implicit dependency between CPU_IDLE and PM as
they belong to the same block in the Makefile. This is fixed in the Kconfig
by selecting explicitely PM is CPU_IDLE is set.

The linux coding style recommend to use no-op functions in the headers
when the subsystem is disabled instead of adding big section in C files.

This patch fix this also.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/Kconfig   |2 ++
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |8 
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 8141b76..42f6b89 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -34,6 +34,7 @@ config ARCH_OMAP3
select CPU_V7
select USB_ARCH_HAS_EHCI if USB_SUPPORT
select ARCH_HAS_OPP
+   select PM if CPU_IDLE
select PM_OPP if PM
select ARM_CPU_SUSPEND if PM
select MULTI_IRQ_HANDLER
@@ -51,6 +52,7 @@ config ARCH_OMAP4
select PL310_ERRATA_727915
select ARM_ERRATA_720789
select ARCH_HAS_OPP
+   select PM if CPU_IDLE
select PM_OPP if PM
select USB_ARCH_HAS_EHCI if USB_SUPPORT
select ARM_CPU_SUSPEND if PM
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 49f92bc..f46c735 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,10 +64,8 @@ endif
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
-obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o \
-  cpuidle34xx.o
-obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o \
-  cpuidle44xx.o
+obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o
+obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)  += smartreflex-class3.o
@@ -81,6 +79,11 @@ endif
 
 endif
 
+ifeq ($(CONFIG_CPU_IDLE),y)
+obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
+obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
+endif
+
 # PRCM
 obj-y  += prm_common.o
 obj-$(CONFIG_ARCH_OMAP2)   += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 207bc1c..3134452 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
 #include control.h
 #include common.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
@@ -379,9 +377,3 @@ int __init omap3_idle_init(void)
 
return 0;
 }
-#else
-int __init omap3_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index be1617c..02d15bb 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,8 +22,6 @@
 #include pm.h
 #include prm.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
@@ -199,9 +197,3 @@ int __init omap4_idle_init(void)
 
return 0;
 }
-#else
-int __init omap4_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 7856489..ab04d3b 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,12 +15,25 @@
 
 #include powerdomain.h
 
+#ifdef CONFIG_CPU_IDLE
+extern int __init omap3_idle_init(void);
+extern int __init omap4_idle_init(void);
+#else
+static inline int omap3_idle_init(void)
+{
+   return 0;
+}
+
+static inline int omap4_idle_init(void)
+{
+   return 0;
+}
+#endif
+
 extern void *omap3_secure_ram_storage;
 extern void omap3_pm_off_mode_enable(int);
 extern void omap_sram_idle(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
-extern int omap3_idle_init(void);
-extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send

Re: [PATCH 2/2] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-08 Thread Daniel Lezcano

On 05/04/2012 07:18 PM, Daniel Lezcano wrote:

Define a CPU_IDLE section in the makefile, declare the functions in
the header files conforming to the kernel coding rules and remove the
'define's in the C files.

CONFIG_PM is enabled when CPU_IDLE is enabled because the cpuidle drivers
use some functions from the pm subsystem.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
---


Hi Kevin,

you did not apply this patch. Is it something wrong with it ?

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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-08 Thread Daniel Lezcano

On 05/08/2012 10:44 PM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


Define a CPU_IDLE section in the makefile, declare the functions in
the header files conforming to the kernel coding rules and remove the
'define's in the C files.

CONFIG_PM is enabled when CPU_IDLE is enabled because the cpuidle drivers
use some functions from the pm subsystem.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com


The changelog doesn't really answer why this change is needed.  IOW, I
don't understand from the changelog exactly what problem this patch is
trying to solve.

AFAICT, it's just shuffling around the dependencies, and changes the
omap*_idle_init() calls into inline nops instead of function call nops.


Ok, I will modify the changelog. I'm always bad with the changelogs, 
this is something I have to improve :) I'm the first one to be happy 
when I find a nice description in the patches log.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] ARM: OMAP3/4: cpuidle - misc fixes

2012-05-04 Thread Daniel Lezcano
These two patches are coming from the series I previously
sent for the cpuidle OMAP3/4 cleanups.

The first one, move the powerdomain lookup check in the init
function, the second one fix the linkage error, when the
CONFIG_PM is not set while CONFIG_CPU_IDLE is. Omap's Kconfig
has been modified to select CONFIG_PM when CONFIG_CPU_IDLE is
set.

I compiled with different options but I was not able to boot
my board because the kernel panics for another reason.

Daniel Lezcano (2):
  ARM: OMAP3: cpuidle - check the powerdomain lookup
  ARM: OMAP3/4: consolidate cpuidle Makefile

 arch/arm/mach-omap2/Kconfig   |2 ++
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |   11 +++
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 5 files changed, 27 insertions(+), 22 deletions(-)

-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] ARM: OMAP3: cpuidle - check the powerdomain lookup

2012-05-04 Thread Daniel Lezcano
At init time, check the powerdomains lookup is successful otherwise
exit the cpuidle driver init function with -ENODEV like what is done for the
omap3 cpuidle driver.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index f682e17..207bc1c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -363,6 +363,9 @@ int __init omap3_idle_init(void)
per_pd = pwrdm_lookup(per_pwrdm);
cam_pd = pwrdm_lookup(cam_pwrdm);
 
+   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());
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-04 Thread Daniel Lezcano
Define a CPU_IDLE section in the makefile, declare the functions in
the header files conforming to the kernel coding rules and remove the
'define's in the C files.

CONFIG_PM is enabled when CPU_IDLE is enabled because the cpuidle drivers
use some functions from the pm subsystem.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/Kconfig   |2 ++
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |8 
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 8141b76..42f6b89 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -34,6 +34,7 @@ config ARCH_OMAP3
select CPU_V7
select USB_ARCH_HAS_EHCI if USB_SUPPORT
select ARCH_HAS_OPP
+   select PM if CPU_IDLE
select PM_OPP if PM
select ARM_CPU_SUSPEND if PM
select MULTI_IRQ_HANDLER
@@ -51,6 +52,7 @@ config ARCH_OMAP4
select PL310_ERRATA_727915
select ARM_ERRATA_720789
select ARCH_HAS_OPP
+   select PM if CPU_IDLE
select PM_OPP if PM
select USB_ARCH_HAS_EHCI if USB_SUPPORT
select ARM_CPU_SUSPEND if PM
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 49f92bc..f46c735 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,10 +64,8 @@ endif
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
-obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o \
-  cpuidle34xx.o
-obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o \
-  cpuidle44xx.o
+obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o
+obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)  += smartreflex-class3.o
@@ -81,6 +79,11 @@ endif
 
 endif
 
+ifeq ($(CONFIG_CPU_IDLE),y)
+obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
+obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
+endif
+
 # PRCM
 obj-y  += prm_common.o
 obj-$(CONFIG_ARCH_OMAP2)   += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 207bc1c..3134452 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
 #include control.h
 #include common.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
@@ -379,9 +377,3 @@ int __init omap3_idle_init(void)
 
return 0;
 }
-#else
-int __init omap3_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index be1617c..02d15bb 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,8 +22,6 @@
 #include pm.h
 #include prm.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
@@ -199,9 +197,3 @@ int __init omap4_idle_init(void)
 
return 0;
 }
-#else
-int __init omap4_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 7856489..ab04d3b 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,12 +15,25 @@
 
 #include powerdomain.h
 
+#ifdef CONFIG_CPU_IDLE
+extern int __init omap3_idle_init(void);
+extern int __init omap4_idle_init(void);
+#else
+static inline int omap3_idle_init(void)
+{
+   return 0;
+}
+
+static inline int omap4_idle_init(void)
+{
+   return 0;
+}
+#endif
+
 extern void *omap3_secure_ram_storage;
 extern void omap3_pm_off_mode_enable(int);
 extern void omap_sram_idle(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
-extern int omap3_idle_init(void);
-extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/18][V3] ARM: OMAP3: cpuidle - remove the 'valid' field

2012-05-03 Thread Daniel Lezcano

On 05/03/2012 10:19 PM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


With the previous changes all the states are valid, except
the last state which can be handled by decreasing the number
of states.

I don't think this changelog is valid anymore as you're not doing
anything to decrease the number of states.

I updated the changelog locally to this:

ARM: OMAP3: cpuidle - remove the 'valid' field

With the previous changes all the states are valid, except the last
state which is now handled at runtime by next_valid_state() based on
the errata flags.

Any problems with that?


No problem :)

Thanks for fixing the Changelog.

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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 18/18][V3] ARM: OMAP3: cpuidle - set global variables static

2012-05-03 Thread Daniel Lezcano

On 05/03/2012 10:26 PM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


and check the powerdomain lookup is successful.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
---
  arch/arm/mach-omap2/cpuidle34xx.c |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 0d28596..116a0d8 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -73,7 +73,7 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
},
  };

-struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
+static struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;

  static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
struct clockdomain *clkdm)
@@ -252,6 +252,9 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 *its own code.
 */

+   if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
+   return -ENODEV;
+


Why check here?  cam_pd is actually used just above this code.

Also, this is in the fast path.  This should just be checked once at
init time instead of every idle path.

For those reasons, I've dropped this part of the patch (updated patch
below.)


Hmm, weird this part should have been in the init function, I likely 
missed a big fuzz I think when porting the patchset to the latest kernel 
version. Thanks for fixing it.



If desired, you can send an additional patch that adds this error
checking at init time and then refuses to register the driver if any of
the pwrdms don't exist.


Yes, I will do it.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/18][V3] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-05-03 Thread Daniel Lezcano

On 05/03/2012 10:34 PM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


Define a CPU_IDLE section in the makefile, declare the functions in
the header files conforming to the kernel coding rules and remove the
'define's in the C files.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com


This patch breaks compilation for the !CONFIG_PM case:

arch/arm/mach-omap2/built-in.o: In function `__omap3_enter_idle':
/work/kernel/omap/pm/arch/arm/mach-omap2/cpuidle34xx.c:121: undefined 
reference to `omap_sram_idle'

Since you moved this stuff out of a CONFIG_PM conditional part of the
Makefile, it broke because pm34xx.c is still compiled conditionally on
CONFIG_PM.

When changing Makefile/Kconfig dependencies like this, please
be sure to at least compile test with the various options
enabled/disabled.

For now, I've dropped this patch from the series.  Feel free to
update/retest/resend since the idea is fine.


Ok, I will update it with the various options.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/18][V3] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-05-01 Thread Daniel Lezcano

On 05/01/2012 12:58 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


On 04/24/2012 04:05 PM, Daniel Lezcano wrote:

This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.

Tested on OMAP3 (igepV2).
Partially tested on OMAP4 (pandaboard), without offlining the cpu1.


Without offlining CPU1, none of this code is executed.  Can you test
with CPU1 offlined?


Unfortunately my OMAP4 board burned :/ I am waiting for a new one.
Rob tested the series but when he unplugged the cpu1, the kernel panics 
for another reason. I guess the problem should have been fixed since the 
last testing.


Rob ? Do you mind the test the series again, the problem you were facing 
when unplugging the cpu1 may have been fixed.


Mike ? if you have time, is it possible you test it on your board ?


Hi,
could be this patchset considered for inclusion ?



Yes.   This is a good series, and a great cleanup.

Unfortunately, there is lots of OMAP PM code to review at the moment so
there's a bit of a lag in my ability to review and test.


Ok, sure. I understand, no pressure :)

Thanks a lot.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/18][V3] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-05-01 Thread Daniel Lezcano

On 05/01/2012 11:55 AM, Shilimkar, Santosh wrote:

On May 1, 2012 1:46 PM, Daniel Lezcanodaniel.lezc...@linaro.org  wrote:

On 05/01/2012 12:58 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org   writes:


On 04/24/2012 04:05 PM, Daniel Lezcano wrote:

This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.

Tested on OMAP3 (igepV2).
Partially tested on OMAP4 (pandaboard), without offlining the cpu1.


Without offlining CPU1, none of this code is executed.  Can you test
with CPU1 offlined?


Unfortunately my OMAP4 board burned :/ I am waiting for a new one.
Rob tested the series but when he unplugged the cpu1, the kernel panics

for another reason. I guess the problem should have been fixed since the
last testing.

  Rob ? Do you mind the test the series again, the problem you were facing

when unplugging the cpu1 may have been fixed.
Have already tested this series on omap4 with cpu offline as well as with
couple idle series on top of it.
I haven't finished omap3 testing and hence not reported yet. Omap4
continies to work with subject series.


Great !

I tested it on omap3 igepv2 board and it works fine too.

Thanks 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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/18][V3] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-04-25 Thread Daniel Lezcano

On 04/24/2012 04:05 PM, Daniel Lezcano wrote:

This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.

Tested on OMAP3 (igepV2).
Partially tested on OMAP4 (pandaboard), without offlining the cpu1.


Hi,

could be this patchset considered for inclusion ?

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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/18][V3] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-04-24 Thread Daniel Lezcano
This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.

Tested on OMAP3 (igepV2).
Partially tested on OMAP4 (pandaboard), without offlining the cpu1.

V3 :
   * replace OMAP4_NUM_STATES and OMAP3_NUM_STATES by ARRAY_SIZE
   * Fixed changelog
   * Fixed OMAP4_NUM_STATES going back and forth in the patchset
   * Removed erratum check at init time

V2 :
   * Fixed a couple of typos in the patch description

V1 : Initial Post

Daniel Lezcano (18):
  ARM: OMAP4: cpuidle - Remove unused valid field
  ARM: OMAP4: cpuidle - Declare the states with the driver declaration
  ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
  ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
  ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
  ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
  ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
time
  ARM: OMAP3: cpuidle - remove rx51 cpuidle parameters table
  ARM: OMAP3: define cpuidle statically
  ARM: OMAP3: cpuidle - remove errata check in the init function
  ARM: OMAP3: cpuidle - remove the 'valid' field
  ARM: OMAP3: cpuidle - remove cpuidle_params_table
  ARM: OMAP3: define statically the omap3_idle_data
  ARM: OMAP3: cpuidle - use omap3_idle_data directly
  ARM: OMAP3: cpuidle - simplify next_valid_state
  ARM: OMAP3: set omap3_idle_data as static
  ARM: OMAP3/4: consolidate cpuidle Makefile
  ARM: OMAP3: cpuidle - set global variables static

 arch/arm/mach-omap2/Makefile  |   11 +-
 arch/arm/mach-omap2/board-rx51.c  |   38 +++---
 arch/arm/mach-omap2/cpuidle34xx.c |  306 +++--
 arch/arm/mach-omap2/cpuidle44xx.c |  134 +++--
 arch/arm/mach-omap2/pm.h  |   38 ++---
 5 files changed, 212 insertions(+), 315 deletions(-)

-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/18][V3] ARM: OMAP4: cpuidle - Remove unused valid field

2012-04-24 Thread Daniel Lezcano
The 'valid' field is never used in the code, let's remove it.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index f386cbe..ee0bc50 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -29,16 +29,15 @@ struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
u32 mpu_state;
-   u8 valid;
 };
 
 static struct cpuidle_params cpuidle_params_table[] = {
/* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5, .valid = 1},
+   {.exit_latency = 2 + 2 , .target_residency = 5 },
/* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960, .valid = 1},
+   {.exit_latency = 328 + 440 , .target_residency = 960 },
/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100, .valid = 1},
+   {.exit_latency = 460 + 518 , .target_residency = 1100 },
 };
 
 #define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
@@ -155,7 +154,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -191,7 +189,6 @@ int __init omap4_idle_init(void)
_fill_cstate(drv, 0, MPUSS ON);
drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/18][V3] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-04-24 Thread Daniel Lezcano
The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   60 
 1 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index ee0bc50..7072c9e 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -132,21 +132,39 @@ 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 */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C1,
+   .desc = MPUSS ON
+   },
+   {
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+   .exit_latency = 328 + 440,
+   .target_residency = 960,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C2,
+   .desc = MPUSS CSWR,
+   },
+   {
+   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+   .exit_latency = 460 + 518,
+   .target_residency = 1100,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C3,
+   .desc = MPUSS OSWR,
+   },
+   },
+   .state_count = OMAP4_NUM_STATES,
+   .safe_state_index = 0,
 };
 
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap4_enter_idle;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-}
-
 static inline struct omap4_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
int idx)
@@ -171,7 +189,6 @@ int __init omap4_idle_init(void)
 {
struct omap4_idle_statedata *cx;
struct cpuidle_device *dev;
-   struct cpuidle_driver *drv = omap4_idle_driver;
unsigned int cpu_id = 0;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
@@ -180,41 +197,30 @@ int __init omap4_idle_init(void)
if ((!mpu_pd) || (!cpu0_pd) || (!cpu1_pd))
return -ENODEV;
 
-
-   drv-safe_state_index = -1;
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   _fill_cstate(drv, 0, MPUSS ON);
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
-   _fill_cstate(drv, 1, MPUSS CSWR);
cx = _fill_cstate_usage(dev, 1);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   _fill_cstate(drv, 2, MPUSS OSWR);
cx = _fill_cstate_usage(dev, 2);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP4_NUM_STATES;
cpuidle_register_driver(omap4_idle_driver);
 
-   dev-state_count = OMAP4_NUM_STATES;
if (cpuidle_register_device(dev)) {
pr_err(%s: CPUidle register device failed\n, __func__);
-   return -EIO;
-   }
+   return -EIO;
+   }
 
return 0;
 }
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/18][V3] ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table

2012-04-24 Thread Daniel Lezcano
We do not longer need this table as we defined the values
in the driver states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   11 +--
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 7072c9e..522ec23 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -31,16 +31,7 @@ struct omap4_idle_statedata {
u32 mpu_state;
 };
 
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5 },
-   /* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960 },
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100 },
-};
-
-#define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
+#define OMAP4_NUM_STATES 3
 
 struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/18][V3] ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration

2012-04-24 Thread Daniel Lezcano
Add the static declaration for the omap4_idle_data variable because its scope
is in the file only.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 522ec23..38ecd27 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,7 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
+static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/18][V3] ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time

2012-04-24 Thread Daniel Lezcano
We initialize the omap4_idle_data variable at compile time allowing us
to remove in the next patch the initialization done at boot time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   21 ++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 38ecd27..9e3effa 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -31,9 +31,24 @@ struct omap4_idle_statedata {
u32 mpu_state;
 };
 
-#define OMAP4_NUM_STATES 3
+static struct omap4_idle_statedata omap4_idle_data[] = {
+   {
+   .cpu_state = PWRDM_POWER_ON,
+   .mpu_state = PWRDM_POWER_ON,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_OFF,
+   },
+};
 
-static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
@@ -152,7 +167,7 @@ struct cpuidle_driver omap4_idle_driver = {
.desc = MPUSS OSWR,
},
},
-   .state_count = OMAP4_NUM_STATES,
+   .state_count = ARRAY_SIZE(omap4_idle_data),
.safe_state_index = 0,
 };
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/18][V3] ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly

2012-04-24 Thread Daniel Lezcano
We are storing the 'omap4_idle_data' in the private data field
of the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   13 +++--
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 9e3effa..f1410f1 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -24,7 +24,7 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/* Machine specific information to be recorded in the C-state driver_data */
+/* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
@@ -65,8 +65,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap4_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap4_idle_statedata *cx = omap4_idle_data[index];
u32 cpu1_state;
int cpu_id = smp_processor_id();
 
@@ -83,7 +82,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
cpu1_state = pwrdm_read_pwrst(cpu1_pd);
if (cpu1_state != PWRDM_POWER_OFF) {
index = drv-safe_state_index;
-   cx = cpuidle_get_statedata(dev-states_usage[index]);
+   cx = omap4_idle_data[index];
}
 
if (index  0)
@@ -176,15 +175,9 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
int idx)
 {
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
return cx;
 }
 
-
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/18][V3] ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot time

2012-04-24 Thread Daniel Lezcano
We initialized it at compile time, no need to do that at boot
time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   24 
 1 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index f1410f1..be1617c 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -170,14 +170,6 @@ struct cpuidle_driver omap4_idle_driver = {
.safe_state_index = 0,
 };
 
-static inline struct omap4_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   return cx;
-}
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
@@ -186,7 +178,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
  */
 int __init omap4_idle_init(void)
 {
-   struct omap4_idle_statedata *cx;
struct cpuidle_device *dev;
unsigned int cpu_id = 0;
 
@@ -199,21 +190,6 @@ int __init omap4_idle_init(void)
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   cx = _fill_cstate_usage(dev, 0);
-   cx-cpu_state = PWRDM_POWER_ON;
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 1);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 2);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_OFF;
-
cpuidle_register_driver(omap4_idle_driver);
 
if (cpuidle_register_device(dev)) {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/18][V3] ARM: OMAP3: cpuidle - remove rx51 cpuidle parameters table

2012-04-24 Thread Daniel Lezcano
As suggested, this table is an optimized version for rx51 and we
remove it in order to consolidate the cpuidle code between omap3
and omap4, we remove this specific data definition which is used
to override the default omap3 latencies but at the cost of extra
code and complexity.

In order to not lose the values which probably took time to be
measured, the table is converted into a comment with an array
description.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/board-rx51.c  |   38 +---
 arch/arm/mach-omap2/cpuidle34xx.c |   17 
 arch/arm/mach-omap2/pm.h  |9 
 3 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 27f01f0..2da92a6 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -59,25 +59,24 @@ static struct platform_device leds_gpio = {
 };
 
 /*
- * cpuidle C-states definition override from the default values.
- * The 'exit_latency' field is the sum of sleep and wake-up latencies.
- */
-static struct cpuidle_params rx51_cpuidle_params[] = {
-   /* C1 */
-   {110 + 162, 5 , 1},
-   /* C2 */
-   {106 + 180, 309, 1},
-   /* C3 */
-   {107 + 410, 46057, 0},
-   /* C4 */
-   {121 + 3374, 46057, 0},
-   /* C5 */
-   {855 + 1146, 46057, 1},
-   /* C6 */
-   {7580 + 4134, 484329, 0},
-   /* C7 */
-   {7505 + 15274, 484329, 1},
-};
+ * cpuidle C-states definition for rx51.
+ *
+ * The 'exit_latency' field is the sum of sleep
+ * and wake-up latencies.
+
+-
+   | state |  exit_latency  |  target_residency  |
+-
+   |  C1   |110 + 162   |5   |
+   |  C2   |106 + 180   |  309   |
+   |  C3   |107 + 410   |46057   |
+   |  C4   |121 + 3374  |46057   |
+   |  C5   |855 + 1146  |46057   |
+   |  C6   |   7580 + 4134  |   484329   |
+   |  C7   |   7505 + 15274 |   484329   |
+-
+
+*/
 
 extern void __init rx51_peripherals_init(void);
 
@@ -98,7 +97,6 @@ static void __init rx51_init(void)
struct omap_sdrc_params *sdrc_params;
 
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
-   omap3_pm_init_cpuidle(rx51_cpuidle_params);
omap_serial_init();
 
sdrc_params = nokia_get_sdram_timings();
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 5358664..3519a8b 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -298,23 +298,6 @@ select_state:
 
 DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 
-void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-   int i;
-
-   if (!cpuidle_board_params)
-   return;
-
-   for (i = 0; i  OMAP3_NUM_STATES; i++) {
-   cpuidle_params_table[i].valid = cpuidle_board_params[i].valid;
-   cpuidle_params_table[i].exit_latency =
-   cpuidle_board_params[i].exit_latency;
-   cpuidle_params_table[i].target_residency =
-   cpuidle_board_params[i].target_residency;
-   }
-   return;
-}
-
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 36fa90b..5646b80 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -50,15 +50,6 @@ struct cpuidle_params {
u8 valid;   /* validates the C-state */
 };
 
-#if defined(CONFIG_PM)  defined(CONFIG_CPU_IDLE)
-extern void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params);
-#else
-static
-inline void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-}
-#endif
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/18][V3] ARM: OMAP3: define cpuidle statically

2012-04-24 Thread Daniel Lezcano
Use the new cpuidle API and define in the driver the states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   86 +---
 1 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 3519a8b..11a2c23 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -301,23 +301,68 @@ DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
+   .states = {
+   {
+   .enter= omap3_enter_idle,
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C1,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 10 + 10,
+   .target_residency = 30,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C2,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 50 + 50,
+   .target_residency = 300,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C3,
+   .desc = MPU RET + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1500 + 1800,
+   .target_residency = 4000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C4,
+   .desc = MPU OFF + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 2500 + 7500,
+   .target_residency = 12000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C5,
+   .desc = MPU RET + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 3000 + 8500,
+   .target_residency = 15000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C6,
+   .desc = MPU OFF + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1 + 3,
+   .target_residency = 3,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C7,
+   .desc = MPU OFF + CORE OFF,
+   },
+   },
+   .state_count = OMAP3_NUM_STATES,
+   .safe_state_index = 0,
 };
 
-/* Helper to fill the C-state common data*/
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap3_enter_idle_bm;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-
-}
-
 /* Helper to register the driver_data */
 static inline struct omap3_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
@@ -350,50 +395,40 @@ int __init omap3_idle_init(void)
cam_pd = pwrdm_lookup(cam_pwrdm);
 
 
-   drv-safe_state_index = -1;
dev = per_cpu(omap3_idle_dev, smp_processor_id());
 
/* C1 . MPU WFI + Core active */
-   _fill_cstate(drv, 0, MPU ON + CORE ON);
-   (drv-states[0])-enter = omap3_enter_idle;
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
/* C2 . MPU WFI + Core inactive */
-   _fill_cstate(drv, 1, MPU ON + CORE ON);
cx = _fill_cstate_usage(dev, 1);
cx-mpu_state = PWRDM_POWER_ON;
cx

[PATCH 10/18][V3] ARM: OMAP3: cpuidle - remove errata check in the init function

2012-04-24 Thread Daniel Lezcano
The errata check is done in the next_valid_state function, no need to check
that in the omap3_idle_init function.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 11a2c23..f394ea6 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -430,16 +430,6 @@ int __init omap3_idle_init(void)
 
/* C7 . MPU OFF + Core OFF */
cx = _fill_cstate_usage(dev, 6);
-   /*
-* Erratum i583: implementation for ES rev  Es1.2 on 3630. We cannot
-* enable OFF mode in a stable form for previous revisions.
-* We disable C7 state as a result.
-*/
-   if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583)) {
-   cx-valid = 0;
-   pr_warn(%s: core off state C7 disabled due to i583\n,
-   __func__);
-   }
cx-mpu_state = PWRDM_POWER_OFF;
cx-core_state = PWRDM_POWER_OFF;
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/18][V3] ARM: OMAP3: cpuidle - remove the 'valid' field

2012-04-24 Thread Daniel Lezcano
With the previous changes all the states are valid, except
the last state which can be handled by decreasing the number
of states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index f394ea6..29b4f87 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -67,7 +67,6 @@ static struct cpuidle_params cpuidle_params_table[] = {
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
-   u8 valid;
 };
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
@@ -191,8 +190,7 @@ static int next_valid_state(struct cpuidle_device *dev,
}
 
/* Check if current state is valid */
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
+   if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
return index;
} else {
@@ -216,8 +214,7 @@ static int next_valid_state(struct cpuidle_device *dev,
idx--;
for (; idx = 0; idx--) {
cx = cpuidle_get_statedata(dev-states_usage[idx]);
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
+   if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
next_index = idx;
break;
@@ -371,7 +368,6 @@ static inline struct omap3_idle_statedata 
*_fill_cstate_usage(
struct omap3_idle_statedata *cx = omap3_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -386,7 +382,6 @@ static inline struct omap3_idle_statedata 
*_fill_cstate_usage(
 int __init omap3_idle_init(void)
 {
struct cpuidle_device *dev;
-   struct cpuidle_driver *drv = omap3_idle_driver;
struct omap3_idle_statedata *cx;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
@@ -399,7 +394,6 @@ int __init omap3_idle_init(void)
 
/* C1 . MPU WFI + Core active */
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
@@ -433,7 +427,6 @@ int __init omap3_idle_init(void)
cx-mpu_state = PWRDM_POWER_OFF;
cx-core_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP3_NUM_STATES;
cpuidle_register_driver(omap3_idle_driver);
 
if (cpuidle_register_device(dev)) {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/18][V3] ARM: OMAP3: cpuidle - remove cpuidle_params_table

2012-04-24 Thread Daniel Lezcano
We do not longer need the ''cpuidle_params_table' array as
we defined the states in the driver and we checked they are
all valid.

We also remove the structure definition as it is no longer used.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   28 +++-
 arch/arm/mach-omap2/pm.h  |   12 
 2 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 29b4f87..a82a887 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -38,36 +38,14 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/*
- * The latencies/thresholds for various C states have
- * to be configured from the respective board files.
- * These are some default values (which might not provide
- * the best power savings) used on boards which do not
- * pass these details from the board file.
- */
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 */
-   {2 + 2, 5, 1},
-   /* C2 */
-   {10 + 10, 30, 1},
-   /* C3 */
-   {50 + 50, 300, 1},
-   /* C4 */
-   {1500 + 1800, 4000, 1},
-   /* C5 */
-   {2500 + 7500, 12000, 1},
-   /* C6 */
-   {3000 + 8500, 15000, 1},
-   /* C7 */
-   {1 + 3, 30, 1},
-};
-#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
 };
+
+#define OMAP3_NUM_STATES 7
+
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 5646b80..7856489 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -38,18 +38,6 @@ static inline int omap4_opp_init(void)
 }
 #endif
 
-/*
- * cpuidle mach specific parameters
- *
- * The board code can override the default C-states definition using
- * omap3_pm_init_cpuidle
- */
-struct cpuidle_params {
-   u32 exit_latency;   /* exit_latency = sleep + wake-up latencies */
-   u32 target_residency;
-   u8 valid;   /* validates the C-state */
-};
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/18][V3] ARM: OMAP3: define statically the omap3_idle_data

2012-04-24 Thread Daniel Lezcano
Initialize the omap3_idle_data array at compile time, that will allow
to remove the initialization at boot time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   37 -
 1 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index a82a887..93e2450 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -44,9 +44,36 @@ struct omap3_idle_statedata {
u32 core_state;
 };
 
-#define OMAP3_NUM_STATES 7
-
-struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
+struct omap3_idle_statedata omap3_idle_data[] = {
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_OFF,
+   },
+};
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
 
@@ -172,7 +199,7 @@ static int next_valid_state(struct cpuidle_device *dev,
(cx-core_state = core_deepest_state)) {
return index;
} else {
-   int idx = OMAP3_NUM_STATES - 1;
+   int idx = ARRAY_SIZE(omap3_idle_data) - 1;
 
/* Reach the current state starting at highest C-state */
for (; idx = 0; idx--) {
@@ -334,7 +361,7 @@ struct cpuidle_driver omap3_idle_driver = {
.desc = MPU OFF + CORE OFF,
},
},
-   .state_count = OMAP3_NUM_STATES,
+   .state_count = ARRAY_SIZE(omap3_idle_data),
.safe_state_index = 0,
 };
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/18][V3] ARM: OMAP3: cpuidle - use omap3_idle_data directly

2012-04-24 Thread Daniel Lezcano
We are storing the 'omap3_idle_data' in the private data field
of the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly.

As the table is initialized statically, let's remove the initialization at
startup too.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   63 +++-
 1 files changed, 6 insertions(+), 57 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 93e2450..242f77d 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -95,8 +95,7 @@ static int __omap3_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap3_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_state = cx-mpu_state, core_state = cx-core_state;
 
local_fiq_disable();
@@ -176,9 +175,8 @@ static int next_valid_state(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct cpuidle_state_usage *curr_usage = dev-states_usage[index];
struct cpuidle_state *curr = drv-states[index];
-   struct omap3_idle_statedata *cx = cpuidle_get_statedata(curr_usage);
+   struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET;
int next_index = -1;
@@ -218,7 +216,7 @@ static int next_valid_state(struct cpuidle_device *dev,
 */
idx--;
for (; idx = 0; idx--) {
-   cx = cpuidle_get_statedata(dev-states_usage[idx]);
+   cx =  omap3_idle_data[idx];
if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
next_index = idx;
@@ -275,7 +273,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 * Prevent PER off if CORE is not in retention or off as this
 * would disable PER wakeups completely.
 */
-   cx = cpuidle_get_statedata(dev-states_usage[index]);
+   cx = omap3_idle_data[index];
core_next_state = cx-core_state;
per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
if ((per_next_state == PWRDM_POWER_OFF) 
@@ -365,19 +363,6 @@ struct cpuidle_driver omap3_idle_driver = {
.safe_state_index = 0,
 };
 
-/* Helper to register the driver_data */
-static inline struct omap3_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap3_idle_statedata *cx = omap3_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
-   return cx;
-}
-
 /**
  * omap3_idle_init - Init routine for OMAP3 idle
  *
@@ -387,52 +372,16 @@ static inline struct omap3_idle_statedata 
*_fill_cstate_usage(
 int __init omap3_idle_init(void)
 {
struct cpuidle_device *dev;
-   struct omap3_idle_statedata *cx;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
core_pd = pwrdm_lookup(core_pwrdm);
per_pd = pwrdm_lookup(per_pwrdm);
cam_pd = pwrdm_lookup(cam_pwrdm);
 
+   cpuidle_register_driver(omap3_idle_driver);
 
dev = per_cpu(omap3_idle_dev, smp_processor_id());
-
-   /* C1 . MPU WFI + Core active */
-   cx = _fill_cstate_usage(dev, 0);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C2 . MPU WFI + Core inactive */
-   cx = _fill_cstate_usage(dev, 1);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C3 . MPU CSWR + Core inactive */
-   cx = _fill_cstate_usage(dev, 2);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C4 . MPU OFF + Core inactive */
-   cx = _fill_cstate_usage(dev, 3);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C5 . MPU RET + Core RET */
-   cx = _fill_cstate_usage(dev, 4);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C6 . MPU OFF + Core RET */
-   cx = _fill_cstate_usage(dev, 5);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C7 . MPU OFF + Core OFF */
-   cx = _fill_cstate_usage(dev, 6);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_OFF;
-
-   cpuidle_register_driver(omap3_idle_driver);
+   dev

[PATCH 15/18][V3] ARM: OMAP3: cpuidle - simplify next_valid_state

2012-04-24 Thread Daniel Lezcano
Simplify the indentation by removing the useless 'else' statement.
Remove the first loop for the 'idx' search as we have it already
with the 'index' passed as parameter.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   53 +---
 1 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 242f77d..e7599e7 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -172,13 +172,12 @@ static inline int omap3_enter_idle(struct cpuidle_device 
*dev,
  * if it satisfies the enable_off_mode condition.
  */
 static int next_valid_state(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
+   struct cpuidle_driver *drv, int index)
 {
-   struct cpuidle_state *curr = drv-states[index];
struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET;
+   int idx;
int next_index = -1;
 
if (enable_off_mode) {
@@ -194,42 +193,28 @@ static int next_valid_state(struct cpuidle_device *dev,
 
/* Check if current state is valid */
if ((cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
+   (cx-core_state = core_deepest_state))
return index;
-   } else {
-   int idx = ARRAY_SIZE(omap3_idle_data) - 1;
-
-   /* Reach the current state starting at highest C-state */
-   for (; idx = 0; idx--) {
-   if (drv-states[idx] == curr) {
-   next_index = idx;
-   break;
-   }
-   }
-
-   /* Should never hit this condition */
-   WARN_ON(next_index == -1);
 
-   /*
-* Drop to next valid state.
-* Start search from the next (lower) state.
-*/
-   idx--;
-   for (; idx = 0; idx--) {
-   cx =  omap3_idle_data[idx];
-   if ((cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
-   next_index = idx;
-   break;
-   }
+   /*
+* Drop to next valid state.
+* Start search from the next (lower) state.
+*/
+   for (idx = index - 1; idx = 0; idx--) {
+   cx =  omap3_idle_data[idx];
+   if ((cx-mpu_state = mpu_deepest_state) 
+   (cx-core_state = core_deepest_state)) {
+   next_index = idx;
+   break;
}
-   /*
-* C1 is always valid.
-* So, no need to check for 'next_index == -1' outside
-* this loop.
-*/
}
 
+   /*
+* C1 is always valid.
+* So, no need to check for 'next_index == -1' outside
+* this loop.
+*/
+
return next_index;
 }
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/18][V3] ARM: OMAP3: set omap3_idle_data as static

2012-04-24 Thread Daniel Lezcano
Reduce the scope of the omap3_idle_data to the file as it is only used
in cpuidle34xx.c.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index e7599e7..ee02a8c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -44,7 +44,7 @@ struct omap3_idle_statedata {
u32 core_state;
 };
 
-struct omap3_idle_statedata omap3_idle_data[] = {
+static struct omap3_idle_statedata omap3_idle_data[] = {
{
.mpu_state = PWRDM_POWER_ON,
.core_state = PWRDM_POWER_ON,
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/18][V3] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-04-24 Thread Daniel Lezcano
Define a CPU_IDLE section in the makefile, declare the functions in
the header files conforming to the kernel coding rules and remove the
'define's in the C files.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |8 
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index d8604a3..92d5fb6 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,10 +64,8 @@ endif
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
-obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o \
-  cpuidle34xx.o
-obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o \
-  cpuidle44xx.o
+obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o
+obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)  += smartreflex-class3.o
@@ -81,6 +79,11 @@ endif
 
 endif
 
+ifeq ($(CONFIG_CPU_IDLE),y)
+obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
+obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
+endif
+
 # PRCM
 obj-y  += prm_common.o
 obj-$(CONFIG_ARCH_OMAP2)   += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index ee02a8c..0d28596 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
 #include control.h
 #include common.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
@@ -376,9 +374,3 @@ int __init omap3_idle_init(void)
 
return 0;
 }
-#else
-int __init omap3_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index be1617c..02d15bb 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,8 +22,6 @@
 #include pm.h
 #include prm.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
@@ -199,9 +197,3 @@ int __init omap4_idle_init(void)
 
return 0;
 }
-#else
-int __init omap4_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 7856489..ab04d3b 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,12 +15,25 @@
 
 #include powerdomain.h
 
+#ifdef CONFIG_CPU_IDLE
+extern int __init omap3_idle_init(void);
+extern int __init omap4_idle_init(void);
+#else
+static inline int omap3_idle_init(void)
+{
+   return 0;
+}
+
+static inline int omap4_idle_init(void)
+{
+   return 0;
+}
+#endif
+
 extern void *omap3_secure_ram_storage;
 extern void omap3_pm_off_mode_enable(int);
 extern void omap_sram_idle(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
-extern int omap3_idle_init(void);
-extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/18][V3] ARM: OMAP3: cpuidle - set global variables static

2012-04-24 Thread Daniel Lezcano
and check the powerdomain lookup is successful.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 0d28596..116a0d8 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -73,7 +73,7 @@ static struct omap3_idle_statedata omap3_idle_data[] = {
},
 };
 
-struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
+static struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
 
 static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
struct clockdomain *clkdm)
@@ -252,6 +252,9 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 *its own code.
 */
 
+   if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
+   return -ENODEV;
+
/*
 * Prevent PER off if CORE is not in retention or off as this
 * would disable PER wakeups completely.
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/17][V2] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-04-23 Thread Daniel Lezcano

On 04/19/2012 03:58 PM, Daniel Lezcano wrote:

On 04/10/2012 12:37 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
Reviewed-by: Santosh Shilimkarsantosh.shilim...@ti.com
---
  arch/arm/mach-omap2/cpuidle44xx.c |   57 
+---

  1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c

index ee0bc50..6d86b59 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -132,21 +132,39 @@ 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 */
+.exit_latency = 2 + 2,
+.target_residency = 5,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C1,
+.desc = MPUSS ON
+},
+{
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+.exit_latency = 328 + 440,
+.target_residency = 960,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C2,
+.desc = MPUSS CSWR,
+},
+{
+/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+.exit_latency = 460 + 518,
+.target_residency = 1100,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C3,
+.desc = MPUSS OSWR,
+},
+},
+.state_count = OMAP4_NUM_STATES,


I think you can drop OMAP4_NUM_STATES here, and just use:

.state_count = ARRAY_SIZE(omap4_idle_driver.states),

Then drop OMAP4_NUM_STATES all together in patch 3.


Ok.


I said 'ok' but it is not :)

omap4_idle_driver.states has a fixed length which is CPUIDLE_STATE_MAX (8).
We need to define it manually as 3 for now.


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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/17][V2] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-04-23 Thread Daniel Lezcano

On 04/23/2012 07:08 PM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


On 04/19/2012 03:58 PM, Daniel Lezcano wrote:

On 04/10/2012 12:37 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org   writes:


The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
Reviewed-by: Santosh Shilimkarsantosh.shilim...@ti.com
---
   arch/arm/mach-omap2/cpuidle44xx.c |   57
+---
   1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c
b/arch/arm/mach-omap2/cpuidle44xx.c
index ee0bc50..6d86b59 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -132,21 +132,39 @@ 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 */
+.exit_latency = 2 + 2,
+.target_residency = 5,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C1,
+.desc = MPUSS ON
+},
+{
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+.exit_latency = 328 + 440,
+.target_residency = 960,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C2,
+.desc = MPUSS CSWR,
+},
+{
+/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+.exit_latency = 460 + 518,
+.target_residency = 1100,
+.flags = CPUIDLE_FLAG_TIME_VALID,
+.enter = omap4_enter_idle,
+.name = C3,
+.desc = MPUSS OSWR,
+},
+},
+.state_count = OMAP4_NUM_STATES,


I think you can drop OMAP4_NUM_STATES here, and just use:

 .state_count = ARRAY_SIZE(omap4_idle_driver.states),

Then drop OMAP4_NUM_STATES all together in patch 3.


Ok.


I said 'ok' but it is not :)

omap4_idle_driver.states has a fixed length which is CPUIDLE_STATE_MAX (8).
We need to define it manually as 3 for now.


I don't see the connection between the two.

Why can't you use ARRAY_SIZE(), and just have an error check later in
the init to see if state_count  max.



Maybe I misunderstood but you say:

.state_count = ARRAY_SIZE(omap4_idle_driver.states),

As in the cpuidle structure, the state array is CPUIDLE_STATE_MAX, 
ARRAY_SIZE will always return 8, not the number of the initialized states.


Anyway, I modified the patchset to use ARRAY_SIZE on the omap4_idle_data 
array, so we have:


.state_count = ARRAY_SIZE(omap4_idle_data),

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/17][V2] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-04-19 Thread Daniel Lezcano

On 04/10/2012 12:37 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
Reviewed-by: Santosh Shilimkarsantosh.shilim...@ti.com
---
  arch/arm/mach-omap2/cpuidle44xx.c |   57 +---
  1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index ee0bc50..6d86b59 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -132,21 +132,39 @@ 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 */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C1,
+   .desc = MPUSS ON
+   },
+   {
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+   .exit_latency = 328 + 440,
+   .target_residency = 960,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C2,
+   .desc = MPUSS CSWR,
+   },
+   {
+   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+   .exit_latency = 460 + 518,
+   .target_residency = 1100,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C3,
+   .desc = MPUSS OSWR,
+   },
+   },
+   .state_count = OMAP4_NUM_STATES,


I think you can drop OMAP4_NUM_STATES here, and just use:

.state_count = ARRAY_SIZE(omap4_idle_driver.states),

Then drop OMAP4_NUM_STATES all together in patch 3.


Ok.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/17][V2] ARM: OMAP3: cpuidle - remove the 'valid' field

2012-04-19 Thread Daniel Lezcano

On 04/10/2012 01:13 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


With the previous changes all the states are valid, except
the last state which can be handled by decreasing the number
of states.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
Reviewed-by: Jean Pihetj-pi...@ti.com
---


[ ... ]


if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583)) {
-   cx-valid = 0;
+   drv-state_count = OMAP3_NUM_STATES - 1;
pr_warn(%s: core off state C7 disabled due to i583\n,
__func__);


I'm not too particular about this one, but it might be cleaner to just
remove this check all together.  This errata already has a check in
next_valid_state() so strictly speaking, it's not needed here.


Yes, right. Thanks for pointing this.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/17][V2] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-04-19 Thread Daniel Lezcano

On 04/10/2012 01:23 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.


Thanks for this really nice cleanup.  I have some comments on specific
patches, but here's some general comments:

Some minor comments:

First, please be sure all patches have a descriptive changelog.  Yes,
even simple ones need changelogs.  In particular, maintainers are
looking for the why of a patch, not just the what or how.

Second, this series introduced a couple sparse warnings:

/work/kernel/omap/pm/arch/arm/mach-omap2/cpuidle44xx.c:134:1: warning: symbol 
'omap4_idle_dev' was not declared. Should it be static?
/work/kernel/omap/pm/arch/arm/mach-omap2/cpuidle44xx.c:136:23: warning: symbol 
'omap4_idle_driver' was not declared. Should it be static?


Ok, I probably missed it. I will fix that it in the next version.

Thanks for reviewing.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/17][V2] ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly

2012-04-19 Thread Daniel Lezcano

On 04/10/2012 12:56 AM, Kevin Hilman wrote:

Daniel Lezcanodaniel.lezc...@linaro.org  writes:


We are storing the 'omap4_idle_data' in the private data field
of the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly
instead dereferencing pointers in an idle critical loop.


Did you notice a performance impact before this change?


No, I didn't and I don't think I will be able to measure it. But by 
experience, when dereferencing a pointer that could leads to a cache 
miss and impact the performances. That may not be the case here, so I 
won't argue with that as I won't able to prove it :)



Also, that simplfies the code.


possibly, but at the expense of clean abstractions which IMO helps readability.

Unless there is a real performance hit here (which I doubt), I'd prefer
to leave this as is.


There are two reasons of this change. We are storing 'state_count' times 
a pointer in a private structure for state_usage but the information is 
already available in the file and easily accessible.
Also, this is set in the fill_cstate function I am removing to let all 
the initialization to be done at compile time.


Furthermore, I don't get why we have a 'driver data' area in a structure 
which is dedicated for the states statistics, IMHO that does not help 
understanding. My mid-term cleanup is to kill the 'driver_data' field in 
the cpuidle core because I don't think it is at the right place.


An idea I had for consolidate all the cpuidle driver was to use the 
containerof macro to define the architecture specific structure and 
declare inside this structure the cpuidle driver and the devices. It is 
similar on how are implemented the 'routes' for the network stack or the 
cgroup subsystems, there is a core engine handling generic structure 
which a contained by the specific structure related to the engine's 
user. That helps a lot for readability.


Well this is an idea but before I have to unify the cpuidle drivers code 
to make it clear what is doable or not.




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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/17][V2] ARM: OMAP3/4 : cpuidle34xx and cpuidle44xx cleanups

2012-04-04 Thread Daniel Lezcano
This patchset makes some cleanup on these cpuidle drivers
and consolidate the code across both architecture.

Tested on OMAP3 (igepV2).
Partially tested on OMAP4 (pandaboard), without offlining the cpu1.

V2 : Fixed a couple of typos in the patch description

V1 : Initial Post

Daniel Lezcano (17):
  ARM: OMAP4: cpuidle - Remove unused valid field
  ARM: OMAP4: cpuidle - Declare the states with the driver declaration
  ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
  ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
  ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
  ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
  ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
time
  ARM: OMAP3: cpuidle - remove rx51 cpuidle parameters table
  ARM: OMAP3: define cpuidle statically
  ARM: OMAP3: cpuidle - remove the 'valid' field
  ARM: OMAP3: cpuidle - remove cpuidle_params_table
  ARM: OMAP3: define statically the omap3_idle_data
  ARM: OMAP3: cpuidle - use omap3_idle_data directly
  ARM: OMAP3 : cpuidle - simplify next_valid_state
  ARM: OMAP3: set omap3_idle_data as static
  ARM: OMAP3/4: consolidate cpuidle Makefile
  ARM: OMAP3: cpuidle - set global variables static

 arch/arm/mach-omap2/Makefile  |   11 +-
 arch/arm/mach-omap2/board-rx51.c  |   38 +++---
 arch/arm/mach-omap2/cpuidle34xx.c |  299 +++--
 arch/arm/mach-omap2/cpuidle44xx.c |  135 +++--
 arch/arm/mach-omap2/pm.h  |   38 ++---
 5 files changed, 219 insertions(+), 302 deletions(-)

-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/17][V2] ARM: OMAP4: cpuidle - Remove unused valid field

2012-04-04 Thread Daniel Lezcano
The 'valid' field is never used in the code, let's remove it.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index f386cbe..ee0bc50 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -29,16 +29,15 @@ struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
u32 mpu_state;
-   u8 valid;
 };
 
 static struct cpuidle_params cpuidle_params_table[] = {
/* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5, .valid = 1},
+   {.exit_latency = 2 + 2 , .target_residency = 5 },
/* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960, .valid = 1},
+   {.exit_latency = 328 + 440 , .target_residency = 960 },
/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100, .valid = 1},
+   {.exit_latency = 460 + 518 , .target_residency = 1100 },
 };
 
 #define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
@@ -155,7 +154,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -191,7 +189,6 @@ int __init omap4_idle_init(void)
_fill_cstate(drv, 0, MPUSS ON);
drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/17][V2] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-04-04 Thread Daniel Lezcano
The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   57 +---
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index ee0bc50..6d86b59 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -132,21 +132,39 @@ 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 */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C1,
+   .desc = MPUSS ON
+   },
+   {
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+   .exit_latency = 328 + 440,
+   .target_residency = 960,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C2,
+   .desc = MPUSS CSWR,
+   },
+   {
+   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+   .exit_latency = 460 + 518,
+   .target_residency = 1100,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C3,
+   .desc = MPUSS OSWR,
+   },
+   },
+   .state_count = OMAP4_NUM_STATES,
+   .safe_state_index = 0,
 };
 
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap4_enter_idle;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-}
-
 static inline struct omap4_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
int idx)
@@ -180,37 +198,28 @@ int __init omap4_idle_init(void)
if ((!mpu_pd) || (!cpu0_pd) || (!cpu1_pd))
return -ENODEV;
 
-
-   drv-safe_state_index = -1;
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   _fill_cstate(drv, 0, MPUSS ON);
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
-   _fill_cstate(drv, 1, MPUSS CSWR);
cx = _fill_cstate_usage(dev, 1);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   _fill_cstate(drv, 2, MPUSS OSWR);
cx = _fill_cstate_usage(dev, 2);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP4_NUM_STATES;
cpuidle_register_driver(omap4_idle_driver);
 
-   dev-state_count = OMAP4_NUM_STATES;
+   dev-state_count = drv-state_count;
+
if (cpuidle_register_device(dev)) {
pr_err(%s: CPUidle register device failed\n, __func__);
return -EIO;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/17][V2] ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table

2012-04-04 Thread Daniel Lezcano
We do not longer need this table as we defined the values
in the driver states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   11 +--
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 6d86b59..cdd7932 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -31,16 +31,7 @@ struct omap4_idle_statedata {
u32 mpu_state;
 };
 
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5 },
-   /* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960 },
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100 },
-};
-
-#define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
+#define OMAP4_NUM_STATES 3
 
 struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/17][V2] ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time

2012-04-04 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   19 ++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index fb0f76e..5b20115 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,24 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
+static struct omap4_idle_statedata omap4_idle_data[] = {
+   {
+   .cpu_state = PWRDM_POWER_ON,
+   .mpu_state = PWRDM_POWER_ON,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_OFF,
+   },
+};
+
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/17][V2] ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly

2012-04-04 Thread Daniel Lezcano
We are storing the 'omap4_idle_data' in the private data field
of the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly
instead dereferencing pointers in an idle critical loop.

Also, that simplfies the code.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   15 ---
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 5b20115..b82f9fe 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -24,7 +24,7 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/* Machine specific information to be recorded in the C-state driver_data */
+/* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
@@ -67,8 +67,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap4_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap4_idle_statedata *cx = omap4_idle_data[index];
u32 cpu1_state;
int cpu_id = smp_processor_id();
 
@@ -85,7 +84,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
cpu1_state = pwrdm_read_pwrst(cpu1_pd);
if (cpu1_state != PWRDM_POWER_OFF) {
index = drv-safe_state_index;
-   cx = cpuidle_get_statedata(dev-states_usage[index]);
+   cx = omap4_idle_data[index];
}
 
if (index  0)
@@ -178,15 +177,9 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
int idx)
 {
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
return cx;
 }
 
-
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
@@ -196,8 +189,8 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
 int __init omap4_idle_init(void)
 {
struct omap4_idle_statedata *cx;
-   struct cpuidle_device *dev;
struct cpuidle_driver *drv = omap4_idle_driver;
+   struct cpuidle_device *dev;
unsigned int cpu_id = 0;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/17][V2] ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot time

2012-04-04 Thread Daniel Lezcano
We initialized it at compile time, no need to do that at boot
time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |   26 +-
 1 files changed, 1 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index b82f9fe..b0dd220 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,7 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-static struct omap4_idle_statedata omap4_idle_data[] = {
+static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES] = {
{
.cpu_state = PWRDM_POWER_ON,
.mpu_state = PWRDM_POWER_ON,
@@ -172,14 +172,6 @@ struct cpuidle_driver omap4_idle_driver = {
.safe_state_index = 0,
 };
 
-static inline struct omap4_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   return cx;
-}
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
@@ -188,7 +180,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
  */
 int __init omap4_idle_init(void)
 {
-   struct omap4_idle_statedata *cx;
struct cpuidle_driver *drv = omap4_idle_driver;
struct cpuidle_device *dev;
unsigned int cpu_id = 0;
@@ -202,21 +193,6 @@ int __init omap4_idle_init(void)
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   cx = _fill_cstate_usage(dev, 0);
-   cx-cpu_state = PWRDM_POWER_ON;
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 1);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 2);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_OFF;
-
cpuidle_register_driver(omap4_idle_driver);
 
dev-state_count = drv-state_count;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/17][V2] ARM: OMAP3: cpuidle - remove rx51 cpuidle parameters table

2012-04-04 Thread Daniel Lezcano
As suggested, this table is an optimized version for rx51 and we
remove it in order to consolidate the cpuidle code between omap3
and omap4, we remove this specific data definition which is used
to override the default omap3 latencies but at the cost of extra
code and complexity.

In order to not lose the values which probably took time to be
measured, the table is converted into a comment with an array
description.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/board-rx51.c  |   38 +---
 arch/arm/mach-omap2/cpuidle34xx.c |   17 
 arch/arm/mach-omap2/pm.h  |9 
 3 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 27f01f0..2da92a6 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -59,25 +59,24 @@ static struct platform_device leds_gpio = {
 };
 
 /*
- * cpuidle C-states definition override from the default values.
- * The 'exit_latency' field is the sum of sleep and wake-up latencies.
- */
-static struct cpuidle_params rx51_cpuidle_params[] = {
-   /* C1 */
-   {110 + 162, 5 , 1},
-   /* C2 */
-   {106 + 180, 309, 1},
-   /* C3 */
-   {107 + 410, 46057, 0},
-   /* C4 */
-   {121 + 3374, 46057, 0},
-   /* C5 */
-   {855 + 1146, 46057, 1},
-   /* C6 */
-   {7580 + 4134, 484329, 0},
-   /* C7 */
-   {7505 + 15274, 484329, 1},
-};
+ * cpuidle C-states definition for rx51.
+ *
+ * The 'exit_latency' field is the sum of sleep
+ * and wake-up latencies.
+
+-
+   | state |  exit_latency  |  target_residency  |
+-
+   |  C1   |110 + 162   |5   |
+   |  C2   |106 + 180   |  309   |
+   |  C3   |107 + 410   |46057   |
+   |  C4   |121 + 3374  |46057   |
+   |  C5   |855 + 1146  |46057   |
+   |  C6   |   7580 + 4134  |   484329   |
+   |  C7   |   7505 + 15274 |   484329   |
+-
+
+*/
 
 extern void __init rx51_peripherals_init(void);
 
@@ -98,7 +97,6 @@ static void __init rx51_init(void)
struct omap_sdrc_params *sdrc_params;
 
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
-   omap3_pm_init_cpuidle(rx51_cpuidle_params);
omap_serial_init();
 
sdrc_params = nokia_get_sdram_timings();
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 5358664..3519a8b 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -298,23 +298,6 @@ select_state:
 
 DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 
-void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-   int i;
-
-   if (!cpuidle_board_params)
-   return;
-
-   for (i = 0; i  OMAP3_NUM_STATES; i++) {
-   cpuidle_params_table[i].valid = cpuidle_board_params[i].valid;
-   cpuidle_params_table[i].exit_latency =
-   cpuidle_board_params[i].exit_latency;
-   cpuidle_params_table[i].target_residency =
-   cpuidle_board_params[i].target_residency;
-   }
-   return;
-}
-
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 36fa90b..5646b80 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -50,15 +50,6 @@ struct cpuidle_params {
u8 valid;   /* validates the C-state */
 };
 
-#if defined(CONFIG_PM)  defined(CONFIG_CPU_IDLE)
-extern void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params);
-#else
-static
-inline void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-}
-#endif
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/17][V2] ARM: OMAP3: define cpuidle statically

2012-04-04 Thread Daniel Lezcano
Use the new cpuidle API and define in the driver the states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   86 +---
 1 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 3519a8b..11a2c23 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -301,23 +301,68 @@ DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
+   .states = {
+   {
+   .enter= omap3_enter_idle,
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C1,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 10 + 10,
+   .target_residency = 30,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C2,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 50 + 50,
+   .target_residency = 300,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C3,
+   .desc = MPU RET + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1500 + 1800,
+   .target_residency = 4000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C4,
+   .desc = MPU OFF + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 2500 + 7500,
+   .target_residency = 12000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C5,
+   .desc = MPU RET + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 3000 + 8500,
+   .target_residency = 15000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C6,
+   .desc = MPU OFF + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1 + 3,
+   .target_residency = 3,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C7,
+   .desc = MPU OFF + CORE OFF,
+   },
+   },
+   .state_count = OMAP3_NUM_STATES,
+   .safe_state_index = 0,
 };
 
-/* Helper to fill the C-state common data*/
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap3_enter_idle_bm;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-
-}
-
 /* Helper to register the driver_data */
 static inline struct omap3_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
@@ -350,50 +395,40 @@ int __init omap3_idle_init(void)
cam_pd = pwrdm_lookup(cam_pwrdm);
 
 
-   drv-safe_state_index = -1;
dev = per_cpu(omap3_idle_dev, smp_processor_id());
 
/* C1 . MPU WFI + Core active */
-   _fill_cstate(drv, 0, MPU ON + CORE ON);
-   (drv-states[0])-enter = omap3_enter_idle;
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
/* C2 . MPU WFI + Core inactive */
-   _fill_cstate(drv, 1, MPU ON + CORE ON);
cx = _fill_cstate_usage(dev, 1);
cx-mpu_state = PWRDM_POWER_ON;
cx

[PATCH 11/17][V2] ARM: OMAP3: cpuidle - remove cpuidle_params_table

2012-04-04 Thread Daniel Lezcano
We do not longer need the ''cpuidle_params_table' array as
we defined the states in the driver and we checked they are
all valid.

We also remove the structure definition as it is no longer used.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   28 +++-
 arch/arm/mach-omap2/pm.h  |   12 
 2 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 3f46e45..cdf1b8f 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -38,36 +38,14 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/*
- * The latencies/thresholds for various C states have
- * to be configured from the respective board files.
- * These are some default values (which might not provide
- * the best power savings) used on boards which do not
- * pass these details from the board file.
- */
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 */
-   {2 + 2, 5, 1},
-   /* C2 */
-   {10 + 10, 30, 1},
-   /* C3 */
-   {50 + 50, 300, 1},
-   /* C4 */
-   {1500 + 1800, 4000, 1},
-   /* C5 */
-   {2500 + 7500, 12000, 1},
-   /* C6 */
-   {3000 + 8500, 15000, 1},
-   /* C7 */
-   {1 + 3, 30, 1},
-};
-#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
 };
+
+#define OMAP3_NUM_STATES 7
+
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 5646b80..7856489 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -38,18 +38,6 @@ static inline int omap4_opp_init(void)
 }
 #endif
 
-/*
- * cpuidle mach specific parameters
- *
- * The board code can override the default C-states definition using
- * omap3_pm_init_cpuidle
- */
-struct cpuidle_params {
-   u32 exit_latency;   /* exit_latency = sleep + wake-up latencies */
-   u32 target_residency;
-   u8 valid;   /* validates the C-state */
-};
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/17][V2] ARM: OMAP3: cpuidle - remove the 'valid' field

2012-04-04 Thread Daniel Lezcano
With the previous changes all the states are valid, except
the last state which can be handled by decreasing the number
of states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 11a2c23..3f46e45 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -67,7 +67,6 @@ static struct cpuidle_params cpuidle_params_table[] = {
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
-   u8 valid;
 };
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
@@ -191,8 +190,7 @@ static int next_valid_state(struct cpuidle_device *dev,
}
 
/* Check if current state is valid */
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
+   if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
return index;
} else {
@@ -216,8 +214,7 @@ static int next_valid_state(struct cpuidle_device *dev,
idx--;
for (; idx = 0; idx--) {
cx = cpuidle_get_statedata(dev-states_usage[idx]);
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
+   if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
next_index = idx;
break;
@@ -371,7 +368,6 @@ static inline struct omap3_idle_statedata 
*_fill_cstate_usage(
struct omap3_idle_statedata *cx = omap3_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -399,7 +395,6 @@ int __init omap3_idle_init(void)
 
/* C1 . MPU WFI + Core active */
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
@@ -436,14 +431,13 @@ int __init omap3_idle_init(void)
 * We disable C7 state as a result.
 */
if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583)) {
-   cx-valid = 0;
+   drv-state_count = OMAP3_NUM_STATES - 1;
pr_warn(%s: core off state C7 disabled due to i583\n,
__func__);
}
cx-mpu_state = PWRDM_POWER_OFF;
cx-core_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP3_NUM_STATES;
cpuidle_register_driver(omap3_idle_driver);
 
if (cpuidle_register_device(dev)) {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/17][V2] ARM: OMAP3: define statically the omap3_idle_data

2012-04-04 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   31 ++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index cdf1b8f..332b636 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -46,7 +46,36 @@ struct omap3_idle_statedata {
 
 #define OMAP3_NUM_STATES 7
 
-struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
+struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES] = {
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_OFF,
+   },
+};
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/17][V2] ARM: OMAP3: cpuidle - use omap3_idle_data directly

2012-04-04 Thread Daniel Lezcano
We are storing the 'omap3_idle_data' in the private data field
of the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly
instead dereferencing pointers in an idle critical loop.

As the table is initialized statically, let's remove the initialization at
startup too.

Also, that simplfies the code.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   65 
 1 files changed, 8 insertions(+), 57 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 332b636..e4738eb 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -97,8 +97,7 @@ static int __omap3_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap3_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_state = cx-mpu_state, core_state = cx-core_state;
 
local_fiq_disable();
@@ -178,9 +177,8 @@ static int next_valid_state(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct cpuidle_state_usage *curr_usage = dev-states_usage[index];
struct cpuidle_state *curr = drv-states[index];
-   struct omap3_idle_statedata *cx = cpuidle_get_statedata(curr_usage);
+   struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET;
int next_index = -1;
@@ -220,7 +218,7 @@ static int next_valid_state(struct cpuidle_device *dev,
 */
idx--;
for (; idx = 0; idx--) {
-   cx = cpuidle_get_statedata(dev-states_usage[idx]);
+   cx =  omap3_idle_data[idx];
if ((cx-mpu_state = mpu_deepest_state) 
(cx-core_state = core_deepest_state)) {
next_index = idx;
@@ -277,7 +275,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 * Prevent PER off if CORE is not in retention or off as this
 * would disable PER wakeups completely.
 */
-   cx = cpuidle_get_statedata(dev-states_usage[index]);
+   cx = omap3_idle_data[index];
core_next_state = cx-core_state;
per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
if ((per_next_state == PWRDM_POWER_OFF) 
@@ -367,19 +365,6 @@ struct cpuidle_driver omap3_idle_driver = {
.safe_state_index = 0,
 };
 
-/* Helper to register the driver_data */
-static inline struct omap3_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap3_idle_statedata *cx = omap3_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
-   return cx;
-}
-
 /**
  * omap3_idle_init - Init routine for OMAP3 idle
  *
@@ -390,48 +375,12 @@ int __init omap3_idle_init(void)
 {
struct cpuidle_device *dev;
struct cpuidle_driver *drv = omap3_idle_driver;
-   struct omap3_idle_statedata *cx;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
core_pd = pwrdm_lookup(core_pwrdm);
per_pd = pwrdm_lookup(per_pwrdm);
cam_pd = pwrdm_lookup(cam_pwrdm);
 
-
-   dev = per_cpu(omap3_idle_dev, smp_processor_id());
-
-   /* C1 . MPU WFI + Core active */
-   cx = _fill_cstate_usage(dev, 0);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C2 . MPU WFI + Core inactive */
-   cx = _fill_cstate_usage(dev, 1);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C3 . MPU CSWR + Core inactive */
-   cx = _fill_cstate_usage(dev, 2);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C4 . MPU OFF + Core inactive */
-   cx = _fill_cstate_usage(dev, 3);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C5 . MPU RET + Core RET */
-   cx = _fill_cstate_usage(dev, 4);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C6 . MPU OFF + Core RET */
-   cx = _fill_cstate_usage(dev, 5);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C7 . MPU OFF + Core OFF */
-   cx = _fill_cstate_usage(dev, 6);
/*
 * Erratum i583: implementation for ES rev  Es1.2 on 3630. We cannot
 * enable OFF mode

[PATCH 14/17][V2] ARM: OMAP3 : cpuidle - simplify next_valid_state

2012-04-04 Thread Daniel Lezcano
Simplify the indentation by removing the useless 'else' statement.
Remove the first loop for the 'idx' search as we have it already
with the 'index' passed as parameter.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |   53 +---
 1 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index e4738eb..35a1471 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -174,13 +174,12 @@ static inline int omap3_enter_idle(struct cpuidle_device 
*dev,
  * if it satisfies the enable_off_mode condition.
  */
 static int next_valid_state(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
+   struct cpuidle_driver *drv, int index)
 {
-   struct cpuidle_state *curr = drv-states[index];
struct omap3_idle_statedata *cx = omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET;
+   int idx;
int next_index = -1;
 
if (enable_off_mode) {
@@ -196,42 +195,28 @@ static int next_valid_state(struct cpuidle_device *dev,
 
/* Check if current state is valid */
if ((cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
+   (cx-core_state = core_deepest_state))
return index;
-   } else {
-   int idx = OMAP3_NUM_STATES - 1;
-
-   /* Reach the current state starting at highest C-state */
-   for (; idx = 0; idx--) {
-   if (drv-states[idx] == curr) {
-   next_index = idx;
-   break;
-   }
-   }
-
-   /* Should never hit this condition */
-   WARN_ON(next_index == -1);
 
-   /*
-* Drop to next valid state.
-* Start search from the next (lower) state.
-*/
-   idx--;
-   for (; idx = 0; idx--) {
-   cx =  omap3_idle_data[idx];
-   if ((cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
-   next_index = idx;
-   break;
-   }
+   /*
+* Drop to next valid state.
+* Start search from the next (lower) state.
+*/
+   for (idx = index - 1; idx = 0; idx--) {
+   cx =  omap3_idle_data[idx];
+   if ((cx-mpu_state = mpu_deepest_state) 
+   (cx-core_state = core_deepest_state)) {
+   next_index = idx;
+   break;
}
-   /*
-* C1 is always valid.
-* So, no need to check for 'next_index == -1' outside
-* this loop.
-*/
}
 
+   /*
+* C1 is always valid.
+* So, no need to check for 'next_index == -1' outside
+* this loop.
+*/
+
return next_index;
 }
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/17][V2] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-04-04 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |8 
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 49f92bc..f46c735 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,10 +64,8 @@ endif
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
-obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o \
-  cpuidle34xx.o
-obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o \
-  cpuidle44xx.o
+obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o
+obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)  += smartreflex-class3.o
@@ -81,6 +79,11 @@ endif
 
 endif
 
+ifeq ($(CONFIG_CPU_IDLE),y)
+obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
+obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
+endif
+
 # PRCM
 obj-y  += prm_common.o
 obj-$(CONFIG_ARCH_OMAP2)   += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index f54e6ae..882d349 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
 #include control.h
 #include common.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
@@ -391,9 +389,3 @@ int __init omap3_idle_init(void)
 
return 0;
 }
-#else
-int __init omap3_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index b0dd220..41303a7 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,8 +22,6 @@
 #include pm.h
 #include prm.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
@@ -204,9 +202,3 @@ int __init omap4_idle_init(void)
 
return 0;
 }
-#else
-int __init omap4_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 7856489..ab04d3b 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,12 +15,25 @@
 
 #include powerdomain.h
 
+#ifdef CONFIG_CPU_IDLE
+extern int __init omap3_idle_init(void);
+extern int __init omap4_idle_init(void);
+#else
+static inline int omap3_idle_init(void)
+{
+   return 0;
+}
+
+static inline int omap4_idle_init(void)
+{
+   return 0;
+}
+#endif
+
 extern void *omap3_secure_ram_storage;
 extern void omap3_pm_off_mode_enable(int);
 extern void omap_sram_idle(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
-extern int omap3_idle_init(void);
-extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/17][V2] ARM: OMAP3: cpuidle - set global variables static

2012-04-04 Thread Daniel Lezcano
and check the powerdomain lookup is successful.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
---
 arch/arm/mach-omap2/cpuidle34xx.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 882d349..413aac4 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -75,7 +75,7 @@ static struct omap3_idle_statedata 
omap3_idle_data[OMAP3_NUM_STATES] = {
},
 };
 
-struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
+static struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
 
 static int _cpuidle_allow_idle(struct powerdomain *pwrdm,
struct clockdomain *clkdm)
@@ -364,6 +364,9 @@ int __init omap3_idle_init(void)
per_pd = pwrdm_lookup(per_pwrdm);
cam_pd = pwrdm_lookup(cam_pwrdm);
 
+   if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
+   return -ENODEV;
+
/*
 * Erratum i583: implementation for ES rev  Es1.2 on 3630. We cannot
 * enable OFF mode in a stable form for previous revisions.
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/17][V2] ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration

2012-04-04 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
Reviewed-by: Jean Pihet j-pi...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/cpuidle44xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index cdd7932..fb0f76e 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,7 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
+static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 1/9] ARM: OMAP3: cpuidle - remove rx51 cpuidle parameters table

2012-03-23 Thread Daniel Lezcano
As suggested, this table is an optimized version for rx51 and we
remove it in order to consolidate the cpuidle code between omap3
and omap4, we remove this specific data definition which is used
to override the default omap3 latencies but at the cost of extra
code and complexity.

In order to not lose the values which probably took time to be
measured, the table is converted into a comment with an array
description.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/board-rx51.c  |   38 +---
 arch/arm/mach-omap2/cpuidle34xx.c |   17 
 arch/arm/mach-omap2/pm.h  |9 
 3 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 27f01f0..2da92a6 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -59,25 +59,24 @@ static struct platform_device leds_gpio = {
 };
 
 /*
- * cpuidle C-states definition override from the default values.
- * The 'exit_latency' field is the sum of sleep and wake-up latencies.
- */
-static struct cpuidle_params rx51_cpuidle_params[] = {
-   /* C1 */
-   {110 + 162, 5 , 1},
-   /* C2 */
-   {106 + 180, 309, 1},
-   /* C3 */
-   {107 + 410, 46057, 0},
-   /* C4 */
-   {121 + 3374, 46057, 0},
-   /* C5 */
-   {855 + 1146, 46057, 1},
-   /* C6 */
-   {7580 + 4134, 484329, 0},
-   /* C7 */
-   {7505 + 15274, 484329, 1},
-};
+ * cpuidle C-states definition for rx51.
+ *
+ * The 'exit_latency' field is the sum of sleep
+ * and wake-up latencies.
+
+-
+   | state |  exit_latency  |  target_residency  |
+-
+   |  C1   |110 + 162   |5   |
+   |  C2   |106 + 180   |  309   |
+   |  C3   |107 + 410   |46057   |
+   |  C4   |121 + 3374  |46057   |
+   |  C5   |855 + 1146  |46057   |
+   |  C6   |   7580 + 4134  |   484329   |
+   |  C7   |   7505 + 15274 |   484329   |
+-
+
+*/
 
 extern void __init rx51_peripherals_init(void);
 
@@ -98,7 +97,6 @@ static void __init rx51_init(void)
struct omap_sdrc_params *sdrc_params;
 
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
-   omap3_pm_init_cpuidle(rx51_cpuidle_params);
omap_serial_init();
 
sdrc_params = nokia_get_sdram_timings();
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 464cffd..d67431a 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -306,23 +306,6 @@ select_state:
 
 DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 
-void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-   int i;
-
-   if (!cpuidle_board_params)
-   return;
-
-   for (i = 0; i  OMAP3_NUM_STATES; i++) {
-   cpuidle_params_table[i].valid = cpuidle_board_params[i].valid;
-   cpuidle_params_table[i].exit_latency =
-   cpuidle_board_params[i].exit_latency;
-   cpuidle_params_table[i].target_residency =
-   cpuidle_board_params[i].target_residency;
-   }
-   return;
-}
-
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index a051431..af73a86 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -51,15 +51,6 @@ struct cpuidle_params {
u8 valid;   /* validates the C-state */
 };
 
-#if defined(CONFIG_PM)  defined(CONFIG_CPU_IDLE)
-extern void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params);
-#else
-static
-inline void omap3_pm_init_cpuidle(struct cpuidle_params *cpuidle_board_params)
-{
-}
-#endif
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 3/9] ARM: OMAP3: cpuidle - set enable_off_mode as static

2012-03-23 Thread Daniel Lezcano
This variable is only used in the pm-debug.c file.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/pm-debug.c |2 +-
 arch/arm/mach-omap2/pm.h   |   30 --
 2 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 814bcd9..86aa398 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -38,7 +38,7 @@
 #include prm2xxx_3xxx.h
 #include pm.h
 
-u32 enable_off_mode;
+static u32 enable_off_mode;
 
 #ifdef CONFIG_DEBUG_FS
 #include linux/debugfs.h
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index af73a86..f5c3072 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -25,6 +25,18 @@ extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
+/*
+ * cpuidle mach specific parameters
+ *
+ * The board code can override the default C-states definition using
+ * omap3_pm_init_cpuidle
+ */
+struct cpuidle_params {
+   u32 exit_latency;   /* exit_latency = sleep + wake-up latencies */
+   u32 target_residency;
+   u8 valid;   /* validates the C-state */
+};
+
 #if defined(CONFIG_PM_OPP)
 extern int omap3_opp_init(void);
 extern int omap4_opp_init(void);
@@ -39,27 +51,9 @@ static inline int omap4_opp_init(void)
 }
 #endif
 
-/*
- * cpuidle mach specific parameters
- *
- * The board code can override the default C-states definition using
- * omap3_pm_init_cpuidle
- */
-struct cpuidle_params {
-   u32 exit_latency;   /* exit_latency = sleep + wake-up latencies */
-   u32 target_residency;
-   u8 valid;   /* validates the C-state */
-};
-
 extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm);
 extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state);
 
-#ifdef CONFIG_PM_DEBUG
-extern u32 enable_off_mode;
-#else
-#define enable_off_mode 0
-#endif
-
 #if defined(CONFIG_PM_DEBUG)  defined(CONFIG_DEBUG_FS)
 extern void pm_dbg_update_time(struct powerdomain *pwrdm, int prev);
 #else
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 4/9] ARM: OMAP3: define cpuidle statically

2012-03-23 Thread Daniel Lezcano
Use the new cpuidle API and define in the driver the states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   85 +---
 1 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 65b4e7aa..62e3cfd 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -228,23 +228,67 @@ DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
 struct cpuidle_driver omap3_idle_driver = {
.name = omap3_idle,
.owner =THIS_MODULE,
+   .states = {
+   {
+   .enter= omap3_enter_idle,
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C1,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 10 + 10,
+   .target_residency = 30,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C2,
+   .desc = MPU ON + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 50 + 50,
+   .target_residency = 300,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C3,
+   .desc = MPU RET + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1500 + 1800,
+   .target_residency = 4000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C4,
+   .desc = MPU OFF + CORE ON,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 2500 + 7500,
+   .target_residency = 12000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C5,
+   .desc = MPU RET + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 3000 + 8500,
+   .target_residency = 15000,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C6,
+   .desc = MPU OFF + CORE RET,
+   },
+   {
+   .enter= omap3_enter_idle_bm,
+   .exit_latency = 1 + 3,
+   .target_residency = 3,
+   .flags= CPUIDLE_FLAG_TIME_VALID,
+   .name = C7,
+   .desc = MPU OFF + CORE OFF,
+   },
+   },
+   .state_count = OMAP3_NUM_STATES,
 };
 
-/* Helper to fill the C-state common data*/
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap3_enter_idle_bm;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-
-}
-
 /* Helper to register the driver_data */
 static inline struct omap3_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
@@ -277,50 +321,40 @@ int __init omap3_idle_init(void)
cam_pd = pwrdm_lookup(cam_pwrdm);
 
 
-   drv-safe_state_index = -1;
dev = per_cpu(omap3_idle_dev, smp_processor_id());
 
/* C1 . MPU WFI + Core active */
-   _fill_cstate(drv, 0, MPU ON + CORE ON);
-   (drv-states[0])-enter = omap3_enter_idle;
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
/* C2 . MPU WFI + Core inactive */
-   _fill_cstate(drv, 1, MPU ON + CORE ON);
cx = _fill_cstate_usage(dev, 1);
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
/* C3 . MPU CSWR + Core inactive

[RFC][PATCH 5/9] ARM: OMAP3: cpuidle - remove the 'valid' field

2012-03-23 Thread Daniel Lezcano
With the previous changes all the states are valid, except
the last state which can be handled by decreasing the number
of states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |6 +-
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 62e3cfd..39aa1b8 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -67,7 +67,6 @@ static struct cpuidle_params cpuidle_params_table[] = {
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
-   u8 valid;
 };
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
@@ -297,7 +296,6 @@ static inline struct omap3_idle_statedata 
*_fill_cstate_usage(
struct omap3_idle_statedata *cx = omap3_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -325,7 +323,6 @@ int __init omap3_idle_init(void)
 
/* C1 . MPU WFI + Core active */
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-mpu_state = PWRDM_POWER_ON;
cx-core_state = PWRDM_POWER_ON;
 
@@ -362,14 +359,13 @@ int __init omap3_idle_init(void)
 * We disable C7 state as a result.
 */
if (IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583)) {
-   cx-valid = 0;
+   drv-state_count = OMAP3_NUM_STATES - 1;
pr_warn(%s: core off state C7 disabled due to i583\n,
__func__);
}
cx-mpu_state = PWRDM_POWER_OFF;
cx-core_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP3_NUM_STATES;
cpuidle_register_driver(omap3_idle_driver);
 
if (cpuidle_register_device(dev)) {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 2/9] ARM: OMAP3: cpuidle - remove next_valid_state function

2012-03-23 Thread Daniel Lezcano
As we will be able to remove C-states from userspace with the sysfs
API, this function is no longer needed. We remove it and that simplifies
the code for more consolidation.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   85 +
 1 files changed, 2 insertions(+), 83 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index d67431a..65b4e7aa 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -164,84 +164,6 @@ return_sleep_time:
 }
 
 /**
- * next_valid_state - Find next valid C-state
- * @dev: cpuidle device
- * @drv: cpuidle driver
- * @index: Index of currently selected c-state
- *
- * If the state corresponding to index is valid, index is returned back
- * to the caller. Else, this function searches for a lower c-state which is
- * still valid (as defined in omap3_power_states[]) and returns its index.
- *
- * A state is valid if the 'valid' field is enabled and
- * if it satisfies the enable_off_mode condition.
- */
-static int next_valid_state(struct cpuidle_device *dev,
-   struct cpuidle_driver *drv,
-   int index)
-{
-   struct cpuidle_state_usage *curr_usage = dev-states_usage[index];
-   struct cpuidle_state *curr = drv-states[index];
-   struct omap3_idle_statedata *cx = cpuidle_get_statedata(curr_usage);
-   u32 mpu_deepest_state = PWRDM_POWER_RET;
-   u32 core_deepest_state = PWRDM_POWER_RET;
-   int next_index = -1;
-
-   if (enable_off_mode) {
-   mpu_deepest_state = PWRDM_POWER_OFF;
-   /*
-* Erratum i583: valable for ES rev  Es1.2 on 3630.
-* CORE OFF mode is not supported in a stable form, restrict
-* instead the CORE state to RET.
-*/
-   if (!IS_PM34XX_ERRATUM(PM_SDRC_WAKEUP_ERRATUM_i583))
-   core_deepest_state = PWRDM_POWER_OFF;
-   }
-
-   /* Check if current state is valid */
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
-   return index;
-   } else {
-   int idx = OMAP3_NUM_STATES - 1;
-
-   /* Reach the current state starting at highest C-state */
-   for (; idx = 0; idx--) {
-   if (drv-states[idx] == curr) {
-   next_index = idx;
-   break;
-   }
-   }
-
-   /* Should never hit this condition */
-   WARN_ON(next_index == -1);
-
-   /*
-* Drop to next valid state.
-* Start search from the next (lower) state.
-*/
-   idx--;
-   for (; idx = 0; idx--) {
-   cx = cpuidle_get_statedata(dev-states_usage[idx]);
-   if ((cx-valid) 
-   (cx-mpu_state = mpu_deepest_state) 
-   (cx-core_state = core_deepest_state)) {
-   next_index = idx;
-   break;
-   }
-   }
-   /*
-* C1 is always valid.
-* So, no need to check for 'next_index == -1' outside
-* this loop.
-*/
-   }
-
-   return next_index;
-}
-
-/**
  * omap3_enter_idle_bm - Checks for any bus activity
  * @dev: cpuidle device
  * @drv: cpuidle driver
@@ -254,7 +176,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
   int index)
 {
-   int new_state_idx;
u32 core_next_state, per_next_state = 0, per_saved_state = 0, cam_state;
struct omap3_idle_statedata *cx;
int ret;
@@ -265,7 +186,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 */
cam_state = pwrdm_read_pwrst(cam_pd);
if (cam_state == PWRDM_POWER_ON) {
-   new_state_idx = drv-safe_state_index;
+   index = drv-safe_state_index;
goto select_state;
}
 
@@ -292,10 +213,8 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
if (per_next_state != per_saved_state)
pwrdm_set_next_pwrst(per_pd, per_next_state);
 
-   new_state_idx = next_valid_state(dev, drv, index);
-
 select_state:
-   ret = omap3_enter_idle(dev, drv, new_state_idx);
+   ret = omap3_enter_idle(dev, drv, index);
 
/* Restore original PER state if it was modified */
if (per_next_state != per_saved_state)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org

[RFC][PATCH 6/9] ARM: OMAP3: cpuidle - remove cpuidle_params_table

2012-03-23 Thread Daniel Lezcano
We do not longer need the ''cpuidle_params_table' array as
we defined the states in the driver and we checked they are
all valid.

We also remove the structure definition as it is no longer used.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   28 +++-
 arch/arm/mach-omap2/pm.h  |   12 
 2 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 39aa1b8..877a7e1 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -38,36 +38,14 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/*
- * The latencies/thresholds for various C states have
- * to be configured from the respective board files.
- * These are some default values (which might not provide
- * the best power savings) used on boards which do not
- * pass these details from the board file.
- */
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 */
-   {2 + 2, 5, 1},
-   /* C2 */
-   {10 + 10, 30, 1},
-   /* C3 */
-   {50 + 50, 300, 1},
-   /* C4 */
-   {1500 + 1800, 4000, 1},
-   /* C5 */
-   {2500 + 7500, 12000, 1},
-   /* C6 */
-   {3000 + 8500, 15000, 1},
-   /* C7 */
-   {1 + 3, 30, 1},
-};
-#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
u32 core_state;
 };
+
+#define OMAP3_NUM_STATES 7
+
 struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index f5c3072..a41c8dd 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -25,18 +25,6 @@ extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-/*
- * cpuidle mach specific parameters
- *
- * The board code can override the default C-states definition using
- * omap3_pm_init_cpuidle
- */
-struct cpuidle_params {
-   u32 exit_latency;   /* exit_latency = sleep + wake-up latencies */
-   u32 target_residency;
-   u8 valid;   /* validates the C-state */
-};
-
 #if defined(CONFIG_PM_OPP)
 extern int omap3_opp_init(void);
 extern int omap4_opp_init(void);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 7/9] ARM: OMAP3: define statically the omap3_idle_data

2012-03-23 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   31 ++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 877a7e1..34e1e34 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -46,7 +46,36 @@ struct omap3_idle_statedata {
 
 #define OMAP3_NUM_STATES 7
 
-struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES];
+struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES] = {
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_ON,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_ON,
+   },
+   {
+   .mpu_state = PWRDM_POWER_RET,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_RET,
+   },
+   {
+   .mpu_state = PWRDM_POWER_OFF,
+   .core_state = PWRDM_POWER_OFF,
+   },
+};
 
 struct powerdomain *mpu_pd, *core_pd, *per_pd, *cam_pd;
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 8/9] ARM: OMAP3: cpuidle - use omap3_idle_data directly

2012-03-23 Thread Daniel Lezcano
We are storing the 'omap3_idle_data' in the private data field
if the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly
instead dereferencing pointers in an idle critical loop.

As the table is initialized statically, let's remove the initialization at
startup too.

Also, that simplfies the code.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle34xx.c |   60 -
 1 files changed, 6 insertions(+), 54 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 34e1e34..726f0bf 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -106,8 +106,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap3_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap3_idle_statedata *cx = omap3_idle_data[index];
struct timespec ts_preidle, ts_postidle, ts_idle;
u32 mpu_state = cx-mpu_state, core_state = cx-core_state;
int idle_time;
@@ -208,7 +207,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
 * Prevent PER off if CORE is not in retention or off as this
 * would disable PER wakeups completely.
 */
-   cx = cpuidle_get_statedata(dev-states_usage[index]);
+   cx = omap3_idle_data[index];
core_next_state = cx-core_state;
per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
if ((per_next_state == PWRDM_POWER_OFF) 
@@ -295,19 +294,6 @@ struct cpuidle_driver omap3_idle_driver = {
.state_count = OMAP3_NUM_STATES,
 };
 
-/* Helper to register the driver_data */
-static inline struct omap3_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap3_idle_statedata *cx = omap3_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
-   return cx;
-}
-
 /**
  * omap3_idle_init - Init routine for OMAP3 idle
  *
@@ -318,48 +304,12 @@ int __init omap3_idle_init(void)
 {
struct cpuidle_device *dev;
struct cpuidle_driver *drv = omap3_idle_driver;
-   struct omap3_idle_statedata *cx;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
core_pd = pwrdm_lookup(core_pwrdm);
per_pd = pwrdm_lookup(per_pwrdm);
cam_pd = pwrdm_lookup(cam_pwrdm);
 
-
-   dev = per_cpu(omap3_idle_dev, smp_processor_id());
-
-   /* C1 . MPU WFI + Core active */
-   cx = _fill_cstate_usage(dev, 0);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C2 . MPU WFI + Core inactive */
-   cx = _fill_cstate_usage(dev, 1);
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C3 . MPU CSWR + Core inactive */
-   cx = _fill_cstate_usage(dev, 2);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C4 . MPU OFF + Core inactive */
-   cx = _fill_cstate_usage(dev, 3);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_ON;
-
-   /* C5 . MPU RET + Core RET */
-   cx = _fill_cstate_usage(dev, 4);
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C6 . MPU OFF + Core RET */
-   cx = _fill_cstate_usage(dev, 5);
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_RET;
-
-   /* C7 . MPU OFF + Core OFF */
-   cx = _fill_cstate_usage(dev, 6);
/*
 * Erratum i583: implementation for ES rev  Es1.2 on 3630. We cannot
 * enable OFF mode in a stable form for previous revisions.
@@ -370,11 +320,13 @@ int __init omap3_idle_init(void)
pr_warn(%s: core off state C7 disabled due to i583\n,
__func__);
}
-   cx-mpu_state = PWRDM_POWER_OFF;
-   cx-core_state = PWRDM_POWER_OFF;
 
cpuidle_register_driver(omap3_idle_driver);
 
+   dev = per_cpu(omap3_idle_dev, smp_processor_id());
+   dev-cpu = 0;
+   dev-state_count = drv-state_count;
+
if (cpuidle_register_device(dev)) {
printk(KERN_ERR %s: CPUidle register device failed\n,
   __func__);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 9/9] ARM: OMAP3/4: consolidate cpuidle Makefile

2012-03-23 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/Makefile  |   11 +++
 arch/arm/mach-omap2/cpuidle34xx.c |8 
 arch/arm/mach-omap2/cpuidle44xx.c |8 
 arch/arm/mach-omap2/pm.h  |   17 +++--
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bd76394..93819c4 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -63,10 +63,8 @@ endif
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)   += pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)   += sleep24xx.o
-obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o \
-  cpuidle34xx.o
-obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o \
-  cpuidle44xx.o
+obj-$(CONFIG_ARCH_OMAP3)   += pm34xx.o sleep34xx.o
+obj-$(CONFIG_ARCH_OMAP4)   += pm44xx.o omap-mpuss-lowpower.o
 obj-$(CONFIG_PM_DEBUG) += pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)  += sr_device.o smartreflex.o
 obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)  += smartreflex-class3.o
@@ -80,6 +78,11 @@ endif
 
 endif
 
+ifeq ($(CONFIG_CPU_IDLE),y)
+obj-$(CONFIG_ARCH_OMAP3)+= cpuidle34xx.o
+obj-$(CONFIG_ARCH_OMAP4)+= cpuidle44xx.o
+endif
+
 # PRCM
 obj-y  += prm_common.o
 obj-$(CONFIG_ARCH_OMAP2)   += prcm.o cm2xxx_3xxx.o prm2xxx_3xxx.o
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c 
b/arch/arm/mach-omap2/cpuidle34xx.c
index 726f0bf..579424c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -36,8 +36,6 @@
 #include control.h
 #include common.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Mach specific information to be recorded in the C-state driver_data */
 struct omap3_idle_statedata {
u32 mpu_state;
@@ -335,9 +333,3 @@ int __init omap3_idle_init(void)
 
return 0;
 }
-#else
-int __init omap3_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index f6a6194..d251187 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -22,8 +22,6 @@
 #include pm.h
 #include prm.h
 
-#ifdef CONFIG_CPU_IDLE
-
 /* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
@@ -219,9 +217,3 @@ int __init omap4_idle_init(void)
 
return 0;
 }
-#else
-int __init omap4_idle_init(void)
-{
-   return 0;
-}
-#endif /* CONFIG_CPU_IDLE */
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index a41c8dd..d9a97e8 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -15,13 +15,26 @@
 
 #include powerdomain.h
 
+#ifdef CONFIG_CPU_IDLE
+extern int omap3_idle_init(void);
+extern int omap4_idle_init(void);
+#else
+static inline int omap3_idle_init(void)
+{
+   return 0;
+}
+
+static inline int omap4_idle_init(void)
+{
+   return 0;
+}
+#endif
+
 extern void *omap3_secure_ram_storage;
 extern void omap3_pm_off_mode_enable(int);
 extern void omap_sram_idle(void);
 extern int omap3_can_sleep(void);
 extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
-extern int omap3_idle_init(void);
-extern int omap4_idle_init(void);
 extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
 extern int (*omap_pm_suspend)(void);
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 4/9] ARM: OMAP3: define cpuidle statically

2012-03-23 Thread Daniel Lezcano

On 03/23/2012 01:35 PM, Jean Pihet wrote:

On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
daniel.lezc...@linaro.org  wrote:

Use the new cpuidle API and define in the driver the states.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
---


[ ... ]


/*
 * Erratum i583: implementation for ES rev  Es1.2 on 3630. We cannot

C7 is enabled only if the errata does not apply.
This causes a problem with the statically defined C-states and also
with the per C-state sysfs disable knob. A consistency check should be
performed before trying to enter a state.


In the patch 5/9, I decrement the state_count if the errata applies. I 
believe it is still compatible with the static C-states.



@@ -338,7 +372,6 @@ int __init omap3_idle_init(void)
drv-state_count = OMAP3_NUM_STATES;
cpuidle_register_driver(omap3_idle_driver);

-   dev-state_count = OMAP3_NUM_STATES;
if (cpuidle_register_device(dev)) {
printk(KERN_ERR %s: CPUidle register device failed\n,
   __func__);
--
1.7.5.4



Thanks!
Jean



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano
This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.

A couple a things call my intention. Why the cpuidle device is set for cpu0 only
and why the WFI is not used ?

Daniel Lezcano (7):
  ARM: OMAP4: cpuidle - Remove unused valid field
  ARM: OMAP4: cpuidle - Declare the states with the driver declaration
  ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
  ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
  ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
  ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
  ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
time

 arch/arm/mach-omap2/cpuidle44xx.c |  126 -
 1 files changed, 54 insertions(+), 72 deletions(-)

-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 1/7] ARM: OMAP4: cpuidle - Remove unused valid field

2012-03-21 Thread Daniel Lezcano
The 'valid' field is never used in the code, let's remove it.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index cfdbb86..1210229 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -29,16 +29,15 @@ struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
u32 mpu_state;
-   u8 valid;
 };
 
 static struct cpuidle_params cpuidle_params_table[] = {
/* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5, .valid = 1},
+   {.exit_latency = 2 + 2 , .target_residency = 5 },
/* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960, .valid = 1},
+   {.exit_latency = 328 + 440 , .target_residency = 960 },
/* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100, .valid = 1},
+   {.exit_latency = 460 + 518 , .target_residency = 1100 },
 };
 
 #define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
@@ -171,7 +170,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
 
-   cx-valid   = cpuidle_params_table[idx].valid;
cpuidle_set_statedata(state_usage, cx);
 
return cx;
@@ -207,7 +205,6 @@ int __init omap4_idle_init(void)
_fill_cstate(drv, 0, MPUSS ON);
drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
-   cx-valid = 1;  /* C1 is always valid */
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 2/7] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-03-21 Thread Daniel Lezcano
The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |   56 +
 1 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 1210229..cd6bee7 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -148,21 +148,38 @@ DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
 struct cpuidle_driver omap4_idle_driver = {
.name = omap4_idle,
.owner =THIS_MODULE,
+   .states = {
+   {
+   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C1,
+   .desc = MPUSS ON
+   },
+   {
+/* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
+   .exit_latency = 328 + 440,
+   .target_residency = 960,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C2,
+   .desc = MPUSS CSWR,
+   },
+   {
+   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
+   .exit_latency = 460 + 518,
+   .target_residency = 1100,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C3,
+   .desc = MPUSS OSWR,
+   },
+   },
+   .state_count = OMAP4_NUM_STATES,
 };
 
-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state = drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap4_enter_idle;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-}
-
 static inline struct omap4_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
int idx)
@@ -196,37 +213,28 @@ int __init omap4_idle_init(void)
if ((!mpu_pd) || (!cpu0_pd) || (!cpu1_pd))
return -ENODEV;
 
-
-   drv-safe_state_index = -1;
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   _fill_cstate(drv, 0, MPUSS ON);
-   drv-safe_state_index = 0;
cx = _fill_cstate_usage(dev, 0);
cx-cpu_state = PWRDM_POWER_ON;
cx-mpu_state = PWRDM_POWER_ON;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */
-   _fill_cstate(drv, 1, MPUSS CSWR);
cx = _fill_cstate_usage(dev, 1);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_RET;
 
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   _fill_cstate(drv, 2, MPUSS OSWR);
cx = _fill_cstate_usage(dev, 2);
cx-cpu_state = PWRDM_POWER_OFF;
cx-mpu_state = PWRDM_POWER_RET;
cx-mpu_logic_state = PWRDM_POWER_OFF;
 
-   drv-state_count = OMAP4_NUM_STATES;
cpuidle_register_driver(omap4_idle_driver);
 
-   dev-state_count = OMAP4_NUM_STATES;
+   dev-state_count = drv-state_count;
+
if (cpuidle_register_device(dev)) {
pr_err(%s: CPUidle register device failed\n, __func__);
return -EIO;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 3/7] ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table

2012-03-21 Thread Daniel Lezcano
We do not longer need this table as we defined the values
in the driver states.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |   11 +--
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index cd6bee7..0455858 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -31,16 +31,7 @@ struct omap4_idle_statedata {
u32 mpu_state;
 };
 
-static struct cpuidle_params cpuidle_params_table[] = {
-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   {.exit_latency = 2 + 2 , .target_residency = 5 },
-   /* C2- CPU0 OFF + CPU1 OFF + MPU CSWR */
-   {.exit_latency = 328 + 440 , .target_residency = 960 },
-   /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */
-   {.exit_latency = 460 + 518 , .target_residency = 1100 },
-};
-
-#define OMAP4_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
+#define OMAP4_NUM_STATES 3
 
 struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 4/7] ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration

2012-03-21 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 0455858..254f97b 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,7 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
+static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 5/7] ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time

2012-03-21 Thread Daniel Lezcano
Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |   19 ++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 254f97b..e14cd56 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,24 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES];
+static struct omap4_idle_statedata omap4_idle_data[] = {
+   {
+   .cpu_state = PWRDM_POWER_ON,
+   .mpu_state = PWRDM_POWER_ON,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_RET,
+   },
+   {
+   .cpu_state = PWRDM_POWER_OFF,
+   .mpu_state = PWRDM_POWER_RET,
+   .mpu_logic_state = PWRDM_POWER_OFF,
+   },
+};
+
 static struct powerdomain *mpu_pd, *cpu0_pd, *cpu1_pd;
 
 /**
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 6/7] ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly

2012-03-21 Thread Daniel Lezcano
We are storing the 'omap4_idle_data' in the private data field
if the cpuidle device. As we are using this variable only in this file,
that does not really make sense. Let's use the global variable directly
instead dereferencing pointers in an idle critical loop.

Also, that simplfies the code.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |   17 +
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index e14cd56..cb91d1f 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -24,7 +24,7 @@
 
 #ifdef CONFIG_CPU_IDLE
 
-/* Machine specific information to be recorded in the C-state driver_data */
+/* Machine specific information */
 struct omap4_idle_statedata {
u32 cpu_state;
u32 mpu_logic_state;
@@ -67,8 +67,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
 {
-   struct omap4_idle_statedata *cx =
-   cpuidle_get_statedata(dev-states_usage[index]);
+   struct omap4_idle_statedata *cx = omap4_idle_data[index];
struct timespec ts_preidle, ts_postidle, ts_idle;
u32 cpu1_state;
int idle_time;
@@ -92,7 +91,7 @@ static int omap4_enter_idle(struct cpuidle_device *dev,
cpu1_state = pwrdm_read_pwrst(cpu1_pd);
if (cpu1_state != PWRDM_POWER_OFF) {
new_state_idx = drv-safe_state_index;
-   cx = cpuidle_get_statedata(dev-states_usage[new_state_idx]);
+   cx = omap4_idle_data[new_state_idx]
}
 
if (index  0)
@@ -193,15 +192,9 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
int idx)
 {
struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   struct cpuidle_state_usage *state_usage = dev-states_usage[idx];
-
-   cpuidle_set_statedata(state_usage, cx);
-
return cx;
 }
 
-
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
@@ -210,9 +203,9 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
  */
 int __init omap4_idle_init(void)
 {
-   struct omap4_idle_statedata *cx;
-   struct cpuidle_device *dev;
+   struct omap4_idle_statedata *cx = omap4_idle_data[index];
struct cpuidle_driver *drv = omap4_idle_driver;
+   struct cpuidle_device *dev;
unsigned int cpu_id = 0;
 
mpu_pd = pwrdm_lookup(mpu_pwrdm);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 7/7] ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot time

2012-03-21 Thread Daniel Lezcano
We initialized it at compile time, no need to do that at boot
time.

Signed-off-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-omap2/cpuidle44xx.c |   26 +-
 1 files changed, 1 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index cb91d1f..fd220f9 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -33,7 +33,7 @@ struct omap4_idle_statedata {
 
 #define OMAP4_NUM_STATES 3
 
-static struct omap4_idle_statedata omap4_idle_data[] = {
+static struct omap4_idle_statedata omap4_idle_data[OMAP4_NUM_STATES] = {
{
.cpu_state = PWRDM_POWER_ON,
.mpu_state = PWRDM_POWER_ON,
@@ -187,14 +187,6 @@ struct cpuidle_driver omap4_idle_driver = {
.state_count = OMAP4_NUM_STATES,
 };
 
-static inline struct omap4_idle_statedata *_fill_cstate_usage(
-   struct cpuidle_device *dev,
-   int idx)
-{
-   struct omap4_idle_statedata *cx = omap4_idle_data[idx];
-   return cx;
-}
-
 /**
  * omap4_idle_init - Init routine for OMAP4 idle
  *
@@ -203,7 +195,6 @@ static inline struct omap4_idle_statedata 
*_fill_cstate_usage(
  */
 int __init omap4_idle_init(void)
 {
-   struct omap4_idle_statedata *cx = omap4_idle_data[index];
struct cpuidle_driver *drv = omap4_idle_driver;
struct cpuidle_device *dev;
unsigned int cpu_id = 0;
@@ -217,21 +208,6 @@ int __init omap4_idle_init(void)
dev = per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;
 
-   cx = _fill_cstate_usage(dev, 0);
-   cx-cpu_state = PWRDM_POWER_ON;
-   cx-mpu_state = PWRDM_POWER_ON;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 1);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_RET;
-
-   cx = _fill_cstate_usage(dev, 2);
-   cx-cpu_state = PWRDM_POWER_OFF;
-   cx-mpu_state = PWRDM_POWER_RET;
-   cx-mpu_logic_state = PWRDM_POWER_OFF;
-
cpuidle_register_driver(omap4_idle_driver);
 
dev-state_count = drv-state_count;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 1/7] ARM: OMAP4: cpuidle - Remove unused valid field

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 10:41 AM, Shilimkar, Santosh wrote:

On Wed, Mar 21, 2012 at 2:57 PM, Daniel Lezcano
daniel.lezc...@linaro.org  wrote:

The 'valid' field is never used in the code, let's remove it.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
---

It is used during the registration. This field has been very useful for
debug when need to disable a C-state etc.
So unless and until there is a strong reason, i would like to retain it.


IMO if it used for debug purpose, it should be moved to the debug code 
and if the debug code is not upstream, then that 'valid' should not be 
here but in the out-of-tree code.


By the way, this may be a debate for nothing because a patchset is on 
the way to disable C-states from sysfs.


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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 10:36 AM, Shilimkar, Santosh wrote:

On Wed, Mar 21, 2012 at 2:57 PM, Daniel Lezcano
daniel.lezc...@linaro.org  wrote:

This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.


Thanks. Will have a look at your series.


Cool, thanks.


A couple a things call my intention. Why the cpuidle device is set for cpu0 only

Because the mainline code CPUIDLE is supported along with CPUhotplug.
This is going to change though with Couple CPUIDLE and corresponding
OMAP updates.


Ok, thanks for the information. I will look deeper. What happens to cpu1 
when it is online and has nothing to do ?



and why the WFI is not used ?


I didn't get this question. Do you mean the generic WFI?


yes.


If yes, then, it's mainly because OMAP need additional
custom barriers.


Ah, ok. I am not sure if it is possible but that may be cool if we can 
call cpu_do_idle instead with additional barrier.




--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 10:56 AM, Santosh Shilimkar wrote:

On Wednesday 21 March 2012 03:21 PM, Daniel Lezcano wrote:

On 03/21/2012 10:36 AM, Shilimkar, Santosh wrote:

On Wed, Mar 21, 2012 at 2:57 PM, Daniel Lezcano
daniel.lezc...@linaro.org   wrote:

This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.


Thanks. Will have a look at your series.


Cool, thanks.


A couple a things call my intention. Why the cpuidle device is set
for cpu0 only

Because the mainline code CPUIDLE is supported along with CPUhotplug.
This is going to change though with Couple CPUIDLE and corresponding
OMAP updates.


Ok, thanks for the information. I will look deeper. What happens to cpu1
when it is online and has nothing to do ?


and why the WFI is not used ?


I didn't get this question. Do you mean the generic WFI?



I execute default idle loop.


So is it not possible to add a cpuidle device for cpu1 and define only 
one state for the 'wfi-for-omap' ?



yes.


If yes, then, it's mainly because OMAP need additional
custom barriers.


Ah, ok. I am not sure if it is possible but that may be cool if we can
call cpu_do_idle instead with additional barrier.


There is no need. Since code around WFI is customised, it make no sense
to call cpu_do_idle(0 ofr only that instruction sake.


For my personal information, why the WFI is customised for omap4 ?

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 11:07 AM, Santosh Shilimkar wrote:

Daniel,

On Wednesday 21 March 2012 02:57 PM, Daniel Lezcano wrote:

This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.

A couple a things call my intention. Why the cpuidle device is set for cpu0 only
and why the WFI is not used ?

Daniel Lezcano (7):
   ARM: OMAP4: cpuidle - Remove unused valid field
   ARM: OMAP4: cpuidle - Declare the states with the driver declaration
   ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
   ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
   ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
   ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
   ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
 time


The series looks fine to me in general. This clean-up is applicable
for OMAP3 cpuidle code as well.


Yes, I am planning to do the same for omap3.

Thanks for reviewing.

  -- Daniel


I want Jean to look at this series because some of his earlier
clean up has introduced those custom functions which
are getting removed in this series.

Regards
santosh





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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 11:49 AM, Shilimkar, Santosh wrote:

On Wed, Mar 21, 2012 at 4:13 PM, Daniel Lezcano
daniel.lezc...@linaro.org  wrote:

On 03/21/2012 10:56 AM, Santosh Shilimkar wrote:


On Wednesday 21 March 2012 03:21 PM, Daniel Lezcano wrote:


On 03/21/2012 10:36 AM, Shilimkar, Santosh wrote:


On Wed, Mar 21, 2012 at 2:57 PM, Daniel Lezcano
daniel.lezc...@linaro.org wrote:


This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.


Thanks. Will have a look at your series.



Cool, thanks.


A couple a things call my intention. Why the cpuidle device is set
for cpu0 only


Because the mainline code CPUIDLE is supported along with CPUhotplug.
This is going to change though with Couple CPUIDLE and corresponding
OMAP updates.



Ok, thanks for the information. I will look deeper. What happens to cpu1
when it is online and has nothing to do ?


and why the WFI is not used ?


I didn't get this question. Do you mean the generic WFI?




I execute default idle loop.



So is it not possible to add a cpuidle device for cpu1 and define only one
state for the 'wfi-for-omap' ?


That's how my post was handling it. But after the review Kevin suggested
me to drop the CPU1 shallow state since it was same as default idle.


Ok, thanks. I am asking that because the more I am looking at the 
different SoCs cpuidle drivers, the more I am convinced we can factor 
out more code across SoCs.



yes.


If yes, then, it's mainly because OMAP need additional
custom barriers.



Ah, ok. I am not sure if it is possible but that may be cool if we can
call cpu_do_idle instead with additional barrier.


There is no need. Since code around WFI is customised, it make no sense
to call cpu_do_idle(0 ofr only that instruction sake.



For my personal information, why the WFI is customised for omap4 ?


OMAP4 silicon has couple of hardware issues around interconnect
and needs to drain the axi buffers with strongly order writes to
ensure that data reaches to peripherals and not get stuck. That
lead to have custom function. Note that, the wfi instruction
itself is same.


Thanks for the explanation.

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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 2/7] ARM: OMAP4: cpuidle - Declare the states with the driver declaration

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 02:31 PM, Jean Pihet wrote:

On Wed, Mar 21, 2012 at 10:27 AM, Daniel Lezcano
daniel.lezc...@linaro.org  wrote:

The cpuidle API allows to declare statically the states in the driver
structure. Let's use it.
We do no longer need the fill_cstate function called at runtime and
by the way adding more instructions at boot time.

Signed-off-by: Daniel Lezcanodaniel.lezc...@linaro.org
---
  arch/arm/mach-omap2/cpuidle44xx.c |   56 +
  1 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/arch/arm/mach-omap2/cpuidle44xx.c 
b/arch/arm/mach-omap2/cpuidle44xx.c
index 1210229..cd6bee7 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -148,21 +148,38 @@ DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev);
  struct cpuidle_driver omap4_idle_driver = {
.name = omap4_idle,
.owner =THIS_MODULE,
+   .states = {
+   {
+   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
+   .exit_latency = 2 + 2,
+   .target_residency = 5,
+   .flags = CPUIDLE_FLAG_TIME_VALID,
+   .enter = omap4_enter_idle,
+   .name = C1,
+   .desc = MPUSS ON
+   },

...

+   },
+   .state_count = OMAP4_NUM_STATES,
  };

-static inline void _fill_cstate(struct cpuidle_driver *drv,
-   int idx, const char *descr)
-{
-   struct cpuidle_state *state =drv-states[idx];
-
-   state-exit_latency = cpuidle_params_table[idx].exit_latency;
-   state-target_residency = cpuidle_params_table[idx].target_residency;
-   state-flags= CPUIDLE_FLAG_TIME_VALID;
-   state-enter= omap4_enter_idle;
-   sprintf(state-name, C%d, idx + 1);
-   strncpy(state-desc, descr, CPUIDLE_DESC_LEN);
-}

I am OK with this change, which makes the code more readable (and so
maintainable).


-
  static inline struct omap4_idle_statedata *_fill_cstate_usage(
struct cpuidle_device *dev,
int idx)
@@ -196,37 +213,28 @@ int __init omap4_idle_init(void)
if ((!mpu_pd) || (!cpu0_pd) || (!cpu1_pd))
return -ENODEV;

-
-   drv-safe_state_index = -1;
dev =per_cpu(omap4_idle_dev, cpu_id);
dev-cpu = cpu_id;

-   /* C1 - CPU0 ON + CPU1 ON + MPU ON */
-   _fill_cstate(drv, 0, MPUSS ON);
-   drv-safe_state_index = 0;

I would keep this or add a clear comment that C1 is the safe state.


Actually with the driver's states declaration, the safe_state_index is 
initialized to zero, which means the default safe_state is always 0 with 
the new API. But I can add the initialization anyway in the structure 
declaration if you want.



...

Thanks,
Jean


--
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 02:19 PM, Jean Pihet wrote:

Hi Santosh, Daniel,

On Wed, Mar 21, 2012 at 11:07 AM, Santosh Shilimkar
santosh.shilim...@ti.com  wrote:

Daniel,

On Wednesday 21 March 2012 02:57 PM, Daniel Lezcano wrote:

This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.

A couple a things call my intention. Why the cpuidle device is set for cpu0 only
and why the WFI is not used ?

Daniel Lezcano (7):
   ARM: OMAP4: cpuidle - Remove unused valid field
   ARM: OMAP4: cpuidle - Declare the states with the driver declaration
   ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
   ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
   ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
   ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
   ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
 time


The series looks fine to me in general. This clean-up is applicable
for OMAP3 cpuidle code as well.

I want Jean to look at this series because some of his earlier
clean up has introduced those custom functions which
are getting removed in this series.

I am OK with the patch set, I only have minor remarks to the individual patches.

Reviewed-by: Jean Pihetj-pi...@ti.com


Thanks for the review Jean.






Thanks!
Jean



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/7] OMAP4 cpuidle cleanup

2012-03-21 Thread Daniel Lezcano

On 03/21/2012 02:43 PM, Jean Pihet wrote:

On Wed, Mar 21, 2012 at 11:07 AM, Santosh Shilimkar
santosh.shilim...@ti.com  wrote:

Daniel,

On Wednesday 21 March 2012 02:57 PM, Daniel Lezcano wrote:

This patchset is a proposition to improve a bit the code.
The changes are code cleanup and does not change the behavior of the
driver itself.

A couple a things call my intention. Why the cpuidle device is set for cpu0 only
and why the WFI is not used ?

Daniel Lezcano (7):
   ARM: OMAP4: cpuidle - Remove unused valid field
   ARM: OMAP4: cpuidle - Declare the states with the driver declaration
   ARM: OMAP4: cpuidle - Remove the cpuidle_params_table table
   ARM: OMAP4: cpuidle - fix static omap4_idle_data declaration
   ARM: OMAP4: cpuidle - Initialize omap4_idle_data at compile time
   ARM: OMAP4: cpuidle - use the omap4_idle_data variable directly
   ARM: OMAP4: cpuidle - remove omap4_idle_data initialization at boot
 time


The series looks fine to me in general. This clean-up is applicable
for OMAP3 cpuidle code as well.

Great!
However OMAP3 has a few specific things that cannot be removed as easily:
- the 'valid' flag is used because only certain combinations of power
domains states are possible,
- the latency settings can be overriden by the board code, so the
cpuidle_params struct is needed.


Right, I noticed that. I am looking for a way to have a similar cleanup 
for omap3 but without breaking the rx51 board.


Thanks
  -- Daniel



I want Jean to look at this series because some of his earlier
clean up has introduced those custom functions which
are getting removed in this series.

Regards
santosh




Thanks,
Jean



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >