From patchwork Wed Apr 4 09:42:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7610 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2F66E23E4C for ; Wed, 4 Apr 2012 09:42:46 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id ED169A1800C for ; Wed, 4 Apr 2012 09:42:45 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so109604iag.11 for ; Wed, 04 Apr 2012 02:42:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/goGDEGwN9r4PE83CiqHCuLByhYfG4eEOpjk8k9wF8w=; b=TQHOsgSFaRCCjCfYtfMPGJnRvI/jkiddi4TGqrvLrceohByqmEQyipPF9aDBVDE6hq WuckOoNb19HtNe+evzMBhzAPfC4tCV1cy67AdCZPRDqA46JBGwiTAWmeqmR7hLUzs+Zj UnF2fkylHKCspGE33xcfBFm06ZgAaRzedxAF1wxZ+JPASW+0VjpUj1VS5PSoVN0xpKXF 8/Bjb1W+Ai4aV+neOBcG0AI1t9irxLf/B08z0NZomBMoWQSRXBhJS4LmU1FyrqQsDhCU 6ZPqRfdtNYIN0/mitcMyvGDGNPEMVllKHfps+QlpjfHfQfb4sogXDo1k1wICa0zvYcEw TgmQ== Received: by 10.50.156.229 with SMTP id wh5mr930824igb.28.1333532565752; Wed, 04 Apr 2012 02:42:45 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.164.217 with SMTP id f25csp31257iby; Wed, 4 Apr 2012 02:42:45 -0700 (PDT) Received: by 10.180.83.72 with SMTP id o8mr3689725wiy.5.1333532564424; Wed, 04 Apr 2012 02:42:44 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id s1si1438865wia.9.2012.04.04.02.42.44 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 02:42:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wi0-f172.google.com with SMTP id hj6so283042wib.13 for ; Wed, 04 Apr 2012 02:42:44 -0700 (PDT) Received: by 10.216.135.97 with SMTP id t75mr975354wei.60.1333532563910; Wed, 04 Apr 2012 02:42:43 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-7-136.w90-60.abo.wanadoo.fr. [90.60.242.136]) by mx.google.com with ESMTPS id bx13sm3462265wib.10.2012.04.04.02.42.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 02:42:43 -0700 (PDT) From: Daniel Lezcano To: tony@atomide.com, khilman@ti.com Cc: j-pihet@ti.com, santosh.shilimkar@ti.com, rob.lee@linaro.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: [PATCH 13/17] ARM: OMAP3: cpuidle - use omap3_idle_data directly Date: Wed, 4 Apr 2012 11:42:15 +0200 Message-Id: <1333532539-10298-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1333532539-10298-1-git-send-email-daniel.lezcano@linaro.org> References: <1333532539-10298-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQmaQQC3vnUJlGPvsOv+kod9f9k55hQJCbm4JxHp/lasxqWnPYpD3cgJc7GmG/XQWTT5C0Vu 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 --- 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 in a stable form for previous revisions. @@ -442,11 +391,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__);