From patchwork Mon Feb 8 11:39:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61392 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1383905lbl; Mon, 8 Feb 2016 03:41:02 -0800 (PST) X-Received: by 10.98.40.200 with SMTP id o191mr14389549pfo.83.1454931662661; Mon, 08 Feb 2016 03:41:02 -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.02; Mon, 08 Feb 2016 03:41:02 -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 S1752555AbcBHLko (ORCPT + 30 others); Mon, 8 Feb 2016 06:40:44 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35239 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263AbcBHLkl (ORCPT ); Mon, 8 Feb 2016 06:40:41 -0500 Received: by mail-pf0-f176.google.com with SMTP id c10so41790359pfc.2 for ; Mon, 08 Feb 2016 03:40:41 -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=8fYCyMqimT9+hdvcpRDEk8S2vMW79EUIR+17WuKv0uo=; b=Qe+CA9R9oqs60LpTqXmMQYjywgsr29sKyo1gTwf28GssJAdPXrN5RYu0qQshKSs32v zbrmqM91btJTaXwYWOG0qs7lGRU8pIOU0IFf+m9pWtjr5mFoy6/hMyVjS8hIlhYIE81b f34nAZZCRJcmhGhIT1nrDT9ygLz/6OWDG+4yY= 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=8fYCyMqimT9+hdvcpRDEk8S2vMW79EUIR+17WuKv0uo=; b=SnjBSu7wsCVzyHcJsgncUMfeMP3eAcdcXxcQnCv5Xac/HgyRjXbRXDCHvbiKYbARKK 1Co+lPy7JCkhHvqqMuBo2Z5fFeVxFER1XidMCbB1rSruHRXlAwLxTf7bn50wcJsqVzBi OkNmx/T9DyrU6osczdtACF9B8VA2+aGkhoTji2WRv//AQU/f0OAkTcldcbmVLBEraWP8 /J7ofDwhnw0lZpniQ0Xku7ALv5hGb8izqOGmDHPwQIEOtdP98zZ8GWhYc9bsTn1fB33w 2qCpb5yaP2HNQEMkUjMd8IlrxDKxJjzZ4Rm/nAwDbgr/c8EO8jnvtJP+Ud6m0rPtAHM8 rofg== X-Gm-Message-State: AG10YORxvvXw2fe5Bps4gcoimDiVzZQZSeNBIwkN26ZXFIqqs17MZ40WO3ZEn7/1TVtXLThP X-Received: by 10.98.42.10 with SMTP id q10mr41588443pfq.73.1454931641026; Mon, 08 Feb 2016 03:40:41 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id n4sm42950436pfi.3.2016.02.08.03.40.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 03:40:40 -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 08/13] cpufreq: Remove cpufreq_governor_lock Date: Mon, 8 Feb 2016 17:09:22 +0530 Message-Id: <103ddd66fd1aa9781747a4c93d38c50a78bceba4.1454931188.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 We used to drop policy->rwsem just before calling __cpufreq_governor() in some cases earlier and so it was possible that __cpufreq_governor() runs concurrently via separate threads. In order to guarantee valid state transitions for governors, 'governor_enabled' was required to be protected using some locking and we created cpufreq_governor_lock for that. But now, __cpufreq_governor() is always called from within policy->rwsem held and so 'governor_enabled' is protected against races even without cpufreq_governor_lock. Get rid of the extra lock now. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 8 -------- drivers/cpufreq/cpufreq_governor.h | 1 - 2 files changed, 9 deletions(-) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 51fb47cd38a0..745da90d7b38 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -146,8 +146,6 @@ void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) rcu_read_unlock(); } -DEFINE_MUTEX(cpufreq_governor_lock); - /* Flag to suspend/resume CPUFreq governors */ static bool cpufreq_suspended; @@ -2014,11 +2012,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, pr_debug("%s: for CPU %u, event %u\n", __func__, policy->cpu, event); - mutex_lock(&cpufreq_governor_lock); if ((policy->governor_enabled && event == CPUFREQ_GOV_START) || (!policy->governor_enabled && (event == CPUFREQ_GOV_LIMITS || event == CPUFREQ_GOV_STOP))) { - mutex_unlock(&cpufreq_governor_lock); return -EBUSY; } @@ -2027,8 +2023,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, else if (event == CPUFREQ_GOV_START) policy->governor_enabled = true; - mutex_unlock(&cpufreq_governor_lock); - ret = policy->governor->governor(policy, event); if (!ret) { @@ -2038,12 +2032,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, policy->governor->initialized--; } else { /* Restore original values */ - mutex_lock(&cpufreq_governor_lock); if (event == CPUFREQ_GOV_STOP) policy->governor_enabled = true; else if (event == CPUFREQ_GOV_START) policy->governor_enabled = false; - mutex_unlock(&cpufreq_governor_lock); } if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) || diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index f164437f235e..886578b5a4fd 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -228,7 +228,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) } extern struct mutex dbs_data_mutex; -extern struct mutex cpufreq_governor_lock; void dbs_check_cpu(struct cpufreq_policy *policy); int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); void od_register_powersave_bias_handler(unsigned int (*f)