From owner-svn-src-all@freebsd.org Sat Aug 8 20:11:49 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 5B4169B60CB; Sat, 8 Aug 2015 20:11:49 +0000 (UTC) (envelope-from ian@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 39731192; Sat, 8 Aug 2015 20:11:49 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t78KBnRd030404; Sat, 8 Aug 2015 20:11:49 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t78KBmdH030401; Sat, 8 Aug 2015 20:11:48 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201508082011.t78KBmdH030401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 8 Aug 2015 20:11:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286469 - 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: Sat, 08 Aug 2015 20:11:49 -0000 Author: ian Date: Sat Aug 8 20:11:47 2015 New Revision: 286469 URL: https://svnweb.freebsd.org/changeset/base/286469 Log: Provide the tty-layer mutex when initializing the pps api. This allows time_pps_fetch() to be used in blocking mode. Also, don't init the pps api for system devices (consoles) that provide a custom attach routine. The device may actually be a keyboard or other non- tty device. If it wants to do pps processing (unlikely) it must handle everything for itself. (In reality, only a sun keyboard uses a custom attach routine, and it doesn't make a good pps device.) Modified: head/sys/dev/uart/uart_bus.h head/sys/dev/uart/uart_core.c head/sys/dev/uart/uart_tty.c Modified: head/sys/dev/uart/uart_bus.h ============================================================================== --- head/sys/dev/uart/uart_bus.h Sat Aug 8 20:08:09 2015 (r286468) +++ head/sys/dev/uart/uart_bus.h Sat Aug 8 20:11:47 2015 (r286469) @@ -150,6 +150,7 @@ void uart_sched_softih(struct uart_softc int uart_tty_attach(struct uart_softc *); int uart_tty_detach(struct uart_softc *); +struct mtx *uart_tty_getlock(struct uart_softc *); void uart_tty_intr(void *arg); /* Modified: head/sys/dev/uart/uart_core.c ============================================================================== --- head/sys/dev/uart/uart_core.c Sat Aug 8 20:08:09 2015 (r286468) +++ head/sys/dev/uart/uart_core.c Sat Aug 8 20:11:47 2015 (r286469) @@ -511,9 +511,6 @@ uart_bus_attach(device_t dev) sc->sc_sysdev->stopbits); } - sc->sc_pps.ppscap = PPS_CAPTUREBOTH; - pps_init(&sc->sc_pps); - sc->sc_leaving = 0; sc->sc_testintr = 1; filt = uart_intr(sc); @@ -568,10 +565,17 @@ uart_bus_attach(device_t dev) printf("\n"); } - error = (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) - ? (*sc->sc_sysdev->attach)(sc) : uart_tty_attach(sc); - if (error) - goto fail; + if (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) { + if ((error = sc->sc_sysdev->attach(sc)) != 0) + goto fail; + } else { + if ((error = uart_tty_attach(sc)) != 0) + goto fail; + sc->sc_pps.ppscap = PPS_CAPTUREBOTH; + sc->sc_pps.driver_mtx = uart_tty_getlock(sc); + sc->sc_pps.driver_abi = PPS_ABI_VERSION; + pps_init_abi(&sc->sc_pps); + } if (sc->sc_sysdev != NULL) sc->sc_sysdev->hwmtx = sc->sc_hwmtx; Modified: head/sys/dev/uart/uart_tty.c ============================================================================== --- head/sys/dev/uart/uart_tty.c Sat Aug 8 20:08:09 2015 (r286468) +++ head/sys/dev/uart/uart_tty.c Sat Aug 8 20:11:47 2015 (r286469) @@ -404,3 +404,13 @@ uart_tty_detach(struct uart_softc *sc) return (0); } + +struct mtx * +uart_tty_getlock(struct uart_softc *sc) +{ + + if (sc->sc_u.u_tty.tp != NULL) + return (tty_getlock(sc->sc_u.u_tty.tp)); + else + return (NULL); +}