From: Clemens Ladisch Reads from an HPET register require a round trip to the south bridge and are almost as slow as PCI reads. By caching the last value we've written to the comparator register, we can eliminate all HPET reads from the fast path in the emulated RTC interrupt handler. Signed-off-by: Clemens Ladisch Acked-by: Venkatesh Pallipadi Signed-off-by: Andrew Morton --- arch/i386/kernel/time_hpet.c | 5 ++++- arch/x86_64/kernel/time.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff -puN arch/i386/kernel/time_hpet.c~hpet-rtc-cache-the-comparator-register arch/i386/kernel/time_hpet.c --- devel/arch/i386/kernel/time_hpet.c~hpet-rtc-cache-the-comparator-register 2005-10-11 00:34:50.000000000 -0700 +++ devel-akpm/arch/i386/kernel/time_hpet.c 2005-10-11 00:34:50.000000000 -0700 @@ -275,6 +275,7 @@ static unsigned long PIE_freq = DEFAULT_ static unsigned long PIE_count; static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */ +static unsigned int hpet_t1_cmp; /* cached comparator register */ /* * Timer 1 for RTC, we do not use periodic interrupt feature, @@ -306,6 +307,7 @@ int hpet_rtc_timer_init(void) cnt = hpet_readl(HPET_COUNTER); cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq); hpet_writel(cnt, HPET_T1_CMP); + hpet_t1_cmp = cnt; local_irq_restore(flags); cfg = hpet_readl(HPET_T1_CFG); @@ -333,9 +335,10 @@ static void hpet_rtc_timer_reinit(void) hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ; /* It is more accurate to use the comparator value than current count.*/ - cnt = hpet_readl(HPET_T1_CMP); + cnt = hpet_t1_cmp; cnt += hpet_tick*HZ/hpet_rtc_int_freq; hpet_writel(cnt, HPET_T1_CMP); + hpet_t1_cmp = cnt; } /* diff -puN arch/x86_64/kernel/time.c~hpet-rtc-cache-the-comparator-register arch/x86_64/kernel/time.c --- devel/arch/x86_64/kernel/time.c~hpet-rtc-cache-the-comparator-register 2005-10-11 00:34:50.000000000 -0700 +++ devel-akpm/arch/x86_64/kernel/time.c 2005-10-11 00:34:50.000000000 -0700 @@ -1462,6 +1462,7 @@ static unsigned long PIE_freq = DEFAULT_ static unsigned long PIE_count; static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */ +static unsigned int hpet_t1_cmp; /* cached comparator register */ int is_hpet_enabled(void) { @@ -1498,6 +1499,7 @@ int hpet_rtc_timer_init(void) cnt = hpet_readl(HPET_COUNTER); cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq); hpet_writel(cnt, HPET_T1_CMP); + hpet_t1_cmp = cnt; local_irq_restore(flags); cfg = hpet_readl(HPET_T1_CFG); @@ -1525,9 +1527,10 @@ static void hpet_rtc_timer_reinit(void) hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ; /* It is more accurate to use the comparator value than current count.*/ - cnt = hpet_readl(HPET_T1_CMP); + cnt = hpet_t1_cmp; cnt += hpet_tick*HZ/hpet_rtc_int_freq; hpet_writel(cnt, HPET_T1_CMP); + hpet_t1_cmp = cnt; } /* _