public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
@ 2010-12-10  9:33 Heiko Schocher
  2010-12-11 11:41 ` Prafulla Wadaskar
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Heiko Schocher @ 2010-12-10  9:33 UTC (permalink / raw)
  To: u-boot

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the arm926ejs timers implementation.

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 and added suggestions
from Reinhard Meyer.

Tested on the arm926ejs mx27 based magnesium board
Tested on the arm926ejs kirkwood based suen3 board

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Albert ARIBAUD <albert.aribaud@free.fr>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Stefano Babic <sbabic@denx.de>
cc: Reinhard Meyer <u-boot@emk-elektronik.de>

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 arch/arm/cpu/arm926ejs/davinci/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
 arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
 arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
 9 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c
index 9da7443..d7b1e46 100644
--- a/arch/arm/cpu/arm926ejs/davinci/timer.c
+++ b/arch/arm/cpu/arm926ejs/davinci/timer.c
@@ -60,8 +60,10 @@ static struct davinci_timer * const timer =
 #define TIMER_LOAD_VAL	(CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
 #define TIM_CLK_DIV	16
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 int timer_init(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
index 2ec6a93..3e80329 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
@@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
 #define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
 					 (CONFIG_SYS_TCLK / 1000))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
index 9175b71..6966b0d 100644
--- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
+++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
@@ -33,8 +33,10 @@
 #define TIMER_LOAD_VAL	0xffffffff
 #define TIMER_FREQ	(CONFIG_MB86R0x_IOCLK  / 256)
 
-static unsigned long long timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
index 11d41a8..14f0c2d 100644
--- a/arch/arm/cpu/arm926ejs/mx25/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
@@ -41,8 +41,10 @@
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
index 8f1d47b..5c1cf01 100644
--- a/arch/arm/cpu/arm926ejs/mx27/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
@@ -43,8 +43,10 @@
 #define GPTCR_CLKSOURCE_32	(4 << 1)	/* Clock source		*/
 #define GPTCR_TEN		1		/* Timer enable		*/
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c
index 7d4b6e6..88a0ee6 100644
--- a/arch/arm/cpu/arm926ejs/omap/timer.c
+++ b/arch/arm/cpu/arm926ejs/omap/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init (void)
 {
diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c
index 089ef47..bbab226 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/timer.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c
@@ -90,8 +90,10 @@ static inline ulong read_timer(void)
 	      / (CONFIG_SYS_TCLK / 1000);
 }
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c
index 06858b4..66cf4de 100644
--- a/arch/arm/cpu/arm926ejs/spear/timer.c
+++ b/arch/arm/cpu/arm926ejs/spear/timer.c
@@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
 static struct misc_regs *const misc_regs_p =
     (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c
index 81d6749..2e243b1 100644
--- a/arch/arm/cpu/arm926ejs/versatile/timer.c
+++ b/arch/arm/cpu/arm926ejs/versatile/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 #define TIMER_ENABLE	(1 << 7)
 #define TIMER_MODE_MSK	(1 << 6)
-- 
1.7.2.3

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

* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
  2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
@ 2010-12-11 11:41 ` Prafulla Wadaskar
  2010-12-13  7:29 ` Stefano Babic
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Prafulla Wadaskar @ 2010-12-11 11:41 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Friday, December 10, 2010 3:03 PM
> To: u-boot at lists.denx.de
> Cc: Heiko Schocher; Albert ARIBAUD; Prafulla Wadaskar; Stefano Babic;
> Reinhard Meyer
> Subject: [PATCH] arm926ejs: timer: Replace bss variable by gdr
> 
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the arm926ejs timers implementation.
> 
> 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 and added suggestions
> from Reinhard Meyer.
> 
> Tested on the arm926ejs mx27 based magnesium board
> Tested on the arm926ejs kirkwood based suen3 board
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> cc: Albert ARIBAUD <albert.aribaud@free.fr>
> cc: Prafulla Wadaskar <prafulla@marvell.com>
> cc: Stefano Babic <sbabic@denx.de>
> cc: Reinhard Meyer <u-boot@emk-elektronik.de>
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>  arch/arm/cpu/arm926ejs/davinci/timer.c   |    6 ++++--
>  arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
>  arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
>  arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
>  arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
>  arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
>  arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
>  arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
>  arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
>  9 files changed, 36 insertions(+), 18 deletions(-)
> 

Acked-by: Prafulla Wadaskar <prafulla@marvell.com>

Regards..
Prafulla . .

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

* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
  2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
  2010-12-11 11:41 ` Prafulla Wadaskar
@ 2010-12-13  7:29 ` Stefano Babic
  2011-01-20 20:43 ` Albert ARIBAUD
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Stefano Babic @ 2010-12-13  7:29 UTC (permalink / raw)
  To: u-boot

On 12/10/2010 10:33 AM, Heiko Schocher wrote:
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the arm926ejs timers implementation.
> 
> 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 and added suggestions
> from Reinhard Meyer.
> 
> Tested on the arm926ejs mx27 based magnesium board
> Tested on the arm926ejs kirkwood based suen3 board
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> cc: Albert ARIBAUD <albert.aribaud@free.fr>
> cc: Prafulla Wadaskar <prafulla@marvell.com>
> cc: Stefano Babic <sbabic@denx.de>
> cc: Reinhard Meyer <u-boot@emk-elektronik.de>
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
  2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
  2010-12-11 11:41 ` Prafulla Wadaskar
  2010-12-13  7:29 ` Stefano Babic
@ 2011-01-20 20:43 ` Albert ARIBAUD
  2011-01-20 20:49   ` Albert ARIBAUD
  2011-01-21  8:48 ` [U-Boot] [PATCH v2] " Heiko Schocher
  2011-01-21  8:56 ` [U-Boot] [PATCH v3] " Heiko Schocher
  4 siblings, 1 reply; 14+ messages in thread
From: Albert ARIBAUD @ 2011-01-20 20:43 UTC (permalink / raw)
  To: u-boot

Le 10/12/2010 10:33, Heiko Schocher a ?crit :
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the arm926ejs timers implementation.
>
> 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 and added suggestions
> from Reinhard Meyer.
>
> Tested on the arm926ejs mx27 based magnesium board
> Tested on the arm926ejs kirkwood based suen3 board
>
> Signed-off-by: Heiko Schocher<hs@denx.de>
> cc: Albert ARIBAUD<albert.aribaud@free.fr>
> cc: Prafulla Wadaskar<prafulla@marvell.com>
> cc: Stefano Babic<sbabic@denx.de>
> cc: Reinhard Meyer<u-boot@emk-elektronik.de>
>
> Signed-off-by: Heiko Schocher<hs@denx.de>
> ---
>   arch/arm/cpu/arm926ejs/davinci/timer.c   |    6 ++++--
>   arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
>   arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
>   arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
>   arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
>   arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
>   arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
>   arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
>   arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
>   9 files changed, 36 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c
> index 9da7443..d7b1e46 100644
> --- a/arch/arm/cpu/arm926ejs/davinci/timer.c
> +++ b/arch/arm/cpu/arm926ejs/davinci/timer.c
> @@ -60,8 +60,10 @@ static struct davinci_timer * const timer =
>   #define TIMER_LOAD_VAL	(CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
>   #define TIM_CLK_DIV	16
>
> -static ulong timestamp;
> -static ulong lastinc;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastinc gd->lastinc
>
>   int timer_init(void)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
> index 2ec6a93..3e80329 100644
> --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c
> +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
> @@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
>   #define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
>   					 (CONFIG_SYS_TCLK / 1000))
>
> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   void reset_timer_masked(void)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
> index 9175b71..6966b0d 100644
> --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
> +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
> @@ -33,8 +33,10 @@
>   #define TIMER_LOAD_VAL	0xffffffff
>   #define TIMER_FREQ	(CONFIG_MB86R0x_IOCLK  / 256)
>
> -static unsigned long long timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   static inline unsigned long long tick_to_time(unsigned long long tick)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
> index 11d41a8..14f0c2d 100644
> --- a/arch/arm/cpu/arm926ejs/mx25/timer.c
> +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
> @@ -41,8 +41,10 @@
>   #include<asm/io.h>
>   #include<asm/arch/imx-regs.h>
>
> -static ulong timestamp;
> -static ulong lastinc;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastinc gd->lastinc
>
>   /*
>    * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
> diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
> index 8f1d47b..5c1cf01 100644
> --- a/arch/arm/cpu/arm926ejs/mx27/timer.c
> +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
> @@ -43,8 +43,10 @@
>   #define GPTCR_CLKSOURCE_32	(4<<  1)	/* Clock source		*/
>   #define GPTCR_TEN		1		/* Timer enable		*/
>
> -static ulong timestamp;
> -static ulong lastinc;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastinc gd->lastinc
>
>   /*
>    * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
> diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c
> index 7d4b6e6..88a0ee6 100644
> --- a/arch/arm/cpu/arm926ejs/omap/timer.c
> +++ b/arch/arm/cpu/arm926ejs/omap/timer.c
> @@ -42,8 +42,10 @@
>   /* macro to read the 32 bit timer */
>   #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
>
> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   int timer_init (void)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c
> index 089ef47..bbab226 100644
> --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c
> +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c
> @@ -90,8 +90,10 @@ static inline ulong read_timer(void)
>   	      / (CONFIG_SYS_TCLK / 1000);
>   }
>
> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   void reset_timer_masked(void)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c
> index 06858b4..66cf4de 100644
> --- a/arch/arm/cpu/arm926ejs/spear/timer.c
> +++ b/arch/arm/cpu/arm926ejs/spear/timer.c
> @@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
>   static struct misc_regs *const misc_regs_p =
>       (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
>
> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   int timer_init(void)
>   {
> diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c
> index 81d6749..2e243b1 100644
> --- a/arch/arm/cpu/arm926ejs/versatile/timer.c
> +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c
> @@ -42,8 +42,10 @@
>   /* macro to read the 32 bit timer */
>   #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
>
> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc
>
>   #define TIMER_ENABLE	(1<<  7)
>   #define TIMER_MODE_MSK	(1<<  6)

Applied to u-boot-arm, with a trivial merge for davinci.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
  2011-01-20 20:43 ` Albert ARIBAUD
@ 2011-01-20 20:49   ` Albert ARIBAUD
  2011-01-21  8:33     ` Heiko Schocher
  0 siblings, 1 reply; 14+ messages in thread
From: Albert ARIBAUD @ 2011-01-20 20:49 UTC (permalink / raw)
  To: u-boot

Le 20/01/2011 21:43, Albert ARIBAUD a ?crit :
> Le 10/12/2010 10:33, Heiko Schocher a ?crit :
>> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
>> values in the arm926ejs timers implementation.
>>
>> 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 and added suggestions
>> from Reinhard Meyer.
>>
>> Tested on the arm926ejs mx27 based magnesium board
>> Tested on the arm926ejs kirkwood based suen3 board
>>
>> Signed-off-by: Heiko Schocher<hs@denx.de>
>> cc: Albert ARIBAUD<albert.aribaud@free.fr>
>> cc: Prafulla Wadaskar<prafulla@marvell.com>
>> cc: Stefano Babic<sbabic@denx.de>
>> cc: Reinhard Meyer<u-boot@emk-elektronik.de>
>>
>> Signed-off-by: Heiko Schocher<hs@denx.de>
>> ---
>>    arch/arm/cpu/arm926ejs/davinci/timer.c   |    6 ++++--
>>    arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
>>    arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
>>    arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
>>    arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
>>    arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
>>    arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
>>    arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
>>    arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
>>    9 files changed, 36 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c
>> index 9da7443..d7b1e46 100644
>> --- a/arch/arm/cpu/arm926ejs/davinci/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/davinci/timer.c
>> @@ -60,8 +60,10 @@ static struct davinci_timer * const timer =
>>    #define TIMER_LOAD_VAL	(CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
>>    #define TIM_CLK_DIV	16
>>
>> -static ulong timestamp;
>> -static ulong lastinc;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastinc gd->lastinc
>>
>>    int timer_init(void)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
>> index 2ec6a93..3e80329 100644
>> --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
>> @@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
>>    #define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
>>    					 (CONFIG_SYS_TCLK / 1000))
>>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    void reset_timer_masked(void)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
>> index 9175b71..6966b0d 100644
>> --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
>> @@ -33,8 +33,10 @@
>>    #define TIMER_LOAD_VAL	0xffffffff
>>    #define TIMER_FREQ	(CONFIG_MB86R0x_IOCLK  / 256)
>>
>> -static unsigned long long timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    static inline unsigned long long tick_to_time(unsigned long long tick)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
>> index 11d41a8..14f0c2d 100644
>> --- a/arch/arm/cpu/arm926ejs/mx25/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
>> @@ -41,8 +41,10 @@
>>    #include<asm/io.h>
>>    #include<asm/arch/imx-regs.h>
>>
>> -static ulong timestamp;
>> -static ulong lastinc;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastinc gd->lastinc
>>
>>    /*
>>     * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
>> diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
>> index 8f1d47b..5c1cf01 100644
>> --- a/arch/arm/cpu/arm926ejs/mx27/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
>> @@ -43,8 +43,10 @@
>>    #define GPTCR_CLKSOURCE_32	(4<<   1)	/* Clock source		*/
>>    #define GPTCR_TEN		1		/* Timer enable		*/
>>
>> -static ulong timestamp;
>> -static ulong lastinc;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastinc gd->lastinc
>>
>>    /*
>>     * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
>> diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c
>> index 7d4b6e6..88a0ee6 100644
>> --- a/arch/arm/cpu/arm926ejs/omap/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/omap/timer.c
>> @@ -42,8 +42,10 @@
>>    /* macro to read the 32 bit timer */
>>    #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
>>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    int timer_init (void)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c
>> index 089ef47..bbab226 100644
>> --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c
>> @@ -90,8 +90,10 @@ static inline ulong read_timer(void)
>>    	      / (CONFIG_SYS_TCLK / 1000);
>>    }
>>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    void reset_timer_masked(void)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c
>> index 06858b4..66cf4de 100644
>> --- a/arch/arm/cpu/arm926ejs/spear/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/spear/timer.c
>> @@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
>>    static struct misc_regs *const misc_regs_p =
>>        (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
>>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    int timer_init(void)
>>    {
>> diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c
>> index 81d6749..2e243b1 100644
>> --- a/arch/arm/cpu/arm926ejs/versatile/timer.c
>> +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c
>> @@ -42,8 +42,10 @@
>>    /* macro to read the 32 bit timer */
>>    #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
>>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>>
>>    #define TIMER_ENABLE	(1<<   7)
>>    #define TIMER_MODE_MSK	(1<<   6)
>
> Applied to u-boot-arm, with a trivial merge for davinci.

Correction -- can't apply it *and* retain correct authorship in commit. 
Heiko, can you post a rebased version?

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr
  2011-01-20 20:49   ` Albert ARIBAUD
@ 2011-01-21  8:33     ` Heiko Schocher
  0 siblings, 0 replies; 14+ messages in thread
From: Heiko Schocher @ 2011-01-21  8:33 UTC (permalink / raw)
  To: u-boot

Hello Albert,

Albert ARIBAUD wrote:
> Le 20/01/2011 21:43, Albert ARIBAUD a ?crit :
>> Le 10/12/2010 10:33, Heiko Schocher a ?crit :
>>> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
>>> values in the arm926ejs timers implementation.
>>>
>>> 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 and added suggestions
>>> from Reinhard Meyer.
>>>
>>> Tested on the arm926ejs mx27 based magnesium board
>>> Tested on the arm926ejs kirkwood based suen3 board
>>>
>>> Signed-off-by: Heiko Schocher<hs@denx.de>
>>> cc: Albert ARIBAUD<albert.aribaud@free.fr>
>>> cc: Prafulla Wadaskar<prafulla@marvell.com>
>>> cc: Stefano Babic<sbabic@denx.de>
>>> cc: Reinhard Meyer<u-boot@emk-elektronik.de>
>>>
>>> Signed-off-by: Heiko Schocher<hs@denx.de>
>>> ---
>>>    arch/arm/cpu/arm926ejs/davinci/timer.c   |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
>>>    arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
>>>    9 files changed, 36 insertions(+), 18 deletions(-)
[...]
>>>    #define TIMER_ENABLE	(1<<   7)
>>>    #define TIMER_MODE_MSK	(1<<   6)
>> Applied to u-boot-arm, with a trivial merge for davinci.
> 
> Correction -- can't apply it *and* retain correct authorship in commit. 
> Heiko, can you post a rebased version?

Ok, I rebase this patch against current mainline, and send a new
version.

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] 14+ messages in thread

* [U-Boot] [PATCH v2] arm926ejs: timer: Replace bss variable by gdr
  2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
                   ` (2 preceding siblings ...)
  2011-01-20 20:43 ` Albert ARIBAUD
@ 2011-01-21  8:48 ` Heiko Schocher
  2011-01-21  8:56 ` [U-Boot] [PATCH v3] " Heiko Schocher
  4 siblings, 0 replies; 14+ messages in thread
From: Heiko Schocher @ 2011-01-21  8:48 UTC (permalink / raw)
  To: u-boot

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the arm926ejs timers implementation.

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 and added suggestions
from Reinhard Meyer.

Tested on the arm926ejs mx27 based magnesium board
Tested on the arm926ejs kirkwood based suen3 board

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Albert ARIBAUD <albert.aribaud@free.fr>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Stefano Babic <sbabic@denx.de>
cc: Reinhard Meyer <u-boot@emk-elektronik.de>
---
 - changes since v1:
   rebased and fixed an trivial merge issue in
   arch/arm/cpu/arm926ejs/davinci/timer.c

 arch/arm/cpu/arm926ejs/davinci/timer.c   |    4 ++++
 arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
 arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
 arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
 9 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c
index 1c6fa4a..9fff95e 100644
--- a/arch/arm/cpu/arm926ejs/davinci/timer.c
+++ b/arch/arm/cpu/arm926ejs/davinci/timer.c
@@ -62,6 +62,10 @@ static struct davinci_timer * const timer =
 #define TIMER_LOAD_VAL	0xffffffff
 
 #define TIM_CLK_DIV	16
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 int timer_init(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
index 2ec6a93..3e80329 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
@@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
 #define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
 					 (CONFIG_SYS_TCLK / 1000))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
index 9175b71..6966b0d 100644
--- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
+++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
@@ -33,8 +33,10 @@
 #define TIMER_LOAD_VAL	0xffffffff
 #define TIMER_FREQ	(CONFIG_MB86R0x_IOCLK  / 256)
 
-static unsigned long long timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
index 11d41a8..14f0c2d 100644
--- a/arch/arm/cpu/arm926ejs/mx25/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
@@ -41,8 +41,10 @@
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
index 8f1d47b..5c1cf01 100644
--- a/arch/arm/cpu/arm926ejs/mx27/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
@@ -43,8 +43,10 @@
 #define GPTCR_CLKSOURCE_32	(4 << 1)	/* Clock source		*/
 #define GPTCR_TEN		1		/* Timer enable		*/
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c
index 7d4b6e6..88a0ee6 100644
--- a/arch/arm/cpu/arm926ejs/omap/timer.c
+++ b/arch/arm/cpu/arm926ejs/omap/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init (void)
 {
diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c
index 089ef47..bbab226 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/timer.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c
@@ -90,8 +90,10 @@ static inline ulong read_timer(void)
 	      / (CONFIG_SYS_TCLK / 1000);
 }
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c
index 06858b4..66cf4de 100644
--- a/arch/arm/cpu/arm926ejs/spear/timer.c
+++ b/arch/arm/cpu/arm926ejs/spear/timer.c
@@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
 static struct misc_regs *const misc_regs_p =
     (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c
index 81d6749..2e243b1 100644
--- a/arch/arm/cpu/arm926ejs/versatile/timer.c
+++ b/arch/arm/cpu/arm926ejs/versatile/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 #define TIMER_ENABLE	(1 << 7)
 #define TIMER_MODE_MSK	(1 << 6)
-- 
1.7.3.4

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
                   ` (3 preceding siblings ...)
  2011-01-21  8:48 ` [U-Boot] [PATCH v2] " Heiko Schocher
@ 2011-01-21  8:56 ` Heiko Schocher
  2011-01-21 17:37   ` Albert ARIBAUD
  2011-01-22  5:39   ` Alexander Holler
  4 siblings, 2 replies; 14+ messages in thread
From: Heiko Schocher @ 2011-01-21  8:56 UTC (permalink / raw)
  To: u-boot

Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the arm926ejs timers implementation.

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 and added suggestions
from Reinhard Meyer.

Tested on the arm926ejs mx27 based magnesium board
Tested on the arm926ejs kirkwood based suen3 board

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Albert ARIBAUD <albert.aribaud@free.fr>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Stefano Babic <sbabic@denx.de>
cc: Reinhard Meyer <u-boot@emk-elektronik.de>

---
 - changes since v1:
   rebased and fixed an trivial merge issue in
   arch/arm/cpu/arm926ejs/davinci/timer.c
 - changes since v2:
   removed changes in arch/arm/cpu/arm926ejs/davinci/timer.c
   complete, as this is fixed in the meantime

 arch/arm/cpu/arm926ejs/kirkwood/timer.c  |    6 ++++--
 arch/arm/cpu/arm926ejs/mb86r0x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/mx25/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/mx27/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/omap/timer.c      |    6 ++++--
 arch/arm/cpu/arm926ejs/orion5x/timer.c   |    6 ++++--
 arch/arm/cpu/arm926ejs/spear/timer.c     |    6 ++++--
 arch/arm/cpu/arm926ejs/versatile/timer.c |    6 ++++--
 8 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
index 2ec6a93..3e80329 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c
@@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
 #define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
 					 (CONFIG_SYS_TCLK / 1000))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
index 9175b71..6966b0d 100644
--- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
+++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c
@@ -33,8 +33,10 @@
 #define TIMER_LOAD_VAL	0xffffffff
 #define TIMER_FREQ	(CONFIG_MB86R0x_IOCLK  / 256)
 
-static unsigned long long timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c
index 11d41a8..14f0c2d 100644
--- a/arch/arm/cpu/arm926ejs/mx25/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx25/timer.c
@@ -41,8 +41,10 @@
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c
index 8f1d47b..5c1cf01 100644
--- a/arch/arm/cpu/arm926ejs/mx27/timer.c
+++ b/arch/arm/cpu/arm926ejs/mx27/timer.c
@@ -43,8 +43,10 @@
 #define GPTCR_CLKSOURCE_32	(4 << 1)	/* Clock source		*/
 #define GPTCR_TEN		1		/* Timer enable		*/
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c
index 7d4b6e6..88a0ee6 100644
--- a/arch/arm/cpu/arm926ejs/omap/timer.c
+++ b/arch/arm/cpu/arm926ejs/omap/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init (void)
 {
diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c
index 089ef47..bbab226 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/timer.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c
@@ -90,8 +90,10 @@ static inline ulong read_timer(void)
 	      / (CONFIG_SYS_TCLK / 1000);
 }
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c
index 06858b4..66cf4de 100644
--- a/arch/arm/cpu/arm926ejs/spear/timer.c
+++ b/arch/arm/cpu/arm926ejs/spear/timer.c
@@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
 static struct misc_regs *const misc_regs_p =
     (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init(void)
 {
diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c
index 81d6749..2e243b1 100644
--- a/arch/arm/cpu/arm926ejs/versatile/timer.c
+++ b/arch/arm/cpu/arm926ejs/versatile/timer.c
@@ -42,8 +42,10 @@
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 #define TIMER_ENABLE	(1 << 7)
 #define TIMER_MODE_MSK	(1 << 6)
-- 
1.7.3.4

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-21  8:56 ` [U-Boot] [PATCH v3] " Heiko Schocher
@ 2011-01-21 17:37   ` Albert ARIBAUD
  2011-01-22  5:39   ` Alexander Holler
  1 sibling, 0 replies; 14+ messages in thread
From: Albert ARIBAUD @ 2011-01-21 17:37 UTC (permalink / raw)
  To: u-boot

Hi Heiko,

Le 21/01/2011 09:56, Heiko Schocher a ?crit :
> Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
> values in the arm926ejs timers implementation.
>
> 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 and added suggestions
> from Reinhard Meyer.
>
> Tested on the arm926ejs mx27 based magnesium board
> Tested on the arm926ejs kirkwood based suen3 board
>
> Signed-off-by: Heiko Schocher<hs@denx.de>
> cc: Albert ARIBAUD<albert.aribaud@free.fr>
> cc: Prafulla Wadaskar<prafulla@marvell.com>
> cc: Stefano Babic<sbabic@denx.de>
> cc: Reinhard Meyer<u-boot@emk-elektronik.de>

Applied to u-boot-arm, thanks.

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-21  8:56 ` [U-Boot] [PATCH v3] " Heiko Schocher
  2011-01-21 17:37   ` Albert ARIBAUD
@ 2011-01-22  5:39   ` Alexander Holler
  2011-01-22  7:46     ` Albert ARIBAUD
  1 sibling, 1 reply; 14+ messages in thread
From: Alexander Holler @ 2011-01-22  5:39 UTC (permalink / raw)
  To: u-boot

Hello,

Am 21.01.2011 09:56, schrieb Heiko Schocher:

> -static ulong timestamp;
> -static ulong lastdec;
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define timestamp gd->tbl
> +#define lastdec gd->lastinc

I'm the only one who doesn't like such defines? They might be handy for 
quick fixes, but in regard to style and readablity I don't like them. 
When looking at teh code where they will used, you won't see the actual 
place where they are stored. And in more complex expression they might 
become dangerous to use because they hide the operator "->".

Regards,

Alexander

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-22  5:39   ` Alexander Holler
@ 2011-01-22  7:46     ` Albert ARIBAUD
  2011-01-22  8:14       ` Reinhard Meyer
  2011-01-22  9:21       ` Alexander Holler
  0 siblings, 2 replies; 14+ messages in thread
From: Albert ARIBAUD @ 2011-01-22  7:46 UTC (permalink / raw)
  To: u-boot

Le 22/01/2011 06:39, Alexander Holler a ?crit :
> Hello,
>
> Am 21.01.2011 09:56, schrieb Heiko Schocher:
>
>> -static ulong timestamp;
>> -static ulong lastdec;
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +#define timestamp gd->tbl
>> +#define lastdec gd->lastinc
>
> I'm the only one who doesn't like such defines? They might be handy for
> quick fixes, but in regard to style and readablity I don't like them.
> When looking at teh code where they will used, you won't see the actual
> place where they are stored. And in more complex expression they might
> become dangerous to use because they hide the operator "->".

I accept the patch because it un-breaks support for ARM cpus, and I 
prefer a working fix to a perfect fix in this specific, transitional, 
situation.

However a general rework of ARM timer code is in order so that all SoCs 
and CPUs share the same set of gd variables with the same names and the 
same logic; and when we get that, this code shall move along.

About this rework, as the saying goes... "Patches Welcome ?". :)

> Regards,
>
> Alexander

Amicalement,
-- 
Albert.

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-22  7:46     ` Albert ARIBAUD
@ 2011-01-22  8:14       ` Reinhard Meyer
  2011-01-22  9:21       ` Alexander Holler
  1 sibling, 0 replies; 14+ messages in thread
From: Reinhard Meyer @ 2011-01-22  8:14 UTC (permalink / raw)
  To: u-boot

Dear Albert ARIBAUD,
> However a general rework of ARM timer code is in order so that all SoCs
> and CPUs share the same set of gd variables with the same names and the
> same logic; and when we get that, this code shall move along.
>
> About this rework, as the saying goes... "Patches Welcome ?". :)

There were several suggestions about that in the past (including from me)
that involve rework everywhere HZ related timeouts are used. I still
prefer a method as follows (because it does not need repeated mul/div calculations
nor necessarily 64 bit arithmetic):

u32 timeout = timeout_init(100); /* 100ms timeout */

do {...} while (!timed_out(timeout));

Internally it would be like:

timeout_init(x):
  return fast_tick + (x * fast_tick_rate) / CONFIG_SYS_HZ;
  /* this might need 64 bit precision in some implementations */

time_out(x):
  return ((i32)(x - fast_tick)) < 0;

If the tick were really high speed (and then 64 bits),
fast_tick could be derived by shifting the tick some bits to the right.

But, as long as we cannot agree on something, there will be no time spent
to make patches...

Best Regards,
Reinhard

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-22  7:46     ` Albert ARIBAUD
  2011-01-22  8:14       ` Reinhard Meyer
@ 2011-01-22  9:21       ` Alexander Holler
  2011-01-24  6:42         ` Heiko Schocher
  1 sibling, 1 reply; 14+ messages in thread
From: Alexander Holler @ 2011-01-22  9:21 UTC (permalink / raw)
  To: u-boot

Am 22.01.2011 08:46, schrieb Albert ARIBAUD:
> Le 22/01/2011 06:39, Alexander Holler a ?crit :
>> Hello,
>>
>> Am 21.01.2011 09:56, schrieb Heiko Schocher:
>>
>>> -static ulong timestamp;
>>> -static ulong lastdec;
>>> +DECLARE_GLOBAL_DATA_PTR;
>>> +
>>> +#define timestamp gd->tbl
>>> +#define lastdec gd->lastinc
>>
>> I'm the only one who doesn't like such defines? They might be handy for
>> quick fixes, but in regard to style and readablity I don't like them.
>> When looking at teh code where they will used, you won't see the actual
>> place where they are stored. And in more complex expression they might
>> become dangerous to use because they hide the operator "->".
>
> I accept the patch because it un-breaks support for ARM cpus, and I
> prefer a working fix to a perfect fix in this specific, transitional,
> situation.

My experience is that such quick fixes (or workarounds) usually 
manifests (because they become forgotten) and later on might even be 
copied to other places. ;)

Anyway, I'll have to thank for that patch, because it fixes at least one 
of the problems I have while trying to chainload a 2010.12 from a 
2010.12 on a kirkwood system.

Regards, and again, thanks for the patch, even if I found it ugly,

Alexander

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

* [U-Boot] [PATCH v3] arm926ejs: timer: Replace bss variable by gdr
  2011-01-22  9:21       ` Alexander Holler
@ 2011-01-24  6:42         ` Heiko Schocher
  0 siblings, 0 replies; 14+ messages in thread
From: Heiko Schocher @ 2011-01-24  6:42 UTC (permalink / raw)
  To: u-boot

Hello Alexander,

Alexander Holler wrote:
> Am 22.01.2011 08:46, schrieb Albert ARIBAUD:
>> Le 22/01/2011 06:39, Alexander Holler a ?crit :
>>> Hello,
>>>
>>> Am 21.01.2011 09:56, schrieb Heiko Schocher:
>>>
>>>> -static ulong timestamp;
>>>> -static ulong lastdec;
>>>> +DECLARE_GLOBAL_DATA_PTR;
>>>> +
>>>> +#define timestamp gd->tbl
>>>> +#define lastdec gd->lastinc
>>>
>>> I'm the only one who doesn't like such defines? They might be handy for
>>> quick fixes, but in regard to style and readablity I don't like them.
>>> When looking at teh code where they will used, you won't see the actual
>>> place where they are stored. And in more complex expression they might
>>> become dangerous to use because they hide the operator "->".
>>
>> I accept the patch because it un-breaks support for ARM cpus, and I
>> prefer a working fix to a perfect fix in this specific, transitional,
>> situation.
> 
> My experience is that such quick fixes (or workarounds) usually
> manifests (because they become forgotten) and later on might even be

As this is a open source project, feel free to work with us, that
this get not forgotten!

> copied to other places. ;)

Yes, it is not the best solution, but it fixes a bug. The patch is
some days old (and made as a quick fix), and I vote also to make a
better approach for timers on arm, but in the time this patch was
pending none did a better (accepted) approach...

> Anyway, I'll have to thank for that patch, because it fixes at least one
> of the problems I have while trying to chainload a 2010.12 from a
> 2010.12 on a kirkwood system.
> 
> Regards, and again, thanks for the patch, even if I found it ugly,

As I said above, feel free to post a patch with a better approach.

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] 14+ messages in thread

end of thread, other threads:[~2011-01-24  6:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10  9:33 [U-Boot] [PATCH] arm926ejs: timer: Replace bss variable by gdr Heiko Schocher
2010-12-11 11:41 ` Prafulla Wadaskar
2010-12-13  7:29 ` Stefano Babic
2011-01-20 20:43 ` Albert ARIBAUD
2011-01-20 20:49   ` Albert ARIBAUD
2011-01-21  8:33     ` Heiko Schocher
2011-01-21  8:48 ` [U-Boot] [PATCH v2] " Heiko Schocher
2011-01-21  8:56 ` [U-Boot] [PATCH v3] " Heiko Schocher
2011-01-21 17:37   ` Albert ARIBAUD
2011-01-22  5:39   ` Alexander Holler
2011-01-22  7:46     ` Albert ARIBAUD
2011-01-22  8:14       ` Reinhard Meyer
2011-01-22  9:21       ` Alexander Holler
2011-01-24  6:42         ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox