Messages in this thread | | | Date | Wed, 9 Jun 2004 12:03:47 +0200 | From | Pavel Machek <> | Subject | Re: [PATCH 3/3] fix for small xloops [Was: Re: Too much error in __const_udelay() ?] |
| |
Hi!
> The const_udelay calculation relies on the "overflow" of the lower 32 bits > of the mull operation. What's in the lower 32 bits is "cut off", so that a > "rounding down" phenomenon exists. For large arguments to {n,u}delay, this does > not matter, as udelay and ndelay round _up_ themselves. However, for small > delays (for cyclone timer: up to 20ns; for pmtmr-based delay timer it's even > up to 1500ns or 1us) it _is_ a critical error. Empirical testing has shown that > it happens only (for usual values of loops_per_jiffies) if xloops is lower or > equal to six. Let's be safe, and double that value, and add one xloop if > xloop is smaller than 13.
Should not you just xloops++, always? Better safe than sorry. Plus you have one less test and branch...
Pavel
> Signed-off-by: Dominik Brodowski <linux@brodo.de> > > diff -ruN linux-original/arch/i386/lib/delay.c linux/arch/i386/lib/delay.c > --- linux-original/arch/i386/lib/delay.c 2004-06-07 23:02:02.472656160 +0200 > +++ linux/arch/i386/lib/delay.c 2004-06-07 22:55:40.063791144 +0200 > @@ -34,6 +34,8 @@ > __asm__("mull %0" > :"=d" (xloops), "=&a" (d0) > :"1" (xloops),"0" (current_cpu_data.loops_per_jiffy * HZ)); > + if (unlikely(xloops < 13)) > + xloops++; > __delay(xloops); > } > > - > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/
-- 934a471f20d6580d5aad759bf0d97ddc - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |