diff options
author | Todd Poynor <toddpoynor@google.com> | 2012-12-20 15:51:00 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2014-03-19 13:09:48 -0700 |
commit | 258432fdd61e1664752affa0352a643ac2c1e572 (patch) | |
tree | 61b8c3e93c45d5742ae427646629df5bb70d985f | |
parent | 24d67a5821777ffbc528d6b49b15402d0f3482c1 (diff) |
cpufreq: interactive: fix race on timer restart on governor start
Starting the governor, or restarting on a hotplugged-in CPU, can race
with the timer start in idle, triggering a BUG on timer already pending.
Start the timer before setting the enable flag, and use enable_sem to
protect the sequence (and ensure correct order of the update to the
enable flag). Delete any existing timer for safety.
Change-Id: Ife77cf9fe099e8fd8543224cbf148c6722c2ffb0
Reported-by: Francisco Franco <francisco.franco@cloudcar.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r-- | drivers/cpufreq/cpufreq_interactive.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 74f56093d2f3..d22d162c9f27 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -919,17 +919,17 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ktime_to_us(ktime_get()); pcpu->hispeed_validate_time = pcpu->floor_validate_time; - pcpu->governor_enabled = 1; - smp_wmb(); + down_write(&pcpu->enable_sem); expires = jiffies + usecs_to_jiffies(timer_rate); pcpu->cpu_timer.expires = expires; add_timer_on(&pcpu->cpu_timer, j); - if (timer_slack_val >= 0) { expires += usecs_to_jiffies(timer_slack_val); pcpu->cpu_slack_timer.expires = expires; add_timer_on(&pcpu->cpu_slack_timer, j); } + pcpu->governor_enabled = 1; + up_write(&pcpu->enable_sem); } /* |