From owner-svn-src-all@FreeBSD.ORG Thu Apr 12 18:46:48 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8A261065672; Thu, 12 Apr 2012 18:46:48 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 998138FC1D; Thu, 12 Apr 2012 18:46:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3CIkmle041387; Thu, 12 Apr 2012 18:46:48 GMT (envelope-from grehan@svn.freebsd.org) Received: (from grehan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3CIkm15041383; Thu, 12 Apr 2012 18:46:48 GMT (envelope-from grehan@svn.freebsd.org) Message-Id: <201204121846.q3CIkm15041383@svn.freebsd.org> From: Peter Grehan Date: Thu, 12 Apr 2012 18:46:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234194 - head/sys/dev/uart X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2012 18:46:48 -0000 Author: grehan Date: Thu Apr 12 18:46:48 2012 New Revision: 234194 URL: http://svn.freebsd.org/changeset/base/234194 Log: Complete polled-mode operation by using a callout if the device will be used in polled-mode. The callout invokes uart_intr, which rearms the timeout. Implemented for bhyve, but generically useful for e.g. embedded bringup when the interrupt controller hasn't been setup, or if it's not deemed worthy to wire an interrupt line from a serial port. Submitted by: neel Reviewed by: marcel Obtained from: NetApp MFC after: 3 weeks Modified: head/sys/dev/uart/uart_bus.h head/sys/dev/uart/uart_core.c head/sys/dev/uart/uart_if.m Modified: head/sys/dev/uart/uart_bus.h ============================================================================== --- head/sys/dev/uart/uart_bus.h Thu Apr 12 18:06:30 2012 (r234193) +++ head/sys/dev/uart/uart_bus.h Thu Apr 12 18:46:48 2012 (r234194) @@ -87,6 +87,7 @@ struct uart_softc { struct resource *sc_ires; /* Interrupt resource. */ void *sc_icookie; int sc_irid; + struct callout sc_timer; int sc_callout:1; /* This UART is opened for callout. */ int sc_fastintr:1; /* This UART uses fast interrupts. */ Modified: head/sys/dev/uart/uart_core.c ============================================================================== --- head/sys/dev/uart/uart_core.c Thu Apr 12 18:06:30 2012 (r234193) +++ head/sys/dev/uart/uart_core.c Thu Apr 12 18:46:48 2012 (r234194) @@ -58,6 +58,12 @@ SLIST_HEAD(uart_devinfo_list, uart_devin static MALLOC_DEFINE(M_UART, "UART", "UART driver"); +#ifndef UART_POLL_FREQ +#define UART_POLL_FREQ 50 +#endif +static int uart_poll_freq = UART_POLL_FREQ; +TUNABLE_INT("debug.uart_poll_freq", &uart_poll_freq); + void uart_add_sysdev(struct uart_devinfo *di) { @@ -257,6 +263,12 @@ uart_intr(void *arg) if (ipend & SER_INT_TXIDLE) uart_intr_txidle(sc); } + + if (sc->sc_polled) { + callout_reset(&sc->sc_timer, hz / uart_poll_freq, + (timeout_t *)uart_intr, sc); + } + return((flag)?FILTER_HANDLED:FILTER_STRAY); } @@ -440,8 +452,9 @@ uart_bus_attach(device_t dev) } } if (sc->sc_ires == NULL) { - /* XXX no interrupt resource. Force polled mode. */ + /* No interrupt resource. Force polled mode. */ sc->sc_polled = 1; + callout_init(&sc->sc_timer, 1); } sc->sc_rxbufsz = 384; Modified: head/sys/dev/uart/uart_if.m ============================================================================== --- head/sys/dev/uart/uart_if.m Thu Apr 12 18:06:30 2012 (r234193) +++ head/sys/dev/uart/uart_if.m Thu Apr 12 18:46:48 2012 (r234194) @@ -26,6 +26,7 @@ # $FreeBSD$ #include +#include #include #include #include