From patchwork Wed Mar 11 14:34:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sanjeev Premi X-Patchwork-Id: 11148 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2BEYcio000319 for ; Wed, 11 Mar 2009 14:34:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751260AbZCKOeZ (ORCPT ); Wed, 11 Mar 2009 10:34:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752046AbZCKOeY (ORCPT ); Wed, 11 Mar 2009 10:34:24 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:35164 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbZCKOeX convert rfc822-to-8bit (ORCPT ); Wed, 11 Mar 2009 10:34:23 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n2BEYA1V007631; Wed, 11 Mar 2009 09:34:16 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id n2BEY9CJ019975; Wed, 11 Mar 2009 20:04:09 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Wed, 11 Mar 2009 20:04:09 +0530 From: "Premi, Sanjeev" To: Kevin Hilman CC: =?iso-8859-1?Q?H=F6gander_Jouni?= , "linux-omap@vger.kernel.org" Date: Wed, 11 Mar 2009 20:04:07 +0530 Subject: RE: [PATCHv2] PM : cpuidle - Update statistics for correct state Thread-Topic: [PATCHv2] PM : cpuidle - Update statistics for correct state Thread-Index: Acmg4Qmt4404fhR2QLKYGIcajR6FpwBdNp+A Message-ID: References: <1236455149-17017-1-git-send-email-premi@ti.com> <87wsazj9f5.fsf@trdhcp146196.ntc.nokia.com> <87ocwbj82x.fsf@trdhcp146196.ntc.nokia.com> <87zlfuy3sb.fsf@deeprootsystems.com> In-Reply-To: <87zlfuy3sb.fsf@deeprootsystems.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org > -----Original Message----- > From: Kevin Hilman [mailto:khilman@deeprootsystems.com] > Sent: Monday, March 09, 2009 11:31 PM > To: Premi, Sanjeev > Cc: Högander Jouni; linux-omap@vger.kernel.org > Subject: Re: [PATCHv2] PM : cpuidle - Update statistics for > correct state > > "Premi, Sanjeev" writes: > > > > > > >> -----Original Message----- > >> From: Högander Jouni [mailto:jouni.hogander@nokia.com] > >> Sent: Monday, March 09, 2009 4:07 PM > >> To: Premi, Sanjeev > >> Cc: linux-omap@vger.kernel.org > >> Subject: Re: [PATCHv2] PM : cpuidle - Update statistics > for correct > >> state > >> > >> "ext Premi, Sanjeev" writes: > >> > >> >> -----Original Message----- > >> >> From: Högander Jouni [mailto:jouni.hogander@nokia.com] > >> >> Sent: Monday, March 09, 2009 3:38 PM > >> >> To: Premi, Sanjeev > >> >> Cc: linux-omap@vger.kernel.org > >> >> Subject: Re: [PATCHv2] PM : cpuidle - Update statistics > >> for correct > >> >> state > >> >> > >> >> ext Sanjeev Premi writes: > >> >> > >> >> > When 'enable_off_mode' is 0, and (mpu_state < > >> PWRDM_POWER_RET) the > >> >> > local variables mpu_state and core_state are modified; but > >> >> the usage > >> >> > count for the original state selected by the governor > >> are updated. > >> >> > > >> >> > This patch updates the 'last_state' in the cpuidle > >> driver to ensure > >> >> > that statistics for the correct state are updated. > >> >> > > >> >> > Signed-off-by: Sanjeev Premi > >> >> > --- > >> >> > arch/arm/mach-omap2/cpuidle34xx.c | 29 > >> >> +++++++++++++++++++---------- > >> >> > 1 files changed, 19 insertions(+), 10 deletions(-) > >> >> > > >> >> > diff --git a/arch/arm/mach-omap2/cpuidle34xx.c > >> >> > b/arch/arm/mach-omap2/cpuidle34xx.c > >> >> > index 62fbb2e..b138abd 100644 > >> >> > --- a/arch/arm/mach-omap2/cpuidle34xx.c > >> >> > +++ b/arch/arm/mach-omap2/cpuidle34xx.c > >> >> > @@ -76,23 +76,32 @@ static int omap3_enter_idle(struct > >> >> cpuidle_device > >> >> > *dev, { > >> >> > struct omap3_processor_cx *cx = > >> cpuidle_get_statedata(state); > >> >> > struct timespec ts_preidle, ts_postidle, ts_idle; > >> >> > - u32 mpu_state = cx->mpu_state, core_state = > >> cx->core_state; > >> >> > - > >> >> > - current_cx_state = *cx; > >> >> > + u32 mpu_state, core_state; > >> >> > > >> >> > /* Used to keep track of the total time in idle */ > >> >> > getnstimeofday(&ts_preidle); > >> >> > > >> >> > - local_irq_disable(); > >> >> > - local_fiq_disable(); > >> >> > - > >> >> > + /* > >> >> > + * Adjust the idle state (if required). > >> >> > + * Also, ensure that usage statistics of correct state > >> >> are updated. > >> >> > + */ > >> >> > if (!enable_off_mode) { > >> >> > - if (mpu_state < PWRDM_POWER_RET) > >> >> > - mpu_state = PWRDM_POWER_RET; > >> >> > - if (core_state < PWRDM_POWER_RET) > >> >> > - core_state = PWRDM_POWER_RET; > >> >> > + if (cx->type > OMAP3_STATE_C4) { > >> >> > + state = > >> &(dev->states[OMAP3_STATE_C4 - 1]); > >> >> > + dev->last_state = state ; > >> >> > + > >> >> > + cx = cpuidle_get_statedata(state); > >> >> > >> >> There is still C3 where OFF is used for MPU. This needs to > >> be taken > >> >> into account. > >> > > >> > [sp] Thanks. Good catch! > >> > I wasn't happy doing the "OMAP3_STATEn - 1"; but could > >> not find a better way. > >> > It should be C2 as defined now. > >> > >> This means C4 is not used if off mode is not enabled? I > think this is > >> not wanted. Would it be possible to remove "OFF" C states when > >> enable_off_mode is written to 0 and add them back when 1 written? > > > > [sp] That should be possible. We could use the 'valid' field > > for the purpose. > > I would gladly take a patch which uses the 'valid' field for > this and then the enter hook whould drop to the next lower > valid state if the state requested is not valid. > > Kevin [sp] I have not yet tested it (working offline for sometime). But, wanted to share the changes for an early review. Initially, I was trying see if the CPUIDLE framework could use ".valid" as an additional argument in cpuidle_state. But, may be that's for later... > > > > > >> > > >> > On another note, would it make sense to swap the > >> definitions for C3 and C4. > >> > C3 : MPU CSWR + CORE CSWR > >> > C4 : MPU OFF + CORE Actove > >> > >> No it doesn't. They are organized by latency. > > > > [sp] Okay. That was a loud thinking from my side :) > >> > >> One grounding for current implementation is that > enable_off_mode is > >> more or less testing interface. In final solution it might be even > >> removed. Adjusting states directly still shows guite accurate > >> information on used C-states. > >> > >> > > >> >> > >> >> > + } > >> >> > } > >> >> > > >> >> > + current_cx_state = *cx; > >> >> > + > >> >> > + mpu_state = cx->mpu_state; > >> >> > + core_state = cx->core_state; > >> >> > + > >> >> > + local_irq_disable(); > >> >> > + local_fiq_disable(); > >> >> > + > >> >> > pwrdm_set_next_pwrst(mpu_pd, mpu_state); > >> >> > pwrdm_set_next_pwrst(core_pd, core_state); > >> >> > > >> >> > -- > >> >> > 1.5.6 > >> >> > > >> >> > -- > >> >> > To unsubscribe from this list: send the line "unsubscribe > >> >> linux-omap" > >> >> > in the body of a message to majordomo@vger.kernel.org More > >> >> majordomo > >> >> > info at http://vger.kernel.org/majordomo-info.html > >> >> > >> >> -- > >> >> Jouni Högander > >> >> > >> >> > >> > >> -- > >> Jouni Högander > >> > >> -- > > To unsubscribe from this list: send the line "unsubscribe > linux-omap" > > in the body of a message to majordomo@vger.kernel.org More > majordomo > > info at http://vger.kernel.org/majordomo-info.html > > -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx index c25158c..9493553 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c @@ -88,16 +88,19 @@ static int omap3_enter_idle(struct cpuidle_device *dev, goto return_sleep_time; /* + * Check if the chosen idle state is valid. + * If no, drop down to a lower valid state. Expects the lowest + * state will always be active. */ + if (!cx->valid) { + for (idx = (cx->type - 1); idx == 1; idx--) { + if (omap3_power_states[idx].valid) + break; } + state = &(dev->states[idx]); + dev->last_state = state ; + + cx = cpuidle_get_statedata(state); } current_cx_state = *cx; @@ -150,6 +153,26 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, return omap3_enter_idle(dev, new_state); } +/** + * omap3_toggle_off_states - Enable / Disable validity of idle states + * @flag: Enable/ Disable support for OFF mode + * + * Called as result of change to "enable_off_mode". + */ +void omap3_toggle_off_states(unsigned short flag) +{ + if (flag) { + omap3_power_states[OMAP3_STATE_C3].valid = 1; + omap3_power_states[OMAP3_STATE_C5].valid = 1; + omap3_power_states[OMAP3_STATE_C6].valid = 1; + } + else { + omap3_power_states[OMAP3_STATE_C3].valid = 0; + omap3_power_states[OMAP3_STATE_C5].valid = 0; + omap3_power_states[OMAP3_STATE_C6].valid = 0; + } +} + DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); /* omap3_init_power_states - Initialises the OMAP3 specific C states. diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 61c6dfb..6785850 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c @@ -47,6 +47,8 @@ atomic_t sleep_block = ATOMIC_INIT(0); static int vdd1_locked; static int vdd2_locked; +extern void omap3_toggle_off_states(unsigned short); + static ssize_t idle_show(struct kobject *, struct kobj_attribute *, char *); static ssize_t idle_store(struct kobject *k, struct kobj_attribute *, const char *buf, size_t n); @@ -112,6 +114,8 @@ static ssize_t idle_store(struct kobject *kobj, struct kobj_ } else if (attr == &enable_off_mode_attr) { enable_off_mode = value; omap3_pm_off_mode_enable(enable_off_mode); + if (cpu_is_omap34xx()) + omap3_toggle_off_states(value); } else if (attr == &voltage_off_while_idle_attr) { voltage_off_while_idle = value; if (voltage_off_while_idle)