summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/pcspeaker.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2012-03-09 20:55:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-19 08:57:43 -0700
commit5bcb3f882ab97f3ebb4c4abd435704ad24c565cb (patch)
treefddaeaaf39f0ec8eccfa2da83fab798de81a2b7e /arch/x86/kernel/pcspeaker.c
parente808b6adb5d0cfef4ab82a210bc680003b200e77 (diff)
x86: Derandom delay_tsc for 64 bit
commit a7f4255f906f60f72e00aad2fb000939449ff32e upstream. Commit f0fbf0abc093 ("x86: integrate delay functions") converted delay_tsc() into a random delay generator for 64 bit. The reason is that it merged the mostly identical versions of delay_32.c and delay_64.c. Though the subtle difference of the result was: static void delay_tsc(unsigned long loops) { - unsigned bclock, now; + unsigned long bclock, now; Now the function uses rdtscl() which returns the lower 32bit of the TSC. On 32bit that's not problematic as unsigned long is 32bit. On 64 bit this fails when the lower 32bit are close to wrap around when bclock is read, because the following check if ((now - bclock) >= loops) break; evaluated to true on 64bit for e.g. bclock = 0xffffffff and now = 0 because the unsigned long (now - bclock) of these values results in 0xffffffff00000001 which is definitely larger than the loops value. That explains Tvortkos observation: "Because I am seeing udelay(500) (_occasionally_) being short, and that by delaying for some duration between 0us (yep) and 491us." Make those variables explicitely u32 again, so this works for both 32 and 64 bit. Reported-by: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/x86/kernel/pcspeaker.c')
0 files changed, 0 insertions, 0 deletions