From patchwork Thu Jan 31 08:14:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 2071421 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F3F76DF2E5 for ; Thu, 31 Jan 2013 08:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755573Ab3AaIOo (ORCPT ); Thu, 31 Jan 2013 03:14:44 -0500 Received: from mail-ea0-f176.google.com ([209.85.215.176]:52288 "EHLO mail-ea0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248Ab3AaIOn (ORCPT ); Thu, 31 Jan 2013 03:14:43 -0500 Received: by mail-ea0-f176.google.com with SMTP id a13so1063029eaa.7 for ; Thu, 31 Jan 2013 00:14:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=n00fAV48h/pUIoKZqJ4S1fveO5H9p7X4Y+QM38Cx64Y=; b=kbywNmOgLSu2XjxbCfApHkBVFUr/Le4rsPxA75GO4i79Uuuxnf0YZh2GONan81vZam J3TuT+MU6/D7ifkF92kkdyeA5KLSZrnhVv8aapBhwtZVPjjhVINXa9cokzKj4IfHJfW2 jmjrXMIr93kuSPUu/te7c9m9DvxUeykJLWjb6b75B1sp1d/1HGpxgDMcjbSdt0Wg1v8S turSg+tpWem+sseVkz+pTe9Se1uogFJxYy2KSBDAJ+SDJr+Q5GcFgwEltek8KtmheEhx EepDEHWpJsmjWuOuOQAdSpxdVzOWhhK1KjpkedacAn+hEM/1BX3vo08LuffFuy/TODka wF4A== X-Received: by 10.14.219.3 with SMTP id l3mr24778289eep.5.1359620081685; Thu, 31 Jan 2013 00:14:41 -0800 (PST) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id t4sm6155777eel.0.2013.01.31.00.14.35 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Jan 2013 00:14:40 -0800 (PST) From: Fabio Baltieri To: "Rafael J. Wysocki" , cpufreq@vger.kernel.org, linux-pm@vger.kernel.org Cc: Viresh Kumar , Linus Walleij , linaro-dev@lists.linaro.org, linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH] cpufreq: governors: implement generic policy_is_shared Date: Thu, 31 Jan 2013 09:14:24 +0100 Message-Id: <1359620064-14751-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-Gm-Message-State: ALoCoQkNKcKR4T0iAqyUUwzC5Bch6UoKcd2VEHA96su93HpuQI4NvNhkPqIHlu3RnkiPf5mK92N1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Implement a generic helper function policy_is_shared() to replace the current dbs_sw_coordinated_cpus() at cpufreq level, so that it can be used by code other than cpufreq governors. Suggested-by: Viresh Kumar Signed-off-by: Fabio Baltieri Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq_conservative.c | 2 +- drivers/cpufreq/cpufreq_governor.c | 8 -------- drivers/cpufreq/cpufreq_governor.h | 1 - drivers/cpufreq/cpufreq_ondemand.c | 2 +- include/linux/cpufreq.h | 5 +++++ 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 5d8e894..653fb06 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -154,7 +154,7 @@ static void cs_dbs_timer(struct work_struct *work) struct cs_cpu_dbs_info_s *dbs_info = container_of(work, struct cs_cpu_dbs_info_s, cdbs.work.work); - if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) { + if (policy_is_shared(dbs_info->cdbs.cur_policy)) { cs_timer_coordinated(dbs_info, dw); } else { mutex_lock(&dbs_info->cdbs.timer_mutex); diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 46f96a4..67e235a 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -161,14 +161,6 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) } EXPORT_SYMBOL_GPL(dbs_check_cpu); -bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs) -{ - struct cpufreq_policy *policy = cdbs->cur_policy; - - return cpumask_weight(policy->cpus) > 1; -} -EXPORT_SYMBOL_GPL(dbs_sw_coordinated_cpus); - static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu, unsigned int sampling_rate) { diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index aaf073d..b72e628 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -172,7 +172,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) u64 get_cpu_idle_time(unsigned int cpu, u64 *wall); void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); -bool dbs_sw_coordinated_cpus(struct cpu_dbs_common_info *cdbs); int cpufreq_governor_dbs(struct dbs_data *dbs_data, struct cpufreq_policy *policy, unsigned int event); #endif /* _CPUFREQ_GOVERNER_H */ diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 1017b90..5ae84ff 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -277,7 +277,7 @@ static void od_dbs_timer(struct work_struct *work) struct od_cpu_dbs_info_s *dbs_info = container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); - if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) { + if (policy_is_shared(dbs_info->cdbs.cur_policy)) { od_timer_coordinated(dbs_info, dw); } else { mutex_lock(&dbs_info->cdbs.timer_mutex); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 5fdc6c6..f106406 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -125,6 +125,11 @@ struct cpufreq_policy { #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ +static inline bool policy_is_shared(struct cpufreq_policy *policy) +{ + return cpumask_weight(policy->cpus) > 1; +} + /******************** cpufreq transition notifiers *******************/ #define CPUFREQ_PRECHANGE (0)