Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1282692

[PATCH V2 4/6] cpufreq: governor: initialize/destroy timer_mutex with 'shared'

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [PATCH V2 4/6] cpufreq: governor: initialize/destroy timer_mutex with 'shared'
Date Thu, 03 Dec 2015 05:20:01 +0100
Message-ID <qBtx7-8sd-9@gated-at.bofh.it> (permalink)
References <qBtnr-8mi-3@gated-at.bofh.it>
X-Original-To Rafael Wysocki <rjw@rjwysocki.net>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=AwmVfAX83xr07tNtVMkMmLP1BRqZYU/mr3UMLgjC2m0=; b=zZC16W/drde47dKoWu6wAk4yW3RSRy4RvmWpmLG1ZsIHDBfrl6veZ6LP9TW6a5Io07 dnRHy0qTu4qkHULCpmr+yPttWaihQVb2lPly83a92k78eQP4Hz4fHUkLLXvEt5DQlmAw Fux/tR3Q3cM6d6f9G5Y8on9b5i9Pd7sygpUOI6xkBDEFSgV2FJVTLpeSX3n5/1M+DNSc dsZz9xZ86O6OTvrvcLnRq53NDJAVaUjo83F3sZGomRe75unpgOargU+b/FPMsOF7OFIw OAK8hTxp0xNtuChLRP0yTSE/nknZSl8sO7fWH+7JEDj6In7Yb7U/r8zpVukEfSCOuhA8 0f9w==
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=AwmVfAX83xr07tNtVMkMmLP1BRqZYU/mr3UMLgjC2m0=; b=JdZsYo0x+gQIap3cVPJQ6jvNKvhCHJ6jqprkGpyaoY+wulKboSrbPRQtA+TnQeoUcu DmFaVSaUWNgOHQ+L+f+Ac+Rfji6aBiNBKCgP/VeKOBXwzy0nUF2tUXSwC2xc+nvzSBVO 8ZgGyqI4uhnFKdfQS5BlkA+P1IoMXGfMWIrocPb2wKAvc9yObtFIjYOjojwJi2Wq50Ze 31T7H2Ldw2g/KOhvc8jv1OpiwCKbKIvRgkpBpesToPaHTu1ACdtIlpT06Lv8LEHV+Cwp JLoaBmruUgUZGqjJQqx4ogQ7wXS7mSalips3BIqKdh2s2thM3O1b5V9xRhZOrw7M2z46 FsvA==
X-Gm-Message-State ALoCoQm5dXskDFfOmZ7T/nuPafYHb1Yr8jH/LQO8HEvacJi14EQPOUpUmjqOlNszKK8pOT4oZ2Wt
X-Received by 10.98.66.206 with SMTP id h75mr10098510pfd.51.1449115694981; Wed, 02 Dec 2015 20:08:14 -0800 (PST)
X-Mailer git-send-email 2.6.2.198.g614a2ac
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 58
Organization linux.* mail to news gateway
X-Original-Cc linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, ashwin.chaugule@linaro.org, Viresh Kumar <viresh.kumar@linaro.org>, linux-kernel@vger.kernel.org (open list)
X-Original-Date Thu, 3 Dec 2015 09:37:52 +0530
X-Original-Message-ID <ff71a7eb4399f803c7d44853ac091ed474d7c9c4.1449115453.git.viresh.kumar@linaro.org>
X-Original-References <cover.1449115453.git.viresh.kumar@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1282692

Show key headers only | View raw


timer_mutex is required to be initialized only while memory for 'shared'
is allocated and in a similar way it is required to be destroyed only
when memory for 'shared' is freed.

There is no need to do the same every time we start/stop the governor.
Move code to initialize/destroy timer_mutex to the relevant places.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_governor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index cdcb56a49b28..999e1f6addf9 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -287,6 +287,7 @@ static int alloc_common_dbs_info(struct cpufreq_policy *policy,
 	for_each_cpu(j, policy->related_cpus)
 		cdata->get_cpu_cdbs(j)->shared = shared;
 
+	mutex_init(&shared->timer_mutex);
 	return 0;
 }
 
@@ -297,6 +298,8 @@ static void free_common_dbs_info(struct cpufreq_policy *policy,
 	struct cpu_common_dbs_info *shared = cdbs->shared;
 	int j;
 
+	mutex_destroy(&shared->timer_mutex);
+
 	for_each_cpu(j, policy->cpus)
 		cdata->get_cpu_cdbs(j)->shared = NULL;
 
@@ -433,7 +436,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
 
 	shared->policy = policy;
 	shared->time_stamp = ktime_get();
-	mutex_init(&shared->timer_mutex);
 
 	for_each_cpu(j, policy->cpus) {
 		struct cpu_dbs_info *j_cdbs = cdata->get_cpu_cdbs(j);
@@ -493,8 +495,6 @@ static int cpufreq_governor_stop(struct cpufreq_policy *policy,
 	mutex_unlock(&shared->timer_mutex);
 
 	gov_cancel_work(dbs_data, policy);
-
-	mutex_destroy(&shared->timer_mutex);
 	return 0;
 }
 
-- 
2.6.2.198.g614a2ac

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH V2 4/6] cpufreq: governor: initialize/destroy timer_mutex with 'shared' Viresh Kumar <viresh.kumar@linaro.org> - 2015-12-03 05:20 +0100

csiph-web