summaryrefslogtreecommitdiffstats
path: root/arch/i386/lib
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-03-19 01:28:40 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-03-19 01:28:40 +0000
commit8abb719409c9060a7c0676f76e9182c1e0b8ca46 (patch)
treeb88cc5a6cd513a04a512b7e6215c873c90a1c5dd /arch/i386/lib
parentf01bd7aeafd95a08aafc9e3636bb26974df69d82 (diff)
Merge with 2.3.99-pre1.
Diffstat (limited to 'arch/i386/lib')
-rw-r--r--arch/i386/lib/delay.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/arch/i386/lib/delay.c b/arch/i386/lib/delay.c
index 6918451a6..ca5eeb796 100644
--- a/arch/i386/lib/delay.c
+++ b/arch/i386/lib/delay.c
@@ -12,12 +12,38 @@
#include <linux/sched.h>
#include <linux/delay.h>
+#include <asm/delay.h>
#ifdef __SMP__
#include <asm/smp.h>
#endif
-void __delay(unsigned long loops)
+int x86_udelay_tsc = 0; /* Delay via TSC */
+
+
+/*
+ * Do a udelay using the TSC for any CPU that happens
+ * to have one that we trust. This could be optimised to avoid
+ * the multiply per loop but its a delay loop so who are we kidding...
+ */
+
+static void __rdtsc_delay(unsigned long loops)
+{
+ unsigned long bclock, now;
+
+ rdtscl(bclock);
+ do
+ {
+ rdtscl(now);
+ }
+ while((now-bclock) < loops);
+}
+
+/*
+ * Non TSC based delay loop for 386, 486, MediaGX
+ */
+
+static void __loop_delay(unsigned long loops)
{
int d0;
__asm__ __volatile__(
@@ -30,6 +56,14 @@ void __delay(unsigned long loops)
:"0" (loops));
}
+void __delay(unsigned long loops)
+{
+ if(x86_udelay_tsc)
+ __rdtsc_delay(loops);
+ else
+ __loop_delay(loops);
+}
+
inline void __const_udelay(unsigned long xloops)
{
int d0;