From patchwork Mon Feb 8 11:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61394 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1383950lbl; Mon, 8 Feb 2016 03:41:08 -0800 (PST) X-Received: by 10.66.235.36 with SMTP id uj4mr42310729pac.85.1454931663451; Mon, 08 Feb 2016 03:41:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bs10si46062182pad.73.2016.02.08.03.41.03; Mon, 08 Feb 2016 03:41:03 -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 S1752666AbcBHLkx (ORCPT + 11 others); Mon, 8 Feb 2016 06:40:53 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34582 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbcBHLkv (ORCPT ); Mon, 8 Feb 2016 06:40:51 -0500 Received: by mail-pa0-f48.google.com with SMTP id uo6so73851643pac.1 for ; Mon, 08 Feb 2016 03:40:51 -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=jSHcJBDI77M068fKRM25KOotfxsmTugNO0v56tmlicQ=; b=MzULS5djKGLyEWT4B325bySAmRG7UPyqI3lvG6xtQ3ZNopKWEgMm3oB4Qya5NCOmLF N58syBpZRupwknAZsXA8fydhpA5/qN1ZYKHxQAPsFuW032TwZh+3dIGT8rM0VA4twpsf 30UFuYLASNMfL0z5n9BJuSOipPamBKATJqKxY= 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=jSHcJBDI77M068fKRM25KOotfxsmTugNO0v56tmlicQ=; b=Q4DS3znvIN/P0o9zjZ39B6N6yGIwFEkRgz+nE5WjbQiI2ro5Hg8OSl3k0TGkSfbt1/ 5OLySYV4CCeHyQpH3E1nEViLmM1iEUJFxDerhUJ239vnc13rLojeUujTMtsjky3vkEIb DON46Vf9vTkqIYq4Tx/6Y6LysCAUtRg7zSWRVRErGrpOJKdZ+XwjkJ1e/cXeaHjn87M8 /2d0EKtA6p9Wzt1bNCh+rGw3ppkC0OOq/iZOoX8kwIlToiJeDBH3qLWx1e3ca3k+G9Bt ooIFc3KFhK2ZU2jV7XGBgYffmttSqYsFv415zIMpB1hEsmUunZ3UGRfQP/k/GpQIYFLP ooPA== X-Gm-Message-State: AG10YOTOO4KfynHKgV+pMG8HRHPgs67y/A8WWH4hPxKURArWjcBfWT/i131xD/r6A17QDjTq X-Received: by 10.66.234.226 with SMTP id uh2mr41295867pac.20.1454931651011; Mon, 08 Feb 2016 03:40:51 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id 27sm18313072pfh.48.2016.02.08.03.40.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 03:40:50 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, peterz@infradead.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V3 10/13] cpufreq: governor: No need to manage state machine now Date: Mon, 8 Feb 2016 17:09:24 +0530 Message-Id: <20ec06049bffdf0a41c89bbe9679a181f8def4cf.1454931189.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 --- drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- drivers/cpufreq/cpufreq_ondemand.c | 6 +++--- 2 files changed, 8 insertions(+), 25 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 5403f863b14d..ee3c2d92da53 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); @@ -551,10 +554,6 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy) struct policy_dbs_info *policy_dbs = policy->governor_data; struct dbs_data *dbs_data = policy_dbs->dbs_data; - /* State should be equivalent to INIT */ - if (policy_dbs->policy) - return -EBUSY; - if (!--dbs_data->usage_count) { kobject_put(&dbs_data->kobj); @@ -585,10 +584,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; @@ -613,7 +608,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 = @@ -636,14 +630,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; } @@ -652,10 +639,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); diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index ccc3419d43f3..745290d7f6a2 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -258,10 +258,10 @@ static void update_sampling_rate(struct dbs_data *dbs_data) policy_dbs = cdbs->policy_dbs; /* - * A valid policy_dbs and policy_dbs->policy means governor - * hasn't stopped or exited yet. + * A valid policy_dbs means governor hasn't stopped or exited + * yet. */ - if (!policy_dbs || !policy_dbs->policy) + if (!policy_dbs) continue; policy = policy_dbs->policy;