public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd
Date: Fri, 10 Dec 2010 06:22:54 +0100	[thread overview]
Message-ID: <4D01B92E.8050506@googlemail.com> (raw)
In-Reply-To: <1291912288-27536-1-git-send-email-dirk.behme@gmail.com>

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;
>   }
>
>   /*
>

  parent reply	other threads:[~2010-12-10  5:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D01B92E.8050506@googlemail.com \
    --to=dirk.behme@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox