From owner-svn-src-projects@FreeBSD.ORG Sun Dec 16 11:16:14 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 7D3C2C4A; Sun, 16 Dec 2012 11:16:14 +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 6158C8FC13; Sun, 16 Dec 2012 11:16:14 +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 qBGBGEPM063984; Sun, 16 Dec 2012 11:16:14 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBGBGEwn063983; Sun, 16 Dec 2012 11:16:14 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201212161116.qBGBGEwn063983@svn.freebsd.org> From: Alexander Motin Date: Sun, 16 Dec 2012 11:16:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r244287 - 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 11:16:14 -0000 Author: mav Date: Sun Dec 16 11:16:13 2012 New Revision: 244287 URL: http://svnweb.freebsd.org/changeset/base/244287 Log: Mostly out of fun, teach i8254 eventtimer driver to program only LSB for very short time intervals (<214us). This allows to get less then 22us usleep(1) time from this anscient timer. It is even better then HPET time now, just with much higher CPU usage. 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 10:12:40 2012 (r244286) +++ projects/calloutng/sys/x86/isa/clock.c Sun Dec 16 11:16:13 2012 (r244287) @@ -125,6 +125,7 @@ struct attimer_softc { static struct attimer_softc *attimer_sc = NULL; static int timer0_period = -2; +static int timer0_last = 0xffff; /* Values for timerX_state: */ #define RELEASED 0 @@ -433,11 +434,17 @@ set_i8254_freq(int mode, uint32_t period 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); + outb(TIMER_CNTR0, new_count & 0xff); + break; + } outb(TIMER_MODE, TIMER_SEL0 | TIMER_INTTC | TIMER_16BIT); outb(TIMER_CNTR0, new_count & 0xff); outb(TIMER_CNTR0, new_count >> 8); break; } + timer0_last = new_count; out: mtx_unlock_spin(&clock_lock); }