From owner-svn-src-projects@FreeBSD.ORG Sun Dec 16 14:09:19 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B24FB2EF; Sun, 16 Dec 2012 14:09:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7F3048FC20; Sun, 16 Dec 2012 14:09:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBGE9JXi089408; Sun, 16 Dec 2012 14:09:19 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBGE9Jn9089407; Sun, 16 Dec 2012 14:09:19 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201212161409.qBGE9Jn9089407@svn.freebsd.org> From: Alexander Motin Date: Sun, 16 Dec 2012 14:09:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r244290 - projects/calloutng/sys/x86/isa X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Dec 2012 14:09:19 -0000 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