diff options
author | Pallipadi, Venkatesh <venkatesh.pallipadi@intel.com> | 2009-06-25 19:44:31 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-06-25 19:47:40 -0400 |
commit | e888d7facd1f1460a638151036d15b6cfb3ccc74 (patch) | |
tree | 7d623ee1b31d431317e87f59013a67d8549b9fae /arch/x86/lib | |
parent | 658dbfeb5e7ab35d440c665d643a6285e43fddcd (diff) |
x86, delay: tsc based udelay should have rdtsc_barrier
delay_tsc needs rdtsc_barrier to provide proper delay.
Output from a test driver using hpet to cross check delay
provided by udelay().
Before:
[ 86.794363] Expected delay 5us actual 4679ns
[ 87.154362] Expected delay 5us actual 698ns
[ 87.514162] Expected delay 5us actual 4539ns
[ 88.653716] Expected delay 5us actual 4539ns
[ 94.664106] Expected delay 10us actual 9638ns
[ 95.049351] Expected delay 10us actual 10126ns
[ 95.416110] Expected delay 10us actual 9568ns
[ 95.799216] Expected delay 10us actual 9638ns
[ 103.624104] Expected delay 10us actual 9707ns
[ 104.020619] Expected delay 10us actual 768ns
[ 104.419951] Expected delay 10us actual 9707ns
After:
[ 50.983320] Expected delay 5us actual 5587ns
[ 51.261807] Expected delay 5us actual 5587ns
[ 51.565715] Expected delay 5us actual 5657ns
[ 51.861171] Expected delay 5us actual 5587ns
[ 52.164704] Expected delay 5us actual 5726ns
[ 52.487457] Expected delay 5us actual 5657ns
[ 52.789338] Expected delay 5us actual 5726ns
[ 57.119680] Expected delay 10us actual 10755ns
[ 57.893997] Expected delay 10us actual 10615ns
[ 58.261287] Expected delay 10us actual 10755ns
[ 58.620505] Expected delay 10us actual 10825ns
[ 58.941035] Expected delay 10us actual 10755ns
[ 59.320903] Expected delay 10us actual 10615ns
[ 61.306311] Expected delay 10us actual 10755ns
[ 61.520542] Expected delay 10us actual 10615ns
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/lib')
-rw-r--r-- | arch/x86/lib/delay.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c index f4568605d7d5..ff485d361182 100644 --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c | |||
@@ -55,8 +55,10 @@ static void delay_tsc(unsigned long loops) | |||
55 | 55 | ||
56 | preempt_disable(); | 56 | preempt_disable(); |
57 | cpu = smp_processor_id(); | 57 | cpu = smp_processor_id(); |
58 | rdtsc_barrier(); | ||
58 | rdtscl(bclock); | 59 | rdtscl(bclock); |
59 | for (;;) { | 60 | for (;;) { |
61 | rdtsc_barrier(); | ||
60 | rdtscl(now); | 62 | rdtscl(now); |
61 | if ((now - bclock) >= loops) | 63 | if ((now - bclock) >= loops) |
62 | break; | 64 | break; |
@@ -78,6 +80,7 @@ static void delay_tsc(unsigned long loops) | |||
78 | if (unlikely(cpu != smp_processor_id())) { | 80 | if (unlikely(cpu != smp_processor_id())) { |
79 | loops -= (now - bclock); | 81 | loops -= (now - bclock); |
80 | cpu = smp_processor_id(); | 82 | cpu = smp_processor_id(); |
83 | rdtsc_barrier(); | ||
81 | rdtscl(bclock); | 84 | rdtscl(bclock); |
82 | } | 85 | } |
83 | } | 86 | } |