x86: integrate delay functions.
delay_32.c, delay_64.c are now equal, and are integrated into delay.c. 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
7e58818d32
commit
f0fbf0abc0
3 changed files with 6 additions and 135 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
obj-$(CONFIG_SMP) := msr-on-cpu.o
|
||||
|
||||
lib-y := delay_$(BITS).o
|
||||
lib-y := delay.o
|
||||
lib-y += usercopy_$(BITS).o getuser_$(BITS).o putuser_$(BITS).o
|
||||
lib-y += memcpy_$(BITS).o
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
/*
|
||||
* Precise Delay Loops for x86-64
|
||||
* Precise Delay Loops for i386
|
||||
*
|
||||
* Copyright (C) 1993 Linus Torvalds
|
||||
* Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
||||
* Copyright (C) 2008 Jiri Hladky <hladky _dot_ jiri _at_ gmail _dot_ com>
|
||||
*
|
||||
* The __delay function must _NOT_ be inlined as its execution time
|
||||
* depends wildly on alignment on many x86 processors.
|
||||
* depends wildly on alignment on many x86 processors. The additional
|
||||
* jump magic is needed to get the timing stable on all the CPU's
|
||||
* we have to worry about.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
|
@ -15,11 +18,12 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/processor.h>
|
||||
#include <asm/delay.h>
|
||||
#include <asm/msr.h>
|
||||
#include <asm/timer.h>
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
#include <asm/smp.h>
|
||||
# include <asm/smp.h>
|
||||
#endif
|
||||
|
||||
/* simple loop based delay: */
|
||||
|
|
@ -43,9 +47,10 @@ static void delay_loop(unsigned long loops)
|
|||
);
|
||||
}
|
||||
|
||||
/* TSC based delay: */
|
||||
static void delay_tsc(unsigned long loops)
|
||||
{
|
||||
unsigned bclock, now;
|
||||
unsigned long bclock, now;
|
||||
int cpu;
|
||||
|
||||
preempt_disable();
|
||||
|
|
@ -79,6 +84,10 @@ static void delay_tsc(unsigned long loops)
|
|||
preempt_enable();
|
||||
}
|
||||
|
||||
/*
|
||||
* Since we calibrate only once at boot, this
|
||||
* function should be set once at boot and not changed
|
||||
*/
|
||||
static void (*delay_fn)(unsigned long) = delay_loop;
|
||||
|
||||
void use_tsc_delay(void)
|
||||
|
|
@ -86,10 +95,10 @@ void use_tsc_delay(void)
|
|||
delay_fn = delay_tsc;
|
||||
}
|
||||
|
||||
int __devinit read_current_timer(unsigned long *timer_value)
|
||||
int __devinit read_current_timer(unsigned long *timer_val)
|
||||
{
|
||||
if (delay_fn == delay_tsc) {
|
||||
rdtscll(*timer_value);
|
||||
rdtscll(*timer_val);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -104,25 +113,25 @@ EXPORT_SYMBOL(__delay);
|
|||
inline void __const_udelay(unsigned long xloops)
|
||||
{
|
||||
int d0;
|
||||
|
||||
xloops *= 4;
|
||||
__asm__("mull %%edx"
|
||||
asm("mull %%edx"
|
||||
:"=d" (xloops), "=&a" (d0)
|
||||
:"1" (xloops), "0"
|
||||
(cpu_data(raw_smp_processor_id()).loops_per_jiffy * (HZ/4)));
|
||||
|
||||
__delay(++xloops);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(__const_udelay);
|
||||
|
||||
void __udelay(unsigned long usecs)
|
||||
{
|
||||
__const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
|
||||
__const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
|
||||
}
|
||||
EXPORT_SYMBOL(__udelay);
|
||||
|
||||
void __ndelay(unsigned long nsecs)
|
||||
{
|
||||
__const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
|
||||
__const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
|
||||
}
|
||||
EXPORT_SYMBOL(__ndelay);
|
||||
Loading…
Reference in a new issue