From patchwork Tue Feb 9 03:46:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61486 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1808385lbl; Mon, 8 Feb 2016 19:48:34 -0800 (PST) X-Received: by 10.98.72.70 with SMTP id v67mr47313584pfa.100.1454989713946; Mon, 08 Feb 2016 19:48:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sj10si50931122pab.65.2016.02.08.19.48.33; Mon, 08 Feb 2016 19:48:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756248AbcBIDs2 (ORCPT + 30 others); Mon, 8 Feb 2016 22:48:28 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:36071 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755860AbcBIDrr (ORCPT ); Mon, 8 Feb 2016 22:47:47 -0500 Received: by mail-pf0-f179.google.com with SMTP id e127so25014938pfe.3 for ; Mon, 08 Feb 2016 19:47:47 -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 :in-reply-to:references; bh=2kdCsR08/bh2To3oEqBwaeebpA8SvWlL1z6ub1Jj2vE=; b=Ij7MxZSzaPC7PznZaQQL7B0F3G7MLMWQTYAndg0AKLcr80QzePIxoxqAtgcFAtgZ+B vp1R7UW7ASx1/umJJpbRPvEOKKmgEeYkeQqEmpUNf9+lJsw/NPNWYrcaMbC0zreBemcm wV/ykH88SsDWGSIL6AXc5TSqqR4d6k2T573I8= 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:in-reply-to:references; bh=2kdCsR08/bh2To3oEqBwaeebpA8SvWlL1z6ub1Jj2vE=; b=jpQ+QY71VjiEHqvRWnbGRs6G4I4gMLkgRtDFub1rkdWEsIYyoF24Icbja5mgTVZUCj qAeMLz2/zU749N5EmqpuRA+wH77u9hXJZrAH2k+9gACl58LLzS1R58ru6s8I6opJ5ye0 6WGmUFFdwoYO6Ij/1VjQf7Gs/kY/uqNocEsLd+1ejbXezRirAbLSlxLcjBwaxRih+E3+ eeH/knOtFy2x4nSlwulXDKW3FVsdB/ltv/1TOf18Zk3/mWNb3aJKEdnvzqpCg4Lm+md9 FsMVrMXvfDzxlr85wCjtCqcYW/hB9rwLBbKcf3yE5aUvsVuoh+8/84/uzsu/2lvAj7MO MkDw== X-Gm-Message-State: AG10YORWT6iOm8b6AcK831z9mYSNL/0X5yrIypDBUEbeweacpbPRUecwH9/4gFuGej75tRNX X-Received: by 10.98.72.70 with SMTP id v67mr47310271pfa.100.1454989667217; Mon, 08 Feb 2016 19:47:47 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id s90sm40927279pfa.49.2016.02.08.19.47.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 19:47:46 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V4 5/7] cpufreq: governor: No need to manage state machine now Date: Tue, 9 Feb 2016 09:16:17 +0530 Message-Id: <9b7ac57013a525863d6c0c5e86419744d37879a4.1454988792.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpufreq core now guarantees that policy->rwsem wouldn't get dropped while calling CPUFREQ_GOV_POLICY_EXIT governor event and will be kept acquired until the complete sequence of governor state changes has finished. And so we can remove the state machine checks that were put in place earlier. This also means that policy_dbs->policy can be initialized while policy_dbs is allocated, to move all initialization together. Signed-off-by: Viresh Kumar Tested-by: Juri Lelli Tested-by: Shilpasri G Bhat --- drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 7038ada3915d..464f346815e0 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -332,8 +332,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); /* @@ -429,6 +431,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); @@ -560,10 +563,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--; @@ -599,10 +598,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; @@ -627,7 +622,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 = @@ -650,14 +644,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; } @@ -666,10 +653,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);