From patchwork Tue Feb 2 10:57:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61008 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp651172lbb; Tue, 2 Feb 2016 02:58:11 -0800 (PST) X-Received: by 10.66.150.66 with SMTP id ug2mr46639257pab.114.1454410688223; Tue, 02 Feb 2016 02:58:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uh6si1296141pab.3.2016.02.02.02.58.07; Tue, 02 Feb 2016 02:58:08 -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 S1754836AbcBBK6E (ORCPT + 30 others); Tue, 2 Feb 2016 05:58:04 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:33987 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754811AbcBBK6A (ORCPT ); Tue, 2 Feb 2016 05:58:00 -0500 Received: by mail-pf0-f179.google.com with SMTP id o185so96549025pfb.1 for ; Tue, 02 Feb 2016 02:58:00 -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=y/bckYiE3h5hb7nfxUvpI/tSmc9pFDpSYTBFmcRYjMA=; b=fwVP96CoUpbZJPlu9gsvbDwbprY0uUC0J1GZBKVin3yAEvZMgbz+NaU2Uk9ZaewntG h6mvu8RW9Hcd4vM6Belyb5AZngKJ0/Ttyemnwo6eBldepcC69Ow7Zj2oPF4txhfUvsGd SX++u8Qj1On2uh5Kqnc4f0+Vvsgtw4A+guMZ8= 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=y/bckYiE3h5hb7nfxUvpI/tSmc9pFDpSYTBFmcRYjMA=; b=ZGASpR1Bh0vafbDkLPMkop4Kn3BPPst6oMogKSNtywwKMFe1gk+nSw14MlCwLacKtC ZgpUqFuZbZsfomjnu6HM8g74VkxWb4Ok1JmKbj7l2PIyEzZMedxPaDqG8UNltyW5kVQW h207VBxAQynXMPYmCPYpgH4Fl33rIiLylm+XulUvEu7kkmOYRFypNzRdUSurhMuljhNn VfugBe5HUlob69uROto9kXqqZFtAyZ/4frlP2znSDAe18puq2DjlI3xQ+1H+XhQB4rJ9 epvkjI5zFv2pZQLO/GO7seR00X5Zdk4G3s6Yx1Ch+bkRuwPB/mcTgozRD4qb1Igs4VFf Rnfg== X-Gm-Message-State: AG10YOTtWYwq0+615GZLocWsS9a4230n5B7HNFNnUCYcUAJQu13/+AJFPz3Baq6hyzlxr5z9 X-Received: by 10.66.235.162 with SMTP id un2mr45643714pac.17.1454410679912; Tue, 02 Feb 2016 02:57:59 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id f27sm1864052pfj.0.2016.02.02.02.57.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Feb 2016 02:57:59 -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, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 5/5] cpufreq: Get rid of ->governor_enabled and its lock Date: Tue, 2 Feb 2016 16:27:25 +0530 Message-Id: <48d24fd180e1fdf1c06a6992748c6365be43e937.1454410226.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.0.79.gdc08a19 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 Invalid state-transitions is verified by governor core now and there is no need to replicate that in cpufreq core. Also we don't drop policy->rwsem anymore, which makes rest of the races go away. Simplify code a bit now. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 24 ------------------------ include/linux/cpufreq.h | 1 - 2 files changed, 25 deletions(-) -- 2.7.0.79.gdc08a19 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5f7e24567e0e..052ad1b9372c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -102,7 +102,6 @@ static LIST_HEAD(cpufreq_governor_list); static struct cpufreq_driver *cpufreq_driver; static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); static DEFINE_RWLOCK(cpufreq_driver_lock); -DEFINE_MUTEX(cpufreq_governor_lock); /* Flag to suspend/resume CPUFreq governors */ static bool cpufreq_suspended; @@ -1963,21 +1962,6 @@ 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; - } - - if (event == CPUFREQ_GOV_STOP) - policy->governor_enabled = false; - else if (event == CPUFREQ_GOV_START) - policy->governor_enabled = true; - - mutex_unlock(&cpufreq_governor_lock); - ret = policy->governor->governor(policy, event); if (!ret) { @@ -1985,14 +1969,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, policy->governor->initialized++; else if (event == CPUFREQ_GOV_POLICY_EXIT) 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/include/linux/cpufreq.h b/include/linux/cpufreq.h index 79b87cebaa9c..e90cf5d31e85 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -80,7 +80,6 @@ struct cpufreq_policy { unsigned int last_policy; /* policy before unplug */ struct cpufreq_governor *governor; /* see below */ void *governor_data; - bool governor_enabled; /* governor start/stop flag */ char last_governor[CPUFREQ_NAME_LEN]; /* last governor used */ struct work_struct update; /* if update_policy() needs to be