From owner-svn-src-projects@FreeBSD.ORG Fri Dec 14 23:13:07 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 7683E446; Fri, 14 Dec 2012 23:13:07 +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 426EF8FC0C; Fri, 14 Dec 2012 23:13:07 +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 qBEND7ao074247; Fri, 14 Dec 2012 23:13:07 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBEND7kw074246; Fri, 14 Dec 2012 23:13:07 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201212142313.qBEND7kw074246@svn.freebsd.org> From: Alexander Motin Date: Fri, 14 Dec 2012 23:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r244235 - projects/calloutng/sys/dev/dcons 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: Fri, 14 Dec 2012 23:13:07 -0000 Author: mav Date: Fri Dec 14 23:13:06 2012 New Revision: 244235 URL: http://svnweb.freebsd.org/changeset/base/244235 Log: Make dcons input polling adaptive, reducing poll rate to 1Hz after several minutes of inactivty to reduce global interrupt rate. Most of users never used FireWire debugging, so it is not very useful to consume power by it. Modified: projects/calloutng/sys/dev/dcons/dcons_os.c Modified: projects/calloutng/sys/dev/dcons/dcons_os.c ============================================================================== --- projects/calloutng/sys/dev/dcons/dcons_os.c Fri Dec 14 23:07:25 2012 (r244234) +++ projects/calloutng/sys/dev/dcons/dcons_os.c Fri Dec 14 23:13:06 2012 (r244235) @@ -74,6 +74,10 @@ #define DCONS_POLL_HZ 25 #endif +#ifndef DCONS_POLL_IDLE +#define DCONS_POLL_IDLE 256 +#endif + #ifndef DCONS_BUF_SIZE #define DCONS_BUF_SIZE (16*1024) #endif @@ -90,6 +94,7 @@ static char bssbuf[DCONS_BUF_SIZE]; /* b static struct dcons_global dg; struct dcons_global *dcons_conf; static int poll_hz = DCONS_POLL_HZ; +static u_int poll_idle = DCONS_POLL_HZ * DCONS_POLL_IDLE; static struct dcons_softc sc[DCONS_NPORT]; @@ -214,14 +219,17 @@ dcons_timeout(void *v) tp = dc->tty; tty_lock(tp); - while ((c = dcons_os_checkc_nopoll(dc)) != -1) + while ((c = dcons_os_checkc_nopoll(dc)) != -1) { ttydisc_rint(tp, c, 0); + poll_idle = 0; + } ttydisc_rint_done(tp); tty_unlock(tp); } - polltime = hz / poll_hz; - if (polltime < 1) - polltime = 1; + poll_idle++; + polltime = hz; + if (poll_idle <= (poll_hz * DCONS_POLL_IDLE)) + polltime /= poll_hz; callout_reset(&dcons_callout, polltime, dcons_timeout, tp); } @@ -368,8 +376,6 @@ dcons_attach(void) dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB); callout_init(&dcons_callout, CALLOUT_MPSAFE); polltime = hz / poll_hz; - if (polltime < 1) - polltime = 1; callout_reset(&dcons_callout, polltime, dcons_timeout, NULL); return(0); }