All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
@ 2010-12-09 16:31 Dirk Behme
  2010-12-09 23:12 ` John Rigby
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Dirk Behme @ 2010-12-09 16:31 UTC (permalink / raw)
  To: u-boot

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the OMAP timer driver.

The usage of bss values in drivers before initialisation of bss is forbidden.
In that special case some data in .rel.dyn gets corrupted.

Signed-off-by: Dirk Behme <dirk.behme@gmail.com>

---

Note: This is compile tested only (therefore the RFC). Please *test*
      on real OMAP HW, e.g. Beagle.

This is change is inspired by

http://git.denx.de/u-boot.git/?p=u-boot.git;a=commitdiff;h=a429db7e3ce6136f80f22584588247926ba60b05

 arch/arm/cpu/armv7/omap-common/timer.c |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Index: u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
===================================================================
--- u-boot.git.orig/arch/arm/cpu/armv7/omap-common/timer.c
+++ u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
@@ -35,8 +35,8 @@
 #include <common.h>
 #include <asm/io.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
 static struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
 
 /*
@@ -74,7 +74,7 @@ ulong get_timer(ulong base)
 
 void set_timer(ulong t)
 {
-	timestamp = t;
+	gd->tbl = t;
 }
 
 /* delay x useconds */
@@ -96,8 +96,8 @@ void __udelay(unsigned long usec)
 void reset_timer_masked(void)
 {
 	/* reset time, capture current incrementer value time */
-	lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
-	timestamp = 0;		/* start "advancing" time stamp from 0 */
+	gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
+	gd->tbl = 0;		/* start "advancing" time stamp from 0 */
 }
 
 ulong get_timer_masked(void)
@@ -105,14 +105,14 @@ ulong get_timer_masked(void)
 	/* current tick value */
 	ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 
-	if (now >= lastinc)	/* normal mode (non roll) */
+	if (now >= gd->lastinc)	/* normal mode (non roll) */
 		/* move stamp fordward with absoulte diff ticks */
-		timestamp += (now - lastinc);
+		gd->tbl += (now - gd->lastinc);
 	else	/* we have rollover of incrementer */
-		timestamp += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
-				- lastinc) + now;
-	lastinc = now;
-	return timestamp;
+		gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
+			     - gd->lastinc) + now;
+	gd->lastinc = now;
+	return gd->tbl;
 }
 
 /*

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-09 16:31 [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd Dirk Behme
@ 2010-12-09 23:12 ` John Rigby
  2010-12-10  0:06 ` Nishanth Menon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: John Rigby @ 2010-12-09 23:12 UTC (permalink / raw)
  To: u-boot

On Thu, Dec 9, 2010 at 9:31 AM, Dirk Behme <dirk.behme@googlemail.com> wrote:
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the OMAP timer driver.
>
> The usage of bss values in drivers before initialisation of bss is forbidden.
> In that special case some data in .rel.dyn gets corrupted.
>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
>
Works for me on Beagle xM Rev A

Tested-by: John Rigby <john.rigby@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-09 16:31 [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd Dirk Behme
  2010-12-09 23:12 ` John Rigby
@ 2010-12-10  0:06 ` Nishanth Menon
  2010-12-10  5:22 ` Dirk Behme
  2010-12-10  7:31 ` Heiko Schocher
  3 siblings, 0 replies; 8+ messages in thread
From: Nishanth Menon @ 2010-12-10  0:06 UTC (permalink / raw)
  To: u-boot

On Thu, Dec 9, 2010 at 10:31 AM, Dirk Behme <dirk.behme@googlemail.com> wrote:
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the OMAP timer driver.
>
> The usage of bss values in drivers before initialisation of bss is forbidden.
> In that special case some data in .rel.dyn gets corrupted.
>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
>
> ---
>
> Note: This is compile tested only (therefore the RFC). Please *test*
> ? ? ?on real OMAP HW, e.g. Beagle.
>
> This is change is inspired by
>
> http://git.denx.de/u-boot.git/?p=u-boot.git;a=commitdiff;h=a429db7e3ce6136f80f22584588247926ba60b05
>
> ?arch/arm/cpu/armv7/omap-common/timer.c | ? 22 +++++++++++-----------
> ?1 file changed, 11 insertions(+), 11 deletions(-)
>
> Index: u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
> ===================================================================
> --- u-boot.git.orig/arch/arm/cpu/armv7/omap-common/timer.c
> +++ u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
> @@ -35,8 +35,8 @@
> ?#include <common.h>
> ?#include <asm/io.h>
>
> -static ulong timestamp;
> -static ulong lastinc;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> ?static struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
>

[...]

Tested-by: Nishanth Menon <nm@ti.com>
Acked-by: Nishanth Menon <nm@ti.com

Tested on OMAP4 pandaboard with codesourcery 2010.09 gcc 4.5.1 and is
seen to fix the issue I reported on
http://groups.google.com/group/pandaboard/browse_thread/thread/d59461353a5e693f

Tests:
on u-boot prompt:
sleep 5 (test if time delays are still functional) -> Pass
mmc boot to MeeGo filesystem -> Pass

Thanks a bunch Dirk - just had started to debug this and steve pointed this out.


Regards,
Nishanth Menon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-09 16:31 [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd Dirk Behme
  2010-12-09 23:12 ` John Rigby
  2010-12-10  0:06 ` Nishanth Menon
@ 2010-12-10  5:22 ` Dirk Behme
  2010-12-10  7:47   ` Wolfgang Denk
  2010-12-10  7:31 ` Heiko Schocher
  3 siblings, 1 reply; 8+ messages in thread
From: Dirk Behme @ 2010-12-10  5:22 UTC (permalink / raw)
  To: u-boot

On 09.12.2010 17:31, Dirk Behme wrote:
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the OMAP timer driver.
>
> The usage of bss values in drivers before initialisation of bss is forbidden.
> In that special case some data in .rel.dyn gets corrupted.
>
> Signed-off-by: Dirk Behme<dirk.behme@gmail.com>

Tested-by: John Rigby <john.rigby@linaro.org>
Tested-by: Nishanth Menon <nm@ti.com>
Acked-by: Nishanth Menon <nm@ti.com

> Note: This is compile tested only (therefore the RFC). Please *test*
>        on real OMAP HW, e.g. Beagle.

To the custodian who has to apply this: Regarding the RFC in the 
subject: Now that this patch is confirmed to work, will you apply this 
patch as is? Or do I have to resend it without 'RFC'?

Many tanks for testing!

Dirk

> This is change is inspired by
>
> http://git.denx.de/u-boot.git/?p=u-boot.git;a=commitdiff;h=a429db7e3ce6136f80f22584588247926ba60b05
>
>   arch/arm/cpu/armv7/omap-common/timer.c |   22 +++++++++++-----------
>   1 file changed, 11 insertions(+), 11 deletions(-)
>
> Index: u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
> ===================================================================
> --- u-boot.git.orig/arch/arm/cpu/armv7/omap-common/timer.c
> +++ u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c
> @@ -35,8 +35,8 @@
>   #include<common.h>
>   #include<asm/io.h>
>
> -static ulong timestamp;
> -static ulong lastinc;
> +DECLARE_GLOBAL_DATA_PTR;
> +
>   static struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
>
>   /*
> @@ -74,7 +74,7 @@ ulong get_timer(ulong base)
>
>   void set_timer(ulong t)
>   {
> -	timestamp = t;
> +	gd->tbl = t;
>   }
>
>   /* delay x useconds */
> @@ -96,8 +96,8 @@ void __udelay(unsigned long usec)
>   void reset_timer_masked(void)
>   {
>   	/* reset time, capture current incrementer value time */
> -	lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
> -	timestamp = 0;		/* start "advancing" time stamp from 0 */
> +	gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
> +	gd->tbl = 0;		/* start "advancing" time stamp from 0 */
>   }
>
>   ulong get_timer_masked(void)
> @@ -105,14 +105,14 @@ ulong get_timer_masked(void)
>   	/* current tick value */
>   	ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
>
> -	if (now>= lastinc)	/* normal mode (non roll) */
> +	if (now>= gd->lastinc)	/* normal mode (non roll) */
>   		/* move stamp fordward with absoulte diff ticks */
> -		timestamp += (now - lastinc);
> +		gd->tbl += (now - gd->lastinc);
>   	else	/* we have rollover of incrementer */
> -		timestamp += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
> -				- lastinc) + now;
> -	lastinc = now;
> -	return timestamp;
> +		gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
> +			     - gd->lastinc) + now;
> +	gd->lastinc = now;
> +	return gd->tbl;
>   }
>
>   /*
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-09 16:31 [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd Dirk Behme
                   ` (2 preceding siblings ...)
  2010-12-10  5:22 ` Dirk Behme
@ 2010-12-10  7:31 ` Heiko Schocher
  2010-12-10  7:45   ` Heiko Schocher
  3 siblings, 1 reply; 8+ messages in thread
From: Heiko Schocher @ 2010-12-10  7:31 UTC (permalink / raw)
  To: u-boot

Hello Dirk,

Dirk Behme wrote:
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the OMAP timer driver.
> 
> The usage of bss values in drivers before initialisation of bss is forbidden.
> In that special case some data in .rel.dyn gets corrupted.
> 
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
> 
> ---
> 
> Note: This is compile tested only (therefore the RFC). Please *test*
>       on real OMAP HW, e.g. Beagle.

Works for me on:

U-Boot 2010.12-rc2-00245-g13e984c (Dec 10 2010 - 08:28:22)
OMAP3530-GP ES3.0, CPU-OPP2, L3-165MHz, Max CPU Clock 600 mHz
OMAP3 Beagle board + LPDDR/NAND

Thanks!

Tested-by: Heiko Schocher<hs@denx.de>

But mmc does not longer work on my beagle board... searching for it

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-10  7:31 ` Heiko Schocher
@ 2010-12-10  7:45   ` Heiko Schocher
  0 siblings, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2010-12-10  7:45 UTC (permalink / raw)
  To: u-boot

Hello Dirk,

Heiko Schocher wrote:
> Dirk Behme wrote:
>> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
>> values in the OMAP timer driver.
>>
>> The usage of bss values in drivers before initialisation of bss is forbidden.
>> In that special case some data in .rel.dyn gets corrupted.
>>
>> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
>>
>> ---
>>
>> Note: This is compile tested only (therefore the RFC). Please *test*
>>       on real OMAP HW, e.g. Beagle.
> 
> Works for me on:
> 
> U-Boot 2010.12-rc2-00245-g13e984c (Dec 10 2010 - 08:28:22)
> OMAP3530-GP ES3.0, CPU-OPP2, L3-165MHz, Max CPU Clock 600 mHz
> OMAP3 Beagle board + LPDDR/NAND
> 
> Thanks!
> 
> Tested-by: Heiko Schocher<hs@denx.de>
> 
> But mmc does not longer work on my beagle board... searching for it

User error, mmc works fine, sorry for the noise.

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-10  5:22 ` Dirk Behme
@ 2010-12-10  7:47   ` Wolfgang Denk
  2010-12-10 23:48     ` Steve Sakoman
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2010-12-10  7:47 UTC (permalink / raw)
  To: u-boot

Dear Dirk Behme,

In message <4D01B92E.8050506@googlemail.com> you wrote:
>
> > Note: This is compile tested only (therefore the RFC). Please *test*
> >        on real OMAP HW, e.g. Beagle.
> 
> To the custodian who has to apply this: Regarding the RFC in the 
> subject: Now that this patch is confirmed to work, will you apply this 
> patch as is? Or do I have to resend it without 'RFC'?

If Sandeep agrees, I wil pull this directly, as this fixes a real
problem for many of us.

Thanks!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The moral of the story is: "Don't stop to  tighten  your  shoe  laces
during the Olympics 100m finals".
                             - Kevin Jones in <DEJo68.K1t@bri.hp.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
  2010-12-10  7:47   ` Wolfgang Denk
@ 2010-12-10 23:48     ` Steve Sakoman
  0 siblings, 0 replies; 8+ messages in thread
From: Steve Sakoman @ 2010-12-10 23:48 UTC (permalink / raw)
  To: u-boot

On Thu, Dec 9, 2010 at 11:47 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Dirk Behme,
>
> In message <4D01B92E.8050506@googlemail.com> you wrote:
>>
>> > Note: This is compile tested only (therefore the RFC). Please *test*
>> > ? ? ? ?on real OMAP HW, e.g. Beagle.
>>
>> To the custodian who has to apply this: Regarding the RFC in the
>> subject: Now that this patch is confirmed to work, will you apply this
>> patch as is? Or do I have to resend it without 'RFC'?
>
> If Sandeep agrees, I wil pull this directly, as this fixes a real
> problem for many of us.

Sorry for the delay in testing, jury duty this week :-(

I build tested for Beagle, Overo, Panda, and SDP4430 - no issues.

Run tested on Beagle, Overo, and Panda - no issues.

Tested-by: Steve Sakoman <steve.sakoman@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-12-10 23:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-09 16:31 [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd Dirk Behme
2010-12-09 23:12 ` John Rigby
2010-12-10  0:06 ` Nishanth Menon
2010-12-10  5:22 ` Dirk Behme
2010-12-10  7:47   ` Wolfgang Denk
2010-12-10 23:48     ` Steve Sakoman
2010-12-10  7:31 ` Heiko Schocher
2010-12-10  7:45   ` Heiko Schocher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.