linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, Bob Picco <bob.picco@hp.com>,
	Clemens Ladisch <clemens@ladisch.de>
Subject: [PATCH 7/7] HPET-RTC: cache the comparator register
Date: Wed, 28 Sep 2005 09:12:37 +0200 (MEST)	[thread overview]
Message-ID: <20050928071236.23025.15941.balrog@turing> (raw)
In-Reply-To: <20050928071155.23025.43523.balrog@turing>

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 <clemens@ladisch.de>

Index: linux-2.6.13/arch/i386/kernel/time_hpet.c
===================================================================
--- linux-2.6.13.orig/arch/i386/kernel/time_hpet.c	2005-09-27 21:59:13.000000000 +0200
+++ linux-2.6.13/arch/i386/kernel/time_hpet.c	2005-09-27 22:01:29.000000000 +0200
@@ -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;
 }
 
 /*
Index: linux-2.6.13/arch/x86_64/kernel/time.c
===================================================================
--- linux-2.6.13.orig/arch/x86_64/kernel/time.c	2005-09-27 21:59:13.000000000 +0200
+++ linux-2.6.13/arch/x86_64/kernel/time.c	2005-09-27 22:01:29.000000000 +0200
@@ -1100,6 +1100,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)
 {
@@ -1136,6 +1137,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);
@@ -1163,9 +1165,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;
 }
 
 /*

  parent reply	other threads:[~2005-09-28  7:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-28  7:11 [PATCH 0/7] HPET fixes and enhancements Clemens Ladisch
2005-09-28  7:12 ` [PATCH 1/7] HPET: remove unused variable Clemens Ladisch
2005-09-28  7:12 ` [PATCH 2/7] HPET: remove superfluous register reads Clemens Ladisch
2005-09-28  7:12 ` [PATCH 3/7] HPET: allow non-power-of-two frequencies Clemens Ladisch
2005-09-28  7:12 ` [PATCH 4/7] HPET: allow shared interrupts Clemens Ladisch
2005-09-28  7:12 ` [PATCH 5/7] HPET-RTC: disable interrupt when no longer needed Clemens Ladisch
2005-09-28 13:03   ` Venkatesh Pallipadi
2005-09-29  6:30     ` Clemens Ladisch
2005-09-28  7:12 ` [PATCH 6/7] HPET-RTC: fix timer config register accesses Clemens Ladisch
2005-09-28 13:06   ` Venkatesh Pallipadi
2005-09-28  7:12 ` Clemens Ladisch [this message]
2005-09-28 15:44 ` [PATCH 0/7] HPET fixes and enhancements Bob Picco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050928071236.23025.15941.balrog@turing \
    --to=clemens@ladisch.de \
    --cc=akpm@osdl.org \
    --cc=bob.picco@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).