Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966942AbcCPPiK (ORCPT ); Wed, 16 Mar 2016 11:38:10 -0400 Received: from [198.137.202.9] ([198.137.202.9]:46464 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S964917AbcCPPiI (ORCPT ); Wed, 16 Mar 2016 11:38:08 -0400 Date: Wed, 16 Mar 2016 16:35:50 +0100 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: Linux PM list , Juri Lelli , Steve Muckle , ACPI Devel Maling List , Linux Kernel Mailing List , Srinivas Pandruvada , Viresh Kumar , Vincent Guittot , Michael Turquette , Ingo Molnar Subject: Re: [PATCH v4 6/7] cpufreq: Support for fast frequency switching Message-ID: <20160316153550.GA6344@twins.programming.kicks-ass.net> References: <1711281.bPmSjlBT7c@vostro.rjw.lan> <1989596.XAKfhFj1lz@vostro.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1989596.XAKfhFj1lz@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1199 Lines: 35 On Wed, Mar 16, 2016 at 03:52:28PM +0100, Rafael J. Wysocki wrote: > +/** > + * cpufreq_enable_fast_switch - Enable fast frequency switching for policy. > + * @policy: cpufreq policy to enable fast frequency switching for. > + * > + * Try to enable fast frequency switching for @policy. > + * > + * The attempt will fail if there is at least one transition notifier registered > + * at this point, as fast frequency switching is quite fundamentally at odds > + * with transition notifiers. Thus if successful, it will make registration of > + * transition notifiers fail going forward. > + * > + * Call under policy->rwsem. Nobody reads a comment.. > + */ > +void cpufreq_enable_fast_switch(struct cpufreq_policy *policy) > +{ lockdep_assert_held(&policy->rwsem); While everybody complains when there's a big nasty splat in their dmesg ;-) > + mutex_lock(&cpufreq_fast_switch_lock); > + if (policy->fast_switch_possible && cpufreq_fast_switch_count >= 0) { > + cpufreq_fast_switch_count++; > + policy->fast_switch_enabled = true; > + } else { > + pr_warn("cpufreq: CPU%u: Fast freqnency switching not enabled\n", > + policy->cpu); > + } > + mutex_unlock(&cpufreq_fast_switch_lock); > +}