* [PATCH 2.5] udelay
@ 2003-01-13 10:04 Vivien Chappelier
0 siblings, 0 replies; 3+ messages in thread
From: Vivien Chappelier @ 2003-01-13 10:04 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
Hi,
The HZ constant has been changed in 2.5 and this breaks
udelay(). Here is a patch to fix this. Note that the first multiply in
udelay is still optimized out by the compiler if the delay is constant,
as in current implementation.
Vivien.
[-- Attachment #2: linux-mips-udelay.diff --]
[-- Type: text/plain, Size: 1125 bytes --]
--- include/asm-mips64/delay.h 2002-12-11 20:44:20.000000000 +0100
+++ include/asm-mips64/delay.h 2003-01-07 20:36:37.000000000 +0100
@@ -41,11 +41,11 @@
{
unsigned long lo;
-#if (HZ == 100)
- usecs *= 0x00068db8bac710cbUL; /* 2**64 / (1000000 / HZ) */
-#elif (HZ == 128)
- usecs *= 0x0008637bd05af6c6UL; /* 2**64 / (1000000 / HZ) */
-#endif
+/* HZ * 2**64 / 1000000 */
+#define __UDELAY_FIXED64_HZ_1000000 (0x8000000000000000UL / (500000 / HZ))
+
+ usecs *= __UDELAY_FIXED64_HZ_1000000;
+
__asm__("dmultu\t%2,%3"
:"=h" (usecs), "=l" (lo)
:"r" (usecs),"r" (lpj));
--- include/asm-mips/delay.h 2002-12-11 20:44:18.000000000 +0100
+++ include/asm-mips/delay.h 2003-01-08 19:25:17.000000000 +0100
@@ -40,11 +40,10 @@
{
unsigned long lo;
-#if (HZ == 100)
- usecs *= 0x00068db8; /* 2**32 / (1000000 / HZ) */
-#elif (HZ == 128)
- usecs *= 0x0008637b; /* 2**32 / (1000000 / HZ) */
-#endif
+/* HZ * 2**32 / 1000000 */
+#define __UDELAY_FIXED32_HZ_1000000 (0x80000000UL / (500000 / HZ))
+
+ usecs *= __UDELAY_FIXED32_HZ_1000000;
__asm__("multu\t%2,%3"
:"=h" (usecs), "=l" (lo)
:"r" (usecs),"r" (lpj));
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2.5] udelay
@ 2003-01-11 18:55 Vivien Chappelier
0 siblings, 0 replies; 3+ messages in thread
From: Vivien Chappelier @ 2003-01-11 18:55 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Hi,
The HZ constant has been changed in 2.5 and this breaks
udelay(). Here is a patch to fix this. Note that the first multiply in
udelay is still optimized out by the compiler if the delay is constant, as
in current implementation.
Vivien.
--- include/asm-mips64/delay.h 2002-12-11 20:44:20.000000000 +0100
+++ include/asm-mips64/delay.h 2003-01-07 20:36:37.000000000 +0100
@@ -41,11 +41,11 @@
{
unsigned long lo;
-#if (HZ == 100)
- usecs *= 0x00068db8bac710cbUL; /* 2**64 / (1000000 / HZ) */
-#elif (HZ == 128)
- usecs *= 0x0008637bd05af6c6UL; /* 2**64 / (1000000 / HZ) */
-#endif
+/* HZ * 2**64 / 1000000 */
+#define __UDELAY_FIXED64_HZ_1000000 (0x8000000000000000UL / (500000 / HZ))
+
+ usecs *= __UDELAY_FIXED64_HZ_1000000;
+
__asm__("dmultu\t%2,%3"
:"=h" (usecs), "=l" (lo)
:"r" (usecs),"r" (lpj));
--- include/asm-mips/delay.h 2002-12-11 20:44:18.000000000 +0100
+++ include/asm-mips/delay.h 2003-01-08 19:25:17.000000000 +0100
@@ -40,11 +40,10 @@
{
unsigned long lo;
-#if (HZ == 100)
- usecs *= 0x00068db8; /* 2**32 / (1000000 / HZ) */
-#elif (HZ == 128)
- usecs *= 0x0008637b; /* 2**32 / (1000000 / HZ) */
-#endif
+/* HZ * 2**32 / 1000000 */
+#define __UDELAY_FIXED32_HZ_1000000 (0x80000000UL / (500000 / HZ))
+
+ usecs *= __UDELAY_FIXED32_HZ_1000000;
__asm__("multu\t%2,%3"
:"=h" (usecs), "=l" (lo)
:"r" (usecs),"r" (lpj));
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2.5] udelay
@ 2002-12-21 18:11 Vivien Chappelier
0 siblings, 0 replies; 3+ messages in thread
From: Vivien Chappelier @ 2002-12-21 18:11 UTC (permalink / raw)
To: linux-mips; +Cc: Ralf Baechle, Ilya Volynets
Hi,
The HZ constant has changed in 2.5 and udelay doesn't work
properly anymore. Here's a patch to fix it. I checked the first multiply
is still optimized out during compilation if the delay is constant. It's
for mips64, but mips32 needs it as well.
Vivien.
--- include/asm-mips64/delay.h 2002-12-11 20:44:20.000000000 +0100
+++ include/asm-mips64/delay.h 2002-12-21 18:48:12.000000000 +0100
@@ -41,11 +41,10 @@
{
unsigned long lo;
-#if (HZ == 100)
- usecs *= 0x00068db8bac710cbUL; /* 2**64 / (1000000 / HZ) */
-#elif (HZ == 128)
- usecs *= 0x0008637bd05af6c6UL; /* 2**64 / (1000000 / HZ) */
-#endif
+/* HZ * 2**64 / 1000000 */
+#define __UDELAY_FIXED64_HZ_1000000 (0x8000000000000000UL / (500000 / HZ))
+
+ usecs *= __UDELAY_FIXED64_HZ_1000000;
__asm__("dmultu\t%2,%3"
:"=h" (usecs), "=l" (lo)
:"r" (usecs),"r" (lpj));
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-13 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-13 10:04 [PATCH 2.5] udelay Vivien Chappelier
-- strict thread matches above, loose matches on Subject: below --
2003-01-11 18:55 Vivien Chappelier
2002-12-21 18:11 Vivien Chappelier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.