mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-22 00:09:11 +03:00
clocksource: sh_tmu: compute mult and shift before registration
Since commit 98962465ed
("nohz: Prevent
clocksource wrapping during idle"), the CPU of an R2D board never goes
to idle. This commit assumes that mult and shift are assigned before
the clocksource is registered. As a consequence the safe maximum sleep
time is negative and the CPU never goes into idle.
This patch fixes the problem by moving mult and shift initialization
from sh_tmu_clocksource_enable() to sh_tmu_register_clocksource().
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Cc: stable@kernel.org
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
019e2574f9
commit
66f49121ff
@ -199,16 +199,8 @@ static cycle_t sh_tmu_clocksource_read(struct clocksource *cs)
|
|||||||
static int sh_tmu_clocksource_enable(struct clocksource *cs)
|
static int sh_tmu_clocksource_enable(struct clocksource *cs)
|
||||||
{
|
{
|
||||||
struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
|
struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = sh_tmu_enable(p);
|
return sh_tmu_enable(p);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* TODO: calculate good shift from rate and counter bit width */
|
|
||||||
cs->shift = 10;
|
|
||||||
cs->mult = clocksource_hz2mult(p->rate, cs->shift);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sh_tmu_clocksource_disable(struct clocksource *cs)
|
static void sh_tmu_clocksource_disable(struct clocksource *cs)
|
||||||
@ -228,6 +220,16 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
|
|||||||
cs->disable = sh_tmu_clocksource_disable;
|
cs->disable = sh_tmu_clocksource_disable;
|
||||||
cs->mask = CLOCKSOURCE_MASK(32);
|
cs->mask = CLOCKSOURCE_MASK(32);
|
||||||
cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
|
cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
|
||||||
|
|
||||||
|
/* clk_get_rate() needs an enabled clock */
|
||||||
|
clk_enable(p->clk);
|
||||||
|
/* channel will be configured at parent clock / 4 */
|
||||||
|
p->rate = clk_get_rate(p->clk) / 4;
|
||||||
|
clk_disable(p->clk);
|
||||||
|
/* TODO: calculate good shift from rate and counter bit width */
|
||||||
|
cs->shift = 10;
|
||||||
|
cs->mult = clocksource_hz2mult(p->rate, cs->shift);
|
||||||
|
|
||||||
dev_info(&p->pdev->dev, "used as clock source\n");
|
dev_info(&p->pdev->dev, "used as clock source\n");
|
||||||
clocksource_register(cs);
|
clocksource_register(cs);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user