From owner-p4-projects@FreeBSD.ORG Sun Jul 27 19:18:37 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2053737B404; Sun, 27 Jul 2003 19:18:37 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 96FA137B401 for ; Sun, 27 Jul 2003 19:18:36 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1870E43F75 for ; Sun, 27 Jul 2003 19:18:36 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h6S2IZ0U050128 for ; Sun, 27 Jul 2003 19:18:35 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h6S2IZBP050125 for perforce@freebsd.org; Sun, 27 Jul 2003 19:18:35 -0700 (PDT) Date: Sun, 27 Jul 2003 19:18:35 -0700 (PDT) Message-Id: <200307280218.h6S2IZBP050125@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 35114 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 02:18:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=35114 Change 35114 by marcel@marcel_nfs on 2003/07/27 19:17:34 o Make sure UART is the console before we compare resources. This avoid false positives. o Set sc_leaving until we're completely attached. This allows spurous interrupts to be short-circuited. o UART_IPEND is expected to return 0 when sc_leaving is set. By still calling UART_IPEND, hardware drivers can do whatever is required to avoid a lockup by clearing the interrupt source. o Improve the ns8250 driver WRT interrupts. Affected files ... .. //depot/projects/uart/dev/uart/uart_core.c#11 edit .. //depot/projects/uart/dev/uart/uart_dev_ns8250.c#11 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_core.c#11 (text+ko) ==== @@ -241,9 +241,6 @@ struct uart_softc *sc = arg; int ipend; - if (sc->sc_leaving) - return; - ipend = UART_IPEND(sc); if (ipend & UART_IPEND_OVERRUN) uart_intr_overrun(sc); @@ -255,6 +252,7 @@ uart_intr_sigchg(sc); if (ipend & UART_IPEND_TXIDLE) uart_intr_txidle(sc); + if (sc->sc_ttypend != 0) swi_sched(sc->sc_softih, 0); } @@ -310,7 +308,8 @@ sc->sc_bas.regshft = regshft; sc->sc_bas.rclk = (rclk == 0) ? sc->sc_class->uc_rclk : rclk; - if (uart_cpu_eqres(&sc->sc_bas, &uart_console.bas)) { + if (uart_console.consdev != NULL && + uart_cpu_eqres(&sc->sc_bas, &uart_console.bas)) { sc->sc_console = 1; /* XXX check if ops matches class. */ } @@ -346,6 +345,13 @@ device_set_softc(dev, sc); /* + * Protect ourselves against interrupts while we're not completely + * finished attaching and initializing. We don't expect interrupts + * until after UART_ATTACH() though. + */ + sc->sc_leaving = 1; + + /* * Re-allocate. We expect that the softc contains the information * collected by uart_bus_probe() intact. */ @@ -441,6 +447,7 @@ swi_add(&tty_ithd, uart_driver_name, uart_tty_intr, sc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih); + sc->sc_leaving = 0; return (0); fail: ==== //depot/projects/uart/dev/uart/uart_dev_ns8250.c#11 (text+ko) ==== @@ -370,14 +370,18 @@ ns8250->lcr = uart_getreg(bas, REG_LCR); ns8250->fcr = FCR_ENABLE | FCR_RX_MEDL; uart_setreg(bas, REG_FCR, ns8250->fcr); - uart_setreg(bas, REG_IER, - IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); uart_barrier(bas); + ns8250_flush(bas, UART_FLUSH_RECEIVER|UART_FLUSH_TRANSMITTER); if (ns8250->mcr & MCR_DTR) ns8250->signals |= UART_SIG_DTR; if (ns8250->mcr & MCR_RTS) ns8250->signals |= UART_SIG_RTS; ns8250_bus_getsig(sc); + + uart_setreg(bas, REG_IER, + IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); + uart_barrier(bas); + return (0); } @@ -433,14 +437,16 @@ ipend |= UART_IPEND_BREAK; if (lsr & LSR_RXRDY) ipend |= UART_IPEND_RXREADY; - if (lsr & LSR_TEMT) + if (lsr & LSR_TEMT) { + (void)uart_getreg(bas, REG_IIR); ipend |= UART_IPEND_TXIDLE; + } sig = ns8250_bus_getsig(sc); if (sig & UART_SIGMASK_DELTA) { ns8250->signals = sig; /* restore delta bits. */ ipend |= UART_IPEND_SIGCHG; } - return (ipend); + return ((sc->sc_leaving) ? 0 : ipend); } static int