Index: ic/pluart.c =================================================================== RCS file: /cvs/src/sys/dev/ic/pluart.c,v diff -u -p -r1.14 pluart.c --- ic/pluart.c 2 Jul 2022 08:50:42 -0000 1.14 +++ ic/pluart.c 8 Jul 2025 00:16:54 -0000 @@ -167,6 +167,8 @@ pluart_attach_common(struct pluart_softc { int fifolen, fr, lcr, maj; + mtx_init(&sc->sc_mtx, IPL_TTY); + if ((sc->sc_hwflags & COM_HW_SBSA) == 0) { if (sc->sc_hwrev == 0) sc->sc_hwrev = UART_PID2_REV(bus_space_read_4(sc->sc_iot, @@ -255,13 +257,7 @@ pluart_intr(void *arg) !ISSET(is, UART_IMSC_TXIM)) return 0; - if (ISSET(is, UART_IMSC_TXIM) && ISSET(tp->t_state, TS_BUSY)) { - CLR(tp->t_state, TS_BUSY | TS_FLUSH); - if (sc->sc_halt > 0) - wakeup(&tp->t_outq); - (*linesw[tp->t_line].l_start)(tp); - } - + mtx_enter(&sc->sc_mtx); p = sc->sc_ibufp; while (!ISSET(bus_space_read_4(iot, ioh, UART_FR), UART_FR_RXFE)) { @@ -292,9 +288,21 @@ pluart_intr(void *arg) /* XXX - msr stuff ? */ } sc->sc_ibufp = p; + mtx_leave(&sc->sc_mtx); softintr_schedule(sc->sc_si); + if (ISSET(is, UART_IMSC_TXIM)) { + KERNEL_LOCK(); + if (ISSET(tp->t_state, TS_BUSY)) { + CLR(tp->t_state, TS_BUSY | TS_FLUSH); + if (sc->sc_halt > 0) + wakeup(&tp->t_outq); + (*linesw[tp->t_line].l_start)(tp); + } + KERNEL_UNLOCK(); + } + return 1; } @@ -493,19 +501,23 @@ pluart_softint(void *arg) u_int16_t *ibufend; int c; int err; - int s; - if (sc == NULL || sc->sc_ibufp == sc->sc_ibuf) + if (sc == NULL) + return; + + mtx_enter(&sc->sc_mtx); + if (sc->sc_ibufp == sc->sc_ibuf) { + mtx_leave(&sc->sc_mtx); return; + } tp = sc->sc_tty; - s = spltty(); ibufp = sc->sc_ibuf; ibufend = sc->sc_ibufp; if (ibufp == ibufend || tp == NULL || !ISSET(tp->t_state, TS_ISOPEN)) { - splx(s); + mtx_leave(&sc->sc_mtx); return; } @@ -524,7 +536,7 @@ pluart_softint(void *arg) } #endif - splx(s); + mtx_leave(&sc->sc_mtx); while (ibufp < ibufend) { c = *ibufp++; Index: ic/pluartvar.h =================================================================== RCS file: /cvs/src/sys/dev/ic/pluartvar.h,v diff -u -p -r1.5 pluartvar.h --- ic/pluartvar.h 27 Jun 2022 13:03:32 -0000 1.5 +++ ic/pluartvar.h 8 Jul 2025 00:16:54 -0000 @@ -58,6 +58,7 @@ struct pluart_softc { u_int16_t sc_ibufs[2][UART_IBUFSIZE]; struct clk *sc_clk; + struct mutex sc_mtx; }; void pluart_attach_common(struct pluart_softc *, int);