From owner-svn-src-all@freebsd.org Thu Jul 16 04:15:23 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B2969A326F; Thu, 16 Jul 2015 04:15:23 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61E8911C5; Thu, 16 Jul 2015 04:15:23 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6G4FNYg069331; Thu, 16 Jul 2015 04:15:23 GMT (envelope-from neel@FreeBSD.org) Received: (from neel@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6G4FN8r069330; Thu, 16 Jul 2015 04:15:23 GMT (envelope-from neel@FreeBSD.org) Message-Id: <201507160415.t6G4FN8r069330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: neel set sender to neel@FreeBSD.org using -f From: Neel Natu Date: Thu, 16 Jul 2015 04:15:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285619 - head/sys/dev/uart X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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, 16 Jul 2015 04:15:23 -0000 Author: neel Date: Thu Jul 16 04:15:22 2015 New Revision: 285619 URL: https://svnweb.freebsd.org/changeset/base/285619 Log: If uart interrupts are not functioning then schedule the callout to do the polling at device attach time [1]. Add tunables 'debug.uart_force_poll' and 'debug.uart_poll_freq' to control uart polling. Submitted by: Aleksey Kuleshov (rndfax@yandex.ru) [1] Modified: head/sys/dev/uart/uart_core.c Modified: head/sys/dev/uart/uart_core.c ============================================================================== --- head/sys/dev/uart/uart_core.c Thu Jul 16 02:34:22 2015 (r285618) +++ head/sys/dev/uart/uart_core.c Thu Jul 16 04:15:22 2015 (r285619) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -62,7 +63,12 @@ static MALLOC_DEFINE(M_UART, "UART", "UA #define UART_POLL_FREQ 50 #endif static int uart_poll_freq = UART_POLL_FREQ; -TUNABLE_INT("debug.uart_poll_freq", &uart_poll_freq); +SYSCTL_INT(_debug, OID_AUTO, uart_poll_freq, CTLFLAG_RDTUN, &uart_poll_freq, + 0, "UART poll frequency"); + +static int uart_force_poll; +SYSCTL_INT(_debug, OID_AUTO, uart_force_poll, CTLFLAG_RDTUN, &uart_force_poll, + 0, "Force UART polling"); void uart_add_sysdev(struct uart_devinfo *di) @@ -514,7 +520,7 @@ uart_bus_attach(device_t dev) * conditions. We may have broken H/W and polling is probably the * safest thing to do. */ - if (filt != FILTER_SCHEDULE_THREAD) { + if (filt != FILTER_SCHEDULE_THREAD && !uart_force_poll) { sc->sc_irid = 0; sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid, RF_ACTIVE | RF_SHAREABLE); @@ -540,6 +546,8 @@ uart_bus_attach(device_t dev) /* No interrupt resource. Force polled mode. */ sc->sc_polled = 1; callout_init(&sc->sc_timer, 1); + callout_reset(&sc->sc_timer, hz / uart_poll_freq, + (timeout_t *)uart_intr, sc); } if (bootverbose && (sc->sc_fastintr || sc->sc_polled)) {