aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2012-03-15 14:24:31 -0400
committerPaul Walmsley <paul@pwsan.com>2012-04-04 11:23:34 -0400
commit0eb4fd9b3e4d08973f7f086dbdb14a0ad5c3d76d (patch)
tree5e767d3317de04c638eac3adf5578959c8a303b1 /arch/arm
parentac387330a67635b4e4b946416e792bc9dd4b8f05 (diff)
ARM: OMAP: clock: fix race in disable all clocks
clk_disable_unused is invoked when CONFIG_OMAP_RESET_CLOCKS=y. Since clk_disable_unused is called as lateinitcall, there can be more than a few workqueues executing off secondary CPU(s). The current code does the following: a) checks if clk is unused b) holds lock c) disables clk d) unlocks Between (a) and (b) being executed on CPU0, It is possible to have a driver executing on CPU1 which could do a get_sync->clk_get (and increase the use_count) of the clock which was just about to be disabled by clk_disable_unused. We ensure instead that the entire list traversal is protected by the lock allowing for parent child clock traversal which could be potentially be done by runtime operations to be safe as well. Reported-by: Todd Poynor <toddpoynor@google.com> Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/plat-omap/clock.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 56b6f8b7053e..8506cbb7fea4 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -441,6 +441,8 @@ static int __init clk_disable_unused(void)
441 return 0; 441 return 0;
442 442
443 pr_info("clock: disabling unused clocks to save power\n"); 443 pr_info("clock: disabling unused clocks to save power\n");
444
445 spin_lock_irqsave(&clockfw_lock, flags);
444 list_for_each_entry(ck, &clocks, node) { 446 list_for_each_entry(ck, &clocks, node) {
445 if (ck->ops == &clkops_null) 447 if (ck->ops == &clkops_null)
446 continue; 448 continue;
@@ -448,10 +450,9 @@ static int __init clk_disable_unused(void)
448 if (ck->usecount > 0 || !ck->enable_reg) 450 if (ck->usecount > 0 || !ck->enable_reg)
449 continue; 451 continue;
450 452
451 spin_lock_irqsave(&clockfw_lock, flags);
452 arch_clock->clk_disable_unused(ck); 453 arch_clock->clk_disable_unused(ck);
453 spin_unlock_irqrestore(&clockfw_lock, flags);
454 } 454 }
455 spin_unlock_irqrestore(&clockfw_lock, flags);
455 456
456 return 0; 457 return 0;
457} 458}