aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2015-01-13 09:44:06 -0500
committerMichael Turquette <mturquette@linaro.org>2015-01-13 13:54:01 -0500
commitdca1a4b5ff6e2c25adeff366eb06270dadeab3db (patch)
treefd13bbae56ec37b25b968ed7f49b2002cd7f72ae /drivers/clk
parent98f87a7ba278e6b9064b8022728c9c14ed467ebe (diff)
clk: at91: keep slow clk enabled to prevent system hang
All slow clk users are not properly claiming it (get + prepare + enable) before using it. If all users properly claiming this clock release it, the clock is disabled, but faulty users still depends on it, and the system hangs. This fix prevents the slow clock from being disabled, and should solve the hanging issue, but offending drivers should be patched to properly claim this clock. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reported-by: Bo Shen <voice.shen@atmel.com> Cc: stable@vger.kernel.org Signed-off-by: Michael Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/at91/clk-slow.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 32f7c1b36204..2f13bd5246b5 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -70,6 +70,7 @@ struct clk_sam9x5_slow {
70 70
71#define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw) 71#define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw)
72 72
73static struct clk *slow_clk;
73 74
74static int clk_slow_osc_prepare(struct clk_hw *hw) 75static int clk_slow_osc_prepare(struct clk_hw *hw)
75{ 76{
@@ -357,6 +358,8 @@ at91_clk_register_sam9x5_slow(void __iomem *sckcr,
357 clk = clk_register(NULL, &slowck->hw); 358 clk = clk_register(NULL, &slowck->hw);
358 if (IS_ERR(clk)) 359 if (IS_ERR(clk))
359 kfree(slowck); 360 kfree(slowck);
361 else
362 slow_clk = clk;
360 363
361 return clk; 364 return clk;
362} 365}
@@ -433,6 +436,8 @@ at91_clk_register_sam9260_slow(struct at91_pmc *pmc,
433 clk = clk_register(NULL, &slowck->hw); 436 clk = clk_register(NULL, &slowck->hw);
434 if (IS_ERR(clk)) 437 if (IS_ERR(clk))
435 kfree(slowck); 438 kfree(slowck);
439 else
440 slow_clk = clk;
436 441
437 return clk; 442 return clk;
438} 443}
@@ -465,3 +470,25 @@ void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
465 470
466 of_clk_add_provider(np, of_clk_src_simple_get, clk); 471 of_clk_add_provider(np, of_clk_src_simple_get, clk);
467} 472}
473
474/*
475 * FIXME: All slow clk users are not properly claiming it (get + prepare +
476 * enable) before using it.
477 * If all users properly claiming this clock decide that they don't need it
478 * anymore (or are removed), it is disabled while faulty users are still
479 * requiring it, and the system hangs.
480 * Prevent this clock from being disabled until all users are properly
481 * requesting it.
482 * Once this is done we should remove this function and the slow_clk variable.
483 */
484static int __init of_at91_clk_slow_retain(void)
485{
486 if (!slow_clk)
487 return 0;
488
489 __clk_get(slow_clk);
490 clk_prepare_enable(slow_clk);
491
492 return 0;
493}
494arch_initcall(of_at91_clk_slow_retain);