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 Alloc and queue xfers on attach / free on ...



details:   https://anonhg.NetBSD.org/src-all/rev/6a5425404c61
branches:  trunk
changeset: 947629:6a5425404c61
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sun May 03 07:12:57 2020 +1000

description:
Alloc and queue xfers on attach / free on detach.

diffstat:

 sys/dev/usb/if_urtwn.c |  68 +++++++++++++++++++++++++------------------------
 1 files changed, 35 insertions(+), 33 deletions(-)

diffs (120 lines):

diff -r 391f55c3139b -r 6a5425404c61 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sun May 03 07:04:28 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c    Sun May 03 07:12:57 2020 +1000
@@ -386,6 +386,7 @@
        struct usb_attach_arg *uaa = aux;
        char *devinfop;
        const struct urtwn_dev *dev;
+       struct urtwn_rx_data *data;
        usb_device_request_t req;
        // NNN loop below size_t i;
        int error;
@@ -599,6 +600,35 @@
                goto fail;
        }
        
+       /* Allocate Tx/Rx buffers. */
+       error = urtwn_alloc_rx_list(sc);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev,
+                   "could not allocate Rx buffers\n");
+               goto fail;
+       }
+
+       error = urtwn_alloc_tx_list(sc);
+       if (error != 0) {
+               aprint_error_dev(sc->sc_dev,
+                   "could not allocate Tx buffers\n");
+               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:
@@ -640,6 +670,10 @@
                urtwn_close_pipes(sc);
        }
 
+       /* Free Tx/Rx buffers. */
+       urtwn_free_tx_list(sc);
+       urtwn_free_rx_list(sc);
+
        /* sendq destroy */
        IFQ_PURGE(&sc->sc_sendq);
        IFQ_LOCK_DESTROY(&sc->sc_sendq);
@@ -5480,7 +5514,6 @@
        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;
 
@@ -5500,19 +5533,7 @@
        sc->fwcur = 0;
        mutex_exit(&sc->sc_fwcmd_mtx);
 
-       /* Allocate Tx/Rx buffers. */
-       error = urtwn_alloc_rx_list(sc);
-       if (error != 0) {
-               aprint_error_dev(sc->sc_dev,
-                   "could not allocate Rx buffers\n");
-               goto fail;
-       }
-       error = urtwn_alloc_tx_list(sc);
-       if (error != 0) {
-               aprint_error_dev(sc->sc_dev,
-                   "could not allocate Tx buffers\n");
-               goto fail;
-       }
+
 
        /* Power on adapter. */
        error = urtwn_power_on(sc);
@@ -5708,21 +5729,6 @@
        /* 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;
@@ -5791,10 +5797,6 @@
                        usbd_abort_pipe(sc->rx_pipe[i]);
        }
 
-       /* Free Tx/Rx buffers. */
-       urtwn_free_tx_list(sc);
-       urtwn_free_rx_list(sc);
-
        sc->sc_running = false;
        if (disable)
                urtwn_chip_stop(sc);



Home | Main Index | Thread Index | Old Index