From patchwork Mon Jan 11 17:35:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 8007321 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 40908BEEE5 for ; Mon, 11 Jan 2016 17:38:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58EB820256 for ; Mon, 11 Jan 2016 17:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A397201F2 for ; Mon, 11 Jan 2016 17:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761293AbcAKRhv (ORCPT ); Mon, 11 Jan 2016 12:37:51 -0500 Received: from foss.arm.com ([217.140.101.70]:57305 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761479AbcAKRht (ORCPT ); Mon, 11 Jan 2016 12:37:49 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6979C601; Mon, 11 Jan 2016 09:37:14 -0800 (PST) Received: from e106622-lin.cambridge.arm.com (e106622-lin.cambridge.arm.com [10.1.208.152]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5E92C3F24D; Mon, 11 Jan 2016 09:37:47 -0800 (PST) From: Juri Lelli To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, juri.lelli@arm.com Subject: [RFC PATCH 18/19] cpufreq: remove transition_lock Date: Mon, 11 Jan 2016 17:35:59 +0000 Message-Id: <1452533760-13787-19-git-send-email-juri.lelli@arm.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> References: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Michael Turquette transition_lock was introduced to serialize cpufreq transition notifiers. Instead of using a different lock for protecting concurrent modifications of policy, it is better to require that callers of transition notifiers implement appropriate locking (this is already the case AFAICS). Removing transition_lock also simplifies current locking scheme. Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Signed-off-by: Juri Lelli Signed-off-by: Michael Turquette --- drivers/cpufreq/cpufreq.c | 19 ++++++++++--------- include/linux/cpufreq.h | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 6c9bef7..78b1e2f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -421,10 +421,15 @@ static void cpufreq_notify_post_transition(struct cpufreq_policy *policy, cpufreq_notify_transition(policy, freqs, CPUFREQ_POSTCHANGE); } +/* + * Callers must ensure proper mutual exclusion on policy (for transition_ + * ongoing/transition_task handling). While holding policy->rwsem is + * sufficient, other scheme might work as well (e.g., cpufreq_governor.c + * holds timer_mutex while entering the path that generates transitions). + */ void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, struct cpufreq_freqs *freqs) { - /* * Catch double invocations of _begin() which lead to self-deadlock. * ASYNC_NOTIFICATION drivers are left out because the cpufreq core @@ -439,22 +444,19 @@ void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, wait: wait_event(policy->transition_wait, !policy->transition_ongoing); - spin_lock(&policy->transition_lock); - - if (unlikely(policy->transition_ongoing)) { - spin_unlock(&policy->transition_lock); + if (unlikely(policy->transition_ongoing)) goto wait; - } policy->transition_ongoing = true; policy->transition_task = current; - spin_unlock(&policy->transition_lock); - cpufreq_notify_transition(policy, freqs, CPUFREQ_PRECHANGE); } EXPORT_SYMBOL_GPL(cpufreq_freq_transition_begin); +/* + * As above, callers must ensure proper mutual exclusion on policy. + */ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, struct cpufreq_freqs *freqs, int transition_failed) { @@ -1057,7 +1059,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) kobject_init(&policy->kobj, &ktype_cpufreq); INIT_LIST_HEAD(&policy->policy_list); init_rwsem(&policy->rwsem); - spin_lock_init(&policy->transition_lock); init_waitqueue_head(&policy->transition_wait); init_completion(&policy->kobj_unregister); INIT_WORK(&policy->update, handle_update); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 79b87ce..6bbb88f 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -105,7 +105,6 @@ struct cpufreq_policy { /* Synchronization for frequency transitions */ bool transition_ongoing; /* Tracks transition status */ - spinlock_t transition_lock; wait_queue_head_t transition_wait; struct task_struct *transition_task; /* Task which is doing the transition */