lkml.org 
[lkml]   [2014]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC v3] cpufreq: Make sure frequency transitions are serialized
From
On 20 March 2014 14:02, Srivatsa S. Bhat
<srivatsa.bhat@linux.vnet.ibm.com> wrote:
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 199b52b..5283f10 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -349,6 +349,39 @@ void cpufreq_notify_post_transition(struct cpufreq_policy *policy,
> EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
>
>
> +void cpufreq_freq_transition_begin(struct cpufreq_policy *policy,
> + struct cpufreq_freqs *freqs, unsigned int state)
> +{
> +wait:
> + wait_event(&policy->transition_wait, !policy->transition_ongoing);
> +
> + mutex_lock(&policy->transition_lock);
> +
> + if (policy->transition_ongoing) {
> + mutex_unlock(&policy->transition_lock);
> + goto wait;
> + }
> +
> + policy->transition_ongoing = true;
> +
> + mutex_unlock(&policy->transition_lock);
> +
> + cpufreq_notify_transition(policy, freqs, CPUFREQ_PRECHANGE);
> +}
> +
> +void cpufreq_freq_transition_end(struct cpufreq_policy *policy,
> + struct cpufreq_freqs *freqs, unsigned int state)
> +{
> + cpufreq_notify_transition(policy, freqs, CPUFREQ_POSTCHANGE);
> +
> + mutex_lock(&policy->transition_lock);

Why do we need locking here? You explained that earlier :)

Also, I would like to add this here:

WARN_ON(policy->transition_ongoing);

> + policy->transition_ongoing = false;
> + mutex_unlock(&policy->transition_lock);
> +
> + wake_up(&policy->transition_wait);
> +}


\
 
 \ /
  Last update: 2014-03-20 10:21    [W:0.059 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site