[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug in include/asm-m68k/delay.h



Hi,

I finally solved the problem with my Amiga keyboard and kernel 2.4.20
which I described in
http://lists.debian.org/debian-68k/2003/debian-68k-200304/msg00072.txt
(key-presses often got repeated about 100 times). I think it was caused
by udelay not delaying as long as specified.

Due to a change in delay.h which occurred somewhere between 2.2.20 and
2.4.20 the number of loops got rounded down to the next smaller
multiple of HZ (=100). Thus the udelay(85) in drivers/char/amikeyb.c did
only 200 loops instead of 260 (= 85 * 30656 * 100 * 4295 / 2**32,
30656 is the value of loops_per_jiffy on my computer).

So I moved the multiplication with HZ from the __delay()-call to the
__const_udelay()-call. To prevent an overflow for big n I replaced the
factor 4295 by 537 (=4296/8) and in turn used loops_per_jiffy<<3 in the
calculation of the number of loops:

--- kernel-source-2.4.20.orig/include/asm-m68k/delay.h	Tue Dec 30 18:36:25 2003
+++ kernel-source-2.4.20/include/asm-m68k/delay.h	Tue Dec 30 19:03:24 2003
@@ -30,17 +30,17 @@
 
 	__asm__ ("mulul %2,%0:%1"
 		: "=d" (xloops), "=d" (tmp)
-		: "d" (xloops), "1" (loops_per_jiffy));
-	__delay(xloops * HZ);
+		: "d" (xloops), "1" (loops_per_jiffy<<3));
+	__delay(xloops);
 }
 
 static inline void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 4295);	/* 2**32 / 1000000 */
+	__const_udelay(usecs * 537 * HZ);	/* 2**32 / 8000000 */
 }
 
 #define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 4295)) : \
+	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 537 * HZ)) : \
 	__udelay(n))
 
 extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)


Where should I send this patch to get it possibly included in the kernel?

Greetings,

Rolf



Reply to: