Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/usb Wrap up abort pipe and rxeof in rx/tx mute...



details:   https://anonhg.NetBSD.org/src-all/rev/00c70513fd6a
branches:  trunk
changeset: 362084:00c70513fd6a
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sun May 03 19:16:20 2020 +1000

description:
Wrap up abort pipe and rxeof in rx/tx mutexes.

diffstat:

 sys/dev/usb/if_urtwn.c |  9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r 1d020d99c348 -r 00c70513fd6a sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sun May 03 12:39:32 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c    Sun May 03 19:16:20 2020 +1000
@@ -2973,11 +2973,13 @@
        DPRINTFN(DBG_FN|DBG_RX, ("%s: %s: status=%d\n",
            device_xname(sc->sc_dev), __func__, status));
 
+       mutex_enter(&sc->sc_rx_mtx);
        if (__predict_false(status != USBD_NORMAL_COMPLETION)) {
                if (status == USBD_STALLED)
                        usbd_clear_endpoint_stall_async(sc->rx_pipe[pidx]);
                else if (status != USBD_CANCELLED)
                        goto resubmit;
+               mutex_exit(&sc->sc_rx_mtx);
                return;
        }
        usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
@@ -3041,6 +3043,7 @@
        usbd_setup_xfer(xfer, data, data->buf, URTWN_RXBUFSZ,
            USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urtwn_rxeof);
        (void)usbd_transfer(xfer);
+       mutex_exit(&sc->sc_rx_mtx);
 }
 
 static void
@@ -5810,17 +5813,21 @@
        callout_stop(&sc->sc_scan_to);
        callout_stop(&sc->sc_calib_to);
 
+       mutex_enter(&sc->sc_tx_mtx);
        /* Abort Tx. */
        for (i = 0; i < sc->tx_npipe; i++) {
                if (sc->tx_pipe[i] != NULL)
                        usbd_abort_pipe(sc->tx_pipe[i]);
        }
-
+       mutex_exit(&sc->sc_tx_mtx);
+
+       mutex_enter(&sc->sc_rx_mtx);
        /* Stop Rx pipe. */
        for (i = 0; i < sc->rx_npipe; i++) {
                if (sc->rx_pipe[i] != NULL)
                        usbd_abort_pipe(sc->rx_pipe[i]);
        }
+       mutex_exit(&sc->sc_rx_mtx);
 
        sc->sc_running = false;
        if (disable)



Home | Main Index | Thread Index | Old Index