Messages in this thread | | | Date | Thu, 20 Mar 2014 14:07:47 +0530 | Subject | Re: [RFC v3] cpufreq: Make sure frequency transitions are serialized | From | Viresh Kumar <> |
| |
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); > +}
| |