From patchwork Tue Feb 9 03:46:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61485 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1808365lbl; Mon, 8 Feb 2016 19:48:29 -0800 (PST) X-Received: by 10.66.191.104 with SMTP id gx8mr47026451pac.21.1454989707210; Mon, 08 Feb 2016 19:48:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yq2si50901180pac.19.2016.02.08.19.48.26; Mon, 08 Feb 2016 19:48:27 -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 S1756164AbcBIDsY (ORCPT + 30 others); Mon, 8 Feb 2016 22:48:24 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33107 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755760AbcBIDrf (ORCPT ); Mon, 8 Feb 2016 22:47:35 -0500 Received: by mail-pa0-f44.google.com with SMTP id cy9so84422929pac.0 for ; Mon, 08 Feb 2016 19:47:35 -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=4tcqRlRIjOVcJ3VR8jhYf4VluKrGEKBLnWUGscWpf/Q=; b=L3aiohX+ew/qt6Sh7o1+6xX94oM9Aobc6IpKFlW7/2YIfdrDXuWGCRbQrlsEo6AUNq KWfHGHm+zlK4zuOV81i6djHU76KJe7lbMWvKVN34Z6r1wXaefRPel8D/aEHLyENnJWJm /3ok678CFsp0o17WMDluUv2XGpbeERxHMjWg0= 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=4tcqRlRIjOVcJ3VR8jhYf4VluKrGEKBLnWUGscWpf/Q=; b=C/vGPKtF3G8/ET8+FtX/Q3b4nADpuHuKbDp9Br+4xUFM7i7azGa90yp+rkq9FZ5fJH 61LPWo++6IxJzvoqynAj3Tfkh/spqU6WaccdyNBWsd+/ETXTCkfDXjf20V0jdHQNdSzZ wtFYmfWaxcnkN2ogZm+RcqR/1xiR8bWcY2iym0uPB8h30wvEnVmTK4OnGOKFakXCUdpz YlmRb6/tbebRXdd8yTBRzXWhT8M9Kj1365m9KMrTXF3OOJD36JlGIvZ9/5GGUP8wgpxm FD2yQPfOcXXiajZ3bEqYfpi2hYG9JtBA8eAqudkiPZb+rdIHmdbSroI8ld1KnB/SDNq4 AkPg== X-Gm-Message-State: AG10YOSOefJz/dx8Jdz4Z+Ai/6uW9FEpdtg7L96K8eoXhZN1YeMweH3xu4UzZH5Anrhm7Hbs X-Received: by 10.66.222.129 with SMTP id qm1mr46870951pac.10.1454989654860; Mon, 08 Feb 2016 19:47:34 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id cf6sm46485780pad.41.2016.02.08.19.47.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 19:47:34 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V4 3/7] cpufreq: Remove cpufreq_governor_lock Date: Tue, 9 Feb 2016 09:16:15 +0530 Message-Id: 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 Tested-by: Juri Lelli Tested-by: Shilpasri G Bhat --- 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 4e77efb7db67..02885e353dfc 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -232,7 +232,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)