* [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd
@ 2010-12-10 8:01 Heiko Schocher
2010-12-10 8:09 ` Albert ARIBAUD
0 siblings, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2010-12-10 8:01 UTC (permalink / raw)
To: u-boot
Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the arm1136 timer driver for mx31 and omap24xx
The usage of bss values in drivers before initialisation of bss is forbidden.
In that special case some data in .rel.dyn gets corrupted.
This patch is similiar to the patch Dirk Behme posted
for the armv7/omap-common/timer.c
Tested on the mx31 based qong board
Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Albert ARIBAUD <albert.aribaud@free.fr>
---
arch/arm/cpu/arm1136/mx31/timer.c | 19 +++++++++----------
arch/arm/cpu/arm1136/omap24xx/timer.c | 19 +++++++++----------
2 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c
index b8848c4..f6be3b9 100644
--- a/arch/arm/cpu/arm1136/mx31/timer.c
+++ b/arch/arm/cpu/arm1136/mx31/timer.c
@@ -39,8 +39,7 @@
#define GPTCR_CLKSOURCE_32 (4 << 6) /* Clock source */
#define GPTCR_TEN 1 /* Timer enable */
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
/* "time" is measured in 1 / CONFIG_SYS_HZ seconds, "tick" is internal timer period */
#ifdef CONFIG_MX31_TIMER_HIGH_PRECISION
@@ -108,8 +107,8 @@ int timer_init (void)
void reset_timer_masked (void)
{
/* reset time */
- lastinc = GPTCNT; /* capture current incrementer value time */
- timestamp = 0; /* start "advancing" time stamp from 0 */
+ gd->lastinc = GPTCNT; /* capture current incrementer value time */
+ gd->tbl = 0; /* start "advancing" time stamp from 0 */
}
void reset_timer(void)
@@ -121,13 +120,13 @@ unsigned long long get_ticks (void)
{
ulong now = GPTCNT; /* current tick value */
- if (now >= lastinc) /* normal mode (non roll) */
+ if (now >= gd->lastinc) /* normal mode (non roll) */
/* move stamp forward with absolut diff ticks */
- timestamp += (now - lastinc);
+ gd->tbl += (now - gd->lastinc);
else /* we have rollover of incrementer */
- timestamp += (0xFFFFFFFF - lastinc) + now;
- lastinc = now;
- return timestamp;
+ gd->tbl += (0xFFFFFFFF - gd->lastinc) + now;
+ gd->lastinc = now;
+ return gd->tbl;
}
ulong get_timer_masked (void)
@@ -148,7 +147,7 @@ ulong get_timer (ulong base)
void set_timer (ulong t)
{
- timestamp = time_to_tick(t);
+ gd->tbl = time_to_tick(t);
}
/* delay x useconds AND preserve advance timestamp value */
diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c
index 68fe1b2..228ceba 100644
--- a/arch/arm/cpu/arm1136/omap24xx/timer.c
+++ b/arch/arm/cpu/arm1136/omap24xx/timer.c
@@ -39,8 +39,7 @@
/* macro to read the 32 bit timer */
#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR)))
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
int timer_init (void)
{
@@ -70,7 +69,7 @@ ulong get_timer (ulong base)
void set_timer (ulong t)
{
- timestamp = t;
+ gd->tbl = t;
}
/* delay x useconds AND preserve advance timestamp value */
@@ -99,20 +98,20 @@ void __udelay (unsigned long usec)
void reset_timer_masked (void)
{
/* reset time */
- lastinc = READ_TIMER; /* capture current incrementer value time */
- timestamp = 0; /* start "advancing" time stamp from 0 */
+ gd->lastinc = READ_TIMER; /* capture current incrementer value time */
+ gd->tbl = 0; /* start "advancing" time stamp from 0 */
}
ulong get_timer_masked (void)
{
ulong now = READ_TIMER; /* current tick value */
- if (now >= lastinc) /* normal mode (non roll) */
- timestamp += (now - lastinc); /* move stamp fordward with absoulte diff ticks */
+ if (now >= gd->lastinc) /* normal mode (non roll) */
+ gd->tbl += (now - gd->lastinc); /* move stamp fordward with absoulte diff ticks */
else /* we have rollover of incrementer */
- timestamp += (0xFFFFFFFF - lastinc) + now;
- lastinc = now;
- return timestamp;
+ gd->tbl += (0xFFFFFFFF - gd->lastinc) + now;
+ gd->lastinc = now;
+ return gd->tbl;
}
/* waits specified delay value and resets timestamp */
--
1.7.2.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd
2010-12-10 8:01 [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd Heiko Schocher
@ 2010-12-10 8:09 ` Albert ARIBAUD
2010-12-17 20:13 ` Wolfgang Denk
0 siblings, 1 reply; 5+ messages in thread
From: Albert ARIBAUD @ 2010-12-10 8:09 UTC (permalink / raw)
To: u-boot
Le 10/12/2010 09:01, Heiko Schocher a ?crit :
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the arm1136 timer driver for mx31 and omap24xx
>
> The usage of bss values in drivers before initialisation of bss is forbidden.
> In that special case some data in .rel.dyn gets corrupted.
>
> This patch is similiar to the patch Dirk Behme posted
> for the armv7/omap-common/timer.c
>
> Tested on the mx31 based qong board
>
> Signed-off-by: Heiko Schocher<hs@denx.de>
> cc: Albert ARIBAUD<albert.aribaud@free.fr>
FWIW,
Acked-by: Albert ARIBAUD <albert.aribaud@free.fr>
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd
2010-12-10 8:09 ` Albert ARIBAUD
@ 2010-12-17 20:13 ` Wolfgang Denk
2010-12-19 8:45 ` Heiko Schocher
0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2010-12-17 20:13 UTC (permalink / raw)
To: u-boot
Dear Albert & Heiko,
In message <4D01E031.3090100@free.fr> you wrote:
>
> > Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> > values in the arm1136 timer driver for mx31 and omap24xx
> >
> > The usage of bss values in drivers before initialisation of bss is forbid> den.
> > In that special case some data in .rel.dyn gets corrupted.
> >
> > This patch is similiar to the patch Dirk Behme posted
> > for the armv7/omap-common/timer.c
> >
> > Tested on the mx31 based qong board
> >
> > Signed-off-by: Heiko Schocher<hs@denx.de>
> > cc: Albert ARIBAUD<albert.aribaud@free.fr>
>
> FWIW,
>
> Acked-by: Albert ARIBAUD <albert.aribaud@free.fr>
Should I pull this into v2010.12, or should we rather wait for amore
general solution and fix it in the next release?
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
Actual war is a very messy business. Very, very messy business.
-- Kirk, "A Taste of Armageddon", stardate 3193.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd
2010-12-17 20:13 ` Wolfgang Denk
@ 2010-12-19 8:45 ` Heiko Schocher
2011-01-20 20:34 ` Albert ARIBAUD
0 siblings, 1 reply; 5+ messages in thread
From: Heiko Schocher @ 2010-12-19 8:45 UTC (permalink / raw)
To: u-boot
Hello Wolfgang,
Wolfgang Denk wrote:
> Dear Albert & Heiko,
>
> In message <4D01E031.3090100@free.fr> you wrote:
>>> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
>>> values in the arm1136 timer driver for mx31 and omap24xx
>>>
>>> The usage of bss values in drivers before initialisation of bss is forbid> den.
>>> In that special case some data in .rel.dyn gets corrupted.
>>>
>>> This patch is similiar to the patch Dirk Behme posted
>>> for the armv7/omap-common/timer.c
>>>
>>> Tested on the mx31 based qong board
>>>
>>> Signed-off-by: Heiko Schocher<hs@denx.de>
>>> cc: Albert ARIBAUD<albert.aribaud@free.fr>
>> FWIW,
>>
>> Acked-by: Albert ARIBAUD <albert.aribaud@free.fr>
>
> Should I pull this into v2010.12, or should we rather wait for amore
> general solution and fix it in the next release?
I vote for pulling this into the v2010.12 release, beause it is a
bugfix and we get a working code with elf relocation(conceding the
patch is not a perfekt solution, but working)
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] 5+ messages in thread
* [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd
2010-12-19 8:45 ` Heiko Schocher
@ 2011-01-20 20:34 ` Albert ARIBAUD
0 siblings, 0 replies; 5+ messages in thread
From: Albert ARIBAUD @ 2011-01-20 20:34 UTC (permalink / raw)
To: u-boot
Le 19/12/2010 09:45, Heiko Schocher a ?crit :
> Hello Wolfgang,
>
> Wolfgang Denk wrote:
>> Dear Albert& Heiko,
>>
>> In message<4D01E031.3090100@free.fr> you wrote:
>>>> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
>>>> values in the arm1136 timer driver for mx31 and omap24xx
>>>>
>>>> The usage of bss values in drivers before initialisation of bss is forbid> den.
>>>> In that special case some data in .rel.dyn gets corrupted.
>>>>
>>>> This patch is similiar to the patch Dirk Behme posted
>>>> for the armv7/omap-common/timer.c
>>>>
>>>> Tested on the mx31 based qong board
>>>>
>>>> Signed-off-by: Heiko Schocher<hs@denx.de>
>>>> cc: Albert ARIBAUD<albert.aribaud@free.fr>
>>> FWIW,
>>>
>>> Acked-by: Albert ARIBAUD<albert.aribaud@free.fr>
>>
>> Should I pull this into v2010.12, or should we rather wait for amore
>> general solution and fix it in the next release?
>
> I vote for pulling this into the v2010.12 release, beause it is a
> bugfix and we get a working code with elf relocation(conceding the
> patch is not a perfekt solution, but working)
>
> bye,
> Heiko
Applied to u-boot-arm, thanks and apologies for the late action.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-20 20:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10 8:01 [U-Boot] [PATCH] arm1136: timer: Replace bss variable by gd Heiko Schocher
2010-12-10 8:09 ` Albert ARIBAUD
2010-12-17 20:13 ` Wolfgang Denk
2010-12-19 8:45 ` Heiko Schocher
2011-01-20 20:34 ` Albert ARIBAUD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox