clocksource: sun5i: fail gracefully when clock rate is unavailable
PATCH 1/1 clocksource: sun5i: fail gracefully when clock rate is unavailable
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
--- drivers/clocksource/timer-sun5i.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/clocksource/timer-sun5i.c +10 -0
@@ -202,6 +202,11 @@ static int __init sun5i_setup_clocksource(struct device_node *node, } rate =clk_get_rate (clk); +if (!rate) { +pr_err ("Couldn't get parent clock rate\n" ); + ret = -EINVAL ; + goto err_disable_clk; + } cs->timer.base = base; cs->timer.clk = clk;
@@ -275,6 +280,11 @@ static int __init sun5i_setup_clockevent(struct device_node *node, void __iomem } rate =clk_get_rate (clk); +if (!rate) { +pr_err ("Couldn't get parent clock rate\n" ); + ret = -EINVAL ; + goto err_disable_clk; + } ce->timer.base = base; ce->timer.ticks_per_jiffy =DIV_ROUND_UP (rate,HZ );
Signature · 1 line
2.20.1
Quoted 10 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks!
Maxime
Signature · 3 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 11 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>---
Applied thanks.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 10 lines · Daniel Lezcano
Quoted 8 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Quoted 5 lines
Quoted 3 lines
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>---
Applied thanks.
I'm not seeing this in linux-next, nor the patch
arm64: arch_timer: Workaround for Allwinner A64 timer instability
Any idea where these ended up?
Thanks
ChenYu
Quoted 16 lines · Chen-Yu Tsai
Quoted 14 lines · Daniel Lezcano
Quoted 11 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>---
Quoted 7 lines
Quoted 1 line
Applied thanks.
I'm not seeing this in linux-next, nor the patch
arm64:
arch_timer: Workaround for Allwinner A64 timer instabilityAny idea where these ended up?
Yeah, I have a rough idea. They are now in linux-next via the clockevents/next branch.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
linux-next not picking up latest clockevents/next
Quoted 20 lines · Daniel Lezcano
Quoted 18 lines · Chen-Yu Tsai
Quoted 15 lines · Daniel Lezcano
Quoted 11 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>---
Applied thanks.
Quoted 8 lines
Quoted 5 lines
I'm not seeing this in linux-next, nor the patch
arm64:
arch_timer: Workaround for Allwinner A64 timer instabilityAny idea where these ended up?
Yeah, I have a rough idea. They are now in linux-next via the clockevents/next branch.
Thanks, Daniel.
Stephen,
Looks like linux-next is not picking up the latest clockevents/next.
The merge log for linux-next-20190124 shows:
Merging clockevents/clockevents/next (bd2bcaa565a2 Merge branch
'clockevents/4.21' of
http://git.linaro.org/people/daniel.lezcano/linux into timers/core)
$ git merge clockevents/clockevents/next
The merged clockevents/next looks outdated compared to
http://git.linaro.org/people/daniel.lezcano/linux.git/log/?h=clockevents/next
Regards
ChenYu
Re: linux-next not picking up latest clockevents/next
Quoted 39 lines · Chen-Yu Tsai
Quoted 20 lines · Daniel Lezcano
Quoted 18 lines · Chen-Yu Tsai
Quoted 15 lines · Daniel Lezcano
Quoted 11 lines · Chen-Yu Tsai
If the clock tree is not fully populated when the timer-sun5i init code is called, attempts to get the clock rate for the timer would fail and return 0.
Make the init code for both clock events and clocksource check the returned clock rate and fail gracefully if the result is 0, instead of causing a divide by 0 exception later on.
Fixes 4a59058f0b09 ("clocksource/drivers/sun5i: Refactor the current code")Signed-off-by Chen-Yu Tsai <[email protected]>---
Applied thanks.
Quoted 8 lines
Quoted 5 lines
I'm not seeing this in linux-next, nor the patch
arm64:
arch_timer: Workaround for Allwinner A64 timer instabilityAny idea where these ended up?
Yeah, I have a rough idea. They are now in linux-next via the clockevents/next branch.
Thanks, Daniel.
Stephen,
Looks like linux-next is not picking up the latest clockevents/next.
The merge log for linux-next-20190124 shows:
Quoted 8 lines
Merging clockevents/clockevents/next (
bd2bcaa565a2Merge branch
'clockevents/4.21' of
http://git.linaro.org/people/daniel.lezcano/linux into timers/core)$ git merge clockevents/clockevents/nextThe merged clockevents/next looks outdated compared to
http://git.linaro.org/people/daniel.lezcano/linux.git/log/?h=clockevents/next
I just updated the branch, so there will be a delay before it gets reflected in linux-next.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog