From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:26
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 <redacted>
---
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(-)
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:27
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 <redacted>
---
arch/arm/mach-omap2/cpuidle34xx.c | 85 +------------------------------------
1 files changed, 2 insertions(+), 83 deletions(-)
@@ -164,84 +164,6 @@ return_sleep_time:}/**-*next_valid_state-FindnextvalidC-state-*@dev:cpuidledevice-*@drv:cpuidledriver-*@index:Indexofcurrentlyselectedc-state-*-*Ifthestatecorrespondingtoindexisvalid,indexisreturnedback-*tothecaller.Else,thisfunctionsearchesforalowerc-statewhichis-*stillvalid(asdefinedinomap3_power_states[])andreturnsitsindex.-*-*Astateisvalidifthe'valid'fieldisenabledand-*ifitsatisfiestheenable_off_modecondition.-*/-staticintnext_valid_state(structcpuidle_device*dev,-structcpuidle_driver*drv,-intindex)-{-structcpuidle_state_usage*curr_usage=&dev->states_usage[index];-structcpuidle_state*curr=&drv->states[index];-structomap3_idle_statedata*cx=cpuidle_get_statedata(curr_usage);-u32mpu_deepest_state=PWRDM_POWER_RET;-u32core_deepest_state=PWRDM_POWER_RET;-intnext_index=-1;--if(enable_off_mode){-mpu_deepest_state=PWRDM_POWER_OFF;-/*-*Erratumi583:valableforESrev<Es1.2on3630.-*COREOFFmodeisnotsupportedinastableform,restrict-*insteadtheCOREstatetoRET.-*/-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)){-returnindex;-}else{-intidx=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);--/*-*Droptonextvalidstate.-*Startsearchfromthenext(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;-}-}-/*-*C1isalwaysvalid.-*So,noneedtocheckfor'next_index==-1'outside-*thisloop.-*/-}--returnnext_index;-}--/***omap3_enter_idle_bm-Checksforanybusactivity*@dev:cpuidledevice*@drv:cpuidledriver
@@ -254,7 +176,6 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,structcpuidle_driver*drv,intindex){-intnew_state_idx;u32core_next_state,per_next_state=0,per_saved_state=0,cam_state;structomap3_idle_statedata*cx;intret;
@@ -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;gotoselect_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)
From: Jean Pihet <hidden> Date: 2012-03-23 12:21:23
Hi Daniel,
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] wrote:
quoted hunk
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 <redacted>
---
?arch/arm/mach-omap2/cpuidle34xx.c | ? 85 +------------------------------------
?1 files changed, 2 insertions(+), 83 deletions(-)
On OMAP3 not all the power states combinations are allowed, so this
code looks for a C-state which satisfies the enable_off_mode flag.
I am planning to remove the enable_off_mode flag but this has to come
with the per-device PM QoS constraints code.
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:28
This variable is only used in the pm-debug.c file.
Signed-off-by: Daniel Lezcano <redacted>
---
arch/arm/mach-omap2/pm-debug.c | 2 +-
arch/arm/mach-omap2/pm.h | 30 ++++++++++++------------------
2 files changed, 13 insertions(+), 19 deletions(-)
From: Jean Pihet <hidden> Date: 2012-03-23 12:22:32
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] wrote:
quoted hunk
This variable is only used in the pm-debug.c file.
Signed-off-by: Daniel Lezcano <redacted>
---
?arch/arm/mach-omap2/pm-debug.c | ? ?2 +-
?arch/arm/mach-omap2/pm.h ? ? ? | ? 30 ++++++++++++------------------
?2 files changed, 13 insertions(+), 19 deletions(-)
From: Daniel Lezcano <hidden> Date: 2012-03-23 12:38:10
On 03/23/2012 01:22 PM, Jean Pihet wrote:
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] wrote:
quoted
This variable is only used in the pm-debug.c file.
Signed-off-by: Daniel Lezcano<redacted>
---
arch/arm/mach-omap2/pm-debug.c | 2 +-
arch/arm/mach-omap2/pm.h | 30 ++++++++++++------------------
2 files changed, 13 insertions(+), 19 deletions(-)
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:29
Use the new cpuidle API and define in the driver the states.
Signed-off-by: Daniel Lezcano <redacted>
---
arch/arm/mach-omap2/cpuidle34xx.c | 85 +++++++++++++++++++++++++-----------
1 files changed, 59 insertions(+), 26 deletions(-)
@@ -228,23 +228,67 @@ DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);structcpuidle_driveromap3_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=10000+30000,+.target_residency=30000,+.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*/-staticinlinevoid_fill_cstate(structcpuidle_driver*drv,-intidx,constchar*descr)-{-structcpuidle_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 */staticinlinestructomap3_idle_statedata*_fill_cstate_usage(structcpuidle_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 */-_fill_cstate(drv,2,"MPU RET + CORE ON");cx=_fill_cstate_usage(dev,2);cx->mpu_state=PWRDM_POWER_RET;cx->core_state=PWRDM_POWER_ON;/* C4 . MPU OFF + Core inactive */-_fill_cstate(drv,3,"MPU OFF + CORE ON");cx=_fill_cstate_usage(dev,3);cx->mpu_state=PWRDM_POWER_OFF;cx->core_state=PWRDM_POWER_ON;/* C5 . MPU RET + Core RET */-_fill_cstate(drv,4,"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 */-_fill_cstate(drv,5,"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 */-_fill_cstate(drv,6,"MPU OFF + CORE OFF");cx=_fill_cstate_usage(dev,6);/**Erratumi583:implementationforESrev<Es1.2on3630.Wecannot
From: Jean Pihet <hidden> Date: 2012-03-23 12:35:12
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] wrote:
quoted hunk
Use the new cpuidle API and define in the driver the states.
Signed-off-by: Daniel Lezcano <redacted>
---
?arch/arm/mach-omap2/cpuidle34xx.c | ? 85 +++++++++++++++++++++++++-----------
?1 files changed, 59 insertions(+), 26 deletions(-)
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.
quoted hunk
@@ -338,7 +372,6 @@ int __init omap3_idle_init(void)
From: Daniel Lezcano <hidden> Date: 2012-03-23 12:41:48
On 03/23/2012 01:35 PM, Jean Pihet wrote:
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] wrote:
quoted
Use the new cpuidle API and define in the driver the states.
Signed-off-by: Daniel Lezcano<redacted>
---
[ ... ]
quoted
/*
* 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.
From: Jean Pihet <hidden> Date: 2012-03-23 13:17:13
On Fri, Mar 23, 2012 at 1:41 PM, Daniel Lezcano
[off-list ref] wrote:
On 03/23/2012 01:35 PM, Jean Pihet wrote:
quoted
On Fri, Mar 23, 2012 at 10:26 AM, Daniel Lezcano
[off-list ref] ?wrote:
quoted
Use the new cpuidle API and define in the driver the states.
Signed-off-by: Daniel Lezcano<redacted>
---
[ ... ]
quoted
quoted
? ? ? ?/*
? ? ? ? * 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.
Correct! That solves the issue with the statically defined C-states.
The (dynamic) per C-state sysfs disable knob requires a runtime check
on .disable though, in case the cpuidle chosen C-state is demoted
(depending on the value of enable_off_mode and later the latency
constraints on the power domain).
quoted
quoted
@@ -338,7 +372,6 @@ int __init omap3_idle_init(void)
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:30
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 <redacted>
---
arch/arm/mach-omap2/cpuidle34xx.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
@@ -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)*WedisableC7stateasaresult.*/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)){
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:31
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 <redacted>
---
arch/arm/mach-omap2/cpuidle34xx.c | 28 +++-------------------------
arch/arm/mach-omap2/pm.h | 12 ------------
2 files changed, 3 insertions(+), 37 deletions(-)
@@ -38,36 +38,14 @@#ifdef CONFIG_CPU_IDLE-/*-*Thelatencies/thresholdsforvariousCstateshave-*tobeconfiguredfromtherespectiveboardfiles.-*Thesearesomedefaultvalues(whichmightnotprovide-*thebestpowersavings)usedonboardswhichdonot-*passthesedetailsfromtheboardfile.-*/-staticstructcpuidle_paramscpuidle_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 */-{10000+30000,300000,1},-};-#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)-/* Mach specific information to be recorded in the C-state driver_data */structomap3_idle_statedata{u32mpu_state;u32core_state;};++#define OMAP3_NUM_STATES 7+structomap3_idle_statedataomap3_idle_data[OMAP3_NUM_STATES];structpowerdomain*mpu_pd,*core_pd,*per_pd,*cam_pd;
From: Daniel Lezcano <hidden> Date: 2012-03-23 09:26:33
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 <redacted>
---
arch/arm/mach-omap2/cpuidle34xx.c | 60 ++++---------------------------------
1 files changed, 6 insertions(+), 54 deletions(-)
@@ -106,8 +106,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,structcpuidle_driver*drv,intindex){-structomap3_idle_statedata*cx=-cpuidle_get_statedata(&dev->states_usage[index]);+structomap3_idle_statedata*cx=&omap3_idle_data[index];structtimespects_preidle,ts_postidle,ts_idle;u32mpu_state=cx->mpu_state,core_state=cx->core_state;intidle_time;
@@ -208,7 +207,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,*PreventPERoffifCOREisnotinretentionoroffasthis*woulddisablePERwakeupscompletely.*/-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 */-staticinlinestructomap3_idle_statedata*_fill_cstate_usage(-structcpuidle_device*dev,-intidx)-{-structomap3_idle_statedata*cx=&omap3_idle_data[idx];-structcpuidle_state_usage*state_usage=&dev->states_usage[idx];--cpuidle_set_statedata(state_usage,cx);--returncx;-}-/***omap3_idle_init-InitroutineforOMAP3idle*
@@ -318,48 +304,12 @@ int __init omap3_idle_init(void){structcpuidle_device*dev;structcpuidle_driver*drv=&omap3_idle_driver;-structomap3_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);/**Erratumi583:implementationforESrev<Es1.2on3630.Wecannot*enableOFFmodeinastableformforpreviousrevisions.
@@ -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__);
@@ -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 */structomap3_idle_statedata{u32mpu_state;
@@ -335,9 +333,3 @@ int __init omap3_idle_init(void)return0;}-#else-int__initomap3_idle_init(void)-{-return0;-}-#endif /* CONFIG_CPU_IDLE */