PERFORCE change 92390 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat Feb 25 12:47:50 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=92390
Change 92390 by marcel at 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);
More information about the p4-projects
mailing list