Skip to contentSkip to conversation

timer: orion-timer: Fix problem in early_init_done()

PATCH In review Stefan Roese 2 participants 4 messages Jan 16, 2023 – Jan 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timer: orion-timer: Fix problem in early_init_done()

It was noticed that Clearfog is currently broken with this newly introduced early_init_done() function. Apparently the timer is enabled here when U-Boot is run but not configured - at least not correctly. Resulting in a hangup in the timer reading functions.

To fix this, also read the value of the reload register and check it's value with the one written to by U-Boot. Only if this matches, the init has already been done.

Cc Martin Rowe <[email protected]>
Cc Tony Dinh <[email protected]>
Cc Pali Rohár <[email protected]>
Cc Michael Walle <[email protected]>
---
 drivers/timer/orion-timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/orion-timer.c +2 -1
index 810a03d54960..9cab27f2e48b 100644
@@ -25,7 +25,8 @@ struct orion_timer_priv {
 
 static bool early_init_done(void *base)
 {
-	if (readl(base + TIMER_CTRL) & TIMER0_EN)
+	if ((readl(base + TIMER_CTRL) & TIMER0_EN) &&
+	    (readl(base + TIMER0_RELOAD) == ~0))
 		return true;
 	return false;
 }
Signature · 1 line
2.39.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Monday 16 January 2023 16:34:45 Stefan Roese wrote:

It was noticed that Clearfog is currently broken with this newly introduced early_init_done() function. Apparently the timer is enabled here when U-Boot is run but not configured - at least not correctly. Resulting in a hangup in the timer reading functions.

To fix this, also read the value of the reload register and check it's value with the one written to by U-Boot. Only if this matches, the init has already been done.

Quoted 5 lines
Cc Martin Rowe <[email protected]>
Cc Tony Dinh <[email protected]>
Cc Pali Rohár <[email protected]>
Cc Michael Walle <[email protected]>

Looks good.

Maybe you should also fixed line:

Fixes 5387b093cb79 ("timer: orion-timer: Fix problem with early static variable")
Quoted 21 lines
---
 drivers/timer/orion-timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/orion-timer.c +2 -1
index 810a03d54960..9cab27f2e48b 100644
@@ -25,7 +25,8 @@ struct orion_timer_priv {
 
 static bool early_init_done(void *base)
 {
-	if (readl(base + TIMER_CTRL) & TIMER0_EN)
+	if ((readl(base + TIMER_CTRL) & TIMER0_EN) &&
+	    (readl(base + TIMER0_RELOAD) == ~0))
 		return true;
 	return false;
 }
Signature · 1 line
2.39.0
#2 lore raw

Hi Pali,

Quoted 16 lines · Pali Rohár
Quoted 9 lines · On Monday 16 January 2023 16:34:45 Stefan Roese wrote:

It was noticed that Clearfog is currently broken with this newly introduced early_init_done() function. Apparently the timer is enabled here when U-Boot is run but not configured - at least not correctly. Resulting in a hangup in the timer reading functions.

To fix this, also read the value of the reload register and check it's value with the one written to by U-Boot. Only if this matches, the init has already been done.

Quoted 5 lines
Cc Martin Rowe <[email protected]>
Cc Tony Dinh <[email protected]>
Cc Pali Rohár <[email protected]>
Cc Michael Walle <[email protected]>
Quoted 7 lines

Looks good.

Maybe you should also fixed line:

Fixes 5387b093cb79 ("timer: orion-timer: Fix problem with early static variable")

Will do when applying. Thanks.

Thanks,
Stefan

Quoted 10 lines
Quoted 10 lines
---
  drivers/timer/orion-timer.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/orion-timer.c +0 -0
index 810a03d54960..9cab27f2e48b 100644
@@ -25,7 +25,8 @@ struct orion_timer_priv {
 
Quoted 11 lines
Quoted 11 lines
drivers/timer/orion-timer.c +2 -1
  static bool early_init_done(void *base)
  {
-	if (readl(base + TIMER_CTRL) & TIMER0_EN)
+	if ((readl(base + TIMER_CTRL) & TIMER0_EN) &&
+	    (readl(base + TIMER0_RELOAD) == ~0))
  		return true;
  	return false;
  }
Signature · 1 line
2.39.0

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#3 lore raw
In reply to Pali Rohár
Quoted 16 lines · Pali Rohár
Quoted 9 lines · On Monday 16 January 2023 16:34:45 Stefan Roese wrote:

It was noticed that Clearfog is currently broken with this newly introduced early_init_done() function. Apparently the timer is enabled here when U-Boot is run but not configured - at least not correctly. Resulting in a hangup in the timer reading functions.

To fix this, also read the value of the reload register and check it's value with the one written to by U-Boot. Only if this matches, the init has already been done.

Quoted 5 lines
Cc Martin Rowe <[email protected]>
Cc Tony Dinh <[email protected]>
Cc Pali Rohár <[email protected]>
Cc Michael Walle <[email protected]>
Quoted 7 lines

Looks good.

Maybe you should also fixed line:

Fixes 5387b093cb79 ("timer: orion-timer: Fix problem with early static variable")

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 10 lines
Quoted 10 lines
---
  drivers/timer/orion-timer.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/timer/orion-timer.c +0 -0
index 810a03d54960..9cab27f2e48b 100644
@@ -25,7 +25,8 @@ struct orion_timer_priv {
 
Quoted 11 lines
Quoted 11 lines
drivers/timer/orion-timer.c +2 -1
  static bool early_init_done(void *base)
  {
-	if (readl(base + TIMER_CTRL) & TIMER0_EN)
+	if ((readl(base + TIMER_CTRL) & TIMER0_EN) &&
+	    (readl(base + TIMER0_RELOAD) == ~0))
  		return true;
  	return false;
  }
Signature · 1 line
2.39.0

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]