From owner-p4-projects@FreeBSD.ORG Sat Feb 25 20:47:50 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 CFF4016A423; Sat, 25 Feb 2006 20:47:49 +0000 (GMT) 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 8D26816A420 for ; Sat, 25 Feb 2006 20:47:49 +0000 (GMT) (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 555F743D46 for ; Sat, 25 Feb 2006 20:47:49 +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 k1PKln6p033001 for ; Sat, 25 Feb 2006 20:47:49 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1PKlm4V032998 for perforce@freebsd.org; Sat, 25 Feb 2006 20:47:48 GMT (envelope-from marcel@freebsd.org) Date: Sat, 25 Feb 2006 20:47:48 GMT Message-Id: <200602252047.k1PKlm4V032998@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 92390 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: Sat, 25 Feb 2006 20:47:50 -0000 http://perforce.freebsd.org/chv.cgi?CH=92390 Change 92390 by marcel@marcel_nfs on 2006/02/25 20:47:01 Slightly change the logic of scheduling the softih. Add a schedih flag to the softc that signals whether to schedule the softc. When scheduled, the flag is cleared. Softih handlers set the flag again to signal that they need to be rescheduled. This avoids that we're rescheduling the softih when not needed. Schedule the softih in the source-specific interrupt handlers. There's no need to schedule the softih at the end of the generic interrupt handler. Affected files ... .. //depot/projects/uart/dev/uart/uart_bus.h#39 edit .. //depot/projects/uart/dev/uart/uart_core.c#45 edit .. //depot/projects/uart/dev/uart/uart_kbd_sun.c#7 edit .. //depot/projects/uart/dev/uart/uart_tty.c#25 edit Differences ... ==== //depot/projects/uart/dev/uart/uart_bus.h#39 (text+ko) ==== @@ -99,6 +99,7 @@ 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#45 (text+ko) ==== @@ -71,6 +71,20 @@ } /* + * Schedule a soft interrupt. + */ +static __inline void +uart_sched_softih(struct uart_softc *sc, uint32_t ipend) +{ + + atomic_set_32(&sc->sc_ttypend, ipend); + if (sc->sc_schedih) { + swi_sched(sc->sc_softih, 0); + sc->sc_schedih = 0; + } +} + +/* * A break condition has been detected. We treat the break condition as * a special case that should not happen during normal operation. When * the break condition is to be passed to higher levels in the form of @@ -91,7 +105,7 @@ } #endif if (sc->sc_opened) - atomic_set_32(&sc->sc_ttypend, SER_INT_BREAK); + uart_sched_softih(sc, SER_INT_BREAK); } /* @@ -118,7 +132,7 @@ UART_RECEIVE(sc); if (uart_rx_put(sc, UART_STAT_OVERRUN)) sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN; - atomic_set_32(&sc->sc_ttypend, SER_INT_RXREADY); + uart_sched_softih(sc, SER_INT_RXREADY); } UART_FLUSH(sc, UART_FLUSH_RECEIVER); } @@ -145,7 +159,7 @@ } #endif if (sc->sc_opened) - atomic_set_32(&sc->sc_ttypend, SER_INT_RXREADY); + uart_sched_softih(sc, SER_INT_RXREADY); else sc->sc_rxput = sc->sc_rxget; /* Ignore received data. */ } @@ -184,8 +198,10 @@ old = sc->sc_ttypend; new = old & ~SER_MASK_STATE; new |= sig & SER_INT_SIGMASK; - new |= SER_INT_SIGCHG; } while (!atomic_cmpset_32(&sc->sc_ttypend, old, new)); + + if (sc->sc_opened) + uart_sched_softih(sc, SER_INT_SIGCHG); } /* @@ -198,7 +214,7 @@ if (sc->sc_txbusy) { sc->sc_txbusy = 0; - atomic_set_32(&sc->sc_ttypend, SER_INT_TXIDLE); + uart_sched_softih(sc, SER_INT_TXIDLE); } } @@ -220,9 +236,6 @@ if (ipend & SER_INT_TXIDLE) uart_intr_txidle(sc); } - - if (sc->sc_opened && sc->sc_ttypend != 0) - swi_sched(sc->sc_softih, 0); } driver_intr_t * ==== //depot/projects/uart/dev/uart/uart_kbd_sun.c#7 (text+ko) ==== @@ -258,6 +258,7 @@ &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); } @@ -273,6 +274,7 @@ 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#25 (text+ko) ==== @@ -306,6 +306,7 @@ if (sc->sc_leaving) return; + sc->sc_schedih = 1; pend = atomic_readandclear_32(&sc->sc_ttypend); if (!(pend & SER_INT_MASK)) return; @@ -379,6 +380,7 @@ 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);