Commit 5bad9c0a authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] round up in __udelay()

Round up in __udelay(): 2**32 / 100000 is 4294.97, so it's more intuitive
to round up, and it causes more predictable results:

n usec delay on a 1500000 BogoMIPS system:

  n 	   before	  -mull		after
  1	 1000 ticks	 1499 ticks	 1500 ticks
 10	14000 ticks	14999 ticks	15000 ticks

n usec delay on a 100000 BogoMIPS system: 

 n 	   before	  -mull		after
  1	    0 ticks	   99 ticks	  100 ticks
 10	    0 ticks	  999 ticks	 1000 ticks
100	 9000 ticks	 9999 ticks	10000 ticks

While it can be argued that some time is also spent in the delay functions,
it's better to spend _at least_ the specified time sleeping, in my humble
opinion.  And the overhead of a specific ->delay() implementation should be
substracted in the specific ->delay() implementation.
Signed-off-by: default avatarDominik Brodowski <linux@brodo.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fdfd31c6
...@@ -40,7 +40,7 @@ inline void __const_udelay(unsigned long xloops) ...@@ -40,7 +40,7 @@ inline void __const_udelay(unsigned long xloops)
void __udelay(unsigned long usecs) void __udelay(unsigned long usecs)
{ {
__const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */ __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
} }
void __ndelay(unsigned long nsecs) void __ndelay(unsigned long nsecs)
......
...@@ -16,7 +16,7 @@ extern void __const_udelay(unsigned long usecs); ...@@ -16,7 +16,7 @@ extern void __const_udelay(unsigned long usecs);
extern void __delay(unsigned long loops); extern void __delay(unsigned long loops);
#define udelay(n) (__builtin_constant_p(n) ? \ #define udelay(n) (__builtin_constant_p(n) ? \
((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \ ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
__udelay(n)) __udelay(n))
#define ndelay(n) (__builtin_constant_p(n) ? \ #define ndelay(n) (__builtin_constant_p(n) ? \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment