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 Move queueing of rx xfers to attach.
details: https://anonhg.NetBSD.org/src-all/rev/fba09f3b579e
branches: trunk
changeset: 374877:fba09f3b579e
user: Nathanial Sloss <nat%netbsd.org@localhost>
date: Sun May 03 22:40:36 2020 +1000
description:
Move queueing of rx xfers to attach.
Move abort pipes to detach.
diffstat:
sys/dev/usb/if_urtwn.c | 68 +++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 34 deletions(-)
diffs (135 lines):
diff -r cd7f6065e670 -r fba09f3b579e sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Sun May 03 21:46:42 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c Sun May 03 22:40:36 2020 +1000
@@ -388,6 +388,7 @@ urtwn_attach(device_t parent, device_t s
struct urtwn_softc *sc = device_private(self);
struct ieee80211com *ic = &sc->sc_ic;
struct usb_attach_arg *uaa = aux;
+ struct urtwn_rx_data *data;
char *devinfop;
const struct urtwn_dev *dev;
usb_device_request_t req;
@@ -618,6 +619,21 @@ urtwn_attach(device_t parent, device_t s
goto fail;
}
+ /* Queue Rx xfers. */
+ for (size_t j = 0; j < sc->rx_npipe; j++) {
+ mutex_enter(&sc->sc_rx_mtx);
+ TAILQ_FOREACH(data, &sc->rx_free_list[j], next) {
+ usbd_setup_xfer(data->xfer, data, data->buf,
+ URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
+ urtwn_rxeof);
+ error = usbd_transfer(data->xfer);
+ if (__predict_false(error != USBD_NORMAL_COMPLETION &&
+ error != USBD_IN_PROGRESS))
+ goto fail;
+ }
+ mutex_exit(&sc->sc_rx_mtx);
+ }
+
return;
fail:
@@ -632,6 +648,7 @@ urtwn_detach(device_t self, int flags)
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
struct ifnet *ifp = vap->iv_ifp;
+ size_t i;
int s;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -659,6 +676,22 @@ urtwn_detach(device_t self, int flags)
urtwn_close_pipes(sc);
}
+ 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);
+
/* Free Tx/Rx buffers. */
urtwn_free_tx_list(sc);
urtwn_free_rx_list(sc);
@@ -901,8 +934,8 @@ urtwn_alloc_tx_list(struct urtwn_softc *
return 0;
fail:
+ mutex_exit(&sc->sc_tx_mtx);
urtwn_free_tx_list(sc);
- mutex_exit(&sc->sc_tx_mtx);
return error;
}
@@ -5528,7 +5561,6 @@ urtwn_init(struct ifnet *ifp)
struct ieee80211com *ic = vap->iv_ic;
struct ifmediareq imr;
struct urtwn_softc *sc = ic->ic_softc;
- struct urtwn_rx_data *data;
uint32_t reg;
int error;
@@ -5744,21 +5776,6 @@ urtwn_init(struct ifnet *ifp)
/* Set default channel. */
urtwn_set_chan(sc, ic->ic_curchan, IEEE80211_HTINFO_2NDCHAN_NONE);
- /* Queue Rx xfers. */
- for (size_t j = 0; j < sc->rx_npipe; j++) {
- mutex_enter(&sc->sc_rx_mtx);
- TAILQ_FOREACH(data, &sc->rx_free_list[j], next) {
- usbd_setup_xfer(data->xfer, data, data->buf,
- URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
- urtwn_rxeof);
- error = usbd_transfer(data->xfer);
- if (__predict_false(error != USBD_NORMAL_COMPLETION &&
- error != USBD_IN_PROGRESS))
- goto fail;
- }
- mutex_exit(&sc->sc_rx_mtx);
- }
-
/* We're ready to go. */
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
@@ -5798,7 +5815,6 @@ urtwn_stop(struct ifnet *ifp, int disabl
struct ieee80211vap *vap = ifp->if_softc;
struct ieee80211com *ic = vap->iv_ic;
struct urtwn_softc *sc = ic->ic_softc;
- size_t i;
int s;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -5815,22 +5831,6 @@ urtwn_stop(struct ifnet *ifp, int disabl
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)
urtwn_chip_stop(sc);
Home |
Main Index |
Thread Index |
Old Index