[U-Boot] [RFC] ARM timing code refactoring

Reinhard Meyer u-boot at emk-elektronik.de
Sun Jan 23 11:26:57 CET 2011


Dear Wolfgang Denk,
> In message<4D3B5171.7090700 at emk-elektronik.de>  you wrote:
>>
>> With all this half quoting and deleting of important parts,
>> my original proposal was lost again.
>
> This is a prettyu long running thread, and I am not exactly sure what
> your original proposal actually was.  Could you please post a
> reference?
I just repost here:

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


More information about the U-Boot mailing list