mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-19 04:14:49 +08:00
x86: provide delay loop for x86_64.
This is for consistency with i386. We call use_tsc_delay() at tsc initialization for x86_64, so we'll be always using it. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
ff1b15b646
commit
0a4d8a472f
@ -513,6 +513,7 @@ void __init tsc_init(void)
|
|||||||
*/
|
*/
|
||||||
for_each_possible_cpu(cpu)
|
for_each_possible_cpu(cpu)
|
||||||
set_cyc2ns_scale(cpu_khz, cpu);
|
set_cyc2ns_scale(cpu_khz, cpu);
|
||||||
|
use_tsc_delay();
|
||||||
|
|
||||||
if (tsc_disabled > 0)
|
if (tsc_disabled > 0)
|
||||||
return;
|
return;
|
||||||
|
@ -22,13 +22,28 @@
|
|||||||
#include <asm/smp.h>
|
#include <asm/smp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int __devinit read_current_timer(unsigned long *timer_value)
|
/* simple loop based delay: */
|
||||||
|
static void delay_loop(unsigned long loops)
|
||||||
{
|
{
|
||||||
rdtscll(*timer_value);
|
asm volatile(
|
||||||
return 0;
|
" test %0,%0 \n"
|
||||||
|
" jz 3f \n"
|
||||||
|
" jmp 1f \n"
|
||||||
|
|
||||||
|
".align 16 \n"
|
||||||
|
"1: jmp 2f \n"
|
||||||
|
|
||||||
|
".align 16 \n"
|
||||||
|
"2: dec %0 \n"
|
||||||
|
" jnz 2b \n"
|
||||||
|
"3: dec %0 \n"
|
||||||
|
|
||||||
|
: /* we don't need output */
|
||||||
|
:"a" (loops)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __delay(unsigned long loops)
|
static void delay_tsc(unsigned long loops)
|
||||||
{
|
{
|
||||||
unsigned bclock, now;
|
unsigned bclock, now;
|
||||||
int cpu;
|
int cpu;
|
||||||
@ -63,6 +78,27 @@ void __delay(unsigned long loops)
|
|||||||
}
|
}
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void (*delay_fn)(unsigned long) = delay_loop;
|
||||||
|
|
||||||
|
void use_tsc_delay(void)
|
||||||
|
{
|
||||||
|
delay_fn = delay_tsc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __devinit read_current_timer(unsigned long *timer_value)
|
||||||
|
{
|
||||||
|
if (delay_fn == delay_tsc) {
|
||||||
|
rdtscll(*timer_value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __delay(unsigned long loops)
|
||||||
|
{
|
||||||
|
delay_fn(loops);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(__delay);
|
EXPORT_SYMBOL(__delay);
|
||||||
|
|
||||||
inline void __const_udelay(unsigned long xloops)
|
inline void __const_udelay(unsigned long xloops)
|
||||||
|
Loading…
Reference in New Issue
Block a user