cpufreq: interactive: fix racy timer stopping
authorTodd Poynor <toddpoynor@google.com>
Wed, 19 Dec 2012 01:50:44 +0000 (17:50 -0800)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 16 Feb 2016 21:52:49 +0000 (13:52 -0800)
commit583695f13bbcc33f356a3fe598c30b10bd0c5c48
tree15d9b6cab7fe4a349f2f246a46ee2ad223c1587e
parent74f0d695dd30194ecd9edebb10a4375abc4d79fb
cpufreq: interactive: fix racy timer stopping

When stopping the governor, del_timer_sync() can race against an
invocation of the idle notifier callback, which has the potential
to reactivate the timer.

To fix this issue, a read-write semaphore is used. Multiple readers are
allowed as long as pcpu->governor_enabled is true.  However it can be
moved to false only after taking a write semaphore which would wait for
any on-going asynchronous activities to complete and prevent any more of
those activities to be initiated.

[toddpoynor@google.com: cosmetic and commit text changes]
Change-Id: Ib51165a735d73dcf964a06754c48bdc1913e13d0
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
drivers/cpufreq/cpufreq_interactive.c