[U-Boot] [PATCH v2] mmc: omap: timeout counter fix

Reinhard Meyer u-boot at emk-elektronik.de
Tue Oct 26 09:48:52 CEST 2010


Dear Wolfgang Denk,
> Dear Reinhard Meyer,
> 
> In message <4CC66ECA.9000106 at emk-elektronik.de> you wrote:
>> Agreed here. People are invited to dig through u-boot and find all
>> those places.
> 
> You know the ones you added best :-)
> 
>>  > int main(void)
>>  > {
>>  > 	unsigned int time = 0xFFFFFFF0;
>>  > 	unsigned int delay = 0x20;
>>  > 	unsigned int start;
>>
>> You are wrong here, because you take it out of context.
> 
> I am not wrong. Feel free to replace "unsigned int" by "unsigned long
> long", and 0xFFFFFFF0 by 0xFFFFFFFFFFFFFFF0ULL, and the "%X" by "%llX".
> 
>> My "demo" is using the (declared as) 64 bit function get_ticks().
>> I mentioned above that this function MUST be truly returning 64
>> bits worth of (incrementing) value to make any version work.
> 
> What's the difference?  It is inherently wrong to believe an overflow
> would never occur just because the precision of a number is "long
> enough". Remeber y2k issues. Remember the time overflog for UNIX
> systems in 2038, etc. etc.
> 
>> If get_ticks() just returns a 32 bit counter value neither method will work
>> reliably. Just check all implementations that this function is implemented
>> correctly.
You should really try to understand what I am saying here:

IF get_timer() returns 0x0000000000000000 to 0x00000000ffffffff and wraps back
to 0x0000000000000000 (thats how it is or was implemented in SOME architectures)
neither mine (agreed to be wrong) nor your code would work if it uses 64 bits vars.

Reinhard


More information about the U-Boot mailing list