[U-Boot-Users] [PATCH] Bug fix for MIPS timer

Andrew Dyer amdyer at gmail.com
Fri Jun 22 19:11:29 CEST 2007


On 6/22/07, Robert Delien <robert.delien at nxp.com> wrote:
>  When building MIPS targets the warning 'integer overflow in expression'
> occurs in nfs.c and net.c because these targets still define their clock
> speed in CFG_HZ instead of the number of miliseconds per second (1000). This
> will cause incorrect timer behavior. The patch attached fixes this and makes
> sure MIPS targets now use a CFG_HZ of 1000.

A couple of comments/questions:

Why did you change the while loop and add the rollover code?  The old code:
-	while ((ulong)((mips_count_get() - start)) < tmo)
-		/*NOP*/;
seems perfectly sane to me and should work whether or not you use
read_32bit_cp0_register(CP0_COUNT) or mips_count_get() assuming tmo
gets set correctly.  Is this something NXP specific?

In udelay() I don't like this part that silently truncates delays.
This could lead to some ugly hard to find timing bugs.

+	/* Safeguard for too-long delays */
+	if (delayTicks >= 0x80000000)
+		delayTicks = 0x7FFFFFFF;

I would calculate the max. count you can handle in the code and run
the timer polling loop multiple times if need be.

Other nits:

long lines
might be a good idea to throw in a compile time warning message if
CFG_HZ != 1000

-- 
Hardware, n.:
        The parts of a computer system that can be kicked.




More information about the U-Boot mailing list