cpufreq: interactive: fix racy timer stopping
authorTodd Poynor <toddpoynor@google.com>
Wed, 19 Dec 2012 01:50:44 +0000 (17:50 -0800)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:18 +0000 (14:16 -0700)
commitbeb55c19d504f6d8fd7cd1c019027d67d4b4084a
tree065f94bb09c24bc12ff6fc32162acc55a6243355
parentf5e5ad4292c6ebe1d57221413d8215d024c6c401
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