Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2003-10-07 22:07:34 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-10-07 22:07:34 -0700
commit43fc52f39db31cb0daa901d89b852a8bfcd19d35 (patch)
tree85993eaf33617ab5f1084ebb1d7e2e8d92a45723
parent639a2b25950f0691f9ba3fcac7622c904f87ab3d (diff)
[PATCH] monotonic seqlock for HPET timer
Replace read/write lock used for HPET timer monotonic_lock with seqlock. Similar to locking used on xtime and monotonic_lock in timers/timer_tsc.c
-rw-r--r--arch/i386/kernel/timers/timer_hpet.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
index f14a6fc7dd06..3beb26646dea 100644
--- a/arch/i386/kernel/timers/timer_hpet.c
+++ b/arch/i386/kernel/timers/timer_hpet.c
@@ -24,7 +24,7 @@ static unsigned long hpet_last; /* hpet counter value at last tick*/
static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */
static unsigned long last_tsc_high; /* msb 32 bits of Time Stamp Counter */
static unsigned long long monotonic_base;
-static rwlock_t monotonic_lock = RW_LOCK_UNLOCKED;
+static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED;
/* convert from cycles(64bits) => nanoseconds (64bits)
* basic equation:
@@ -57,12 +57,14 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
static unsigned long long monotonic_clock_hpet(void)
{
unsigned long long last_offset, this_offset, base;
+ unsigned seq;
/* atomically read monotonic base & last_offset */
- read_lock_irq(&monotonic_lock);
- last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
- base = monotonic_base;
- read_unlock_irq(&monotonic_lock);
+ do {
+ seq = read_seqbegin(&monotonic_lock);
+ last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
+ base = monotonic_base;
+ } while (read_seqretry(&monotonic_lock, seq));
/* Read the Time Stamp Counter */
rdtscll(this_offset);
@@ -99,7 +101,7 @@ static void mark_offset_hpet(void)
unsigned long long this_offset, last_offset;
unsigned long offset;
- write_lock(&monotonic_lock);
+ write_seqlock(&monotonic_lock);
last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
rdtsc(last_tsc_low, last_tsc_high);
@@ -113,7 +115,7 @@ static void mark_offset_hpet(void)
/* update the monotonic base value */
this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
monotonic_base += cycles_2_ns(this_offset - last_offset);
- write_unlock(&monotonic_lock);
+ write_sequnlock(&monotonic_lock);
}
void delay_hpet(unsigned long loops)