From owner-p4-projects@FreeBSD.ORG Wed Mar 29 18:28:04 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BE9A116A424; Wed, 29 Mar 2006 18:28:04 +0000 (UTC) X-Original-To: perforce@freebsd.org 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 9B3B416A41F for ; Wed, 29 Mar 2006 18:28:04 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C34243D45 for ; Wed, 29 Mar 2006 18:28:04 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2TIS4AN061337 for ; Wed, 29 Mar 2006 18:28:04 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2TIS4qg061333 for perforce@freebsd.org; Wed, 29 Mar 2006 18:28:04 GMT (envelope-from marcel@freebsd.org) Date: Wed, 29 Mar 2006 18:28:04 GMT Message-Id: <200603291828.k2TIS4qg061333@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 Cc: Subject: PERFORCE change 94252 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 18:28:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=94252 Change 94252 by marcel@marcel_nfs on 2006/03/29 18:27:21 Remove sc_schedih. It was used to limit calling swi_sched(), but introduced a race. Instead call swi_sched() on the 0 to !0 transition of the TTY pending interrupt status. Do this atomically. Affected files ... .. //depot/projects/uart/dev/uart/uart_bus.h#42 edit .. //depot/projects/uart/dev/uart/uart_core.c#49 edit .. //depot/projects/uart/dev/uart/uart_kbd_sun.c#8 edit .. //depot/projects/uart/dev/uart/uart_tty.c#26 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_bus.h#42 (text+ko) ==== @@ -100,7 +100,6 @@ int sc_opened:1; /* This UART is open for business. */ int sc_polled:1; /* This UART has no interrupts. */ int sc_txbusy:1; /* This UART is transmitting. */ - int sc_schedih:1; /* The softih needs (re)scheduling. */ struct uart_devinfo *sc_sysdev; /* System device (or NULL). */ ==== //depot/projects/uart/dev/uart/uart_core.c#49 (text+ko) ==== @@ -71,17 +71,21 @@ } /* - * Schedule a soft interrupt. + * Schedule a soft interrupt. We do this on the 0 to !0 transition + * of the TTY pending interrupt status. */ -static __inline void +static void uart_sched_softih(struct uart_softc *sc, uint32_t ipend) { + uint32_t new, old; + + do { + old = sc->sc_ttypend; + new = old | ipend; + } while (!atomic_cmpset_32(&sc->sc_ttypend, old, new)); - atomic_set_32(&sc->sc_ttypend, ipend); - if (sc->sc_schedih) { + if (old == 0) swi_sched(sc->sc_softih, 0); - sc->sc_schedih = 0; - } } /* ==== //depot/projects/uart/dev/uart/uart_kbd_sun.c#8 (text+ko) ==== @@ -258,7 +258,6 @@ &sunkbd_softc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih); sc->sc_opened = 1; - sc->sc_schedih = 1; KBD_INIT_DONE(&sunkbd_softc.sc_kbd); } @@ -274,7 +273,6 @@ if (sc->sc_uart->sc_leaving) return; - sc->sc_uart->sc_schedih = 1; pend = atomic_readandclear_32(&sc->sc_uart->sc_ttypend); if (!(pend & SER_INT_MASK)) return; ==== //depot/projects/uart/dev/uart/uart_tty.c#26 (text+ko) ==== @@ -306,7 +306,6 @@ if (sc->sc_leaving) return; - sc->sc_schedih = 1; pend = atomic_readandclear_32(&sc->sc_ttypend); if (!(pend & SER_INT_MASK)) return; @@ -380,7 +379,6 @@ swi_add(&tty_intr_event, uart_driver_name, uart_tty_intr, sc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih); - sc->sc_schedih = 1; ttycreate(tp, TS_CALLOUT, "u%r", unit);