Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clocksource: sirf: Fix incorrect clock enable counter for timer

In the clocksource driver, we didn't explicitly enable the clock. it makes the
clk reference counter wrong. We didn't encounter any hang issue because the
tick's clock input has been open and is shared by some other hardware
components, but if we don't enable those components in kernel, in the stage of
disabling unused clk in kernel boot, Linux tick hangs.

This patch fixes it. it does an explicit prepare and enable to the clock input,
and increases the usage counter of the clk.

Signed-off-by: Zhiwu Song <Zhiwu.Song@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Zhiwu Song and committed by
Daniel Lezcano
38941522 40c96312

+6
+3
drivers/clocksource/timer-marco.c
··· 260 260 261 261 clk = of_clk_get(np, 0); 262 262 BUG_ON(IS_ERR(clk)); 263 + 264 + BUG_ON(clk_prepare_enable(clk)); 265 + 263 266 rate = clk_get_rate(clk); 264 267 265 268 BUG_ON(rate < MARCO_CLOCK_FREQ);
+3
drivers/clocksource/timer-prima2.c
··· 200 200 201 201 clk = of_clk_get(np, 0); 202 202 BUG_ON(IS_ERR(clk)); 203 + 204 + BUG_ON(clk_prepare_enable(clk)); 205 + 203 206 rate = clk_get_rate(clk); 204 207 205 208 BUG_ON(rate < PRIMA2_CLOCK_FREQ);