From patchwork Thu Oct 29 12:27:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 55759 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp529804lbr; Thu, 29 Oct 2015 05:28:00 -0700 (PDT) X-Received: by 10.50.50.232 with SMTP id f8mr9556487igo.66.1446121680120; Thu, 29 Oct 2015 05:28:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si2842227ioe.71.2015.10.29.05.27.59; Thu, 29 Oct 2015 05:28:00 -0700 (PDT) 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=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 S1756859AbbJ2M1s (ORCPT + 28 others); Thu, 29 Oct 2015 08:27:48 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36848 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751855AbbJ2M1p (ORCPT ); Thu, 29 Oct 2015 08:27:45 -0400 Received: by pacfv9 with SMTP id fv9so41605863pac.3 for ; Thu, 29 Oct 2015 05:27:45 -0700 (PDT) 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=XRdMd32Fb8AcDLcDSjCzAIdZVWVicTMVbgIZvRwaMHQxS9k1IjD1nCH55MD4GZr6FM uqiJOqj4pbJKR9y7a2eqNAHcKMrwhZMY8w7I7+QZleWu0LSOma/vR2Q9k0795xac+iPf vBE3mUqOEjxkcdvcIWuTGpIb+5JnjNtVCp8cNz0I0Mt9pwmmuKDxAeuTvY50O8QIop5G oGh5eowVxJrbPrlkhDsRcy5TI40jSPWTeK4/RG9eVFXzEotx+a1iQVpJpIddhVtT68lx 2xEbSmLIM9lK6hYpP15e8SYL4DpJkIrxw8aSY65GRsRi+0Jcyp89XuuwLd8TmKvg1usS l5HQ== 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=iytEBNr2aedIdnlt/RytlMpwljFAr6sYTi5zuFXSJVIaQzsUiw6yV7Kk3l250md7fs mb5bh9bylsN6Qu1lsMYDhvI9T7LGvN4qFNxt6cCexHs8G/8uwXmvttfSMaw4/298YXic yCAKVGDAqgkmR4DVniz9h/0YzCW+ymqfQpO+Go3ym6cos3kM2ASe6SKnlgC1192d+EgZ ylc25iiUsqyRPOwm43XRB3XQbtxhn+n/Scb+lBwDPWQFOFptDoNtiEu1PW9LHPGysfdn UyeehmgCFrLHvnjo7GqLsFAgbiYJgsEcSQc9TmM1DBd//WyPQW8pVqKD8T+4pMWLX/+9 PR/Q== X-Gm-Message-State: ALoCoQnmECdcs+cXFfoguZf4Yan511hU4/GEgM4Mf0M/0prZ7tEfoI7dZfjgrxW2uV9iUwVfkOk+ X-Received: by 10.66.191.225 with SMTP id hb1mr1627902pac.153.1446121665280; Thu, 29 Oct 2015 05:27:45 -0700 (PDT) Received: from localhost ([122.172.111.169]) by smtp.gmail.com with ESMTPSA id ce3sm2208313pbb.35.2015.10.29.05.27.44 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 29 Oct 2015 05:27:44 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 4/6] cpufreq: governor: initialize/destroy timer_mutex with 'shared' Date: Thu, 29 Oct 2015 17:57:23 +0530 Message-Id: X-Mailer: git-send-email 2.6.2.198.g614a2ac 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 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-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/ 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; }