Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45462
b: refs/heads/master
c: ed5316d
h: refs/heads/master
v: v3
  • Loading branch information
Jack Steiner authored and Andi Kleen committed Jan 11, 2007
1 parent 435e014 commit 4e20432
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d24a81e84cee7cbf4656d178842838ac5ab23a4
refs/heads/master: ed5316d4457b35c7b4942af028d6b878174264f7
25 changes: 21 additions & 4 deletions trunk/arch/x86_64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,25 @@ core_initcall(cpufreq_tsc);
*/

#define TICK_COUNT 100000000
#define TICK_MIN 5000

/*
* Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
* occurs between the reads of the hpet & TSC.
*/
static void __init read_hpet_tsc(int *hpet, int *tsc)
{
int tsc1, tsc2, hpet1;

do {
tsc1 = get_cycles_sync();
hpet1 = hpet_readl(HPET_COUNTER);
tsc2 = get_cycles_sync();
} while (tsc2 - tsc1 > TICK_MIN);
*hpet = hpet1;
*tsc = tsc2;
}


static unsigned int __init hpet_calibrate_tsc(void)
{
Expand All @@ -666,13 +685,11 @@ static unsigned int __init hpet_calibrate_tsc(void)
local_irq_save(flags);
local_irq_disable();

hpet_start = hpet_readl(HPET_COUNTER);
rdtscl(tsc_start);
read_hpet_tsc(&hpet_start, &tsc_start);

do {
local_irq_disable();
hpet_now = hpet_readl(HPET_COUNTER);
tsc_now = get_cycles_sync();
read_hpet_tsc(&hpet_now, &tsc_now);
local_irq_restore(flags);
} while ((tsc_now - tsc_start) < TICK_COUNT &&
(hpet_now - hpet_start) < TICK_COUNT);
Expand Down

0 comments on commit 4e20432

Please sign in to comment.