From patchwork Thu Dec 3 04:07:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 57597 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3272763lbb; Wed, 2 Dec 2015 20:10:13 -0800 (PST) X-Received: by 10.66.158.169 with SMTP id wv9mr10066552pab.138.1449115813696; Wed, 02 Dec 2015 20:10:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12si9165742pfi.64.2015.12.02.20.10.13; Wed, 02 Dec 2015 20:10:13 -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.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758633AbbLCEKL (ORCPT + 11 others); Wed, 2 Dec 2015 23:10:11 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34206 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756206AbbLCEIP (ORCPT ); Wed, 2 Dec 2015 23:08:15 -0500 Received: by padhx2 with SMTP id hx2so59447746pad.1 for ; Wed, 02 Dec 2015 20:08:15 -0800 (PST) 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=Sm/whwLc0ib7Ggnj8Gn04Fytl6CZURVpXsyge58ZXOL2EN5nd9SYTKAmrTEi1uXq6Q Ofcu8GDOqOh9gmeLb1CzxWdkW5BQuYKDgNQ7iYq+9WcHDAiKPe1oUB8lg6n7ZECtdQCI ic2DltoHnUAMJuD07Agfna4aQpfhBoPDgQRrOJ0Wih5f2fTSRD3HpsCHvcnU5B9/rOh6 rkIwsLYTYpiG18tl8J8JBAZgWbLthJB1OivUPLTQuvjKFDvOhDnPsB6gqYvwdf6/+TjY UCOQ1L0ZP1VrTFIq21d/ENyaC3ULKivsMrQPwhhcmb2okNl8IdEpJPndlSj9TXwK4RUa VCEQ== X-Gm-Message-State: ALoCoQm0slVQNTZ4WIOiKJB8d+K5o9sgkBoacT/08TK61sFr5loiH2dIeUnxW6Vg1isnjTmpxu5d X-Received: by 10.98.66.206 with SMTP id h75mr10098510pfd.51.1449115694981; Wed, 02 Dec 2015 20:08:14 -0800 (PST) Received: from localhost ([122.172.170.156]) by smtp.gmail.com with ESMTPSA id t71sm7216958pfi.60.2015.12.02.20.08.13 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Dec 2015 20:08:14 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, ashwin.chaugule@linaro.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2 4/6] cpufreq: governor: initialize/destroy timer_mutex with 'shared' Date: Thu, 3 Dec 2015 09:37:52 +0530 Message-Id: X-Mailer: git-send-email 2.6.2.198.g614a2ac 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 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 --- drivers/cpufreq/cpufreq_governor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.6.2.198.g614a2ac -- 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 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; }