svn commit: r244290 - projects/calloutng/sys/x86/isa
Alexander Motin
mav at FreeBSD.org
Sun Dec 16 14:09:19 UTC 2012
Author: mav
Date: Sun Dec 16 14:09:18 2012
New Revision: 244290
URL: http://svnweb.freebsd.org/changeset/base/244290
Log:
Continue fun of r244287: do not write i8254 mode register if the same value
was already written earlier. This reduces usleep(1) latency with i8254
eventtimer from 22 to 19.5us.
Hinted by: bde
Modified:
projects/calloutng/sys/x86/isa/clock.c
Modified: projects/calloutng/sys/x86/isa/clock.c
==============================================================================
--- projects/calloutng/sys/x86/isa/clock.c Sun Dec 16 14:01:56 2012 (r244289)
+++ projects/calloutng/sys/x86/isa/clock.c Sun Dec 16 14:09:18 2012 (r244290)
@@ -125,6 +125,7 @@ struct attimer_softc {
static struct attimer_softc *attimer_sc = NULL;
static int timer0_period = -2;
+static int timer0_mode = 0xffff;
static int timer0_last = 0xffff;
/* Values for timerX_state: */
@@ -405,7 +406,7 @@ DELAY(int n)
static void
set_i8254_freq(int mode, uint32_t period)
{
- int new_count;
+ int new_count, new_mode;
mtx_lock_spin(&clock_lock);
if (mode == MODE_STOP) {
@@ -424,26 +425,33 @@ set_i8254_freq(int mode, uint32_t period
timer0_period = (mode == MODE_PERIODIC) ? new_count : -1;
switch (mode) {
case MODE_STOP:
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_INTTC | TIMER_16BIT);
+ new_mode = TIMER_SEL0 | TIMER_INTTC | TIMER_16BIT;
+ outb(TIMER_MODE, new_mode);
outb(TIMER_CNTR0, 0);
outb(TIMER_CNTR0, 0);
break;
case MODE_PERIODIC:
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
+ new_mode = TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT;
+ outb(TIMER_MODE, new_mode);
outb(TIMER_CNTR0, new_count & 0xff);
outb(TIMER_CNTR0, new_count >> 8);
break;
case MODE_ONESHOT:
if (new_count < 256 && timer0_last < 256) {
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_INTTC | TIMER_LSB);
+ new_mode = TIMER_SEL0 | TIMER_INTTC | TIMER_LSB;
+ if (new_mode != timer0_mode)
+ outb(TIMER_MODE, new_mode);
outb(TIMER_CNTR0, new_count & 0xff);
break;
}
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_INTTC | TIMER_16BIT);
+ new_mode = TIMER_SEL0 | TIMER_INTTC | TIMER_16BIT;
+ if (new_mode != timer0_mode)
+ outb(TIMER_MODE, new_mode);
outb(TIMER_CNTR0, new_count & 0xff);
outb(TIMER_CNTR0, new_count >> 8);
break;
}
+ timer0_mode = new_mode;
timer0_last = new_count;
out:
mtx_unlock_spin(&clock_lock);
@@ -454,6 +462,8 @@ i8254_restore(void)
{
timer0_period = -2;
+ timer0_mode = 0xffff;
+ timer0_last = 0xffff;
if (attimer_sc != NULL)
set_i8254_freq(attimer_sc->mode, attimer_sc->period);
else
More information about the svn-src-projects
mailing list