From patchwork Thu Jun 26 15:08:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 32564 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB200201EF for ; Thu, 26 Jun 2014 15:08:52 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id tr6sf20460836ieb.11 for ; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=inKXtjfRbb2NyZI+0EVWA+/ZNUAmU+Qu4nG4RRxr4hI=; b=jiKq3A5NCNUuFJy9yK6WcLr5tTx28WNmSVOSFzNWfRY0KfaoAwbOvJ9JvRBK7beznY VF2lrlJD0kdDLiLVSSHtxFyJi6iPvmEWoyelKQv+CjiEVHlaam8NjsgFh7753v6VhUBO WtI+KdA0mINwNj+3KyKFZELTcj0lUQ0v5XkvrcHWPxowVuk4Yf6FvlZsMaX95pdmJ3OI GsPIegBOK4G/O09WMy2tcW+V8WyS6IgaXxVvkPW+scvp7jD8ZxxeVQbCw89h7qBe8xvZ L9QhgrIptV1lrfGbjd5Toq3tgDiBCb8W55fiVM4HGhl+PYhZfO+eT3/mTo0IBKNG8szz /V1w== X-Gm-Message-State: ALoCoQlQggKC9hvljj+jNJMU0tn/+rgnWCLve2LevPOAijhN6+6EkCcDPK2+httCpNVnzsWfk2sc X-Received: by 10.182.241.169 with SMTP id wj9mr8180024obc.14.1403795332367; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.111 with SMTP id b102ls233698qga.31.gmail; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) X-Received: by 10.52.74.170 with SMTP id u10mr1235929vdv.65.1403795332245; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) Received: from mail-vc0-x232.google.com (mail-vc0-x232.google.com [2607:f8b0:400c:c03::232]) by mx.google.com with ESMTPS id s7si4579648vcl.50.2014.06.26.08.08.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Jun 2014 08:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::232 as permitted sender) client-ip=2607:f8b0:400c:c03::232; Received: by mail-vc0-f178.google.com with SMTP id ij19so3722997vcb.9 for ; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr1856938vca.45.1403795332126; Thu, 26 Jun 2014 08:08:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp37088vcb; Thu, 26 Jun 2014 08:08:51 -0700 (PDT) X-Received: by 10.68.161.101 with SMTP id xr5mr22066644pbb.168.1403795331398; Thu, 26 Jun 2014 08:08:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id el5si10202492pbc.217.2014.06.26.08.08.50; Thu, 26 Jun 2014 08:08:50 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753590AbaFZPIu (ORCPT + 13 others); Thu, 26 Jun 2014 11:08:50 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:40648 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751AbaFZPIt (ORCPT ); Thu, 26 Jun 2014 11:08:49 -0400 Received: by mail-pb0-f54.google.com with SMTP id un15so3261429pbc.41 for ; Thu, 26 Jun 2014 08:08:49 -0700 (PDT) X-Received: by 10.66.148.196 with SMTP id tu4mr22898346pab.122.1403795329261; Thu, 26 Jun 2014 08:08:49 -0700 (PDT) Received: from user-ubuntu.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id g6sm36362821pat.2.2014.06.26.08.08.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Jun 2014 08:08:48 -0700 (PDT) From: Thomas Abraham To: linux-pm@vger.kernel.org Cc: viresh.kumar@linaro.org, sudeep.karkadanagesha@arm.com, thomas.ab@samsung.com Subject: [PATCH] cpufreq: arm_big_little: set lowest frequcency for cluster when no cpus in it Date: Thu, 26 Jun 2014 20:38:33 +0530 Message-Id: <1403795313-6903-1-git-send-email-thomas.ab@samsung.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Original-Sender: thomas.ab@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::232 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Thomas Abraham If there are no active cpus in a cluster, the clock frequency of the cluster can be lowered to the lowest possible frequency for that cluster. This can help reduce the output clock speed of the PLL clocking the cluster and save power. The get_table_min() function is also moved with this change to avoid forward declaration. The function get_table_max() is also moved along with get_table_min() so that these two functions are adjacent the code. Signed-off-by: Thomas Abraham --- drivers/cpufreq/arm_big_little.c | 51 +++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 1f4d4e3..4b1431f 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -75,6 +75,28 @@ static inline int cpu_to_cluster(int cpu) MAX_CLUSTERS : raw_cpu_to_cluster(cpu); } +/* get the minimum frequency in the cpufreq_frequency_table */ +static inline u32 get_table_min(struct cpufreq_frequency_table *table) +{ + struct cpufreq_frequency_table *pos; + uint32_t min_freq = ~0; + cpufreq_for_each_entry(pos, table) + if (pos->frequency < min_freq) + min_freq = pos->frequency; + return min_freq; +} + +/* get the maximum frequency in the cpufreq_frequency_table */ +static inline u32 get_table_max(struct cpufreq_frequency_table *table) +{ + struct cpufreq_frequency_table *pos; + uint32_t max_freq = 0; + cpufreq_for_each_entry(pos, table) + if (pos->frequency > max_freq) + max_freq = pos->frequency; + return max_freq; +} + static unsigned int find_cluster_maxfreq(int cluster) { int j; @@ -170,9 +192,14 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) mutex_lock(&cluster_lock[old_cluster]); - /* Set freq of old cluster if there are cpus left on it */ + /* + * Set freq of old cluster. If there are no cpus left on it, + * set the lowest possible frequency for that cluster. + */ new_rate = find_cluster_maxfreq(old_cluster); new_rate = ACTUAL_FREQ(old_cluster, new_rate); + if (!new_rate) + new_rate = get_table_min(freq_table[old_cluster]); if (new_rate) { pr_debug("%s: Updating rate of old cluster: %d, to freq: %d\n", @@ -223,28 +250,6 @@ static inline u32 get_table_count(struct cpufreq_frequency_table *table) return count; } -/* get the minimum frequency in the cpufreq_frequency_table */ -static inline u32 get_table_min(struct cpufreq_frequency_table *table) -{ - struct cpufreq_frequency_table *pos; - uint32_t min_freq = ~0; - cpufreq_for_each_entry(pos, table) - if (pos->frequency < min_freq) - min_freq = pos->frequency; - return min_freq; -} - -/* get the maximum frequency in the cpufreq_frequency_table */ -static inline u32 get_table_max(struct cpufreq_frequency_table *table) -{ - struct cpufreq_frequency_table *pos; - uint32_t max_freq = 0; - cpufreq_for_each_entry(pos, table) - if (pos->frequency > max_freq) - max_freq = pos->frequency; - return max_freq; -} - static int merge_cluster_tables(void) { int i, j, k = 0, count = 1;