diff options
-rw-r--r-- | arch/i386/lib/delay.c | 3 | ||||
-rw-r--r-- | arch/x86_64/lib/delay.c | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/arch/i386/lib/delay.c b/arch/i386/lib/delay.c index f6edb11364df..66595edcd7b6 100644 --- a/arch/i386/lib/delay.c +++ b/arch/i386/lib/delay.c @@ -12,6 +12,7 @@ #include <linux/module.h> #include <linux/sched.h> +#include <linux/preempt.h> #include <linux/delay.h> #include <asm/processor.h> @@ -42,11 +43,13 @@ static void delay_tsc(unsigned long loops) { unsigned long bclock, now; + preempt_disable(); /* TSC's are per-cpu */ rdtscl(bclock); do { rep_nop(); rdtscl(now); } while ((now-bclock) < loops); + preempt_enable(); } /* diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c index 2dbebd308347..4d3f1f641336 100644 --- a/arch/x86_64/lib/delay.c +++ b/arch/x86_64/lib/delay.c @@ -10,7 +10,9 @@ #include <linux/module.h> #include <linux/sched.h> +#include <linux/preempt.h> #include <linux/delay.h> + #include <asm/delay.h> #include <asm/msr.h> @@ -27,14 +29,15 @@ int read_current_timer(unsigned long *timer_value) void __delay(unsigned long loops) { unsigned bclock, now; - + + preempt_disable(); /* TSC's are pre-cpu */ rdtscl(bclock); - do - { + do { rep_nop(); rdtscl(now); } - while((now-bclock) < loops); + while ((now-bclock) < loops); + preempt_enable(); } EXPORT_SYMBOL(__delay); |