[U-Boot] [RFC PATCH] lib/timer: initialize timebase_l/timebase_h

Alexander Graf agraf at suse.de
Tue Oct 25 09:52:48 CEST 2016



On 25/10/2016 02:51, Andre Przywara wrote:
> On systems using the generic timer routines defined in lib/time.c we
> use timebase_l and timebase_h fields from the gd to detect wraparounds
> in our tick counter. The tick calculcation algorithm silently assumes
> that a long is only 32 bits, which leads to wrong results when timebase_h
> is not 0 on 64-bit systems.
> As one possible fix lets initialize timebase_h (and timebase_l) to 0, so
> on 64-bit systems timebase_h will never(TM) be bigger than 0 and thus
> cannot spoil timebase_l by being ORed into it.
> 
> This fixes occasional timeout issues on the Pine64 (and possibly other
> ARM64 systems).
> 
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> ---
> Hi,
> 
> I am bit puzzled what the proper fix is, this one is the easiest I could
> come up with. Not sure if the gd should be zeroed normally (and it's just
> broken on sunxi/arm64 because of some linker issues) or whether we really
> forgot to initialize those fields and just got away with it.

The gd clearing happens via crt0_64.S -> board_init_f_init_reserve().
There we should have fully cleared all memory associated with global data.

I can't see anything obviously wrong in that code. Could you try to dump
gd if the timer offsets are != 0 on init? Maybe we can conclude
something from the data in it.


Alex


More information about the U-Boot mailing list