From patchwork Wed Feb 10 07:00:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61616 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2474330lbl; Tue, 9 Feb 2016 23:00:25 -0800 (PST) X-Received: by 10.98.14.146 with SMTP id 18mr38895137pfo.35.1455087625343; Tue, 09 Feb 2016 23:00:25 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb11si3128220pad.66.2016.02.09.23.00.24; Tue, 09 Feb 2016 23:00:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753838AbcBJHAX (ORCPT + 11 others); Wed, 10 Feb 2016 02:00:23 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35400 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533AbcBJHAW (ORCPT ); Wed, 10 Feb 2016 02:00:22 -0500 Received: by mail-pa0-f45.google.com with SMTP id ho8so7282828pac.2 for ; Tue, 09 Feb 2016 23:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cGKDP87+NG1caNy4i8LglRi89g55cXCzIBTfaXgLmq0=; b=GF6KfSRTxrb9m1XqfsZUxjnEl7ALAIYEk1kM2iDBub79JvuTR1/AKrYeCvZbQpPMC8 pSyELZiFHZRKiHAm2G+S85m7aTeYb3lYkx0V2H5KyOVV6msAVhw3Wj2V7qh+oNHJJCUG tuah0xLtbhubUm5Z0aM+o3w4uDAXFaeg0Qf+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cGKDP87+NG1caNy4i8LglRi89g55cXCzIBTfaXgLmq0=; b=JpS+5fteVqfJbWpspGM58i5J0WDP+LMegO0sCjGkokRa0BgZ0iRHxSyNiuZTzQe5t7 5PVSiom26LjLzskQM8CFHsps/onJDU5S0MP0ImXjouzla+OiojWtmhA7mVSaf55PYGjo 6P2YMulOMuAsP6eu7w/rL6BuRWBlgqvIjZ6R63+VQWKwNmoai9ANKZOwWxkPhfbon1xK oNG+MM5DR12SYg/UYvAixSd6MRmhss9IhFBRSHWW0UJuSB/w0DAWZ3L9tRRjR3WOpdhu hQvMJIum2AUjwMjpnvW4oBWL/8mwxjZh2ZO+3vEeWOU2VjbIhB3R8HgVu0rY6zOHyfPl kJQg== X-Gm-Message-State: AG10YOQCPDbkL7BngnTr0KqoYeXoLEXHF6qpxmAK8+sEdRz2yxCHOdYHycFG1XSLcUHNeubq X-Received: by 10.67.1.129 with SMTP id bg1mr9759317pad.63.1455087622042; Tue, 09 Feb 2016 23:00:22 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id i15sm2393351pfi.55.2016.02.09.23.00.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 23:00:21 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , Juri Lelli , Shilpasri G Bhat , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V5 1/3] cpufreq: governor: No need to manage state machine now Date: Wed, 10 Feb 2016 12:30:11 +0530 Message-Id: <8ddf5eb44eebba01062234d9aed931e3b6882a2b.1455087379.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpufreq core now guarantees that policy->rwsem won't be dropped while running the ->governor callback for the CPUFREQ_GOV_POLICY_EXIT event and will be held acquired until the complete sequence of governor state changes has finished. This allows governor state machine checks to be dropped from multiple functions in cpufreq_governor.c. This also means that policy_dbs->policy can be initialized upfront, so the entire initialization of struct policy_dbs is carried out in one place. Signed-off-by: Viresh Kumar Tested-by: Juri Lelli Tested-by: Shilpasri G Bhat --- Rafael, The 4th patch is dropped and 5-7 are updated on top of that. drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) -- 2.7.1.370.gb2aa7f8 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" 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/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 3a9dab752148..481585611097 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -233,8 +233,10 @@ static inline void gov_clear_update_util(struct cpufreq_policy *policy) synchronize_rcu(); } -static void gov_cancel_work(struct policy_dbs_info *policy_dbs) +static void gov_cancel_work(struct cpufreq_policy *policy) { + struct policy_dbs_info *policy_dbs = policy->governor_data; + /* Tell dbs_update_util_handler() to skip queuing up work items. */ atomic_inc(&policy_dbs->skip_work); /* @@ -330,6 +332,7 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poli if (!policy_dbs) return NULL; + policy_dbs->policy = policy; mutex_init(&policy_dbs->timer_mutex); atomic_set(&policy_dbs->skip_work, 0); init_irq_work(&policy_dbs->irq_work, dbs_irq_work); @@ -460,10 +463,6 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy) struct dbs_data *dbs_data = policy_dbs->dbs_data; int count; - /* State should be equivalent to INIT */ - if (policy_dbs->policy) - return -EBUSY; - mutex_lock(&dbs_data->mutex); list_del(&policy_dbs->list); count = --dbs_data->usage_count; @@ -499,10 +498,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy) if (!policy->cur) return -EINVAL; - /* State should be equivalent to INIT */ - if (policy_dbs->policy) - return -EBUSY; - sampling_rate = dbs_data->sampling_rate; ignore_nice = dbs_data->ignore_nice_load; @@ -527,7 +522,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy) if (ignore_nice) j_cdbs->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; } - policy_dbs->policy = policy; if (gov->governor == GOV_CONSERVATIVE) { struct cs_cpu_dbs_info_s *cs_dbs_info = @@ -550,14 +544,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy) static int cpufreq_governor_stop(struct cpufreq_policy *policy) { - struct policy_dbs_info *policy_dbs = policy->governor_data; - - /* State should be equivalent to START */ - if (!policy_dbs->policy) - return -EBUSY; - - gov_cancel_work(policy_dbs); - policy_dbs->policy = NULL; + gov_cancel_work(policy); return 0; } @@ -566,10 +553,6 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy) { struct policy_dbs_info *policy_dbs = policy->governor_data; - /* State should be equivalent to START */ - if (!policy_dbs->policy) - return -EBUSY; - mutex_lock(&policy_dbs->timer_mutex); if (policy->max < policy->cur) __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);