From patchwork Fri Aug 9 11:59:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 2841897 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A5DC4BF546 for ; Fri, 9 Aug 2013 12:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FCE420300 for ; Fri, 9 Aug 2013 11:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E22E202F7 for ; Fri, 9 Aug 2013 11:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966169Ab3HIL74 (ORCPT ); Fri, 9 Aug 2013 07:59:56 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:16254 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965820Ab3HIL74 (ORCPT ); Fri, 9 Aug 2013 07:59:56 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MR90016LINOB3K0@mailout4.samsung.com>; Fri, 09 Aug 2013 20:59:55 +0900 (KST) X-AuditID: cbfee61b-b7efe6d000007b11-86-5204d9bb6d8c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A3.53.31505.BB9D4025; Fri, 09 Aug 2013 20:59:55 +0900 (KST) Received: from amdc1032.localnet ([106.116.147.136]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MR9006UGINTVI70@mmp1.samsung.com>; Fri, 09 Aug 2013 20:59:55 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: "Rafael J. Wysocki" Cc: Daniel Lezcano , Amit Daniel Kachhap , linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [RFC PATCH] cpuidle: fix device->state_count handling Date: Fri, 09 Aug 2013 13:59:27 +0200 Message-id: <8500767.uCb7Y0sjbx@amdc1032> User-Agent: KMail/4.8.4 (Linux/3.2.0-45-generic; KDE/4.8.5; i686; ; ) MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCLMWRmVeSWpSXmKPExsVy+t9jAd3dN1mCDJpnc1k0XA2xmPdZ1uJz 7xFGixnn9zFZ9C/sZXJg9bhzbQ+bR9+WVYwejxa3MHp83iQXwBLFZZOSmpNZllqkb5fAlTHn Yxd7wR6xipXztzM3MHYIdzFyckgImEicmvGHBcIWk7hwbz1bFyMXh5DAIkaJld++skA4LUwS fxYcYAWpYhOwkpjYvooRxBYRUJXY8uQ/O0gRs8A8RomJh5uYQRLCAnYSM5++A7NZgIr+rL0E ZvMKaEp8vrucCcQWFXCVOLfoBwtEXFDix+R7YDazgLzEvv1TWSFsLYn1O48zTWDkm4WkbBaS sllIyhYwMq9iFE0tSC4oTkrPNdIrTswtLs1L10vOz93ECA7LZ9I7GFc1WBxiFOBgVOLhVdzO HCTEmlhWXJl7iFGCg1lJhHf7BJYgId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwHW60DhQTSE0tS s1NTC1KLYLJMHJxSDYxaH1RtLtgmNs6NXXRvRsrS2XoaTixcl+/OfBmwKdNn4eP81qeyHbN5 YzbNKk/8VyF/48O7SxMvsR1VWWn5cG8Tf9aOZev+hxqIXk6Tr9bpPDalsCFKKHfGwtpQv1dZ uxb0PzLvuJ21Y9aOKc9fmsmszKl4vezI/2mP9vKdXqH4vU7Lc67gobthSizFGYmGWsxFxYkA uLMXfEcCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device->state_count instead of driver->state_count in cpuidle_play_dead(), ladder_select_state() and menu_select(). This allows cpuidle drivers to override maximum allowable state number for a given device, which is what some cpuidle drivers would like to do (i.e. EXYNOS cpuidle driver). Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Kyungmin Park Cc: Amit Daniel Kachhap Reviewed-by: Tomasz Figa --- Alternatively, we can make EXYNOS cpuidle driver work without device->state_count (at a some tiny performance cost?). This would allow us to remove device->state_count completely as it is not needed by any other cpuidle driver currently (AFAICS). drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/cpuidle/cpuidle.c =================================================================== --- a/drivers/cpuidle/cpuidle.c 2013-08-08 14:36:09.611488750 +0200 +++ b/drivers/cpuidle/cpuidle.c 2013-08-08 14:39:02.291486116 +0200 @@ -57,7 +57,7 @@ int cpuidle_play_dead(void) return -ENODEV; /* Find lowest-power state that supports long-term idle */ - for (i = drv->state_count - 1; i >= CPUIDLE_DRIVER_STATE_START; i--) + for (i = dev->state_count - 1; i >= CPUIDLE_DRIVER_STATE_START; i--) if (drv->states[i].enter_dead) return drv->states[i].enter_dead(dev, i); Index: b/drivers/cpuidle/governors/ladder.c =================================================================== --- a/drivers/cpuidle/governors/ladder.c 2013-08-08 14:36:09.611488750 +0200 +++ b/drivers/cpuidle/governors/ladder.c 2013-08-08 14:39:02.299486116 +0200 @@ -87,7 +87,7 @@ static int ladder_select_state(struct cp last_residency = last_state->threshold.promotion_time + 1; /* consider promotion */ - if (last_idx < drv->state_count - 1 && + if (last_idx < dev->state_count - 1 && !drv->states[last_idx + 1].disabled && !dev->states_usage[last_idx + 1].disable && last_residency > last_state->threshold.promotion_time && Index: b/drivers/cpuidle/governors/menu.c =================================================================== --- a/drivers/cpuidle/governors/menu.c 2013-08-08 14:36:09.611488750 +0200 +++ b/drivers/cpuidle/governors/menu.c 2013-08-08 14:39:02.299486116 +0200 @@ -312,7 +312,7 @@ static int menu_select(struct cpuidle_dr * Find the idle state with the lowest power while satisfying * our constraints. */ - for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { + for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) { struct cpuidle_state *s = &drv->states[i]; struct cpuidle_state_usage *su = &dev->states_usage[i];