[v3,1/3] clocksource: davinci: only enable clockevents once tim34 is initialized
diff mbox series

Message ID 20200110171643.18578-2-brgl@bgdev.pl
State Mainlined
Commit cea931c25104e6bddc42eb067f58193f355dbdd7
Headers show
Series
  • ARM: davinci: convert dm365 to using the new clocksource driver
Related show

Commit Message

Bartosz Golaszewski Jan. 10, 2020, 5:16 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The DM365 platform has a strange quirk (only present when using ancient
u-boot - mainline u-boot v2013.01 and later works fine) where if we
enable the second half of the timer in periodic mode before we do its
initialization - the time won't start flowing and we can't boot.

When using more recent u-boot, we can enable the timer, then reinitialize
it and all works fine.

To work around this issue only enable clockevents once tim34 is
initialized i.e. move clockevents_config_and_register() below tim34
initialization.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/clocksource/timer-davinci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Daniel Lezcano Jan. 10, 2020, 5:56 p.m. UTC | #1
On 10/01/2020 18:16, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> The DM365 platform has a strange quirk (only present when using ancient
> u-boot - mainline u-boot v2013.01 and later works fine) where if we
> enable the second half of the timer in periodic mode before we do its
> initialization - the time won't start flowing and we can't boot.
> 
> When using more recent u-boot, we can enable the timer, then reinitialize
> it and all works fine.
> 
> To work around this issue only enable clockevents once tim34 is
> initialized i.e. move clockevents_config_and_register() below tim34
> initialization.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Shall I take it through my tree?

> ---
>  drivers/clocksource/timer-davinci.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
> index 62745c962049..e421946a91c5 100644
> --- a/drivers/clocksource/timer-davinci.c
> +++ b/drivers/clocksource/timer-davinci.c
> @@ -302,10 +302,6 @@ int __init davinci_timer_register(struct clk *clk,
>  		return rv;
>  	}
>  
> -	clockevents_config_and_register(&clockevent->dev, tick_rate,
> -					DAVINCI_TIMER_MIN_DELTA,
> -					DAVINCI_TIMER_MAX_DELTA);
> -
>  	davinci_clocksource.dev.rating = 300;
>  	davinci_clocksource.dev.read = davinci_clocksource_read;
>  	davinci_clocksource.dev.mask =
> @@ -323,6 +319,10 @@ int __init davinci_timer_register(struct clk *clk,
>  		davinci_clocksource_init_tim34(base);
>  	}
>  
> +	clockevents_config_and_register(&clockevent->dev, tick_rate,
> +					DAVINCI_TIMER_MIN_DELTA,
> +					DAVINCI_TIMER_MAX_DELTA);
> +
>  	rv = clocksource_register_hz(&davinci_clocksource.dev, tick_rate);
>  	if (rv) {
>  		pr_err("Unable to register clocksource");
>
Bartosz Golaszewski Jan. 11, 2020, 10:19 a.m. UTC | #2
pt., 10 sty 2020 o 18:56 Daniel Lezcano <daniel.lezcano@linaro.org> napisał(a):
>
> On 10/01/2020 18:16, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > The DM365 platform has a strange quirk (only present when using ancient
> > u-boot - mainline u-boot v2013.01 and later works fine) where if we
> > enable the second half of the timer in periodic mode before we do its
> > initialization - the time won't start flowing and we can't boot.
> >
> > When using more recent u-boot, we can enable the timer, then reinitialize
> > it and all works fine.
> >
> > To work around this issue only enable clockevents once tim34 is
> > initialized i.e. move clockevents_config_and_register() below tim34
> > initialization.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Shall I take it through my tree?
>

Not sure, I'd say Sekhar should take it through arm-soc together with
the latter two patches if he's ok with this. Let's wait for him to
respond.

Bart
Sekhar Nori Jan. 13, 2020, 11:56 a.m. UTC | #3
Hi Daniel, Bart,

On 11/01/20 3:59 PM, Daniel Lezcano wrote:
> 
> 
> On Sat, 11 Jan 2020 at 11:20, Bartosz Golaszewski <brgl@bgdev.pl
> <mailto:brgl@bgdev.pl>> wrote:
> 
>     pt., 10 sty 2020 o 18:56 Daniel Lezcano <daniel.lezcano@linaro.org
>     <mailto:daniel.lezcano@linaro.org>> napisał(a):
>     >
>     > On 10/01/2020 18:16, Bartosz Golaszewski wrote:
>     > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com
>     <mailto:bgolaszewski@baylibre.com>>
>     > >
>     > > The DM365 platform has a strange quirk (only present when using
>     ancient
>     > > u-boot - mainline u-boot v2013.01 and later works fine) where if we
>     > > enable the second half of the timer in periodic mode before we
>     do its
>     > > initialization - the time won't start flowing and we can't boot.
>     > >
>     > > When using more recent u-boot, we can enable the timer, then
>     reinitialize
>     > > it and all works fine.
>     > >
>     > > To work around this issue only enable clockevents once tim34 is
>     > > initialized i.e. move clockevents_config_and_register() below tim34
>     > > initialization.
>     > >
>     > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com
>     <mailto:bgolaszewski@baylibre.com>>
>     >
>     > Shall I take it through my tree?
>     >
> 
>     Not sure, I'd say Sekhar should take it through arm-soc together with
>     the latter two patches if he's ok with this. Let's wait for him to
>     respond.
> 
> 
> Just in case:
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org
> <mailto:daniel.lezcano@linaro.org>>

I was able to test the series on all 6 DaVinci SoCs. I will send this
upstream with Daniel's ack.

Thanks,
Sekhar

Patch
diff mbox series

diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
index 62745c962049..e421946a91c5 100644
--- a/drivers/clocksource/timer-davinci.c
+++ b/drivers/clocksource/timer-davinci.c
@@ -302,10 +302,6 @@  int __init davinci_timer_register(struct clk *clk,
 		return rv;
 	}
 
-	clockevents_config_and_register(&clockevent->dev, tick_rate,
-					DAVINCI_TIMER_MIN_DELTA,
-					DAVINCI_TIMER_MAX_DELTA);
-
 	davinci_clocksource.dev.rating = 300;
 	davinci_clocksource.dev.read = davinci_clocksource_read;
 	davinci_clocksource.dev.mask =
@@ -323,6 +319,10 @@  int __init davinci_timer_register(struct clk *clk,
 		davinci_clocksource_init_tim34(base);
 	}
 
+	clockevents_config_and_register(&clockevent->dev, tick_rate,
+					DAVINCI_TIMER_MIN_DELTA,
+					DAVINCI_TIMER_MAX_DELTA);
+
 	rv = clocksource_register_hz(&davinci_clocksource.dev, tick_rate);
 	if (rv) {
 		pr_err("Unable to register clocksource");