See patch

-- 
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: [email protected]http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866

libpayload timer functions fix. Due to integer data types used the actual delay
time overflows, posibly resulting in much shorter delay times than specified.

For example, with an 1.6GHz CPU 
- ndelay would overflow every 2.6us
- udelay would overflow every 2.6ms
- mdelay would overflow every 2.6s
- delay would overflow every 2.6s

Signed-off-by: Stefan Reinauer <[email protected]>


Index: arch/i386/timer.c
===================================================================
--- arch/i386/timer.c
+++ arch/i386/timer.c
@@ -88,7 +88,7 @@
  */
 void ndelay(unsigned int n)
 {
-       _delay(n * cpu_khz / 1000000);
+       _delay((unsigned long long)n * cpu_khz / 1000000);
 }
 
 /**
@@ -98,7 +98,7 @@
  */
 void udelay(unsigned int n)
 {
-       _delay(n * cpu_khz / 1000);
+       _delay((unsigned long long)n * cpu_khz / 1000);
 }
 
 /**
@@ -108,7 +108,7 @@
  */
 void mdelay(unsigned int m)
 {
-       _delay(m * cpu_khz);
+       _delay((unsigned long long)m * cpu_khz);
 }
 
 /**
@@ -118,5 +118,7 @@
  */
 void delay(unsigned int s)
 {
-       _delay(s * cpu_khz * 1000);
+       int i;
+       for (i=0; i<1000; i++)
+               _delay((unsigned long long)s * cpu_khz);
 }
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to