Index: sys/dev/usb/aubtfwl.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/aubtfwl.c,v retrieving revision 1.5.10.7 diff -u -p -r1.5.10.7 aubtfwl.c --- sys/dev/usb/aubtfwl.c 29 Sep 2015 11:38:28 -0000 1.5.10.7 +++ sys/dev/usb/aubtfwl.c 4 Oct 2015 08:34:19 -0000 @@ -149,19 +149,13 @@ aubtfwl_firmware_load(device_t self, con goto out_firmware; } - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) { - aprint_error_dev(self, "failed to alloc xfer\n"); - error = 1; + error = usbd_create_xfer(pipe, AR3K_FIRMWARE_CHUNK_SIZE, 0, 0, &xfer); + if (error) { + aprint_verbose_dev(self, "cannot create xfer(%d)\n", + error); goto out_pipe; } - - buf = usbd_alloc_buffer(xfer, AR3K_FIRMWARE_CHUNK_SIZE); - if (buf == NULL) { - aprint_error_dev(self, "failed to alloc buffer\n"); - error = 1; - goto out_xfer; - } + buf = usbd_get_buffer(xfer); error = firmware_read(fwh, fwo, buf, AR3K_FIRMWARE_HEADER_SIZE); if (error != 0) { @@ -204,7 +198,7 @@ aubtfwl_firmware_load(device_t self, con aprint_verbose_dev(self, "firmware load complete\n"); out_xfer: - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); out_pipe: usbd_close_pipe(pipe); out_firmware: Index: sys/dev/usb/auvitek.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/auvitek.c,v retrieving revision 1.9.4.2 diff -u -p -r1.9.4.2 auvitek.c --- sys/dev/usb/auvitek.c 21 Mar 2015 11:33:37 -0000 1.9.4.2 +++ sys/dev/usb/auvitek.c 4 Oct 2015 08:34:19 -0000 @@ -219,24 +219,6 @@ auvitek_attach(device_t parent, device_t return; } - for (i = 0; i < AUVITEK_NBULK_XFERS; i++) { - sc->sc_ab.ab_bx[i].bx_sc = sc; - sc->sc_ab.ab_bx[i].bx_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_ab.ab_bx[i].bx_xfer == NULL) { - aprint_error_dev(self, "couldn't allocate xfer\n"); - sc->sc_dying = 1; - return; - } - sc->sc_ab.ab_bx[i].bx_buffer = usbd_alloc_buffer( - sc->sc_ab.ab_bx[i].bx_xfer, AUVITEK_BULK_BUFLEN); - if (sc->sc_ab.ab_bx[i].bx_buffer == NULL) { - aprint_error_dev(self, - "couldn't allocate xfer buffer\n"); - sc->sc_dying = 1; - return; - } - } - aprint_debug_dev(self, "bulk endpoint 0x%02x size %d\n", sc->sc_ab.ab_endpt, AUVITEK_BULK_BUFLEN); @@ -278,7 +260,6 @@ static int auvitek_detach(device_t self, int flags) { struct auvitek_softc *sc = device_private(self); - unsigned int i; sc->sc_dying = 1; @@ -297,11 +278,6 @@ auvitek_detach(device_t self, int flags) mutex_destroy(&sc->sc_subdev_lock); - for (i = 0; i < AUVITEK_NBULK_XFERS; i++) { - if (sc->sc_ab.ab_bx[i].bx_xfer) - usbd_free_xfer(sc->sc_ab.ab_bx[i].bx_xfer); - } - return 0; } Index: sys/dev/usb/auvitek_dtv.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/auvitek_dtv.c,v retrieving revision 1.6.14.3 diff -u -p -r1.6.14.3 auvitek_dtv.c --- sys/dev/usb/auvitek_dtv.c 19 Mar 2015 17:26:42 -0000 1.6.14.3 +++ sys/dev/usb/auvitek_dtv.c 4 Oct 2015 08:34:19 -0000 @@ -152,7 +152,24 @@ auvitek_dtv_open(void *priv, int flags) if (sc->sc_xc5k == NULL) return ENXIO; - return auvitek_dtv_init_pipes(sc); + int err = auvitek_dtv_init_pipes(sc); + if (err) + return err; + + for (size_t i = 0; i < AUVITEK_NBULK_XFERS; i++) { + sc->sc_ab.ab_bx[i].bx_sc = sc; + err = usbd_create_xfer(sc->sc_ab.ab_pipe, + AUVITEK_BULK_BUFLEN, 0, 0, &sc->sc_ab.ab_bx[i].bx_xfer); + if (err) { + aprint_error_dev(sc->sc_dev, + "couldn't allocate xfer\n"); + sc->sc_dying = 1; + return err; + } + } + + + return 0; } static void @@ -163,6 +180,11 @@ auvitek_dtv_close(void *priv) auvitek_dtv_stop_transfer(sc); auvitek_dtv_close_pipes(sc); + for (size_t i = 0; i < AUVITEK_NBULK_XFERS; i++) { + if (sc->sc_ab.ab_bx[i].bx_xfer) + usbd_destroy_xfer(sc->sc_ab.ab_bx[i].bx_xfer); + } + sc->sc_dtvsubmitcb = NULL; sc->sc_dtvsubmitarg = NULL; } @@ -344,13 +366,10 @@ static int auvitek_dtv_bulk_start1(struct auvitek_bulk_xfer *bx) { struct auvitek_softc *sc = bx->bx_sc; - struct auvitek_bulk *ab = &sc->sc_ab; - int err; + usbd_status err; - usbd_setup_xfer(bx->bx_xfer, ab->ab_pipe, bx, - bx->bx_buffer, AUVITEK_BULK_BUFLEN, - //USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - 0, 100, + usbd_setup_xfer(bx->bx_xfer, bx, bx->bx_buffer, AUVITEK_BULK_BUFLEN, + 0 /* USBD_SHORT_XFER_OK */, 100 /* USBD_NO_TIMEOUT */, auvitek_dtv_bulk_cb); KERNEL_LOCK(1, curlwp); Index: sys/dev/usb/auvitek_video.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/auvitek_video.c,v retrieving revision 1.6.32.3 diff -u -p -r1.6.32.3 auvitek_video.c --- sys/dev/usb/auvitek_video.c 19 Mar 2015 17:26:42 -0000 1.6.32.3 +++ sys/dev/usb/auvitek_video.c 4 Oct 2015 08:34:19 -0000 @@ -584,20 +584,15 @@ auvitek_start_xfer(struct auvitek_softc for (i = 0; i < AUVITEK_NISOC_XFERS; i++) { struct auvitek_isoc *isoc = &ax->ax_i[i]; - isoc->i_xfer = usbd_alloc_xfer(sc->sc_udev); - if (isoc->i_xfer == NULL) { + int error = usbd_create_xfer(ax->ax_pipe, + nframes * uframe_len, 0, ax->ax_nframes, &isoc->i_xfer); + if (error) { aprint_error_dev(sc->sc_dev, - "couldn't allocate usb xfer\n"); - return ENOMEM; + "couldn't create usb xfer\n"); + return error; } - isoc->i_buf = usbd_alloc_buffer(isoc->i_xfer, - nframes * uframe_len); - if (isoc->i_buf == NULL) { - aprint_error_dev(sc->sc_dev, - "couldn't allocate usb xfer buffer\n"); - return ENOMEM; - } + isoc->i_buf = usbd_get_buffer(isoc->i_xfer); } return auvitek_isoc_start(sc); @@ -619,8 +614,7 @@ auvitek_stop_xfer(struct auvitek_softc * for (i = 0; i < AUVITEK_NISOC_XFERS; i++) { struct auvitek_isoc *isoc = &ax->ax_i[i]; if (isoc->i_xfer != NULL) { - usbd_free_buffer(isoc->i_xfer); - usbd_free_xfer(isoc->i_xfer); + usbd_destroy_xfer(isoc->i_xfer); isoc->i_xfer = NULL; } if (isoc->i_frlengths != NULL) { @@ -675,7 +669,6 @@ auvitek_isoc_start1(struct auvitek_isoc isoc->i_frlengths[i] = ax->ax_uframe_len; usbd_setup_isoc_xfer(isoc->i_xfer, - ax->ax_pipe, isoc, isoc->i_frlengths, ax->ax_nframes, Index: sys/dev/usb/emdtv_dtv.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/emdtv_dtv.c,v retrieving revision 1.10.14.3 diff -u -p -r1.10.14.3 emdtv_dtv.c --- sys/dev/usb/emdtv_dtv.c 6 Apr 2015 15:18:13 -0000 1.10.14.3 +++ sys/dev/usb/emdtv_dtv.c 4 Oct 2015 08:34:19 -0000 @@ -182,6 +182,20 @@ emdtv_dtv_open(void *priv, int flags) if (sc->sc_dying) return ENXIO; + aprint_debug_dev(sc->sc_dev, "allocating isoc xfers (pktsz %d)\n", + sc->sc_isoc_maxpacketsize); + + for (size_t i = 0; i < EMDTV_NXFERS; i++) { + int error = usbd_create_xfer(sc->sc_isoc_pipe, + sc->sc_isoc_buflen, USBD_SHORT_XFER_OK, EMDTV_NFRAMES, + &sc->sc_ix[i].ix_xfer); + if (error) + return error; + sc->sc_ix[i].ix_buf = usbd_get_buffer(sc->sc_ix[i].ix_xfer); + aprint_debug_dev(sc->sc_dev, " ix[%zu] xfer %p buf %p\n", + i, sc->sc_ix[i].ix_xfer, sc->sc_ix[i].ix_buf); + } + switch (sc->sc_board->eb_tuner) { case EMDTV_TUNER_XC3028: if (sc->sc_xc3028 == NULL) { @@ -234,6 +248,15 @@ emdtv_dtv_open(void *priv, int flags) static void emdtv_dtv_close(void *priv) { + struct emdtv_softc *sc = priv; + + for (size_t i = 0; i < EMDTV_NXFERS; i++) + if (sc->sc_ix[i].ix_xfer) { + usbd_destroy_xfer(sc->sc_ix[i].ix_xfer); + sc->sc_ix[i].ix_xfer = NULL; + sc->sc_ix[i].ix_buf = NULL; + } + return; } @@ -297,7 +320,7 @@ emdtv_dtv_start_transfer(void *priv, void (*cb)(void *, const struct dtv_payload *), void *arg) { struct emdtv_softc *sc = priv; - int i, s; + int s; s = splusb(); @@ -305,19 +328,6 @@ emdtv_dtv_start_transfer(void *priv, sc->sc_dtvsubmitcb = cb; sc->sc_dtvsubmitarg = arg; - aprint_debug_dev(sc->sc_dev, "allocating isoc xfers (pktsz %d)\n", - sc->sc_isoc_maxpacketsize); - - KERNEL_LOCK(1, curlwp); - for (i = 0; i < EMDTV_NXFERS; i++) { - sc->sc_ix[i].ix_xfer = usbd_alloc_xfer(sc->sc_udev); - sc->sc_ix[i].ix_buf = usbd_alloc_buffer(sc->sc_ix[i].ix_xfer, - sc->sc_isoc_buflen); - aprint_debug_dev(sc->sc_dev, " ix[%d] xfer %p buf %p\n", - i, sc->sc_ix[i].ix_xfer, sc->sc_ix[i].ix_buf); - } - KERNEL_UNLOCK_ONE(curlwp); - aprint_debug_dev(sc->sc_dev, "starting isoc transactions\n"); emdtv_dtv_isoc_startall(sc); @@ -330,7 +340,6 @@ static int emdtv_dtv_stop_transfer(void *priv) { struct emdtv_softc *sc = priv; - int i; aprint_debug_dev(sc->sc_dev, "stopping stream\n"); @@ -339,13 +348,6 @@ emdtv_dtv_stop_transfer(void *priv) KERNEL_LOCK(1, curlwp); if (sc->sc_isoc_pipe != NULL) usbd_abort_pipe(sc->sc_isoc_pipe); - - for (i = 0; i < EMDTV_NXFERS; i++) - if (sc->sc_ix[i].ix_xfer) { - usbd_free_xfer(sc->sc_ix[i].ix_xfer); - sc->sc_ix[i].ix_xfer = NULL; - sc->sc_ix[i].ix_buf = NULL; - } KERNEL_UNLOCK_ONE(curlwp); sc->sc_dtvsubmitcb = NULL; @@ -378,7 +380,6 @@ emdtv_dtv_isoc_start(struct emdtv_softc ix->ix_frlengths[i] = sc->sc_isoc_maxpacketsize; usbd_setup_isoc_xfer(ix->ix_xfer, - sc->sc_isoc_pipe, ix, ix->ix_frlengths, EMDTV_NFRAMES, Index: sys/dev/usb/if_athn_usb.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_athn_usb.c,v retrieving revision 1.6.8.5 diff -u -p -r1.6.8.5 if_athn_usb.c --- sys/dev/usb/if_athn_usb.c 6 Apr 2015 15:18:13 -0000 1.6.8.5 +++ sys/dev/usb/if_athn_usb.c 4 Oct 2015 08:34:20 -0000 @@ -293,12 +293,23 @@ athn_usb_attach(device_t parent, device_ if (athn_usb_alloc_tx_cmd(usc) != 0) goto fail; + /* Allocate Tx/Rx buffers. */ + error = athn_usb_alloc_rx_list(usc); + if (error != 0) + goto fail; + error = athn_usb_alloc_tx_list(usc); + if (error != 0) + goto fail; + config_mountroot(self, athn_usb_attachhook); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, usc->usc_udev, sc->sc_dev); return; fail: + /* Free Tx/Rx buffers. */ + athn_usb_free_tx_list(usc); + athn_usb_free_rx_list(usc); athn_usb_free_tx_cmd(usc); athn_usb_close_pipes(usc); usb_rem_task(usc->usc_udev, &usc->usc_task); @@ -585,18 +596,11 @@ athn_usb_alloc_rx_list(struct athn_usb_s data->sc = usc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(usc->usc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(usc->usc_rx_data_pipe, + ATHN_USB_RXBUFSZ, USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { aprint_error_dev(usc->usc_dev, "could not allocate xfer\n"); - error = ENOMEM; - break; - } - data->buf = usbd_alloc_buffer(data->xfer, ATHN_USB_RXBUFSZ); - if (data->buf == NULL) { - aprint_error_dev(usc->usc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; break; } } @@ -618,7 +622,7 @@ athn_usb_free_rx_list(struct athn_usb_so CTASSERT(sizeof(xfer) == sizeof(void *)); xfer = atomic_swap_ptr(&usc->usc_rx_data[i].xfer, NULL); if (xfer != NULL) - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); } } @@ -638,20 +642,14 @@ athn_usb_alloc_tx_list(struct athn_usb_s data->sc = usc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(usc->usc_udev); - if (data->xfer == NULL) { - aprint_error_dev(usc->usc_dev, - "could not allocate xfer\n"); - error = ENOMEM; - break; - } - data->buf = usbd_alloc_buffer(data->xfer, ATHN_USB_TXBUFSZ); - if (data->buf == NULL) { + error = usbd_create_xfer(usc->usc_tx_data_pipe, + ATHN_USB_TXBUFSZ, USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { aprint_error_dev(usc->usc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; + "could not create xfer on TX pipe\n"); break; } + /* Append this Tx buffer to our free list. */ TAILQ_INSERT_TAIL(&usc->usc_tx_free_list, data, next); } @@ -674,7 +672,7 @@ athn_usb_free_tx_list(struct athn_usb_so CTASSERT(sizeof(xfer) == sizeof(void *)); xfer = atomic_swap_ptr(&usc->usc_tx_data[i].xfer, NULL); if (xfer != NULL) - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); } } @@ -687,17 +685,14 @@ athn_usb_alloc_tx_cmd(struct athn_usb_so data->sc = usc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(usc->usc_udev); - if (data->xfer == NULL) { - aprint_error_dev(usc->usc_dev, "could not allocate xfer\n"); - return ENOMEM; - } - data->buf = usbd_alloc_buffer(data->xfer, ATHN_USB_TXCMDSZ); - if (data->buf == NULL) { + int err = usbd_create_xfer(usc->usc_tx_intr_pipe, ATHN_USB_TXCMDSZ, + 0, 0, &data->xfer); + if (err) { aprint_error_dev(usc->usc_dev, - "could not allocate xfer buffer\n"); - return ENOMEM; + "could not allocate command xfer\n"); + return err; } + return 0; } @@ -711,7 +706,7 @@ athn_usb_free_tx_cmd(struct athn_usb_sof CTASSERT(sizeof(xfer) == sizeof(void *)); xfer = atomic_swap_ptr(&usc->usc_tx_cmd.xfer, NULL); if (xfer != NULL) - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); } Static void @@ -905,7 +900,7 @@ athn_usb_htc_msg(struct athn_usb_softc * memcpy(&msg[1], buf, len); - usbd_setup_xfer(data->xfer, usc->usc_tx_intr_pipe, NULL, data->buf, + usbd_setup_xfer(data->xfer, NULL, data->buf, sizeof(*htc) + sizeof(*msg) + len, USBD_SHORT_XFER_OK, ATHN_USB_CMD_TIMEOUT, NULL); return usbd_sync_transfer(data->xfer); @@ -1091,7 +1086,7 @@ athn_usb_wmi_xcmd(struct athn_usb_softc memcpy(&wmi[1], ibuf, ilen); - usbd_setup_xfer(data->xfer, usc->usc_tx_intr_pipe, usc, data->buf, + usbd_setup_xfer(data->xfer, usc, data->buf, sizeof(*htc) + sizeof(*wmi) + ilen, USBD_SHORT_XFER_OK, ATHN_USB_CMD_TIMEOUT, athn_usb_wmieof); @@ -1822,7 +1817,7 @@ athn_usb_swba(struct athn_usb_softc *usc m_copydata(m, 0, m->m_pkthdr.len, (void *)&bcn[1]); - usbd_setup_xfer(data->xfer, usc->usc_tx_data_pipe, data, data->buf, + usbd_setup_xfer(data->xfer, data, data->buf, sizeof(*hdr) + sizeof(*htc) + sizeof(*bcn) + m->m_pkthdr.len, USBD_SHORT_XFER_OK, ATHN_USB_TX_TIMEOUT, athn_usb_bcneof); @@ -2209,9 +2204,8 @@ athn_usb_rxeof(struct usbd_xfer *xfer, v resubmit: /* Setup a new transfer. */ - usbd_setup_xfer(xfer, usc->usc_rx_data_pipe, data, data->buf, - ATHN_USB_RXBUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, athn_usb_rxeof); + usbd_setup_xfer(xfer, data, data->buf, ATHN_USB_RXBUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, athn_usb_rxeof); (void)usbd_transfer(xfer); } @@ -2360,9 +2354,8 @@ athn_usb_tx(struct athn_softc *sc, struc xferlen = frm - data->buf; s = splnet(); - usbd_setup_xfer(data->xfer, usc->usc_tx_data_pipe, data, data->buf, - xferlen, USBD_FORCE_SHORT_XFER, ATHN_USB_TX_TIMEOUT, - athn_usb_txeof); + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, + USBD_FORCE_SHORT_XFER, ATHN_USB_TX_TIMEOUT, athn_usb_txeof); error = usbd_transfer(data->xfer); if (__predict_false(error != USBD_IN_PROGRESS && error != 0)) { splx(s); @@ -2578,13 +2571,6 @@ athn_usb_init(struct ifnet *ifp) usc->usc_cmdq.cur = usc->usc_cmdq.next = usc->usc_cmdq.queued = 0; mutex_spin_exit(&usc->usc_task_mtx); - /* Allocate Tx/Rx buffers. */ - error = athn_usb_alloc_rx_list(usc); - if (error != 0) - goto fail; - error = athn_usb_alloc_tx_list(usc); - if (error != 0) - goto fail; /* Steal one buffer for beacons. */ mutex_enter(&usc->usc_tx_mtx); usc->usc_tx_bcn = TAILQ_FIRST(&usc->usc_tx_free_list); @@ -2691,7 +2677,7 @@ athn_usb_init(struct ifnet *ifp) for (i = 0; i < ATHN_USB_RX_LIST_COUNT; i++) { data = &usc->usc_rx_data[i]; - usbd_setup_xfer(data->xfer, usc->usc_rx_data_pipe, data, data->buf, + usbd_setup_xfer(data->xfer, data, data->buf, ATHN_USB_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, athn_usb_rxeof); error = usbd_transfer(data->xfer); Index: sys/dev/usb/if_atu.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_atu.c,v retrieving revision 1.50.2.8 diff -u -p -r1.50.2.8 if_atu.c --- sys/dev/usb/if_atu.c 21 Mar 2015 11:33:37 -0000 1.50.2.8 +++ sys/dev/usb/if_atu.c 4 Oct 2015 08:34:21 -0000 @@ -312,7 +312,13 @@ atu_usb_request(struct atu_softc *sc, ui s = splnet(); - xfer = usbd_alloc_xfer(sc->atu_udev); + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->atu_udev); + int error = usbd_create_xfer(pipe0, length, USBD_SHORT_XFER_OK, 0, + &xfer); + if (error) { + splx(s); + return USBD_IOERROR; + } usbd_setup_default_xfer(xfer, sc->atu_udev, 0, 500000, &req, data, length, USBD_SHORT_XFER_OK, 0); @@ -333,7 +339,7 @@ atu_usb_request(struct atu_softc *sc, ui } #endif /* ATU_DEBUG */ - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); splx(s); return(err); @@ -1549,13 +1555,10 @@ atu_rx_list_init(struct atu_softc *sc) c->atu_sc = sc; c->atu_idx = i; if (c->atu_xfer == NULL) { - c->atu_xfer = usbd_alloc_xfer(sc->atu_udev); - if (c->atu_xfer == NULL) - return ENOBUFS; - c->atu_buf = usbd_alloc_buffer(c->atu_xfer, - ATU_RX_BUFSZ); - if (c->atu_buf == NULL) /* XXX free xfer */ - return ENOBUFS; + int err = usbd_create_xfer(sc->atu_ep[ATU_ENDPT_RX], + ATU_RX_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->atu_xfer); + if (err) + return err; if (atu_newbuf(sc, c, NULL) == ENOBUFS) /* XXX free? */ return(ENOBUFS); } @@ -1581,14 +1584,11 @@ atu_tx_list_init(struct atu_softc *sc) c->atu_sc = sc; c->atu_idx = i; if (c->atu_xfer == NULL) { - c->atu_xfer = usbd_alloc_xfer(sc->atu_udev); - if (c->atu_xfer == NULL) - return(ENOBUFS); - c->atu_mbuf = NULL; - c->atu_buf = usbd_alloc_buffer(c->atu_xfer, - ATU_TX_BUFSZ); - if (c->atu_buf == NULL) - return(ENOBUFS); /* XXX free xfer */ + int err = usbd_create_xfer(sc->atu_ep[ATU_ENDPT_TX], + ATU_TX_BUFSZ, 0, 0, &c->atu_xfer); + if (err) { + return err; + } SLIST_INSERT_HEAD(&cd->atu_tx_free, c, atu_list); } } @@ -1610,7 +1610,7 @@ atu_xfer_list_free(struct atu_softc *sc, ch[i].atu_mbuf = NULL; } if (ch[i].atu_xfer != NULL) { - usbd_free_xfer(ch[i].atu_xfer); + usbd_destroy_xfer(ch[i].atu_xfer); ch[i].atu_xfer = NULL; } } @@ -1720,9 +1720,8 @@ done1: splx(s); done: /* Setup new transfer. */ - usbd_setup_xfer(c->atu_xfer, sc->atu_ep[ATU_ENDPT_RX], c, c->atu_buf, - ATU_RX_BUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - atu_rxeof); + usbd_setup_xfer(c->atu_xfer, c, c->atu_buf, ATU_RX_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, atu_rxeof); usbd_transfer(c->atu_xfer); } @@ -1827,9 +1826,8 @@ atu_tx_start(struct atu_softc *sc, struc c->atu_length = len; c->atu_mbuf = m; - usbd_setup_xfer(c->atu_xfer, sc->atu_ep[ATU_ENDPT_TX], - c, c->atu_buf, c->atu_length, 0, ATU_TX_TIMEOUT, - atu_txeof); + usbd_setup_xfer(c->atu_xfer, c, c->atu_buf, c->atu_length, 0, + ATU_TX_TIMEOUT, atu_txeof); /* Let's get this thing into the air! */ c->atu_in_xfer = 1; @@ -2015,9 +2013,8 @@ atu_init(struct ifnet *ifp) for (i = 0; i < ATU_RX_LIST_CNT; i++) { c = &sc->atu_cdata.atu_rx_chain[i]; - usbd_setup_xfer(c->atu_xfer, sc->atu_ep[ATU_ENDPT_RX], c, - c->atu_buf, ATU_RX_BUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, atu_rxeof); + usbd_setup_xfer(c->atu_xfer, c, c->atu_buf, ATU_RX_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, atu_rxeof); usbd_transfer(c->atu_xfer); } Index: sys/dev/usb/if_aue.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_aue.c,v retrieving revision 1.132.4.8 diff -u -p -r1.132.4.8 if_aue.c --- sys/dev/usb/if_aue.c 6 Jun 2015 14:40:13 -0000 1.132.4.8 +++ sys/dev/usb/if_aue.c 4 Oct 2015 08:34:25 -0000 @@ -1011,12 +1011,11 @@ aue_rx_list_init(struct aue_softc *sc) if (aue_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; if (c->aue_xfer == NULL) { - c->aue_xfer = usbd_alloc_xfer(sc->aue_udev); - if (c->aue_xfer == NULL) - return ENOBUFS; - c->aue_buf = usbd_alloc_buffer(c->aue_xfer, AUE_BUFSZ); - if (c->aue_buf == NULL) - return ENOBUFS; /* XXX free xfer */ + int err = usbd_create_xfer(sc->aue_ep[AUE_ENDPT_RX], + AUE_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->aue_xfer); + if (err) { + return err; + } } } @@ -1039,12 +1038,11 @@ aue_tx_list_init(struct aue_softc *sc) c->aue_idx = i; c->aue_mbuf = NULL; if (c->aue_xfer == NULL) { - c->aue_xfer = usbd_alloc_xfer(sc->aue_udev); - if (c->aue_xfer == NULL) - return ENOBUFS; - c->aue_buf = usbd_alloc_buffer(c->aue_xfer, AUE_BUFSZ); - if (c->aue_buf == NULL) - return ENOBUFS; + int err = usbd_create_xfer(sc->aue_ep[AUE_ENDPT_TX], + AUE_BUFSZ, USBD_FORCE_SHORT_XFER, 0, &c->aue_xfer); + if (err) { + return err; + } } } @@ -1179,10 +1177,8 @@ aue_rxeof(struct usbd_xfer *xfer, void * done: /* Setup new transfer. */ - usbd_setup_xfer(xfer, sc->aue_ep[AUE_ENDPT_RX], - c, c->aue_buf, AUE_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, aue_rxeof); + usbd_setup_xfer(xfer, c, c->aue_buf, AUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, aue_rxeof); usbd_transfer(xfer); DPRINTFN(10,("%s: %s: start rx\n", device_xname(sc->aue_dev), @@ -1322,9 +1318,8 @@ aue_send(struct aue_softc *sc, struct mb c->aue_buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); total_len = m->m_pkthdr.len + 2; - usbd_setup_xfer(c->aue_xfer, sc->aue_ep[AUE_ENDPT_TX], - c, c->aue_buf, total_len, USBD_FORCE_SHORT_XFER, - AUE_TX_TIMEOUT, aue_txeof); + usbd_setup_xfer(c->aue_xfer, c, c->aue_buf, total_len, + USBD_FORCE_SHORT_XFER, AUE_TX_TIMEOUT, aue_txeof); /* Transmit */ err = usbd_transfer(c->aue_xfer); @@ -1421,20 +1416,38 @@ aue_init(void *xsc) else AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); + if (sc->aue_ep[AUE_ENDPT_RX] == NULL) { + if (aue_openpipes(sc)) { + splx(s); + return; + } + } /* Init TX ring. */ - if (aue_tx_list_init(sc) == ENOBUFS) { + if (aue_tx_list_init(sc) != 0) { aprint_error_dev(sc->aue_dev, "tx list init failed\n"); splx(s); return; } /* Init RX ring. */ - if (aue_rx_list_init(sc) == ENOBUFS) { + if (aue_rx_list_init(sc) != 0) { aprint_error_dev(sc->aue_dev, "rx list init failed\n"); splx(s); return; } + /* Start up the receive pipe. */ + for (i = 0; i < AUE_RX_LIST_CNT; i++) { + struct aue_chain *c = &sc->aue_cdata.aue_rx_chain[i]; + + usbd_setup_xfer(c->aue_xfer, c, c->aue_buf, AUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, aue_rxeof); + (void)usbd_transfer(c->aue_xfer); /* XXX */ + DPRINTFN(5,("%s: %s: start read\n", device_xname(sc->aue_dev), + __func__)); + + } + /* Load the multicast filter. */ aue_setmulti(sc); @@ -1445,13 +1458,6 @@ aue_init(void *xsc) mii_mediachg(mii); - if (sc->aue_ep[AUE_ENDPT_RX] == NULL) { - if (aue_openpipes(sc)) { - splx(s); - return; - } - } - ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -1463,9 +1469,7 @@ aue_init(void *xsc) Static int aue_openpipes(struct aue_softc *sc) { - struct aue_chain *c; usbd_status err; - int i; /* Open RX and TX pipes. */ err = usbd_open_pipe(sc->aue_iface, sc->aue_ed[AUE_ENDPT_RX], @@ -1492,18 +1496,6 @@ aue_openpipes(struct aue_softc *sc) return EIO; } - /* Start up the receive pipe. */ - for (i = 0; i < AUE_RX_LIST_CNT; i++) { - c = &sc->aue_cdata.aue_rx_chain[i]; - usbd_setup_xfer(c->aue_xfer, sc->aue_ep[AUE_ENDPT_RX], - c, c->aue_buf, AUE_BUFSZ, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - aue_rxeof); - (void)usbd_transfer(c->aue_xfer); /* XXX */ - DPRINTFN(5,("%s: %s: start read\n", device_xname(sc->aue_dev), - __func__)); - - } return 0; } @@ -1699,7 +1691,7 @@ aue_stop(struct aue_softc *sc) sc->aue_cdata.aue_rx_chain[i].aue_mbuf = NULL; } if (sc->aue_cdata.aue_rx_chain[i].aue_xfer != NULL) { - usbd_free_xfer(sc->aue_cdata.aue_rx_chain[i].aue_xfer); + usbd_destroy_xfer(sc->aue_cdata.aue_rx_chain[i].aue_xfer); sc->aue_cdata.aue_rx_chain[i].aue_xfer = NULL; } } @@ -1711,7 +1703,7 @@ aue_stop(struct aue_softc *sc) sc->aue_cdata.aue_tx_chain[i].aue_mbuf = NULL; } if (sc->aue_cdata.aue_tx_chain[i].aue_xfer != NULL) { - usbd_free_xfer(sc->aue_cdata.aue_tx_chain[i].aue_xfer); + usbd_destroy_xfer(sc->aue_cdata.aue_tx_chain[i].aue_xfer); sc->aue_cdata.aue_tx_chain[i].aue_xfer = NULL; } } Index: sys/dev/usb/if_axe.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_axe.c,v retrieving revision 1.67.4.6 diff -u -p -r1.67.4.6 if_axe.c --- sys/dev/usb/if_axe.c 6 Jun 2015 14:40:13 -0000 1.67.4.6 +++ sys/dev/usb/if_axe.c 4 Oct 2015 08:34:27 -0000 @@ -945,15 +945,11 @@ axe_rx_list_init(struct axe_softc *sc) c->axe_sc = sc; c->axe_idx = i; if (c->axe_xfer == NULL) { - c->axe_xfer = usbd_alloc_xfer(sc->axe_udev); - if (c->axe_xfer == NULL) + int err = usbd_create_xfer(sc->axe_ep[AXE_ENDPT_RX], + sc->axe_bufsz, USBD_SHORT_XFER_OK, 0, &c->axe_xfer); return ENOBUFS; - c->axe_buf = usbd_alloc_buffer(c->axe_xfer, - sc->axe_bufsz); - if (c->axe_buf == NULL) { - usbd_free_xfer(c->axe_xfer); - return ENOBUFS; - } + if (err) + return err; } } @@ -975,15 +971,11 @@ axe_tx_list_init(struct axe_softc *sc) c->axe_sc = sc; c->axe_idx = i; if (c->axe_xfer == NULL) { - c->axe_xfer = usbd_alloc_xfer(sc->axe_udev); - if (c->axe_xfer == NULL) - return ENOBUFS; - c->axe_buf = usbd_alloc_buffer(c->axe_xfer, - sc->axe_bufsz); - if (c->axe_buf == NULL) { - usbd_free_xfer(c->axe_xfer); - return ENOBUFS; - } + int err = usbd_create_xfer(sc->axe_ep[AXE_ENDPT_TX], + sc->axe_bufsz, USBD_FORCE_SHORT_XFER, 0, + &c->axe_xfer); + if (err) + return err; } } @@ -1104,10 +1096,8 @@ axe_rxeof(struct usbd_xfer *xfer, void * done: /* Setup new transfer. */ - usbd_setup_xfer(xfer, sc->axe_ep[AXE_ENDPT_RX], - c, c->axe_buf, sc->axe_bufsz, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, axe_rxeof); + usbd_setup_xfer(xfer, c, c->axe_buf, sc->axe_bufsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, axe_rxeof); usbd_transfer(xfer); DPRINTFN(10,("%s: %s: start rx\n", device_xname(sc->axe_dev), __func__)); @@ -1254,9 +1244,8 @@ axe_encap(struct axe_softc *sc, struct m length = m->m_pkthdr.len; } - usbd_setup_xfer(c->axe_xfer, sc->axe_ep[AXE_ENDPT_TX], - c, c->axe_buf, length, USBD_FORCE_SHORT_XFER, 10000, - axe_txeof); + usbd_setup_xfer(c->axe_xfer, c, c->axe_buf, length, + USBD_FORCE_SHORT_XFER, 10000, axe_txeof); /* Transmit */ err = usbd_transfer(c->axe_xfer); @@ -1343,14 +1332,14 @@ axe_init(struct ifnet *ifp) /* Enable RX logic. */ /* Init RX ring. */ - if (axe_rx_list_init(sc) == ENOBUFS) { + if (axe_rx_list_init(sc) != 0) { aprint_error_dev(sc->axe_dev, "rx list init failed\n"); splx(s); return ENOBUFS; } /* Init TX ring. */ - if (axe_tx_list_init(sc) == ENOBUFS) { + if (axe_tx_list_init(sc) != 0) { aprint_error_dev(sc->axe_dev, "tx list init failed\n"); splx(s); return ENOBUFS; @@ -1414,10 +1403,8 @@ axe_init(struct ifnet *ifp) /* Start up the receive pipe. */ for (i = 0; i < AXE_RX_LIST_CNT; i++) { c = &sc->axe_cdata.axe_rx_chain[i]; - usbd_setup_xfer(c->axe_xfer, sc->axe_ep[AXE_ENDPT_RX], - c, c->axe_buf, sc->axe_bufsz, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - axe_rxeof); + usbd_setup_xfer(c->axe_xfer, c, c->axe_buf, sc->axe_bufsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, axe_rxeof); usbd_transfer(c->axe_xfer); } @@ -1563,7 +1550,7 @@ axe_stop(struct ifnet *ifp, int disable) /* Free RX resources. */ for (i = 0; i < AXE_RX_LIST_CNT; i++) { if (sc->axe_cdata.axe_rx_chain[i].axe_xfer != NULL) { - usbd_free_xfer(sc->axe_cdata.axe_rx_chain[i].axe_xfer); + usbd_destroy_xfer(sc->axe_cdata.axe_rx_chain[i].axe_xfer); sc->axe_cdata.axe_rx_chain[i].axe_xfer = NULL; } } @@ -1571,7 +1558,7 @@ axe_stop(struct ifnet *ifp, int disable) /* Free TX resources. */ for (i = 0; i < AXE_TX_LIST_CNT; i++) { if (sc->axe_cdata.axe_tx_chain[i].axe_xfer != NULL) { - usbd_free_xfer(sc->axe_cdata.axe_tx_chain[i].axe_xfer); + usbd_destroy_xfer(sc->axe_cdata.axe_tx_chain[i].axe_xfer); sc->axe_cdata.axe_tx_chain[i].axe_xfer = NULL; } } Index: sys/dev/usb/if_axen.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_axen.c,v retrieving revision 1.3.6.7 diff -u -p -r1.3.6.7 if_axen.c --- sys/dev/usb/if_axen.c 6 Jun 2015 14:40:13 -0000 1.3.6.7 +++ sys/dev/usb/if_axen.c 4 Oct 2015 08:34:30 -0000 @@ -919,15 +919,11 @@ axen_rx_list_init(struct axen_softc *sc) c->axen_sc = sc; c->axen_idx = i; if (c->axen_xfer == NULL) { - c->axen_xfer = usbd_alloc_xfer(sc->axen_udev); - if (c->axen_xfer == NULL) - return ENOBUFS; - c->axen_buf = usbd_alloc_buffer(c->axen_xfer, - sc->axen_bufsz); - if (c->axen_buf == NULL) { - usbd_free_xfer(c->axen_xfer); - return ENOBUFS; - } + int err = usbd_create_xfer(sc->axen_ep[AXEN_ENDPT_RX], + sc->axen_bufsz, USBD_SHORT_XFER_OK, 0, + &c->axen_xfer); + if (err) + return err; } } @@ -949,15 +945,11 @@ axen_tx_list_init(struct axen_softc *sc) c->axen_sc = sc; c->axen_idx = i; if (c->axen_xfer == NULL) { - c->axen_xfer = usbd_alloc_xfer(sc->axen_udev); - if (c->axen_xfer == NULL) - return ENOBUFS; - c->axen_buf = usbd_alloc_buffer(c->axen_xfer, - sc->axen_bufsz); - if (c->axen_buf == NULL) { - usbd_free_xfer(c->axen_xfer); - return ENOBUFS; - } + int err = usbd_create_xfer(sc->axen_ep[AXEN_ENDPT_TX], + sc->axen_bufsz, USBD_FORCE_SHORT_XFER, 0, + &c->axen_xfer); + if (err) + return err; } } @@ -1132,10 +1124,8 @@ done: memset(c->axen_buf, 0, sc->axen_bufsz); /* Setup new transfer. */ - usbd_setup_xfer(xfer, sc->axen_ep[AXEN_ENDPT_RX], - c, c->axen_buf, sc->axen_bufsz, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, axen_rxeof); + usbd_setup_xfer(xfer, c, c->axen_buf, sc->axen_bufsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, axen_rxeof); usbd_transfer(xfer); DPRINTFN(10,("%s: %s: start rx\n",device_xname(sc->axen_dev),__func__)); @@ -1267,9 +1257,8 @@ axen_encap(struct axen_softc *sc, struct length += sizeof(hdr); } - usbd_setup_xfer(c->axen_xfer, sc->axen_ep[AXEN_ENDPT_TX], - c, c->axen_buf, length, USBD_FORCE_SHORT_XFER, - 10000, axen_txeof); + usbd_setup_xfer(c->axen_xfer, c, c->axen_buf, length, + USBD_FORCE_SHORT_XFER, 10000, axen_txeof); /* Transmit */ err = usbd_transfer(c->axen_xfer); @@ -1350,7 +1339,7 @@ axen_init(struct ifnet *ifp) axen_unlock_mii(sc); /* Init RX ring. */ - if (axen_rx_list_init(sc) == ENOBUFS) { + if (axen_rx_list_init(sc)) { aprint_error_dev(sc->axen_dev, "rx list init failed\n"); axen_unlock_mii(sc); splx(s); @@ -1358,7 +1347,7 @@ axen_init(struct ifnet *ifp) } /* Init TX ring. */ - if (axen_tx_list_init(sc) == ENOBUFS) { + if (axen_tx_list_init(sc)) { aprint_error_dev(sc->axen_dev, "tx list init failed\n"); axen_unlock_mii(sc); splx(s); @@ -1399,10 +1388,9 @@ axen_init(struct ifnet *ifp) /* Start up the receive pipe. */ for (i = 0; i < AXEN_RX_LIST_CNT; i++) { c = &sc->axen_cdata.axen_rx_chain[i]; - usbd_setup_xfer(c->axen_xfer, sc->axen_ep[AXEN_ENDPT_RX], - c, c->axen_buf, sc->axen_bufsz, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, axen_rxeof); + + usbd_setup_xfer(c->axen_xfer, c, c->axen_buf, sc->axen_bufsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, axen_rxeof); usbd_transfer(c->axen_xfer); } @@ -1549,7 +1537,7 @@ axen_stop(struct ifnet *ifp, int disable /* Free RX resources. */ for (i = 0; i < AXEN_RX_LIST_CNT; i++) { if (sc->axen_cdata.axen_rx_chain[i].axen_xfer != NULL) { - usbd_free_xfer(sc->axen_cdata.axen_rx_chain[i].axen_xfer); + usbd_destroy_xfer(sc->axen_cdata.axen_rx_chain[i].axen_xfer); sc->axen_cdata.axen_rx_chain[i].axen_xfer = NULL; } } @@ -1557,7 +1545,7 @@ axen_stop(struct ifnet *ifp, int disable /* Free TX resources. */ for (i = 0; i < AXEN_TX_LIST_CNT; i++) { if (sc->axen_cdata.axen_tx_chain[i].axen_xfer != NULL) { - usbd_free_xfer(sc->axen_cdata.axen_tx_chain[i].axen_xfer); + usbd_destroy_xfer(sc->axen_cdata.axen_tx_chain[i].axen_xfer); sc->axen_cdata.axen_tx_chain[i].axen_xfer = NULL; } } Index: sys/dev/usb/if_cdce.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_cdce.c,v retrieving revision 1.38.14.5 diff -u -p -r1.38.14.5 if_cdce.c --- sys/dev/usb/if_cdce.c 6 Jun 2015 14:40:13 -0000 1.38.14.5 +++ sys/dev/usb/if_cdce.c 4 Oct 2015 08:34:32 -0000 @@ -376,9 +376,8 @@ cdce_encap(struct cdce_softc *sc, struct } c->cdce_mbuf = m; - usbd_setup_xfer(c->cdce_xfer, sc->cdce_bulkout_pipe, c, c->cdce_buf, - m->m_pkthdr.len + extra, USBD_FORCE_SHORT_XFER, - 10000, cdce_txeof); + usbd_setup_xfer(c->cdce_xfer, c, c->cdce_buf, m->m_pkthdr.len + extra, + USBD_FORCE_SHORT_XFER, 10000, cdce_txeof); err = usbd_transfer(c->cdce_xfer); if (err != USBD_IN_PROGRESS) { cdce_stop(sc); @@ -429,7 +428,7 @@ cdce_stop(struct cdce_softc *sc) sc->cdce_cdata.cdce_rx_chain[i].cdce_mbuf = NULL; } if (sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer != NULL) { - usbd_free_xfer + usbd_destroy_xfer (sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer); sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer = NULL; } @@ -441,7 +440,7 @@ cdce_stop(struct cdce_softc *sc) sc->cdce_cdata.cdce_tx_chain[i].cdce_mbuf = NULL; } if (sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer != NULL) { - usbd_free_xfer( + usbd_destroy_xfer( sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer); sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer = NULL; } @@ -538,13 +537,13 @@ cdce_init(void *xsc) s = splnet(); - if (cdce_tx_list_init(sc) == ENOBUFS) { + if (cdce_tx_list_init(sc)) { printf("%s: tx list init failed\n", device_xname(sc->cdce_dev)); splx(s); return; } - if (cdce_rx_list_init(sc) == ENOBUFS) { + if (cdce_rx_list_init(sc)) { printf("%s: rx list init failed\n", device_xname(sc->cdce_dev)); splx(s); return; @@ -572,9 +571,9 @@ cdce_init(void *xsc) for (i = 0; i < CDCE_RX_LIST_CNT; i++) { c = &sc->cdce_cdata.cdce_rx_chain[i]; - usbd_setup_xfer(c->cdce_xfer, sc->cdce_bulkin_pipe, c, - c->cdce_buf, CDCE_BUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, cdce_rxeof); + + usbd_setup_xfer(c->cdce_xfer, c, c->cdce_buf, CDCE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cdce_rxeof); usbd_transfer(c->cdce_xfer); } @@ -627,15 +626,10 @@ cdce_rx_list_init(struct cdce_softc *sc) c->cdce_idx = i; if (cdce_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; - if (c->cdce_xfer == NULL) { - c->cdce_xfer = usbd_alloc_xfer(sc->cdce_udev); - if (c->cdce_xfer == NULL) - return ENOBUFS; - c->cdce_buf = usbd_alloc_buffer(c->cdce_xfer, - CDCE_BUFSZ); - if (c->cdce_buf == NULL) - return ENOBUFS; - } + int err = usbd_create_xfer(sc->cdce_bulkin_pipe, CDCE_BUFSZ, + USBD_SHORT_XFER_OK, 0, &c->cdce_xfer); + if (err) + return err; } return 0; @@ -655,12 +649,11 @@ cdce_tx_list_init(struct cdce_softc *sc) c->cdce_idx = i; c->cdce_mbuf = NULL; if (c->cdce_xfer == NULL) { - c->cdce_xfer = usbd_alloc_xfer(sc->cdce_udev); - if (c->cdce_xfer == NULL) - return ENOBUFS; - c->cdce_buf = usbd_alloc_buffer(c->cdce_xfer, CDCE_BUFSZ); - if (c->cdce_buf == NULL) - return ENOBUFS; + int err = usbd_create_xfer(sc->cdce_bulkout_pipe, + CDCE_BUFSZ, USBD_FORCE_SHORT_XFER, 0, + &c->cdce_xfer); + if (err) + return err; } } @@ -729,9 +722,8 @@ done1: done: /* Setup new transfer. */ - usbd_setup_xfer(c->cdce_xfer, sc->cdce_bulkin_pipe, c, c->cdce_buf, - CDCE_BUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - cdce_rxeof); + usbd_setup_xfer(c->cdce_xfer, c, c->cdce_buf, CDCE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cdce_rxeof); usbd_transfer(c->cdce_xfer); } Index: sys/dev/usb/if_cue.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_cue.c,v retrieving revision 1.68.4.7 diff -u -p -r1.68.4.7 if_cue.c --- sys/dev/usb/if_cue.c 6 Jun 2015 14:40:13 -0000 1.68.4.7 +++ sys/dev/usb/if_cue.c 4 Oct 2015 08:34:33 -0000 @@ -677,14 +677,11 @@ cue_rx_list_init(struct cue_softc *sc) if (cue_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; if (c->cue_xfer == NULL) { - c->cue_xfer = usbd_alloc_xfer(sc->cue_udev); - if (c->cue_xfer == NULL) - return ENOBUFS; - c->cue_buf = usbd_alloc_buffer(c->cue_xfer, CUE_BUFSZ); - if (c->cue_buf == NULL) { - usbd_free_xfer(c->cue_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->cue_ep[CUE_ENDPT_RX], + CUE_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->cue_xfer); + if (error) + return error; + c->cue_buf = usbd_get_buffer(c->cue_xfer); } } @@ -705,14 +702,11 @@ cue_tx_list_init(struct cue_softc *sc) c->cue_idx = i; c->cue_mbuf = NULL; if (c->cue_xfer == NULL) { - c->cue_xfer = usbd_alloc_xfer(sc->cue_udev); - if (c->cue_xfer == NULL) - return ENOBUFS; - c->cue_buf = usbd_alloc_buffer(c->cue_xfer, CUE_BUFSZ); - if (c->cue_buf == NULL) { - usbd_free_xfer(c->cue_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->cue_ep[CUE_ENDPT_TX], + CUE_BUFSZ, 0, 0, &c->cue_xfer); + if (error) + return error; + c->cue_buf = usbd_get_buffer(c->cue_xfer); } } @@ -802,10 +796,10 @@ cue_rxeof(struct usbd_xfer *xfer, void * splx(s); done: + /* Setup new transfer. */ - usbd_setup_xfer(c->cue_xfer, sc->cue_ep[CUE_ENDPT_RX], - c, c->cue_buf, CUE_BUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, cue_rxeof); + usbd_setup_xfer(c->cue_xfer, c, c->cue_buf, CUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cue_rxeof); usbd_transfer(c->cue_xfer); DPRINTFN(10,("%s: %s: start rx\n", device_xname(sc->cue_dev), @@ -925,8 +919,8 @@ cue_send(struct cue_softc *sc, struct mb c->cue_buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); /* XXX 10000 */ - usbd_setup_xfer(c->cue_xfer, sc->cue_ep[CUE_ENDPT_TX], - c, c->cue_buf, total_len, 0, 10000, cue_txeof); + usbd_setup_xfer(c->cue_xfer, c, c->cue_buf, total_len, 0, 10000, + cue_txeof); /* Transmit */ err = usbd_transfer(c->cue_xfer); @@ -1023,20 +1017,6 @@ cue_init(void *xsc) ctl |= CUE_ETHCTL_PROMISC; cue_csr_write_1(sc, CUE_ETHCTL, ctl); - /* Init TX ring. */ - if (cue_tx_list_init(sc) == ENOBUFS) { - printf("%s: tx list init failed\n", device_xname(sc->cue_dev)); - splx(s); - return; - } - - /* Init RX ring. */ - if (cue_rx_list_init(sc) == ENOBUFS) { - printf("%s: rx list init failed\n", device_xname(sc->cue_dev)); - splx(s); - return; - } - /* Load the multicast filter. */ cue_setmulti(sc); @@ -1060,6 +1040,20 @@ cue_init(void *xsc) return; } } + /* Init TX ring. */ + if (cue_tx_list_init(sc)) { + printf("%s: tx list init failed\n", device_xname(sc->cue_dev)); + splx(s); + return; + } + + /* Init RX ring. */ + if (cue_rx_list_init(sc)) { + printf("%s: rx list init failed\n", device_xname(sc->cue_dev)); + splx(s); + return; + } + ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -1095,10 +1089,9 @@ cue_open_pipes(struct cue_softc *sc) /* Start up the receive pipe. */ for (i = 0; i < CUE_RX_LIST_CNT; i++) { c = &sc->cue_cdata.cue_rx_chain[i]; - usbd_setup_xfer(c->cue_xfer, sc->cue_ep[CUE_ENDPT_RX], - c, c->cue_buf, CUE_BUFSZ, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - cue_rxeof); + + usbd_setup_xfer(c->cue_xfer, c, c->cue_buf, CUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, cue_rxeof); usbd_transfer(c->cue_xfer); } @@ -1273,7 +1266,7 @@ cue_stop(struct cue_softc *sc) sc->cue_cdata.cue_rx_chain[i].cue_mbuf = NULL; } if (sc->cue_cdata.cue_rx_chain[i].cue_xfer != NULL) { - usbd_free_xfer(sc->cue_cdata.cue_rx_chain[i].cue_xfer); + usbd_destroy_xfer(sc->cue_cdata.cue_rx_chain[i].cue_xfer); sc->cue_cdata.cue_rx_chain[i].cue_xfer = NULL; } } @@ -1285,7 +1278,7 @@ cue_stop(struct cue_softc *sc) sc->cue_cdata.cue_tx_chain[i].cue_mbuf = NULL; } if (sc->cue_cdata.cue_tx_chain[i].cue_xfer != NULL) { - usbd_free_xfer(sc->cue_cdata.cue_tx_chain[i].cue_xfer); + usbd_destroy_xfer(sc->cue_cdata.cue_tx_chain[i].cue_xfer); sc->cue_cdata.cue_tx_chain[i].cue_xfer = NULL; } } Index: sys/dev/usb/if_kue.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_kue.c,v retrieving revision 1.81.4.6 diff -u -p -r1.81.4.6 if_kue.c --- sys/dev/usb/if_kue.c 6 Jun 2015 14:40:13 -0000 1.81.4.6 +++ sys/dev/usb/if_kue.c 4 Oct 2015 08:34:33 -0000 @@ -593,12 +593,11 @@ kue_rx_list_init(struct kue_softc *sc) c->kue_sc = sc; c->kue_idx = i; if (c->kue_xfer == NULL) { - c->kue_xfer = usbd_alloc_xfer(sc->kue_udev); - if (c->kue_xfer == NULL) - return ENOBUFS; - c->kue_buf = usbd_alloc_buffer(c->kue_xfer, KUE_BUFSZ); - if (c->kue_buf == NULL) - return ENOBUFS; /* XXX free xfer */ + int error = usbd_create_xfer(sc->kue_ep[KUE_ENDPT_RX], + KUE_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->kue_xfer); + if (error) + return error; + c->kue_buf = usbd_get_buffer(c->kue_xfer); } } @@ -620,12 +619,11 @@ kue_tx_list_init(struct kue_softc *sc) c->kue_sc = sc; c->kue_idx = i; if (c->kue_xfer == NULL) { - c->kue_xfer = usbd_alloc_xfer(sc->kue_udev); - if (c->kue_xfer == NULL) - return ENOBUFS; - c->kue_buf = usbd_alloc_buffer(c->kue_xfer, KUE_BUFSZ); - if (c->kue_buf == NULL) - return ENOBUFS; + int error = usbd_create_xfer(sc->kue_ep[KUE_ENDPT_TX], + KUE_BUFSZ, 0, 0, &c->kue_xfer); + if (error) + return error; + c->kue_buf = usbd_get_buffer(c->kue_xfer); } } @@ -731,9 +729,8 @@ kue_rxeof(struct usbd_xfer *xfer, void * done: /* Setup new transfer. */ - usbd_setup_xfer(c->kue_xfer, sc->kue_ep[KUE_ENDPT_RX], - c, c->kue_buf, KUE_BUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, kue_rxeof); + usbd_setup_xfer(c->kue_xfer, c, c->kue_buf, KUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, kue_rxeof); usbd_transfer(c->kue_xfer); DPRINTFN(10,("%s: %s: start rx\n", device_xname(sc->kue_dev), @@ -810,9 +807,8 @@ kue_send(struct kue_softc *sc, struct mb total_len = 2 + m->m_pkthdr.len; total_len = roundup2(total_len, 64); - usbd_setup_xfer(c->kue_xfer, sc->kue_ep[KUE_ENDPT_TX], - c, c->kue_buf, total_len, 0, USBD_DEFAULT_TIMEOUT, - kue_txeof); + usbd_setup_xfer(c->kue_xfer, c, c->kue_buf, total_len, 0, + USBD_DEFAULT_TIMEOUT, kue_txeof); /* Transmit */ err = usbd_transfer(c->kue_xfer); @@ -905,28 +901,37 @@ kue_init(void *xsc) #endif kue_setword(sc, KUE_CMD_SET_URB_SIZE, 64); + /* Load the multicast filter. */ + kue_setmulti(sc); + + if (sc->kue_ep[KUE_ENDPT_RX] == NULL) { + if (kue_open_pipes(sc)) { + splx(s); + return; + } + } /* Init TX ring. */ - if (kue_tx_list_init(sc) == ENOBUFS) { + if (kue_tx_list_init(sc)) { printf("%s: tx list init failed\n", device_xname(sc->kue_dev)); splx(s); return; } /* Init RX ring. */ - if (kue_rx_list_init(sc) == ENOBUFS) { + if (kue_rx_list_init(sc)) { printf("%s: rx list init failed\n", device_xname(sc->kue_dev)); splx(s); return; } - /* Load the multicast filter. */ - kue_setmulti(sc); - - if (sc->kue_ep[KUE_ENDPT_RX] == NULL) { - if (kue_open_pipes(sc)) { - splx(s); - return; - } + /* Start up the receive pipe. */ + for (size_t i = 0; i < KUE_RX_LIST_CNT; i++) { + struct kue_chain *c = &sc->kue_cdata.kue_rx_chain[i]; + usbd_setup_xfer(c->kue_xfer, c, c->kue_buf, KUE_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, kue_rxeof); + DPRINTFN(5,("%s: %s: start read\n", device_xname(sc->kue_dev), + __func__)); + usbd_transfer(c->kue_xfer); } ifp->if_flags |= IFF_RUNNING; @@ -939,8 +944,6 @@ static int kue_open_pipes(struct kue_softc *sc) { usbd_status err; - struct kue_chain *c; - int i; DPRINTFN(5,("%s: %s: enter\n", device_xname(sc->kue_dev),__func__)); @@ -961,18 +964,6 @@ kue_open_pipes(struct kue_softc *sc) return EIO; } - /* Start up the receive pipe. */ - for (i = 0; i < KUE_RX_LIST_CNT; i++) { - c = &sc->kue_cdata.kue_rx_chain[i]; - usbd_setup_xfer(c->kue_xfer, sc->kue_ep[KUE_ENDPT_RX], - c, c->kue_buf, KUE_BUFSZ, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - kue_rxeof); - DPRINTFN(5,("%s: %s: start read\n", device_xname(sc->kue_dev), - __func__)); - usbd_transfer(c->kue_xfer); - } - return 0; } @@ -1144,7 +1135,7 @@ kue_stop(struct kue_softc *sc) /* Free RX resources. */ for (i = 0; i < KUE_RX_LIST_CNT; i++) { if (sc->kue_cdata.kue_rx_chain[i].kue_xfer != NULL) { - usbd_free_xfer(sc->kue_cdata.kue_rx_chain[i].kue_xfer); + usbd_destroy_xfer(sc->kue_cdata.kue_rx_chain[i].kue_xfer); sc->kue_cdata.kue_rx_chain[i].kue_xfer = NULL; } } @@ -1152,7 +1143,7 @@ kue_stop(struct kue_softc *sc) /* Free TX resources. */ for (i = 0; i < KUE_TX_LIST_CNT; i++) { if (sc->kue_cdata.kue_tx_chain[i].kue_xfer != NULL) { - usbd_free_xfer(sc->kue_cdata.kue_tx_chain[i].kue_xfer); + usbd_destroy_xfer(sc->kue_cdata.kue_tx_chain[i].kue_xfer); sc->kue_cdata.kue_tx_chain[i].kue_xfer = NULL; } } Index: sys/dev/usb/if_otus.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_otus.c,v retrieving revision 1.25.6.4 diff -u -p -r1.25.6.4 if_otus.c --- sys/dev/usb/if_otus.c 21 Mar 2015 11:33:37 -0000 1.25.6.4 +++ sys/dev/usb/if_otus.c 4 Oct 2015 08:34:34 -0000 @@ -1031,23 +1031,21 @@ otus_open_pipes(struct otus_softc *sc) goto fail; } - if (otus_alloc_tx_data_list(sc) != 0) { + if (otus_alloc_tx_data_list(sc)) { aprint_error_dev(sc->sc_dev, "could not allocate Tx xfers\n"); goto fail; } - if (otus_alloc_rx_data_list(sc) != 0) { + if (otus_alloc_rx_data_list(sc)) { aprint_error_dev(sc->sc_dev, "could not allocate Rx xfers\n"); goto fail; } for (i = 0; i < OTUS_RX_DATA_LIST_COUNT; i++) { - struct otus_rx_data *data; + struct otus_rx_data *data = &sc->sc_rx_data[i]; - data = &sc->sc_rx_data[i]; - usbd_setup_xfer(data->xfer, sc->sc_data_rx_pipe, data, data->buf, - OTUS_RXBUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, otus_rxeof); + usbd_setup_xfer(data->xfer, data, data->buf, OTUS_RXBUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, otus_rxeof); error = usbd_transfer(data->xfer); if (error != USBD_IN_PROGRESS && error != 0) { aprint_error_dev(sc->sc_dev, @@ -1093,19 +1091,14 @@ otus_alloc_tx_cmd(struct otus_softc *sc) DPRINTFN(DBG_FN, sc, "\n"); cmd = &sc->sc_tx_cmd; - cmd->xfer = usbd_alloc_xfer(sc->sc_udev); - if (cmd->xfer == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer\n"); - return ENOMEM; - } - cmd->buf = usbd_alloc_buffer(cmd->xfer, OTUS_MAX_TXCMDSZ); - if (cmd->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer buffer\n"); - usbd_free_xfer(cmd->xfer); - return ENOMEM; - } + + int error = usbd_create_xfer(sc->sc_cmd_tx_pipe, OTUS_MAX_TXCMDSZ, + USBD_FORCE_SHORT_XFER, 0, &cmd->xfer); + if (error) + return error; + + cmd->buf = usbd_get_buffer(cmd->xfer); + return 0; } @@ -1120,7 +1113,7 @@ otus_free_tx_cmd(struct otus_softc *sc) mutex_enter(&sc->sc_cmd_mtx); if (sc->sc_tx_cmd.xfer != NULL) - usbd_free_xfer(sc->sc_tx_cmd.xfer); + usbd_destroy_xfer(sc->sc_tx_cmd.xfer); sc->sc_tx_cmd.xfer = NULL; sc->sc_tx_cmd.buf = NULL; mutex_exit(&sc->sc_cmd_mtx); @@ -1142,20 +1135,14 @@ otus_alloc_tx_data_list(struct otus_soft data->sc = sc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_data_tx_pipe, OTUS_TXBUFSZ, + USBD_FORCE_SHORT_XFER, 0, &data->xfer); + if (error) { aprint_error_dev(sc->sc_dev, "could not allocate xfer\n"); - error = ENOMEM; - break; - } - data->buf = usbd_alloc_buffer(data->xfer, OTUS_TXBUFSZ); - if (data->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; break; } + data->buf = usbd_get_buffer(data->xfer); /* Append this Tx buffer to our free list. */ TAILQ_INSERT_TAIL(&sc->sc_tx_free_list, data, next); } @@ -1177,7 +1164,7 @@ otus_free_tx_data_list(struct otus_softc for (i = 0; i < OTUS_TX_DATA_LIST_COUNT; i++) { if (sc->sc_tx_data[i].xfer != NULL) - usbd_free_xfer(sc->sc_tx_data[i].xfer); + usbd_destroy_xfer(sc->sc_tx_data[i].xfer); } } @@ -1194,20 +1181,15 @@ otus_alloc_rx_data_list(struct otus_soft data->sc = sc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_data_rx_pipe, OTUS_RXBUFSZ, + USBD_SHORT_XFER_OK, 0, &data->xfer); + + if (error) { aprint_error_dev(sc->sc_dev, "could not allocate xfer\n"); - error = ENOMEM; - goto fail; - } - data->buf = usbd_alloc_buffer(data->xfer, OTUS_RXBUFSZ); - if (data->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; goto fail; } + data->buf = usbd_get_buffer(data->xfer); } return 0; @@ -1227,7 +1209,7 @@ otus_free_rx_data_list(struct otus_softc for (i = 0; i < OTUS_RX_DATA_LIST_COUNT; i++) if (sc->sc_rx_data[i].xfer != NULL) - usbd_free_xfer(sc->sc_rx_data[i].xfer); + usbd_destroy_xfer(sc->sc_rx_data[i].xfer); } Static void @@ -1440,7 +1422,7 @@ otus_cmd(struct otus_softc *sc, uint8_t s = splusb(); cmd->odata = odata; cmd->done = 0; - usbd_setup_xfer(cmd->xfer, sc->sc_cmd_tx_pipe, cmd, cmd->buf, xferlen, + usbd_setup_xfer(cmd->xfer, cmd, cmd->buf, xferlen, USBD_FORCE_SHORT_XFER, OTUS_CMD_TIMEOUT, NULL); error = usbd_sync_transfer(cmd->xfer); if (error != 0) { @@ -1897,7 +1879,7 @@ otus_rxeof(struct usbd_xfer *xfer, void } resubmit: - usbd_setup_xfer(xfer, sc->sc_data_rx_pipe, data, data->buf, OTUS_RXBUFSZ, + usbd_setup_xfer(xfer, data, data->buf, OTUS_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, otus_rxeof); (void)usbd_transfer(data->xfer); } @@ -2054,7 +2036,7 @@ otus_tx(struct otus_softc *sc, struct mb DPRINTFN(DBG_TX, sc, "queued len=%d mac=0x%04x phy=0x%08x rate=%d\n", head->len, head->macctl, head->phyctl, otus_rates[ridx].rate); - usbd_setup_xfer(data->xfer, sc->sc_data_tx_pipe, data, data->buf, xferlen, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, OTUS_TX_TIMEOUT, otus_txeof); error = usbd_transfer(data->xfer); if (__predict_false( Index: sys/dev/usb/if_rum.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_rum.c,v retrieving revision 1.48.6.9 diff -u -p -r1.48.6.9 if_rum.c --- sys/dev/usb/if_rum.c 29 Sep 2015 11:38:28 -0000 1.48.6.9 +++ sys/dev/usb/if_rum.c 4 Oct 2015 08:34:35 -0000 @@ -509,7 +509,7 @@ rum_detach(device_t self, int flags) callout_stop(&sc->sc_amrr_ch); if (sc->amrr_xfer != NULL) { - usbd_free_xfer(sc->amrr_xfer); + usbd_destroy_xfer(sc->amrr_xfer); sc->amrr_xfer = NULL; } @@ -547,20 +547,12 @@ rum_alloc_tx_list(struct rum_softc *sc) data->sc = sc; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_tx_pipeh, + RT2573_TX_DESC_SIZE + IEEE80211_MAX_LEN, + USBD_FORCE_SHORT_XFER, 0, &data->xfer); + if (error) { printf("%s: could not allocate tx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } - - data->buf = usbd_alloc_buffer(data->xfer, - RT2573_TX_DESC_SIZE + IEEE80211_MAX_LEN); - if (data->buf == NULL) { - printf("%s: could not allocate tx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } @@ -584,7 +576,7 @@ rum_free_tx_list(struct rum_softc *sc) data = &sc->tx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } @@ -606,18 +598,11 @@ rum_alloc_rx_list(struct rum_softc *sc) data->sc = sc; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_rx_pipeh, MCLBYTES, + USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { printf("%s: could not allocate rx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } - - if (usbd_alloc_buffer(data->xfer, MCLBYTES) == NULL) { - printf("%s: could not allocate rx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } @@ -656,7 +641,7 @@ rum_free_rx_list(struct rum_softc *sc) data = &sc->rx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } @@ -928,8 +913,8 @@ rum_rxeof(struct usbd_xfer *xfer, void * DPRINTFN(15, ("rx done\n")); skip: /* setup a new transfer */ - usbd_setup_xfer(xfer, sc->sc_rx_pipeh, data, data->buf, MCLBYTES, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, rum_rxeof); + usbd_setup_xfer(xfer, data, data->buf, MCLBYTES, USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, rum_rxeof); usbd_transfer(xfer); } @@ -1197,7 +1182,7 @@ rum_tx_data(struct rum_softc *sc, struct /* mbuf is no longer needed */ m_freem(mprot); - usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, RUM_TX_TIMEOUT, rum_txeof); error = usbd_transfer(data->xfer); @@ -1264,7 +1249,7 @@ rum_tx_data(struct rum_softc *sc, struct /* mbuf is no longer needed */ m_freem(m0); - usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf, xferlen, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, RUM_TX_TIMEOUT, rum_txeof); error = usbd_transfer(data->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) @@ -1982,7 +1967,6 @@ rum_init(struct ifnet *ifp) #define N(a) (sizeof (a) / sizeof ((a)[0])) struct rum_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; - struct rum_rx_data *data; uint32_t tmp; usbd_status error = 0; unsigned int i, ntries; @@ -2035,8 +2019,10 @@ rum_init(struct ifnet *ifp) /* * Allocate xfer for AMRR statistics requests. */ - sc->amrr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->amrr_xfer == NULL) { + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->sc_udev); + error = usbd_create_xfer(pipe0, sizeof(sc->sta), 0, 0, + &sc->amrr_xfer); + if (error) { printf("%s: could not allocate AMRR xfer\n", device_xname(sc->sc_dev)); goto fail; @@ -2082,10 +2068,12 @@ rum_init(struct ifnet *ifp) * Start up the receive pipe. */ for (i = 0; i < RUM_RX_LIST_COUNT; i++) { + struct rum_rx_data *data; + data = &sc->rx_data[i]; - usbd_setup_xfer(data->xfer, sc->sc_rx_pipeh, data, data->buf, - MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, rum_rxeof); + usbd_setup_xfer(data->xfer, data, data->buf, MCLBYTES, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, rum_rxeof); error = usbd_transfer(data->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) { @@ -2146,7 +2134,7 @@ rum_stop(struct ifnet *ifp, int disable) rum_write(sc, RT2573_MAC_CSR1, 0); if (sc->amrr_xfer != NULL) { - usbd_free_xfer(sc->amrr_xfer); + usbd_destroy_xfer(sc->amrr_xfer); sc->amrr_xfer = NULL; } Index: sys/dev/usb/if_run.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_run.c,v retrieving revision 1.10.6.6 diff -u -p -r1.10.6.6 if_run.c --- sys/dev/usb/if_run.c 29 Sep 2015 11:38:28 -0000 1.10.6.6 +++ sys/dev/usb/if_run.c 4 Oct 2015 08:34:36 -0000 @@ -733,16 +733,12 @@ run_alloc_rx_ring(struct run_softc *sc) data->sc = sc; /* backpointer for callbacks */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->rxq.pipeh, RUN_MAX_RXSZ, + USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) goto fail; - } - data->buf = usbd_alloc_buffer(data->xfer, RUN_MAX_RXSZ); - if (data->buf == NULL) { - error = ENOMEM; - goto fail; - } + + data->buf = usbd_get_buffer(data->xfer); } if (error != 0) fail: run_free_rx_ring(sc); @@ -762,7 +758,7 @@ run_free_rx_ring(struct run_softc *sc) } for (i = 0; i < RUN_RX_RING_COUNT; i++) { if (rxq->data[i].xfer != NULL) - usbd_free_xfer(rxq->data[i].xfer); + usbd_destroy_xfer(rxq->data[i].xfer); rxq->data[i].xfer = NULL; } } @@ -785,16 +781,12 @@ run_alloc_tx_ring(struct run_softc *sc, data->sc = sc; /* backpointer for callbacks */ data->qid = qid; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(txq->pipeh, RUN_MAX_TXSZ, + USBD_FORCE_SHORT_XFER, 0, &data->xfer); + if (error) goto fail; - } - data->buf = usbd_alloc_buffer(data->xfer, RUN_MAX_TXSZ); - if (data->buf == NULL) { - error = ENOMEM; - goto fail; - } + + data->buf = usbd_get_buffer(data->xfer); /* zeroize the TXD + TXWI part */ memset(data->buf, 0, sizeof(struct rt2870_txd) + sizeof(struct rt2860_txwi)); @@ -817,7 +809,7 @@ run_free_tx_ring(struct run_softc *sc, i } for (i = 0; i < RUN_TX_RING_COUNT; i++) { if (txq->data[i].xfer != NULL) - usbd_free_xfer(txq->data[i].xfer); + usbd_destroy_xfer(txq->data[i].xfer); txq->data[i].xfer = NULL; } } @@ -2190,7 +2182,7 @@ run_rxeof(struct usbd_xfer *xfer, void * } skip: /* setup a new transfer */ - usbd_setup_xfer(xfer, sc->rxq.pipeh, data, data->buf, RUN_MAX_RXSZ, + usbd_setup_xfer(xfer, data, data->buf, RUN_MAX_RXSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, run_rxeof); (void)usbd_transfer(data->xfer); } @@ -2349,7 +2341,7 @@ run_tx(struct run_softc *sc, struct mbuf xferlen += sizeof(*txd) + 4; - usbd_setup_xfer(data->xfer, ring->pipeh, data, data->buf, xferlen, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, RUN_TX_TIMEOUT, run_txeof); error = usbd_transfer(data->xfer); if (__predict_false(error != USBD_IN_PROGRESS && @@ -3624,9 +3616,8 @@ run_init(struct ifnet *ifp) for (i = 0; i < RUN_RX_RING_COUNT; i++) { struct run_rx_data *data = &sc->rxq.data[i]; - usbd_setup_xfer(data->xfer, sc->rxq.pipeh, data, data->buf, - RUN_MAX_RXSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, run_rxeof); + usbd_setup_xfer(data->xfer, data, data->buf, RUN_MAX_RXSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, run_rxeof); error = usbd_transfer(data->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) Index: sys/dev/usb/if_smsc.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_smsc.c,v retrieving revision 1.22.2.7 diff -u -p -r1.22.2.7 if_smsc.c --- sys/dev/usb/if_smsc.c 22 Sep 2015 12:06:01 -0000 1.22.2.7 +++ sys/dev/usb/if_smsc.c 4 Oct 2015 08:34:36 -0000 @@ -560,20 +560,6 @@ smsc_init(struct ifnet *ifp) /* Reset the ethernet interface. */ smsc_reset(sc); - /* Init RX ring. */ - if (smsc_rx_list_init(sc) == ENOBUFS) { - aprint_error_dev(sc->sc_dev, "rx list init failed\n"); - splx(s); - return EIO; - } - - /* Init TX ring. */ - if (smsc_tx_list_init(sc) == ENOBUFS) { - aprint_error_dev(sc->sc_dev, "tx list init failed\n"); - splx(s); - return EIO; - } - /* Load the multicast filter. */ smsc_setmulti(sc); @@ -599,13 +585,25 @@ smsc_init(struct ifnet *ifp) return EIO; } + /* Init RX ring. */ + if (smsc_rx_list_init(sc)) { + aprint_error_dev(sc->sc_dev, "rx list init failed\n"); + splx(s); + return EIO; + } + + /* Init TX ring. */ + if (smsc_tx_list_init(sc)) { + aprint_error_dev(sc->sc_dev, "tx list init failed\n"); + splx(s); + return EIO; + } + /* Start up the receive pipe. */ for (i = 0; i < SMSC_RX_LIST_CNT; i++) { c = &sc->sc_cdata.rx_chain[i]; - usbd_setup_xfer(c->sc_xfer, sc->sc_ep[SMSC_ENDPT_RX], - c, c->sc_buf, sc->sc_bufsz, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, smsc_rxeof); + usbd_setup_xfer(c->sc_xfer, c, c->sc_buf, sc->sc_bufsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, smsc_rxeof); usbd_transfer(c->sc_xfer); } @@ -733,7 +731,7 @@ smsc_stop(struct ifnet *ifp, int disable sc->sc_cdata.rx_chain[i].sc_mbuf = NULL; } if (sc->sc_cdata.rx_chain[i].sc_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.rx_chain[i].sc_xfer); + usbd_destroy_xfer(sc->sc_cdata.rx_chain[i].sc_xfer); sc->sc_cdata.rx_chain[i].sc_xfer = NULL; } } @@ -745,7 +743,7 @@ smsc_stop(struct ifnet *ifp, int disable sc->sc_cdata.tx_chain[i].sc_mbuf = NULL; } if (sc->sc_cdata.tx_chain[i].sc_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.tx_chain[i].sc_xfer); + usbd_destroy_xfer(sc->sc_cdata.tx_chain[i].sc_xfer); sc->sc_cdata.tx_chain[i].sc_xfer = NULL; } } @@ -1416,9 +1414,7 @@ smsc_rxeof(struct usbd_xfer *xfer, void done: /* Setup new transfer. */ - usbd_setup_xfer(xfer, sc->sc_ep[SMSC_ENDPT_RX], - c, c->sc_buf, sc->sc_bufsz, - USBD_SHORT_XFER_OK, + usbd_setup_xfer(xfer, c, c->sc_buf, sc->sc_bufsz, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, smsc_rxeof); usbd_transfer(xfer); @@ -1483,15 +1479,12 @@ smsc_tx_list_init(struct smsc_softc *sc) c->sc_idx = i; c->sc_mbuf = NULL; if (c->sc_xfer == NULL) { - c->sc_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->sc_xfer == NULL) - return ENOBUFS; - c->sc_buf = usbd_alloc_buffer(c->sc_xfer, - sc->sc_bufsz); - if (c->sc_buf == NULL) { - usbd_free_xfer(c->sc_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_ep[SMSC_ENDPT_TX], + sc->sc_bufsz, USBD_FORCE_SHORT_XFER, 0, + &c->sc_xfer); + if (error) + ; + c->sc_buf = usbd_get_buffer(c->sc_xfer); } } @@ -1512,15 +1505,11 @@ smsc_rx_list_init(struct smsc_softc *sc) c->sc_idx = i; c->sc_mbuf = NULL; if (c->sc_xfer == NULL) { - c->sc_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->sc_xfer == NULL) - return ENOBUFS; - c->sc_buf = usbd_alloc_buffer(c->sc_xfer, - sc->sc_bufsz); - if (c->sc_buf == NULL) { - usbd_free_xfer(c->sc_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_ep[SMSC_ENDPT_RX], + sc->sc_bufsz, USBD_SHORT_XFER_OK, 0, &c->sc_xfer); + if (error) + return error; + c->sc_buf = usbd_get_buffer(c->sc_xfer); } } @@ -1577,9 +1566,8 @@ smsc_encap(struct smsc_softc *sc, struct c->sc_mbuf = m; - usbd_setup_xfer(c->sc_xfer, sc->sc_ep[SMSC_ENDPT_TX], - c, c->sc_buf, frm_len, USBD_FORCE_SHORT_XFER, - 10000, smsc_txeof); + usbd_setup_xfer(c->sc_xfer, c, c->sc_buf, frm_len, + USBD_FORCE_SHORT_XFER, 10000, smsc_txeof); err = usbd_transfer(c->sc_xfer); /* XXXNH get task to stop interface */ Index: sys/dev/usb/if_udav.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_udav.c,v retrieving revision 1.43.4.6 diff -u -p -r1.43.4.6 if_udav.c --- sys/dev/usb/if_udav.c 6 Jun 2015 14:40:14 -0000 1.43.4.6 +++ sys/dev/usb/if_udav.c 4 Oct 2015 08:34:36 -0000 @@ -662,20 +662,6 @@ udav_init(struct ifnet *ifp) else UDAV_CLRBIT(sc, UDAV_RCR, UDAV_RCR_ALL|UDAV_RCR_PRMSC); - /* Initialize transmit ring */ - if (udav_tx_list_init(sc) == ENOBUFS) { - printf("%s: tx list init failed\n", device_xname(sc->sc_dev)); - splx(s); - return EIO; - } - - /* Initialize receive ring */ - if (udav_rx_list_init(sc) == ENOBUFS) { - printf("%s: rx list init failed\n", device_xname(sc->sc_dev)); - splx(s); - return EIO; - } - /* Load the multicast filter */ udav_setmulti(sc); @@ -698,6 +684,20 @@ udav_init(struct ifnet *ifp) } } + /* Initialize transmit ring */ + if (udav_tx_list_init(sc)) { + printf("%s: tx list init failed\n", device_xname(sc->sc_dev)); + splx(s); + return EIO; + } + + /* Initialize receive ring */ + if (udav_rx_list_init(sc)) { + printf("%s: rx list init failed\n", device_xname(sc->sc_dev)); + splx(s); + return EIO; + } + ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -875,10 +875,8 @@ udav_openpipes(struct udav_softc *sc) /* Start up the receive pipe. */ for (i = 0; i < UDAV_RX_LIST_CNT; i++) { c = &sc->sc_cdata.udav_rx_chain[i]; - usbd_setup_xfer(c->udav_xfer, sc->sc_pipe_rx, - c, c->udav_buf, UDAV_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, udav_rxeof); + usbd_setup_xfer(c->udav_xfer, c, c->udav_buf, UDAV_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, udav_rxeof); (void)usbd_transfer(c->udav_xfer); DPRINTF(("%s: %s: start read\n", device_xname(sc->sc_dev), __func__)); @@ -943,14 +941,11 @@ udav_rx_list_init(struct udav_softc *sc) if (udav_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; if (c->udav_xfer == NULL) { - c->udav_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->udav_xfer == NULL) - return ENOBUFS; - c->udav_buf = usbd_alloc_buffer(c->udav_xfer, UDAV_BUFSZ); - if (c->udav_buf == NULL) { - usbd_free_xfer(c->udav_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_pipe_rx, UDAV_BUFSZ, + USBD_SHORT_XFER_OK, 0, &c->udav_xfer); + if (error) + return error; + c->udav_buf = usbd_get_buffer(c->udav_xfer); } } @@ -973,14 +968,11 @@ udav_tx_list_init(struct udav_softc *sc) c->udav_idx = i; c->udav_mbuf = NULL; if (c->udav_xfer == NULL) { - c->udav_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->udav_xfer == NULL) - return ENOBUFS; - c->udav_buf = usbd_alloc_buffer(c->udav_xfer, UDAV_BUFSZ); - if (c->udav_buf == NULL) { - usbd_free_xfer(c->udav_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_pipe_tx, UDAV_BUFSZ, + USBD_FORCE_SHORT_XFER, 0, &c->udav_xfer); + if (error) + return error; + c->udav_buf = usbd_get_buffer(c->udav_xfer); } } @@ -1051,9 +1043,8 @@ udav_send(struct udav_softc *sc, struct c->udav_buf[1] = (uint8_t)(total_len >> 8); total_len += 2; - usbd_setup_xfer(c->udav_xfer, sc->sc_pipe_tx, c, c->udav_buf, total_len, - USBD_FORCE_SHORT_XFER, - UDAV_TX_TIMEOUT, udav_txeof); + usbd_setup_xfer(c->udav_xfer, c, c->udav_buf, total_len, + USBD_FORCE_SHORT_XFER, UDAV_TX_TIMEOUT, udav_txeof); /* Transmit */ sc->sc_refcnt++; @@ -1210,9 +1201,8 @@ udav_rxeof(struct usbd_xfer *xfer, void done: /* Setup new transfer */ - usbd_setup_xfer(xfer, sc->sc_pipe_rx, c, c->udav_buf, UDAV_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, udav_rxeof); + usbd_setup_xfer(xfer, c, c->udav_buf, UDAV_BUFSZ, USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, udav_rxeof); sc->sc_refcnt++; usbd_transfer(xfer); if (--sc->sc_refcnt < 0) @@ -1347,7 +1337,7 @@ udav_stop(struct ifnet *ifp, int disable sc->sc_cdata.udav_rx_chain[i].udav_mbuf = NULL; } if (sc->sc_cdata.udav_rx_chain[i].udav_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.udav_rx_chain[i].udav_xfer); + usbd_destroy_xfer(sc->sc_cdata.udav_rx_chain[i].udav_xfer); sc->sc_cdata.udav_rx_chain[i].udav_xfer = NULL; } } @@ -1359,7 +1349,7 @@ udav_stop(struct ifnet *ifp, int disable sc->sc_cdata.udav_tx_chain[i].udav_mbuf = NULL; } if (sc->sc_cdata.udav_tx_chain[i].udav_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.udav_tx_chain[i].udav_xfer); + usbd_destroy_xfer(sc->sc_cdata.udav_tx_chain[i].udav_xfer); sc->sc_cdata.udav_tx_chain[i].udav_xfer = NULL; } } Index: sys/dev/usb/if_upgt.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_upgt.c,v retrieving revision 1.12.4.6 diff -u -p -r1.12.4.6 if_upgt.c --- sys/dev/usb/if_upgt.c 26 Jun 2015 15:39:11 -0000 1.12.4.6 +++ sys/dev/usb/if_upgt.c 4 Oct 2015 08:34:37 -0000 @@ -399,7 +399,7 @@ upgt_attach_hook(device_t arg) */ struct upgt_data *data_rx = &sc->rx_data; - usbd_setup_xfer(data_rx->xfer, sc->sc_rx_pipeh, data_rx, data_rx->buf, + usbd_setup_xfer(data_rx->xfer, data_rx, data_rx->buf, MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, upgt_rx_cb); error = usbd_transfer(data_rx->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) { @@ -1660,9 +1660,8 @@ upgt_tx_task(void *arg) DPRINTF(2, "%s: TX start data sending\n", device_xname(sc->sc_dev)); - usbd_setup_xfer(data_tx->xfer, sc->sc_tx_pipeh, data_tx, - data_tx->buf, len, USBD_FORCE_SHORT_XFER, - UPGT_USB_TIMEOUT, NULL); + usbd_setup_xfer(data_tx->xfer, data_tx, data_tx->buf, len, + USBD_FORCE_SHORT_XFER, UPGT_USB_TIMEOUT, NULL); error = usbd_transfer(data_tx->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) { @@ -1802,7 +1801,7 @@ upgt_rx_cb(struct usbd_xfer *xfer, void } skip: /* setup new transfer */ - usbd_setup_xfer(xfer, sc->sc_rx_pipeh, data_rx, data_rx->buf, MCLBYTES, + usbd_setup_xfer(xfer, data_rx, data_rx->buf, MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, upgt_rx_cb); (void)usbd_transfer(xfer); } @@ -2250,19 +2249,15 @@ upgt_alloc_tx(struct upgt_softc *sc) data_tx->sc = sc; - data_tx->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data_tx->xfer == NULL) { + int err = usbd_create_xfer(sc->sc_tx_pipeh, MCLBYTES, 0, 0, + &data_tx->xfer); + if (err) { aprint_error_dev(sc->sc_dev, "could not allocate TX xfer\n"); - return ENOMEM; + return err; } - data_tx->buf = usbd_alloc_buffer(data_tx->xfer, MCLBYTES); - if (data_tx->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate TX buffer\n"); - return ENOMEM; - } + data_tx->buf = usbd_get_buffer(data_tx->xfer); } return 0; @@ -2275,18 +2270,14 @@ upgt_alloc_rx(struct upgt_softc *sc) data_rx->sc = sc; - data_rx->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data_rx->xfer == NULL) { + int err = usbd_create_xfer(sc->sc_rx_pipeh, MCLBYTES, + USBD_SHORT_XFER_OK, 0, &data_rx->xfer); + if (err) { aprint_error_dev(sc->sc_dev, "could not allocate RX xfer\n"); - return ENOMEM; + return err; } - data_rx->buf = usbd_alloc_buffer(data_rx->xfer, MCLBYTES); - if (data_rx->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate RX buffer\n"); - return ENOMEM; - } + data_rx->buf = usbd_get_buffer(data_rx->xfer); return 0; } @@ -2298,18 +2289,14 @@ upgt_alloc_cmd(struct upgt_softc *sc) data_cmd->sc = sc; - data_cmd->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data_cmd->xfer == NULL) { + int err = usbd_create_xfer(sc->sc_tx_pipeh, MCLBYTES, + USBD_FORCE_SHORT_XFER, 0, &data_cmd->xfer); + if (err) { aprint_error_dev(sc->sc_dev, "could not allocate RX xfer\n"); - return ENOMEM; + return err; } - data_cmd->buf = usbd_alloc_buffer(data_cmd->xfer, MCLBYTES); - if (data_cmd->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate RX buffer\n"); - return ENOMEM; - } + data_cmd->buf = usbd_get_buffer(data_cmd->xfer); mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_SOFTNET); @@ -2325,7 +2312,7 @@ upgt_free_tx(struct upgt_softc *sc) struct upgt_data *data_tx = &sc->tx_data[i]; if (data_tx->xfer != NULL) { - usbd_free_xfer(data_tx->xfer); + usbd_destroy_xfer(data_tx->xfer); data_tx->xfer = NULL; } @@ -2339,7 +2326,7 @@ upgt_free_rx(struct upgt_softc *sc) struct upgt_data *data_rx = &sc->rx_data; if (data_rx->xfer != NULL) { - usbd_free_xfer(data_rx->xfer); + usbd_destroy_xfer(data_rx->xfer); data_rx->xfer = NULL; } @@ -2352,7 +2339,7 @@ upgt_free_cmd(struct upgt_softc *sc) struct upgt_data *data_cmd = &sc->cmd_data; if (data_cmd->xfer != NULL) { - usbd_free_xfer(data_cmd->xfer); + usbd_destroy_xfer(data_cmd->xfer); data_cmd->xfer = NULL; } @@ -2365,8 +2352,8 @@ upgt_bulk_xmit(struct upgt_softc *sc, st { usbd_status status; - status = usbd_bulk_transfer(data->xfer, pipeh, - flags, UPGT_USB_TIMEOUT, data->buf, size); + status = usbd_bulk_transfer(data->xfer, pipeh, flags, UPGT_USB_TIMEOUT, + data->buf, size); if (status != USBD_NORMAL_COMPLETION) { aprint_error_dev(sc->sc_dev, "%s: error %s\n", __func__, usbd_errstr(status)); Index: sys/dev/usb/if_upl.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_upl.c,v retrieving revision 1.47.4.7 diff -u -p -r1.47.4.7 if_upl.c --- sys/dev/usb/if_upl.c 6 Jun 2015 14:40:14 -0000 1.47.4.7 +++ sys/dev/usb/if_upl.c 4 Oct 2015 08:34:37 -0000 @@ -434,14 +434,11 @@ upl_rx_list_init(struct upl_softc *sc) if (upl_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; if (c->upl_xfer == NULL) { - c->upl_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->upl_xfer == NULL) - return ENOBUFS; - c->upl_buf = usbd_alloc_buffer(c->upl_xfer, UPL_BUFSZ); - if (c->upl_buf == NULL) { - usbd_free_xfer(c->upl_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_ep[UPL_ENDPT_RX], + UPL_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->upl_xfer); + if (error) + return error; + c->upl_buf = usbd_get_buffer(c->upl_xfer); } } @@ -464,14 +461,11 @@ upl_tx_list_init(struct upl_softc *sc) c->upl_idx = i; c->upl_mbuf = NULL; if (c->upl_xfer == NULL) { - c->upl_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->upl_xfer == NULL) - return ENOBUFS; - c->upl_buf = usbd_alloc_buffer(c->upl_xfer, UPL_BUFSZ); - if (c->upl_buf == NULL) { - usbd_free_xfer(c->upl_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_ep[UPL_ENDPT_TX], + UPL_BUFSZ, 0, 0, &c->upl_xfer); + if (error) + return error; + c->upl_buf = usbd_get_buffer(c->upl_xfer); } } @@ -553,9 +547,8 @@ upl_rxeof(struct usbd_xfer *xfer, void * done: #if 1 /* Setup new transfer. */ - usbd_setup_xfer(c->upl_xfer, sc->sc_ep[UPL_ENDPT_RX], - c, c->upl_buf, UPL_BUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, upl_rxeof); + usbd_setup_xfer(c->upl_xfer, c, c->upl_buf, UPL_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, upl_rxeof); usbd_transfer(c->upl_xfer); DPRINTFN(10,("%s: %s: start rx\n", device_xname(sc->sc_dev), @@ -633,9 +626,8 @@ upl_send(struct upl_softc *sc, struct mb DPRINTFN(10,("%s: %s: total_len=%d\n", device_xname(sc->sc_dev), __func__, total_len)); - usbd_setup_xfer(c->upl_xfer, sc->sc_ep[UPL_ENDPT_TX], - c, c->upl_buf, total_len, 0, USBD_DEFAULT_TIMEOUT, - upl_txeof); + usbd_setup_xfer(c->upl_xfer, c, c->upl_buf, total_len, 0, + USBD_DEFAULT_TIMEOUT, upl_txeof); /* Transmit */ err = usbd_transfer(c->upl_xfer); @@ -707,25 +699,33 @@ upl_init(void *xsc) s = splnet(); + if (sc->sc_ep[UPL_ENDPT_RX] == NULL) { + if (upl_openpipes(sc)) { + splx(s); + return; + } + } /* Init TX ring. */ - if (upl_tx_list_init(sc) == ENOBUFS) { + if (upl_tx_list_init(sc)) { printf("%s: tx list init failed\n", device_xname(sc->sc_dev)); splx(s); return; } /* Init RX ring. */ - if (upl_rx_list_init(sc) == ENOBUFS) { + if (upl_rx_list_init(sc)) { printf("%s: rx list init failed\n", device_xname(sc->sc_dev)); splx(s); return; } - if (sc->sc_ep[UPL_ENDPT_RX] == NULL) { - if (upl_openpipes(sc)) { - splx(s); - return; - } + /* Start up the receive pipe. */ + for (int i = 0; i < UPL_RX_LIST_CNT; i++) { + struct upl_chain *c = &sc->sc_cdata.upl_rx_chain[i]; + usbd_setup_xfer(c->upl_xfer, c, c->upl_buf, UPL_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, + upl_rxeof); + usbd_transfer(c->upl_xfer); } ifp->if_flags |= IFF_RUNNING; @@ -737,9 +737,7 @@ upl_init(void *xsc) Static int upl_openpipes(struct upl_softc *sc) { - struct upl_chain *c; usbd_status err; - int i; /* Open RX and TX pipes. */ err = usbd_open_pipe(sc->sc_iface, sc->sc_ed[UPL_ENDPT_RX], @@ -766,19 +764,6 @@ upl_openpipes(struct upl_softc *sc) return EIO; } - -#if 1 - /* Start up the receive pipe. */ - for (i = 0; i < UPL_RX_LIST_CNT; i++) { - c = &sc->sc_cdata.upl_rx_chain[i]; - usbd_setup_xfer(c->upl_xfer, sc->sc_ep[UPL_ENDPT_RX], - c, c->upl_buf, UPL_BUFSZ, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - upl_rxeof); - usbd_transfer(c->upl_xfer); - } -#endif - return 0; } @@ -971,7 +956,7 @@ upl_stop(struct upl_softc *sc) sc->sc_cdata.upl_rx_chain[i].upl_mbuf = NULL; } if (sc->sc_cdata.upl_rx_chain[i].upl_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.upl_rx_chain[i].upl_xfer); + usbd_destroy_xfer(sc->sc_cdata.upl_rx_chain[i].upl_xfer); sc->sc_cdata.upl_rx_chain[i].upl_xfer = NULL; } } @@ -983,7 +968,7 @@ upl_stop(struct upl_softc *sc) sc->sc_cdata.upl_tx_chain[i].upl_mbuf = NULL; } if (sc->sc_cdata.upl_tx_chain[i].upl_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.upl_tx_chain[i].upl_xfer); + usbd_destroy_xfer(sc->sc_cdata.upl_tx_chain[i].upl_xfer); sc->sc_cdata.upl_tx_chain[i].upl_xfer = NULL; } } Index: sys/dev/usb/if_ural.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_ural.c,v retrieving revision 1.44.14.6 diff -u -p -r1.44.14.6 if_ural.c --- sys/dev/usb/if_ural.c 29 Sep 2015 11:38:28 -0000 1.44.14.6 +++ sys/dev/usb/if_ural.c 4 Oct 2015 08:34:38 -0000 @@ -547,7 +547,7 @@ ural_detach(device_t self, int flags) callout_stop(&sc->sc_amrr_ch); if (sc->amrr_xfer != NULL) { - usbd_free_xfer(sc->amrr_xfer); + usbd_destroy_xfer(sc->amrr_xfer); sc->amrr_xfer = NULL; } @@ -585,23 +585,16 @@ ural_alloc_tx_list(struct ural_softc *sc data = &sc->tx_data[i]; data->sc = sc; - - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_tx_pipeh, + RAL_TX_DESC_SIZE + MCLBYTES, USBD_FORCE_SHORT_XFER, 0, + &data->xfer); + if (error) { printf("%s: could not allocate tx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } - data->buf = usbd_alloc_buffer(data->xfer, - RAL_TX_DESC_SIZE + MCLBYTES); - if (data->buf == NULL) { - printf("%s: could not allocate tx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } + data->buf = usbd_get_buffer(data->xfer); } return 0; @@ -620,7 +613,7 @@ ural_free_tx_list(struct ural_softc *sc) data = &sc->tx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } @@ -642,18 +635,11 @@ ural_alloc_rx_list(struct ural_softc *sc data->sc = sc; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->sc_rx_pipeh, MCLBYTES, + USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { printf("%s: could not allocate rx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } - - if (usbd_alloc_buffer(data->xfer, MCLBYTES) == NULL) { - printf("%s: could not allocate rx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } @@ -692,7 +678,7 @@ ural_free_rx_list(struct ural_softc *sc) data = &sc->rx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } @@ -1012,7 +998,7 @@ ural_rxeof(struct usbd_xfer *xfer, void DPRINTFN(15, ("rx done\n")); skip: /* setup a new transfer */ - usbd_setup_xfer(xfer, sc->sc_rx_pipeh, data, data->buf, MCLBYTES, + usbd_setup_xfer(xfer, data, data->buf, MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, ural_rxeof); usbd_transfer(xfer); } @@ -1159,25 +1145,22 @@ ural_tx_bcn(struct ural_softc *sc, struc rate = IEEE80211_IS_CHAN_5GHZ(ni->ni_chan) ? 12 : 2; - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return ENOMEM; - /* xfer length needs to be a multiple of two! */ xferlen = (RAL_TX_DESC_SIZE + m0->m_pkthdr.len + 1) & ~1; - buf = usbd_alloc_buffer(xfer, xferlen); - if (buf == NULL) { - usbd_free_xfer(xfer); - return ENOMEM; - } + error = usbd_create_xfer(sc->sc_tx_pipeh, xferlen, + USBD_FORCE_SHORT_XFER, 0, &xfer); + if (error) + return error; - usbd_setup_xfer(xfer, sc->sc_tx_pipeh, NULL, &cmd, sizeof(cmd), - USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, NULL); + buf = usbd_get_buffer(xfer); + + usbd_setup_xfer(xfer, NULL, &cmd, sizeof(cmd), USBD_FORCE_SHORT_XFER, + RAL_TX_TIMEOUT, NULL); error = usbd_sync_transfer(xfer); if (error != 0) { - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); return error; } @@ -1190,11 +1173,11 @@ ural_tx_bcn(struct ural_softc *sc, struc DPRINTFN(10, ("sending beacon frame len=%u rate=%u xfer len=%u\n", m0->m_pkthdr.len, rate, xferlen)); - usbd_setup_xfer(xfer, sc->sc_tx_pipeh, NULL, buf, xferlen, - USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, NULL); + usbd_setup_xfer(xfer, NULL, buf, xferlen, USBD_FORCE_SHORT_XFER, + RAL_TX_TIMEOUT, NULL); error = usbd_sync_transfer(xfer); - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); return error; } @@ -1274,9 +1257,8 @@ ural_tx_mgt(struct ural_softc *sc, struc DPRINTFN(10, ("sending mgt frame len=%u rate=%u xfer len=%u\n", m0->m_pkthdr.len, rate, xferlen)); - usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf, - xferlen, USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, - ural_txeof); + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, + USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, ural_txeof); error = usbd_transfer(data->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) { @@ -1364,10 +1346,8 @@ ural_tx_data(struct ural_softc *sc, stru DPRINTFN(10, ("sending data frame len=%u rate=%u xfer len=%u\n", m0->m_pkthdr.len, rate, xferlen)); - - usbd_setup_xfer(data->xfer, sc->sc_tx_pipeh, data, data->buf, - xferlen, USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, - ural_txeof); + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, + USBD_FORCE_SHORT_XFER, RAL_TX_TIMEOUT, ural_txeof); error = usbd_transfer(data->xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) @@ -2114,7 +2094,6 @@ ural_init(struct ifnet *ifp) struct ural_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_key *wk; - struct ural_rx_data *data; uint16_t tmp; usbd_status error; int i, ntries; @@ -2177,8 +2156,9 @@ ural_init(struct ifnet *ifp) /* * Allocate xfer for AMRR statistics requests. */ - sc->amrr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->amrr_xfer == NULL) { + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->sc_udev); + error = usbd_create_xfer(pipe0, sizeof(sc->sta), 0, 0, &sc->amrr_xfer); + if (error) { printf("%s: could not allocate AMRR xfer\n", device_xname(sc->sc_dev)); goto fail; @@ -2224,10 +2204,10 @@ ural_init(struct ifnet *ifp) * Start up the receive pipe. */ for (i = 0; i < RAL_RX_LIST_COUNT; i++) { - data = &sc->rx_data[i]; + struct ural_rx_data *data = &sc->rx_data[i]; - usbd_setup_xfer(data->xfer, sc->sc_rx_pipeh, data, data->buf, - MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, ural_rxeof); + usbd_setup_xfer(data->xfer, data, data->buf, MCLBYTES, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, ural_rxeof); usbd_transfer(data->xfer); } @@ -2278,7 +2258,7 @@ ural_stop(struct ifnet *ifp, int disable ural_write(sc, RAL_MAC_CSR1, 0); if (sc->amrr_xfer != NULL) { - usbd_free_xfer(sc->amrr_xfer); + usbd_destroy_xfer(sc->amrr_xfer); sc->amrr_xfer = NULL; } Index: sys/dev/usb/if_url.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_url.c,v retrieving revision 1.48.4.6 diff -u -p -r1.48.4.6 if_url.c --- sys/dev/usb/if_url.c 6 Jun 2015 14:40:14 -0000 1.48.4.6 +++ sys/dev/usb/if_url.c 4 Oct 2015 08:34:38 -0000 @@ -547,20 +547,6 @@ url_init(struct ifnet *ifp) URL_CLRBIT2(sc, URL_RCR, URL_RCR_AAM|URL_RCR_AAP); - /* Initialize transmit ring */ - if (url_tx_list_init(sc) == ENOBUFS) { - printf("%s: tx list init failed\n", device_xname(sc->sc_dev)); - splx(s); - return EIO; - } - - /* Initialize receive ring */ - if (url_rx_list_init(sc) == ENOBUFS) { - printf("%s: rx list init failed\n", device_xname(sc->sc_dev)); - splx(s); - return EIO; - } - /* Load the multicast filter */ url_setmulti(sc); @@ -578,6 +564,29 @@ url_init(struct ifnet *ifp) return EIO; } } + /* Initialize transmit ring */ + if (url_tx_list_init(sc)) { + printf("%s: tx list init failed\n", device_xname(sc->sc_dev)); + splx(s); + return EIO; + } + + /* Initialize receive ring */ + if (url_rx_list_init(sc)) { + printf("%s: rx list init failed\n", device_xname(sc->sc_dev)); + splx(s); + return EIO; + } + /* Start up the receive pipe. */ + for (i = 0; i < URL_RX_LIST_CNT; i++) { + struct url_chain *c = &sc->sc_cdata.url_rx_chain[i]; + + usbd_setup_xfer(c->url_xfer, c, c->url_buf, URL_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, url_rxeof); + (void)usbd_transfer(c->url_xfer); + DPRINTF(("%s: %s: start read\n", device_xname(sc->sc_dev), + __func__)); + } ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -695,9 +704,7 @@ url_setmulti(struct url_softc *sc) Static int url_openpipes(struct url_softc *sc) { - struct url_chain *c; usbd_status err; - int i; int error = 0; if (sc->sc_dying) @@ -740,19 +747,6 @@ url_openpipes(struct url_softc *sc) } #endif - - /* Start up the receive pipe. */ - for (i = 0; i < URL_RX_LIST_CNT; i++) { - c = &sc->sc_cdata.url_rx_chain[i]; - usbd_setup_xfer(c->url_xfer, sc->sc_pipe_rx, - c, c->url_buf, URL_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, url_rxeof); - (void)usbd_transfer(c->url_xfer); - DPRINTF(("%s: %s: start read\n", device_xname(sc->sc_dev), - __func__)); - } - done: if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); @@ -812,14 +806,11 @@ url_rx_list_init(struct url_softc *sc) if (url_newbuf(sc, c, NULL) == ENOBUFS) return ENOBUFS; if (c->url_xfer == NULL) { - c->url_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->url_xfer == NULL) - return ENOBUFS; - c->url_buf = usbd_alloc_buffer(c->url_xfer, URL_BUFSZ); - if (c->url_buf == NULL) { - usbd_free_xfer(c->url_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_pipe_rx, URL_BUFSZ, + USBD_SHORT_XFER_OK, 0, &c->url_xfer); + if (error) + return error; + c->url_buf = usbd_get_buffer(c->url_xfer); } } @@ -842,14 +833,11 @@ url_tx_list_init(struct url_softc *sc) c->url_idx = i; c->url_mbuf = NULL; if (c->url_xfer == NULL) { - c->url_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->url_xfer == NULL) - return ENOBUFS; - c->url_buf = usbd_alloc_buffer(c->url_xfer, URL_BUFSZ); - if (c->url_buf == NULL) { - usbd_free_xfer(c->url_xfer); - return ENOBUFS; - } + int error = usbd_create_xfer(sc->sc_pipe_tx, URL_BUFSZ, + USBD_FORCE_SHORT_XFER, 0, &c->url_xfer); + if (error) + return error; + c->url_buf = usbd_get_buffer(c->url_xfer); } } @@ -914,9 +902,8 @@ url_send(struct url_softc *sc, struct mb URL_MIN_FRAME_LEN - total_len); total_len = URL_MIN_FRAME_LEN; } - usbd_setup_xfer(c->url_xfer, sc->sc_pipe_tx, c, c->url_buf, total_len, - USBD_FORCE_SHORT_XFER, - URL_TX_TIMEOUT, url_txeof); + usbd_setup_xfer(c->url_xfer,c, c->url_buf, total_len, + USBD_FORCE_SHORT_XFER, URL_TX_TIMEOUT, url_txeof); /* Transmit */ sc->sc_refcnt++; @@ -1072,9 +1059,8 @@ url_rxeof(struct usbd_xfer *xfer, void * done: /* Setup new transfer */ - usbd_setup_xfer(xfer, sc->sc_pipe_rx, c, c->url_buf, URL_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, url_rxeof); + usbd_setup_xfer(xfer, c, c->url_buf, URL_BUFSZ, USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, url_rxeof); sc->sc_refcnt++; usbd_transfer(xfer); if (--sc->sc_refcnt < 0) @@ -1209,7 +1195,7 @@ url_stop(struct ifnet *ifp, int disable) sc->sc_cdata.url_rx_chain[i].url_mbuf = NULL; } if (sc->sc_cdata.url_rx_chain[i].url_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.url_rx_chain[i].url_xfer); + usbd_destroy_xfer(sc->sc_cdata.url_rx_chain[i].url_xfer); sc->sc_cdata.url_rx_chain[i].url_xfer = NULL; } } @@ -1221,7 +1207,7 @@ url_stop(struct ifnet *ifp, int disable) sc->sc_cdata.url_tx_chain[i].url_mbuf = NULL; } if (sc->sc_cdata.url_tx_chain[i].url_xfer != NULL) { - usbd_free_xfer(sc->sc_cdata.url_tx_chain[i].url_xfer); + usbd_destroy_xfer(sc->sc_cdata.url_tx_chain[i].url_xfer); sc->sc_cdata.url_tx_chain[i].url_xfer = NULL; } } Index: sys/dev/usb/if_urndis.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_urndis.c,v retrieving revision 1.9.4.5 diff -u -p -r1.9.4.5 if_urndis.c --- sys/dev/usb/if_urndis.c 26 May 2015 12:02:26 -0000 1.9.4.5 +++ sys/dev/usb/if_urndis.c 4 Oct 2015 08:34:39 -0000 @@ -754,9 +754,8 @@ urndis_encap(struct urndis_softc *sc, st c->sc_mbuf = m; - usbd_setup_xfer(c->sc_xfer, sc->sc_bulkout_pipe, c, c->sc_buf, - le32toh(msg->rm_len), USBD_FORCE_SHORT_XFER, 10000, - urndis_txeof); + usbd_setup_xfer(c->sc_xfer, c, c->sc_buf, le32toh(msg->rm_len), + USBD_FORCE_SHORT_XFER, 10000, urndis_txeof); /* Transmit */ err = usbd_transfer(c->sc_xfer); @@ -925,13 +924,11 @@ urndis_rx_list_init(struct urndis_softc return ENOBUFS; if (c->sc_xfer == NULL) { - c->sc_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->sc_xfer == NULL) - return ENOBUFS; - c->sc_buf = usbd_alloc_buffer(c->sc_xfer, - RNDIS_BUFSZ); - if (c->sc_buf == NULL) - return ENOBUFS; + int err = usbd_create_xfer(sc->sc_bulkin_pipe, + RNDIS_BUFSZ, USBD_SHORT_XFER_OK, 0, &c->sc_xfer); + if (err) + return err; + c->sc_buf = usbd_get_buffer(c->sc_xfer); } } @@ -952,13 +949,11 @@ urndis_tx_list_init(struct urndis_softc c->sc_idx = i; c->sc_mbuf = NULL; if (c->sc_xfer == NULL) { - c->sc_xfer = usbd_alloc_xfer(sc->sc_udev); - if (c->sc_xfer == NULL) - return ENOBUFS; - c->sc_buf = usbd_alloc_buffer(c->sc_xfer, - RNDIS_BUFSZ); - if (c->sc_buf == NULL) - return ENOBUFS; + int err = usbd_create_xfer(sc->sc_bulkout_pipe, + RNDIS_BUFSZ, USBD_FORCE_SHORT_XFER, 0, &c->sc_xfer); + if (err) + return err; + c->sc_buf = usbd_get_buffer(c->sc_xfer); } } return 0; @@ -1041,22 +1036,6 @@ urndis_init(struct ifnet *ifp) s = splnet(); - err = urndis_tx_list_init(sc); - if (err) { - printf("%s: tx list init failed\n", - DEVNAME(sc)); - splx(s); - return err; - } - - err = urndis_rx_list_init(sc); - if (err) { - printf("%s: rx list init failed\n", - DEVNAME(sc)); - splx(s); - return err; - } - usberr = usbd_open_pipe(sc->sc_iface_data, sc->sc_bulkin_no, USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); if (usberr) { @@ -1075,14 +1054,27 @@ urndis_init(struct ifnet *ifp) return EIO; } + err = urndis_tx_list_init(sc); + if (err) { + printf("%s: tx list init failed\n", + DEVNAME(sc)); + splx(s); + return err; + } + + err = urndis_rx_list_init(sc); + if (err) { + printf("%s: rx list init failed\n", + DEVNAME(sc)); + splx(s); + return err; + } + for (i = 0; i < RNDIS_RX_LIST_CNT; i++) { - struct urndis_chain *c; + struct urndis_chain *c = &sc->sc_data.sc_rx_chain[i]; - c = &sc->sc_data.sc_rx_chain[i]; - usbd_setup_xfer(c->sc_xfer, sc->sc_bulkin_pipe, c, - c->sc_buf, RNDIS_BUFSZ, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, urndis_rxeof); + usbd_setup_xfer(c->sc_xfer, c, c->sc_buf, RNDIS_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urndis_rxeof); usbd_transfer(c->sc_xfer); } @@ -1135,7 +1127,7 @@ urndis_stop(struct ifnet *ifp) sc->sc_data.sc_rx_chain[i].sc_mbuf = NULL; } if (sc->sc_data.sc_rx_chain[i].sc_xfer != NULL) { - usbd_free_xfer(sc->sc_data.sc_rx_chain[i].sc_xfer); + usbd_destroy_xfer(sc->sc_data.sc_rx_chain[i].sc_xfer); sc->sc_data.sc_rx_chain[i].sc_xfer = NULL; } } @@ -1146,7 +1138,7 @@ urndis_stop(struct ifnet *ifp) sc->sc_data.sc_tx_chain[i].sc_mbuf = NULL; } if (sc->sc_data.sc_tx_chain[i].sc_xfer != NULL) { - usbd_free_xfer(sc->sc_data.sc_tx_chain[i].sc_xfer); + usbd_destroy_xfer(sc->sc_data.sc_tx_chain[i].sc_xfer); sc->sc_data.sc_tx_chain[i].sc_xfer = NULL; } } @@ -1225,9 +1217,8 @@ urndis_rxeof(struct usbd_xfer *xfer, done: /* Setup new transfer. */ - usbd_setup_xfer(c->sc_xfer, sc->sc_bulkin_pipe, c, c->sc_buf, - RNDIS_BUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - urndis_rxeof); + usbd_setup_xfer(c->sc_xfer, c, c->sc_buf, RNDIS_BUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urndis_rxeof); usbd_transfer(c->sc_xfer); } Index: sys/dev/usb/if_urtw.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_urtw.c,v retrieving revision 1.6.6.9 diff -u -p -r1.6.6.9 if_urtw.c --- sys/dev/usb/if_urtw.c 29 Sep 2015 11:38:28 -0000 1.6.6.9 +++ sys/dev/usb/if_urtw.c 4 Oct 2015 08:34:39 -0000 @@ -895,16 +895,11 @@ urtw_alloc_rx_data_list(struct urtw_soft data->sc = sc; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { - printf("%s: could not allocate rx xfer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } + error = usbd_create_xfer(sc->sc_rxpipe, MCLBYTES, + USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { - if (usbd_alloc_buffer(data->xfer, URTW_RX_MAXSIZE) == NULL) { - printf("%s: could not allocate rx buffer\n", + printf("%s: could not allocate rx xfer\n", device_xname(sc->sc_dev)); error = ENOMEM; goto fail; @@ -947,7 +942,7 @@ urtw_free_rx_data_list(struct urtw_softc struct urtw_rx_data *data = &sc->sc_rx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } if (data->m != NULL) { @@ -962,31 +957,29 @@ urtw_alloc_tx_data_list(struct urtw_soft { int i, error; - for (i = 0; i < URTW_TX_DATA_LIST_COUNT; i++) { - struct urtw_tx_data *data = &sc->sc_tx_data[i]; + for (size_t j = 0; j < URTW_PRIORITY_MAX; j++) { + for (i = 0; i < URTW_TX_DATA_LIST_COUNT; i++) { + struct urtw_tx_data *data = &sc->sc_tx_data[j][i]; - data->sc = sc; - data->ni = NULL; + data->sc = sc; + data->ni = NULL; - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { - printf("%s: could not allocate tx xfer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } + error = usbd_create_xfer((j == URTW_PRIORITY_LOW) ? + sc->sc_txpipe_low : sc->sc_txpipe_normal, + URTW_TX_MAXSIZE, USBD_FORCE_SHORT_XFER, 0, + &data->xfer); + if (error) { + printf("%s: could not allocate tx xfer\n", + device_xname(sc->sc_dev)); + goto fail; + } - data->buf = usbd_alloc_buffer(data->xfer, URTW_TX_MAXSIZE); - if (data->buf == NULL) { - printf("%s: could not allocate tx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } + data->buf = usbd_get_buffer(data->xfer); - if (((unsigned long)data->buf) % 4) - printf("%s: warn: unaligned buffer %p\n", - device_xname(sc->sc_dev), data->buf); + if (((unsigned long)data->buf) % 4) + printf("%s: warn: unaligned buffer %p\n", + device_xname(sc->sc_dev), data->buf); + } } return 0; @@ -1007,16 +1000,18 @@ urtw_free_tx_data_list(struct urtw_softc if (sc->sc_txpipe_normal != NULL) usbd_abort_pipe(sc->sc_txpipe_normal); - for (i = 0; i < URTW_TX_DATA_LIST_COUNT; i++) { - struct urtw_tx_data *data = &sc->sc_tx_data[i]; - - if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); - data->xfer = NULL; - } - if (data->ni != NULL) { - ieee80211_free_node(data->ni); - data->ni = NULL; + for (size_t j = 0; j < URTW_PRIORITY_MAX; j++) { + for (i = 0; i < URTW_TX_DATA_LIST_COUNT; i++) { + struct urtw_tx_data *data = &sc->sc_tx_data[j][i]; + + if (data->xfer != NULL) { + usbd_destroy_xfer(data->xfer); + data->xfer = NULL; + } + if (data->ni != NULL) { + ieee80211_free_node(data->ni); + data->ni = NULL; + } } } } @@ -2175,9 +2170,8 @@ urtw_rx_enable(struct urtw_softc *sc) for (i = 0; i < URTW_RX_DATA_LIST_COUNT; i++) { rx_data = &sc->sc_rx_data[i]; - usbd_setup_xfer(rx_data->xfer, sc->sc_rxpipe, rx_data, - rx_data->buf, MCLBYTES, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, urtw_rxeof); + usbd_setup_xfer(rx_data->xfer, rx_data, rx_data->buf, MCLBYTES, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urtw_rxeof); error = usbd_transfer(rx_data->xfer); if (error != USBD_IN_PROGRESS && error != 0) { printf("%s: could not queue Rx transfer\n", @@ -2304,7 +2298,9 @@ urtw_init(struct ifnet *ifp) goto fail; /* reset softc variables */ - sc->sc_txidx = sc->sc_tx_low_queued = sc->sc_tx_normal_queued = 0; + for (size_t j = 0; j < URTW_PRIORITY_MAX; j++) { + sc->sc_txidx[j] = sc->sc_tx_queued[j] = 0; + } sc->sc_txtimer = 0; if (!(sc->sc_flags & URTW_INIT_ONCE)) { @@ -2430,8 +2426,8 @@ urtw_start(struct ifnet *ifp) for (;;) { IF_POLL(&ic->ic_mgtq, m0); if (m0 != NULL) { - if (sc->sc_tx_low_queued >= URTW_TX_DATA_LIST_COUNT || - sc->sc_tx_normal_queued >= + + if (sc->sc_tx_queued[URTW_PRIORITY_NORMAL] >= URTW_TX_DATA_LIST_COUNT) { ifp->if_flags |= IFF_OACTIVE; break; @@ -2449,8 +2445,7 @@ urtw_start(struct ifnet *ifp) IFQ_POLL(&ifp->if_snd, m0); if (m0 == NULL) break; - if (sc->sc_tx_low_queued >= URTW_TX_DATA_LIST_COUNT || - sc->sc_tx_normal_queued >= + if (sc->sc_tx_queued[URTW_PRIORITY_NORMAL] >= URTW_TX_DATA_LIST_COUNT) { ifp->if_flags |= IFF_OACTIVE; break; @@ -2536,7 +2531,7 @@ urtw_txeof_low(struct usbd_xfer *xfer, v sc->sc_txtimer = 0; ifp->if_opackets++; - sc->sc_tx_low_queued--; + sc->sc_tx_queued[URTW_PRIORITY_LOW]--; ifp->if_flags &= ~IFF_OACTIVE; urtw_start(ifp); @@ -2575,7 +2570,7 @@ urtw_txeof_normal(struct usbd_xfer *xfer sc->sc_txtimer = 0; ifp->if_opackets++; - sc->sc_tx_normal_queued--; + sc->sc_tx_queued[URTW_PRIORITY_NORMAL]--; ifp->if_flags &= ~IFF_OACTIVE; urtw_start(ifp); @@ -2624,8 +2619,9 @@ urtw_tx_start(struct urtw_softc *sc, str if ((0 == xferlen % 64) || (0 == xferlen % 512)) xferlen += 1; - data = &sc->sc_tx_data[sc->sc_txidx]; - sc->sc_txidx = (sc->sc_txidx + 1) % URTW_TX_DATA_LIST_COUNT; + data = &sc->sc_tx_data[prior][sc->sc_txidx[prior]]; + sc->sc_txidx[prior] = + (sc->sc_txidx[prior] + 1) % URTW_TX_DATA_LIST_COUNT; memset(data->buf, 0, URTW_TX_MAXSIZE); data->buf[0] = m0->m_pkthdr.len & 0xff; @@ -2672,9 +2668,7 @@ urtw_tx_start(struct urtw_softc *sc, str /* mbuf is no longer needed. */ m_freem(m0); - usbd_setup_xfer(data->xfer, - (prior == URTW_PRIORITY_LOW) ? sc->sc_txpipe_low : - sc->sc_txpipe_normal, data, data->buf, xferlen, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, URTW_DATA_TIMEOUT, (prior == URTW_PRIORITY_LOW) ? urtw_txeof_low : urtw_txeof_normal); error = usbd_transfer(data->xfer); @@ -2689,10 +2683,7 @@ urtw_tx_start(struct urtw_softc *sc, str printf("%s: could not control LED (%d)\n", device_xname(sc->sc_dev), error); - if (prior == URTW_PRIORITY_LOW) - sc->sc_tx_low_queued++; - else - sc->sc_tx_normal_queued++; + sc->sc_tx_queued[prior]++; return 0; } @@ -3167,7 +3158,7 @@ urtw_rxeof(struct usbd_xfer *xfer, void splx(s); skip: /* setup a new transfer */ - usbd_setup_xfer(xfer, sc->sc_rxpipe, data, data->buf, MCLBYTES, + usbd_setup_xfer(xfer, data, data->buf, MCLBYTES, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urtw_rxeof); (void)usbd_transfer(xfer); } @@ -3670,7 +3661,9 @@ urtw_8187b_init(struct ifnet *ifp) urtw_write8_m(sc, URTW_ACM_CONTROL, 0); /* Reset softc variables. */ - sc->sc_txidx = sc->sc_tx_low_queued = sc->sc_tx_normal_queued = 0; + for (size_t j = 0; j < URTW_PRIORITY_MAX; j++) { + sc->sc_txidx[j] = sc->sc_tx_queued[j] = 0; + } sc->sc_txtimer = 0; if (!(sc->sc_flags & URTW_INIT_ONCE)) { Index: sys/dev/usb/if_urtwn.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_urtwn.c,v retrieving revision 1.34.4.8 diff -u -p -r1.34.4.8 if_urtwn.c --- sys/dev/usb/if_urtwn.c 6 Apr 2015 15:18:13 -0000 1.34.4.8 +++ sys/dev/usb/if_urtwn.c 4 Oct 2015 08:34:40 -0000 @@ -254,6 +254,8 @@ static void urtwn_rxeof(struct usbd_xfer static void urtwn_txeof(struct usbd_xfer *, void *, usbd_status); static int urtwn_tx(struct urtwn_softc *, struct mbuf *, struct ieee80211_node *, struct urtwn_tx_data *); +static struct urtwn_tx_data * + urtwn_get_tx_data(struct urtwn_softc *, size_t); static void urtwn_start(struct ifnet *); static void urtwn_watchdog(struct ifnet *); static int urtwn_ioctl(struct ifnet *, u_long, void *); @@ -642,21 +644,15 @@ urtwn_alloc_rx_list(struct urtwn_softc * data->sc = sc; /* Backpointer for callbacks. */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->rx_pipe, URTWN_RXBUFSZ, + USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { aprint_error_dev(sc->sc_dev, "could not allocate xfer\n"); - error = ENOMEM; break; } - data->buf = usbd_alloc_buffer(data->xfer, URTWN_RXBUFSZ); - if (data->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; - break; - } + data->buf = usbd_get_buffer(data->xfer); } if (error != 0) urtwn_free_rx_list(sc); @@ -676,7 +672,7 @@ urtwn_free_rx_list(struct urtwn_softc *s CTASSERT(sizeof(xfer) == sizeof(void *)); xfer = atomic_swap_ptr(&sc->rx_data[i].xfer, NULL); if (xfer != NULL) - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); } } @@ -690,30 +686,28 @@ urtwn_alloc_tx_list(struct urtwn_softc * DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); mutex_enter(&sc->sc_tx_mtx); - TAILQ_INIT(&sc->tx_free_list); - for (i = 0; i < URTWN_TX_LIST_COUNT; i++) { - data = &sc->tx_data[i]; + for (size_t j = 0; j < sc->tx_npipe; j++) { + TAILQ_INIT(&sc->tx_free_list[j]); + for (i = 0; i < URTWN_TX_LIST_COUNT; i++) { + data = &sc->tx_data[j][i]; + + data->sc = sc; /* Backpointer for callbacks. */ + data->pidx = j; + + error = usbd_create_xfer(sc->tx_pipe[j], + URTWN_TXBUFSZ, USBD_FORCE_SHORT_XFER, 0, + &data->xfer); + if (error) { + aprint_error_dev(sc->sc_dev, + "could not allocate xfer\n"); + goto fail; + } - data->sc = sc; /* Backpointer for callbacks. */ + data->buf = usbd_get_buffer(data->xfer); - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer\n"); - error = ENOMEM; - goto fail; - } - - data->buf = usbd_alloc_buffer(data->xfer, URTWN_TXBUFSZ); - if (data->buf == NULL) { - aprint_error_dev(sc->sc_dev, - "could not allocate xfer buffer\n"); - error = ENOMEM; - goto fail; + /* Append this Tx buffer to our free list. */ + TAILQ_INSERT_TAIL(&sc->tx_free_list[j], data, next); } - - /* Append this Tx buffer to our free list. */ - TAILQ_INSERT_TAIL(&sc->tx_free_list, data, next); } mutex_exit(&sc->sc_tx_mtx); return 0; @@ -733,11 +727,13 @@ urtwn_free_tx_list(struct urtwn_softc *s DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); /* NB: Caller must abort pipe first. */ - for (i = 0; i < URTWN_TX_LIST_COUNT; i++) { - CTASSERT(sizeof(xfer) == sizeof(void *)); - xfer = atomic_swap_ptr(&sc->tx_data[i].xfer, NULL); - if (xfer != NULL) - usbd_free_xfer(xfer); + for (size_t j = 0; j < sc->tx_npipe; j++) { + for (i = 0; i < URTWN_TX_LIST_COUNT; i++) { + CTASSERT(sizeof(xfer) == sizeof(void *)); + xfer = atomic_swap_ptr(&sc->tx_data[j][i].xfer, NULL); + if (xfer != NULL) + usbd_destroy_xfer(xfer); + } } } @@ -2394,7 +2390,7 @@ urtwn_rxeof(struct usbd_xfer *xfer, void resubmit: /* Setup a new transfer. */ - usbd_setup_xfer(xfer, sc->rx_pipe, data, data->buf, URTWN_RXBUFSZ, + usbd_setup_xfer(xfer, data, data->buf, URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, urtwn_rxeof); (void)usbd_transfer(xfer); } @@ -2405,7 +2401,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void struct urtwn_tx_data *data = priv; struct urtwn_softc *sc = data->sc; struct ifnet *ifp = &sc->sc_if; - struct usbd_pipe *pipe = data->pipe; + size_t pidx = data->pidx; int s; DPRINTFN(DBG_FN|DBG_TX, ("%s: %s: status=%d\n", @@ -2413,7 +2409,7 @@ urtwn_txeof(struct usbd_xfer *xfer, void mutex_enter(&sc->sc_tx_mtx); /* Put this Tx buffer back to our free list. */ - TAILQ_INSERT_TAIL(&sc->tx_free_list, data, next); + TAILQ_INSERT_TAIL(&sc->tx_free_list[pidx], data, next); mutex_exit(&sc->sc_tx_mtx); s = splnet(); @@ -2422,8 +2418,10 @@ urtwn_txeof(struct usbd_xfer *xfer, void if (__predict_false(status != USBD_NORMAL_COMPLETION)) { if (status != USBD_NOT_STARTED && status != USBD_CANCELLED) { - if (status == USBD_STALLED) + if (status == USBD_STALLED) { + struct usbd_pipe *pipe = sc->tx_pipe[pidx]; usbd_clear_endpoint_stall_async(pipe); + } ifp->if_oerrors++; } splx(s); @@ -2444,10 +2442,9 @@ urtwn_tx(struct urtwn_softc *sc, struct struct ieee80211_frame *wh; struct ieee80211_key *k = NULL; struct r92c_tx_desc *txd; - struct usbd_pipe *pipe; size_t i, padsize, xferlen; uint16_t seq, sum; - uint8_t raid, type, tid, qid; + uint8_t raid, type, tid; int s, hasqos, error; DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); @@ -2478,24 +2475,16 @@ urtwn_tx(struct urtwn_softc *sc, struct bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m); } + /* non-qos data frames */ + tid = R92C_TXDW1_QSEL_BE; if ((hasqos = ieee80211_has_qos(wh))) { /* data frames in 11n mode */ struct ieee80211_qosframe *qwh = (void *)wh; tid = qwh->i_qos[0] & IEEE80211_QOS_TID; - qid = TID_TO_WME_AC(tid); } else if (type != IEEE80211_FC0_TYPE_DATA) { - /* Use AC_VO for management frames. */ - qid = WME_AC_VO; - tid = 0; /* compiler happy */ - } else { - /* non-qos data frames */ - tid = R92C_TXDW1_QSEL_BE; - qid = WME_AC_BE; + tid = R92C_TXDW1_QSEL_MGNT; } - /* Get the USB pipe to use for this AC. */ - pipe = sc->tx_pipe[sc->ac2idx[qid]]; - if (((sizeof(*txd) + m->m_pkthdr.len) % 64) == 0) /* XXX: 64 */ padsize = 8; else @@ -2612,8 +2601,7 @@ urtwn_tx(struct urtwn_softc *sc, struct m_copydata(m, 0, m->m_pkthdr.len, (char *)&txd[1] + padsize); s = splnet(); - data->pipe = pipe; - usbd_setup_xfer(data->xfer, pipe, data, data->buf, xferlen, + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, USBD_FORCE_SHORT_XFER, URTWN_TX_TIMEOUT, urtwn_txeof); error = usbd_transfer(data->xfer); @@ -2628,6 +2616,21 @@ urtwn_tx(struct urtwn_softc *sc, struct return 0; } +struct urtwn_tx_data * +urtwn_get_tx_data(struct urtwn_softc *sc, size_t pidx) +{ + struct urtwn_tx_data *data = NULL; + + mutex_enter(&sc->sc_tx_mtx); + if (!TAILQ_EMPTY(&sc->tx_free_list[pidx])) { + data = TAILQ_FIRST(&sc->tx_free_list[pidx]); + TAILQ_REMOVE(&sc->tx_free_list[pidx], data, next); + } + mutex_exit(&sc->sc_tx_mtx); + + return data; +} + static void urtwn_start(struct ifnet *ifp) { @@ -2645,23 +2648,20 @@ urtwn_start(struct ifnet *ifp) data = NULL; for (;;) { - mutex_enter(&sc->sc_tx_mtx); - if (data == NULL && !TAILQ_EMPTY(&sc->tx_free_list)) { - data = TAILQ_FIRST(&sc->tx_free_list); - TAILQ_REMOVE(&sc->tx_free_list, data, next); - } - mutex_exit(&sc->sc_tx_mtx); - - if (data == NULL) { - ifp->if_flags |= IFF_OACTIVE; - DPRINTFN(DBG_TX, ("%s: empty tx_free_list\n", - device_xname(sc->sc_dev))); - return; - } - /* Send pending management frames first. */ - IF_DEQUEUE(&ic->ic_mgtq, m); + IF_POLL(&ic->ic_mgtq, m); if (m != NULL) { + /* Use AC_VO for management frames. */ + + data = urtwn_get_tx_data(sc, sc->ac2idx[WME_AC_VO]); + + if (data == NULL) { + ifp->if_flags |= IFF_OACTIVE; + DPRINTFN(DBG_TX, ("%s: empty tx_free_list\n", + device_xname(sc->sc_dev))); + return; + } + IF_DEQUEUE(&ic->ic_mgtq, m); ni = (void *)m->m_pkthdr.rcvif; m->m_pkthdr.rcvif = NULL; goto sendit; @@ -2670,10 +2670,31 @@ urtwn_start(struct ifnet *ifp) break; /* Encapsulate and send data frames. */ - IFQ_DEQUEUE(&ifp->if_snd, m); + IFQ_POLL(&ifp->if_snd, m); if (m == NULL) break; + struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *); + uint8_t type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; + uint8_t qid = WME_AC_BE; + if (ieee80211_has_qos(wh)) { + /* data frames in 11n mode */ + struct ieee80211_qosframe *qwh = (void *)wh; + uint8_t tid = qwh->i_qos[0] & IEEE80211_QOS_TID; + qid = TID_TO_WME_AC(tid); + } else if (type != IEEE80211_FC0_TYPE_DATA) { + qid = WME_AC_VO; + } + data = urtwn_get_tx_data(sc, sc->ac2idx[qid]); + + if (data == NULL) { + ifp->if_flags |= IFF_OACTIVE; + DPRINTFN(DBG_TX, ("%s: empty tx_free_list\n", + device_xname(sc->sc_dev))); + return; + } + IFQ_DEQUEUE(&ifp->if_snd, m); + if (m->m_len < (int)sizeof(*eh) && (m = m_pullup(m, sizeof(*eh))) == NULL) { ifp->if_oerrors++; @@ -2703,17 +2724,11 @@ urtwn_start(struct ifnet *ifp) ifp->if_oerrors++; continue; } - data = NULL; m_freem(m); ieee80211_free_node(ni); sc->tx_timer = 5; ifp->if_timer = 1; } - - /* Return the Tx buffer to the free list */ - mutex_enter(&sc->sc_tx_mtx); - TAILQ_INSERT_TAIL(&sc->tx_free_list, data, next); - mutex_exit(&sc->sc_tx_mtx); } static void @@ -4400,9 +4415,8 @@ urtwn_init(struct ifnet *ifp) /* Queue Rx xfers. */ for (i = 0; i < URTWN_RX_LIST_COUNT; i++) { data = &sc->rx_data[i]; - usbd_setup_xfer(data->xfer, sc->rx_pipe, data, data->buf, - URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, urtwn_rxeof); + 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)) Index: sys/dev/usb/if_urtwnvar.h =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_urtwnvar.h,v retrieving revision 1.8.4.1 diff -u -p -r1.8.4.1 if_urtwnvar.h --- sys/dev/usb/if_urtwnvar.h 19 Mar 2015 17:26:43 -0000 1.8.4.1 +++ sys/dev/usb/if_urtwnvar.h 4 Oct 2015 08:34:40 -0000 @@ -73,7 +73,7 @@ struct urtwn_rx_data { struct urtwn_tx_data { struct urtwn_softc *sc; - struct usbd_pipe * pipe; + size_t pidx; struct usbd_xfer * xfer; uint8_t *buf; TAILQ_ENTRY(urtwn_tx_data) next; @@ -165,8 +165,8 @@ struct urtwn_softc { struct urtwn_host_cmd_ring cmdq; int fwcur; struct urtwn_rx_data rx_data[URTWN_RX_LIST_COUNT]; - struct urtwn_tx_data tx_data[URTWN_TX_LIST_COUNT]; - TAILQ_HEAD(, urtwn_tx_data) tx_free_list; + struct urtwn_tx_data tx_data[R92C_MAX_EPOUT][URTWN_TX_LIST_COUNT]; + TAILQ_HEAD(, urtwn_tx_data) tx_free_list[R92C_MAX_EPOUT]; struct r92c_rom rom; uint8_t r88e_rom[512]; Index: sys/dev/usb/if_urtwreg.h =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_urtwreg.h,v retrieving revision 1.1.22.1 diff -u -p -r1.1.22.1 if_urtwreg.h --- sys/dev/usb/if_urtwreg.h 19 Mar 2015 17:26:43 -0000 1.1.22.1 +++ sys/dev/usb/if_urtwreg.h 4 Oct 2015 08:34:40 -0000 @@ -363,12 +363,12 @@ struct urtw_softc { struct usbd_pipe * sc_txpipe_normal; #define URTW_PRIORITY_LOW 0 #define URTW_PRIORITY_NORMAL 1 +#define URTW_PRIORITY_MAX 2 #define URTW_DATA_TIMEOUT 10000 /* 10 sec */ struct urtw_rx_data sc_rx_data[URTW_RX_DATA_LIST_COUNT]; - struct urtw_tx_data sc_tx_data[URTW_TX_DATA_LIST_COUNT]; - uint32_t sc_tx_low_queued; - uint32_t sc_tx_normal_queued; - uint32_t sc_txidx; + struct urtw_tx_data sc_tx_data[URTW_PRIORITY_MAX][URTW_TX_DATA_LIST_COUNT]; + uint32_t sc_tx_queued[URTW_PRIORITY_MAX];; + uint32_t sc_txidx[URTW_PRIORITY_MAX]; uint8_t sc_rts_retry; uint8_t sc_tx_retry; uint8_t sc_preamble_mode; Index: sys/dev/usb/if_zyd.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_zyd.c,v retrieving revision 1.36.14.7 diff -u -p -r1.36.14.7 if_zyd.c --- sys/dev/usb/if_zyd.c 29 Sep 2015 11:38:28 -0000 1.36.14.7 +++ sys/dev/usb/if_zyd.c 4 Oct 2015 08:34:41 -0000 @@ -581,20 +581,14 @@ zyd_alloc_tx_list(struct zyd_softc *sc) data->sc = sc; /* backpointer for callbacks */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->zyd_ep[ZYD_ENDPT_BOUT], + ZYD_MAX_TXBUFSZ, USBD_FORCE_SHORT_XFER, 0, &data->xfer); + if (error) { printf("%s: could not allocate tx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } - data->buf = usbd_alloc_buffer(data->xfer, ZYD_MAX_TXBUFSZ); - if (data->buf == NULL) { - printf("%s: could not allocate tx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } + data->buf = usbd_get_buffer(data->xfer); /* clear Tx descriptor */ memset(data->buf, 0, sizeof(struct zyd_tx_desc)); @@ -614,7 +608,7 @@ zyd_free_tx_list(struct zyd_softc *sc) struct zyd_tx_data *data = &sc->tx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } if (data->ni != NULL) { @@ -634,20 +628,14 @@ zyd_alloc_rx_list(struct zyd_softc *sc) data->sc = sc; /* backpointer for callbacks */ - data->xfer = usbd_alloc_xfer(sc->sc_udev); - if (data->xfer == NULL) { + error = usbd_create_xfer(sc->zyd_ep[ZYD_ENDPT_BIN], + ZYX_MAX_RXBUFSZ, USBD_SHORT_XFER_OK, 0, &data->xfer); + if (error) { printf("%s: could not allocate rx xfer\n", device_xname(sc->sc_dev)); - error = ENOMEM; - goto fail; - } - data->buf = usbd_alloc_buffer(data->xfer, ZYX_MAX_RXBUFSZ); - if (data->buf == NULL) { - printf("%s: could not allocate rx buffer\n", - device_xname(sc->sc_dev)); - error = ENOMEM; goto fail; } + data->buf = usbd_get_buffer(data->xfer); } return 0; @@ -664,7 +652,7 @@ zyd_free_rx_list(struct zyd_softc *sc) struct zyd_rx_data *data = &sc->rx_data[i]; if (data->xfer != NULL) { - usbd_free_xfer(data->xfer); + usbd_destroy_xfer(data->xfer); data->xfer = NULL; } } @@ -803,8 +791,10 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c usbd_status uerror; int s = 0; - if ((xfer = usbd_alloc_xfer(sc->sc_udev)) == NULL) - return ENOMEM; + error = usbd_create_xfer(sc->zyd_ep[ZYD_ENDPT_IOUT], + sizeof(uint16_t) + ilen, USBD_FORCE_SHORT_XFER, 0, &xfer); + if (error) + return error; cmd.code = htole16(code); memcpy(cmd.data, idata, ilen); @@ -820,19 +810,19 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c SIMPLEQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); } - usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_IOUT], 0, &cmd, - sizeof(uint16_t) + ilen, xferflags, ZYD_INTR_TIMEOUT, NULL); + usbd_setup_xfer(xfer, 0, &cmd, sizeof(uint16_t) + ilen, xferflags, + ZYD_INTR_TIMEOUT, NULL); uerror = usbd_transfer(xfer); if (uerror != USBD_IN_PROGRESS && uerror != 0) { if (flags & ZYD_CMD_FLAG_READ) splx(s); printf("%s: could not send command (error=%s)\n", device_xname(sc->sc_dev), usbd_errstr(uerror)); - (void)usbd_free_xfer(xfer); + (void)usbd_destroy_xfer(xfer); return EIO; } if (!(flags & ZYD_CMD_FLAG_READ)) { - (void)usbd_free_xfer(xfer); + (void)usbd_destroy_xfer(xfer); return 0; /* write: don't wait for reply */ } /* wait at most one second for command reply */ @@ -842,7 +832,7 @@ zyd_cmd(struct zyd_softc *sc, uint16_t c SIMPLEQ_REMOVE(&sc->sc_rqh, &rq, rq, rq); splx(s); - (void)usbd_free_xfer(xfer); + (void)usbd_destroy_xfer(xfer); return error; } @@ -2044,8 +2034,8 @@ zyd_rxeof(struct usbd_xfer *xfer, void * } skip: /* setup a new transfer */ - usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_BIN], data, NULL, - ZYX_MAX_RXBUFSZ, USBD_SHORT_XFER_OK, + + usbd_setup_xfer(xfer, data, NULL, ZYX_MAX_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, zyd_rxeof); (void)usbd_transfer(xfer); } @@ -2149,9 +2139,8 @@ zyd_tx_mgt(struct zyd_softc *sc, struct m_freem(m0); /* mbuf no longer needed */ - usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BOUT], data, - data->buf, xferlen, USBD_FORCE_SHORT_XFER, - ZYD_TX_TIMEOUT, zyd_txeof); + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, + USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof); error = usbd_transfer(data->xfer); if (error != USBD_IN_PROGRESS && error != 0) { ifp->if_oerrors++; @@ -2307,9 +2296,8 @@ zyd_tx_data(struct zyd_softc *sc, struct m_freem(m0); /* mbuf no longer needed */ - usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BOUT], data, - data->buf, xferlen, USBD_FORCE_SHORT_XFER, - ZYD_TX_TIMEOUT, zyd_txeof); + usbd_setup_xfer(data->xfer, data, data->buf, xferlen, + USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof); error = usbd_transfer(data->xfer); if (error != USBD_IN_PROGRESS && error != 0) { ifp->if_oerrors++; @@ -2520,9 +2508,8 @@ zyd_init(struct ifnet *ifp) for (i = 0; i < ZYD_RX_LIST_CNT; i++) { struct zyd_rx_data *data = &sc->rx_data[i]; - usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BIN], data, - NULL, ZYX_MAX_RXBUFSZ, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, zyd_rxeof); + usbd_setup_xfer(data->xfer, data, NULL, ZYX_MAX_RXBUFSZ, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, zyd_rxeof); error = usbd_transfer(data->xfer); if (error != USBD_IN_PROGRESS && error != 0) { printf("%s: could not queue Rx transfer\n", Index: sys/dev/usb/irmce.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/irmce.c,v retrieving revision 1.1.32.4 diff -u -p -r1.1.32.4 irmce.c --- sys/dev/usb/irmce.c 21 Mar 2015 11:33:37 -0000 1.1.32.4 +++ sys/dev/usb/irmce.c 4 Oct 2015 08:34:41 -0000 @@ -203,23 +203,49 @@ irmce_attach(device_t parent, device_t s aprint_error_dev(self, "bad maxpktsize\n"); return; } + usbd_status err; - sc->sc_bulkin_xfer = usbd_alloc_xfer(sc->sc_udev); - sc->sc_bulkout_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_bulkin_xfer == NULL || sc->sc_bulkout_xfer == NULL) { - aprint_error_dev(self, "couldn't alloc xfer\n"); + err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_ep, + USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); + if (err) { + aprint_error_dev(sc->sc_dev, + "couldn't open bulk-in pipe: %s\n", usbd_errstr(err)); return; } - sc->sc_bulkin_buffer = usbd_alloc_buffer(sc->sc_bulkin_xfer, - sc->sc_bulkin_maxpktsize); - sc->sc_bulkout_buffer = usbd_alloc_buffer(sc->sc_bulkout_xfer, - sc->sc_bulkout_maxpktsize); - if (sc->sc_bulkin_buffer == NULL || sc->sc_bulkout_buffer == NULL) { - aprint_error_dev(self, "couldn't alloc xfer buffer\n"); + err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_ep, + USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); + if (err) { + aprint_error_dev(sc->sc_dev, + "couldn't open bulk-out pipe: %s\n", usbd_errstr(err)); + usbd_close_pipe(sc->sc_bulkin_pipe); + sc->sc_bulkin_pipe = NULL; return; } + int error; + error = usbd_create_xfer(sc->sc_bulkin_pipe, sc->sc_bulkin_maxpktsize, + USBD_SHORT_XFER_OK, 0, &sc->sc_bulkin_xfer); + if (error) { + goto fail; + } + + error = usbd_create_xfer(sc->sc_bulkout_pipe, + sc->sc_bulkout_maxpktsize, USBD_FORCE_SHORT_XFER, 0, + &sc->sc_bulkout_xfer); + if (error) { + goto fail; + } + sc->sc_bulkin_buffer = usbd_get_buffer(sc->sc_bulkin_xfer); + sc->sc_bulkout_buffer = usbd_get_buffer(sc->sc_bulkout_xfer); + irmce_rescan(self, NULL, NULL); + return; + +fail: + if (sc->sc_bulkin_xfer) + usbd_destroy_xfer(sc->sc_bulkin_xfer); + if (sc->sc_bulkout_xfer) + usbd_destroy_xfer(sc->sc_bulkout_xfer); } static int @@ -235,12 +261,12 @@ irmce_detach(device_t self, int flags) } if (sc->sc_bulkin_xfer) { - usbd_free_xfer(sc->sc_bulkin_xfer); + usbd_destroy_xfer(sc->sc_bulkin_xfer); sc->sc_bulkin_buffer = NULL; sc->sc_bulkin_xfer = NULL; } if (sc->sc_bulkout_xfer) { - usbd_free_xfer(sc->sc_bulkout_xfer); + usbd_destroy_xfer(sc->sc_bulkout_xfer); sc->sc_bulkout_buffer = NULL; sc->sc_bulkout_xfer = NULL; } @@ -304,9 +330,9 @@ irmce_reset(struct irmce_softc *sc) *p++ = reset_cmd[n]; wlen = sizeof(reset_cmd); - err = usbd_bulk_transfer(sc->sc_bulkin_xfer, - sc->sc_bulkout_pipe, USBD_FORCE_SHORT_XFER, - USBD_DEFAULT_TIMEOUT, sc->sc_bulkout_buffer, &wlen); + err = usbd_bulk_transfer(sc->sc_bulkout_xfer, sc->sc_bulkout_pipe, + USBD_FORCE_SHORT_XFER, USBD_DEFAULT_TIMEOUT, + sc->sc_bulkout_buffer, &wlen); if (err != USBD_NORMAL_COMPLETION) { if (err == USBD_INTERRUPTED) return EINTR; @@ -323,26 +349,7 @@ static int irmce_open(void *priv, int flag, int mode, struct proc *p) { struct irmce_softc *sc = priv; - usbd_status err; - - err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_ep, - USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); - if (err) { - aprint_error_dev(sc->sc_dev, - "couldn't open bulk-in pipe: %s\n", usbd_errstr(err)); - return ENXIO; - } - err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_ep, - USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); - if (err) { - aprint_error_dev(sc->sc_dev, - "couldn't open bulk-out pipe: %s\n", usbd_errstr(err)); - usbd_close_pipe(sc->sc_bulkin_pipe); - sc->sc_bulkin_pipe = NULL; - return ENXIO; - } - - err = irmce_reset(sc); + int err = irmce_reset(sc); if (err) { aprint_error_dev(sc->sc_dev, "couldn't reset device: %s\n", usbd_errstr(err)); @@ -550,6 +557,7 @@ irmce_read(void *priv, struct uio *uio, while (uio->uio_resid > 0) { rlen = sc->sc_bulkin_maxpktsize; + err = usbd_bulk_transfer(sc->sc_bulkin_xfer, sc->sc_bulkin_pipe, USBD_SHORT_XFER_OK, USBD_DEFAULT_TIMEOUT, sc->sc_bulkin_buffer, &rlen); Index: sys/dev/usb/pseye.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/pseye.c,v retrieving revision 1.21.34.7 diff -u -p -r1.21.34.7 pseye.c --- sys/dev/usb/pseye.c 21 Mar 2015 11:33:37 -0000 1.21.34.7 +++ sys/dev/usb/pseye.c 4 Oct 2015 08:34:42 -0000 @@ -238,20 +238,22 @@ pseye_attach(device_t parent, device_t s sc->sc_bulkin = ed_bulkin->bEndpointAddress; - sc->sc_bulkin_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_bulkin_xfer == NULL) { - sc->sc_dying = 1; + int error = pseye_init_pipes(sc); + if (error) { + aprint_error_dev(self, "couldn't open pipes\n"); return; } - sc->sc_bulkin_buffer = usbd_alloc_buffer(sc->sc_bulkin_xfer, - sc->sc_bulkin_bufferlen); - if (sc->sc_bulkin_buffer == NULL) { - usbd_free_xfer(sc->sc_bulkin_xfer); - sc->sc_bulkin_xfer = NULL; - sc->sc_dying = 1; + + error = usbd_create_xfer(sc->sc_bulkin_pipe, sc->sc_bulkin_bufferlen, + USBD_SHORT_XFER_OK, 0, &sc->sc_bulkin_xfer); + if (error) { + aprint_error_dev(self, "couldn't create transfer\n"); + pseye_close_pipes(sc); return; } + sc->sc_bulkin_buffer = usbd_get_buffer(sc->sc_bulkin_xfer); + pseye_init(sc); if (!pmf_device_register(self, NULL, NULL)) @@ -284,7 +286,7 @@ pseye_detach(device_t self, int flags) } if (sc->sc_bulkin_xfer != NULL) { - usbd_free_xfer(sc->sc_bulkin_xfer); + usbd_destroy_xfer(sc->sc_bulkin_xfer); sc->sc_bulkin_xfer = NULL; } @@ -621,8 +623,7 @@ pseye_get_frame(struct pseye_softc *sc, return USBD_IOERROR; return usbd_bulk_transfer(sc->sc_bulkin_xfer, sc->sc_bulkin_pipe, - USBD_SHORT_XFER_OK, 1000, - sc->sc_bulkin_buffer, plen); + USBD_SHORT_XFER_OK, 1000, sc->sc_bulkin_buffer, plen); } static int @@ -641,8 +642,6 @@ pseye_init_pipes(struct pseye_softc *sc) return ENOMEM; } - pseye_start(sc); - return 0; } @@ -655,8 +654,6 @@ pseye_close_pipes(struct pseye_softc *sc sc->sc_bulkin_pipe = NULL; } - pseye_stop(sc); - return 0; } @@ -730,7 +727,9 @@ pseye_open(void *opaque, int flags) if (sc->sc_dying) return EIO; - return pseye_init_pipes(sc); + pseye_start(sc); + + return 0; } static void @@ -738,7 +737,7 @@ pseye_close(void *opaque) { struct pseye_softc *sc = opaque; - pseye_close_pipes(sc); + pseye_stop(sc); } static const char * Index: sys/dev/usb/stuirda.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/stuirda.c,v retrieving revision 1.16.2.6 diff -u -p -r1.16.2.6 stuirda.c --- sys/dev/usb/stuirda.c 21 Mar 2015 11:33:37 -0000 1.16.2.6 +++ sys/dev/usb/stuirda.c 4 Oct 2015 08:34:42 -0000 @@ -230,23 +230,21 @@ stuirda_fwload(struct uirda_softc *sc) { device_xname(sc->sc_dev), rc); goto giveup3; } - fwxfer = usbd_alloc_xfer(sc->sc_udev); - if (fwxfer == NULL) { + + /* XXXNH USBD_FORCE_SHORT_XFER? */ + int err = usbd_create_xfer(fwpipe, 1024, USBD_FORCE_SHORT_XFER, 0, + &fwxfer); + if (err) { printf("%s: Cannot alloc xfer\n", device_xname(sc->sc_dev)); goto giveup4; } - usbbuf = usbd_alloc_buffer(fwxfer, 1024); - if (usbbuf == NULL) { - printf("%s: Cannot alloc usb buf\n", device_xname(sc->sc_dev)); - goto giveup5; - } + usbbuf = usbd_get_buffer(fwxfer); n = (buffer + fwsize - p); while (n > 0) { if (n > 1023) n = 1023; memcpy(usbbuf, p, n); - rc = usbd_bulk_transfer(fwxfer, fwpipe, - USBD_SYNCHRONOUS|USBD_FORCE_SHORT_XFER, + rc = usbd_bulk_transfer(fwxfer, fwpipe, USBD_FORCE_SHORT_XFER, 5000, usbbuf, &n); printf("%s: write: rc=%d, %d left\n", device_xname(sc->sc_dev), rc, n); @@ -262,9 +260,8 @@ stuirda_fwload(struct uirda_softc *sc) { delay(100000); /* TODO: more code here */ rc = 0; - usbd_free_buffer(fwxfer); + usbd_destroy_xfer(fwxfer); - giveup5: usbd_free_xfer(fwxfer); giveup4: usbd_close_pipe(fwpipe); giveup3: firmware_free(buffer, fwsize); giveup2: firmware_close(fh); @@ -307,25 +304,25 @@ stuirda_write(void *h, struct uio *uio, } error = uiomove(sc->sc_wr_buf + STUIRDA_HEADER_SIZE, n, uio); - if (!error) { - DPRINTFN(1, ("uirdawrite: transfer %d bytes\n", n)); + if (error) + goto done; - n += STUIRDA_HEADER_SIZE + sc->sc_wr_buf[1]; - err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, - USBD_FORCE_SHORT_XFER, - UIRDA_WR_TIMEOUT, - sc->sc_wr_buf, &n); - DPRINTFN(2, ("uirdawrite: err=%d\n", err)); - if (err) { - if (err == USBD_INTERRUPTED) - error = EINTR; - else if (err == USBD_TIMEOUT) - error = ETIMEDOUT; - else - error = EIO; - } - } + DPRINTFN(1, ("uirdawrite: transfer %d bytes\n", n)); + + n += STUIRDA_HEADER_SIZE + sc->sc_wr_buf[1]; + err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, + USBD_FORCE_SHORT_XFER, UIRDA_WR_TIMEOUT, sc->sc_wr_buf, &n); + DPRINTFN(2, ("uirdawrite: err=%d\n", err)); + if (err) { + if (err == USBD_INTERRUPTED) + error = EINTR; + else if (err == USBD_TIMEOUT) + error = ETIMEDOUT; + else + error = EIO; + } +done: mutex_exit(&sc->sc_wr_buf_lk); if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); Index: sys/dev/usb/u3g.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/u3g.c,v retrieving revision 1.31.2.9 diff -u -p -r1.31.2.9 u3g.c --- sys/dev/usb/u3g.c 21 Mar 2015 11:33:37 -0000 1.31.2.9 +++ sys/dev/usb/u3g.c 4 Oct 2015 08:34:42 -0000 @@ -311,9 +311,10 @@ send_bulkmsg(struct usbd_device *dev, vo return UMATCH_NONE; } - xfer = usbd_alloc_xfer(dev); - if (xfer != NULL) { - usbd_setup_xfer(xfer, pipe, NULL, cmd, cmdlen, + int error = usbd_create_xfer(pipe, cmdlen, 0, 0, &xfer); + if (!error) { + + usbd_setup_xfer(xfer, NULL, cmd, cmdlen, USBD_SYNCHRONOUS, USBD_DEFAULT_TIMEOUT, NULL); err = usbd_transfer(xfer); @@ -324,7 +325,7 @@ send_bulkmsg(struct usbd_device *dev, vo #else err = 0; #endif - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); } else { aprint_error("u3ginit: failed to allocate xfer\n"); err = USBD_NOMEM; Index: sys/dev/usb/uaudio.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uaudio.c,v retrieving revision 1.140.2.10 diff -u -p -r1.140.2.10 uaudio.c --- sys/dev/usb/uaudio.c 29 Sep 2015 11:38:29 -0000 1.140.2.10 +++ sys/dev/usb/uaudio.c 4 Oct 2015 08:34:42 -0000 @@ -2619,8 +2619,11 @@ uaudio_trigger_input(void *addr, void *s ch->intr = intr; ch->arg = arg; - for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) /* XXX -1 shouldn't be needed */ + /* XXX -1 shouldn't be needed */ + for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) { uaudio_chan_rtransfer(ch); + } + mutex_spin_enter(&sc->sc_intr_lock); return 0; @@ -2744,22 +2747,19 @@ uaudio_chan_close(struct uaudio_softc *s Static usbd_status uaudio_chan_alloc_buffers(struct uaudio_softc *sc, struct chan *ch) { - struct usbd_xfer *xfer; - void *tbuf; int i, size; size = (ch->bytes_per_frame + ch->sample_size) * UAUDIO_NFRAMES; for (i = 0; i < UAUDIO_NCHANBUFS; i++) { - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) + struct usbd_xfer *xfer; + + int err = usbd_create_xfer(ch->pipe, size, 0, UAUDIO_NFRAMES, + &xfer); + if (err) goto bad; + ch->chanbufs[i].xfer = xfer; - tbuf = usbd_alloc_buffer(xfer, size); - if (tbuf == 0) { - i++; - goto bad; - } - ch->chanbufs[i].buffer = tbuf; + ch->chanbufs[i].buffer = usbd_get_buffer(xfer); ch->chanbufs[i].chan = ch; } @@ -2768,7 +2768,7 @@ uaudio_chan_alloc_buffers(struct uaudio_ bad: while (--i >= 0) /* implicit buffer free */ - usbd_free_xfer(ch->chanbufs[i].xfer); + usbd_destroy_xfer(ch->chanbufs[i].xfer); return USBD_NOMEM; } @@ -2778,7 +2778,7 @@ uaudio_chan_free_buffers(struct uaudio_s int i; for (i = 0; i < UAUDIO_NCHANBUFS; i++) - usbd_free_xfer(ch->chanbufs[i].xfer); + usbd_destroy_xfer(ch->chanbufs[i].xfer); } /* Called with USB lock held. */ @@ -2839,9 +2839,8 @@ uaudio_chan_ptransfer(struct chan *ch) //DPRINTFN(5, "ptransfer xfer=%p\n", cb->xfer); /* Fill the request */ - usbd_setup_isoc_xfer(cb->xfer, ch->pipe, cb, cb->sizes, - UAUDIO_NFRAMES, 0, - uaudio_chan_pintr); + usbd_setup_isoc_xfer(cb->xfer, cb, cb->sizes, UAUDIO_NFRAMES, 0, + uaudio_chan_pintr); (void)usbd_transfer(cb->xfer); } @@ -2922,9 +2921,8 @@ uaudio_chan_rtransfer(struct chan *ch) DPRINTFN(5, "transfer xfer=%p\n", cb->xfer); /* Fill the request */ - usbd_setup_isoc_xfer(cb->xfer, ch->pipe, cb, cb->sizes, - UAUDIO_NFRAMES, 0, - uaudio_chan_rintr); + usbd_setup_isoc_xfer(cb->xfer, cb, cb->sizes, UAUDIO_NFRAMES, 0, + uaudio_chan_rintr); (void)usbd_transfer(cb->xfer); } Index: sys/dev/usb/ubt.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ubt.c,v retrieving revision 1.51.4.5 diff -u -p -r1.51.4.5 ubt.c --- sys/dev/usb/ubt.c 21 Mar 2015 11:33:37 -0000 1.51.4.5 +++ sys/dev/usb/ubt.c 4 Oct 2015 08:34:43 -0000 @@ -775,32 +775,32 @@ ubt_abortdealloc(struct ubt_softc *sc) /* Free all xfers and xfer buffers (implicit) */ if (sc->sc_cmd_xfer != NULL) { - usbd_free_xfer(sc->sc_cmd_xfer); + usbd_destroy_xfer(sc->sc_cmd_xfer); sc->sc_cmd_xfer = NULL; sc->sc_cmd_buf = NULL; } if (sc->sc_aclrd_xfer != NULL) { - usbd_free_xfer(sc->sc_aclrd_xfer); + usbd_destroy_xfer(sc->sc_aclrd_xfer); sc->sc_aclrd_xfer = NULL; sc->sc_aclrd_buf = NULL; } if (sc->sc_aclwr_xfer != NULL) { - usbd_free_xfer(sc->sc_aclwr_xfer); + usbd_destroy_xfer(sc->sc_aclwr_xfer); sc->sc_aclwr_xfer = NULL; sc->sc_aclwr_buf = NULL; } for (i = 0 ; i < UBT_NXFERS ; i++) { if (sc->sc_scord[i].xfer != NULL) { - usbd_free_xfer(sc->sc_scord[i].xfer); + usbd_destroy_xfer(sc->sc_scord[i].xfer); sc->sc_scord[i].xfer = NULL; sc->sc_scord[i].buf = NULL; } if (sc->sc_scowr[i].xfer != NULL) { - usbd_free_xfer(sc->sc_scowr[i].xfer); + usbd_destroy_xfer(sc->sc_scowr[i].xfer); sc->sc_scowr[i].xfer = NULL; sc->sc_scowr[i].buf = NULL; } @@ -863,16 +863,12 @@ ubt_enable(device_t self) } /* Commands */ - sc->sc_cmd_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_cmd_xfer == NULL) { - error = ENOMEM; - goto bad; - } - sc->sc_cmd_buf = usbd_alloc_buffer(sc->sc_cmd_xfer, UBT_BUFSIZ_CMD); - if (sc->sc_cmd_buf == NULL) { - error = ENOMEM; + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->sc_udev); + error = usbd_create_xfer(pipe0, UBT_BUFSIZ_CMD, 0, 0, + &sc->sc_cmd_xfer); + if (error) goto bad; - } + sc->sc_cmd_buf = usbd_get_buffer(sc->sc_cmd_xfer); sc->sc_cmd_busy = 0; /* ACL read */ @@ -882,16 +878,11 @@ ubt_enable(device_t self) error = EIO; goto bad; } - sc->sc_aclrd_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_aclrd_xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_aclrd_pipe, UBT_BUFSIZ_ACL, + USBD_SHORT_XFER_OK, 0, &sc->sc_aclrd_xfer); + if (error) goto bad; - } - sc->sc_aclrd_buf = usbd_alloc_buffer(sc->sc_aclrd_xfer, UBT_BUFSIZ_ACL); - if (sc->sc_aclrd_buf == NULL) { - error = ENOMEM; - goto bad; - } + sc->sc_aclrd_buf = usbd_get_buffer(sc->sc_aclrd_xfer); sc->sc_aclrd_busy = 0; ubt_recv_acl_start(sc); @@ -902,16 +893,11 @@ ubt_enable(device_t self) error = EIO; goto bad; } - sc->sc_aclwr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_aclwr_xfer == NULL) { - error = ENOMEM; - goto bad; - } - sc->sc_aclwr_buf = usbd_alloc_buffer(sc->sc_aclwr_xfer, UBT_BUFSIZ_ACL); - if (sc->sc_aclwr_buf == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_aclwr_pipe, UBT_BUFSIZ_ACL, + USBD_FORCE_SHORT_XFER, 0, &sc->sc_aclwr_xfer); + if (error) goto bad; - } + sc->sc_aclwr_xfer = usbd_get_buffer(sc->sc_aclwr_xfer); sc->sc_aclwr_busy = 0; /* SCO read */ @@ -924,17 +910,15 @@ ubt_enable(device_t self) } for (i = 0 ; i < UBT_NXFERS ; i++) { - sc->sc_scord[i].xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_scord[i].xfer == NULL) { - error = ENOMEM; - goto bad; - } - sc->sc_scord[i].buf = usbd_alloc_buffer(sc->sc_scord[i].xfer, - sc->sc_scord_size * UBT_NFRAMES); - if (sc->sc_scord[i].buf == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_scord_pipe, + sc->sc_scord_size * UBT_NFRAMES, + USBD_SHORT_XFER_OK, UBT_NFRAMES, + &sc->sc_scord[i].xfer); + if (error) goto bad; - } + + sc->sc_scord[i].buf = + usbd_get_buffer(sc->sc_scord[i].xfer); sc->sc_scord[i].softc = sc; sc->sc_scord[i].busy = 0; ubt_recv_sco_start1(sc, &sc->sc_scord[i]); @@ -951,17 +935,14 @@ ubt_enable(device_t self) } for (i = 0 ; i < UBT_NXFERS ; i++) { - sc->sc_scowr[i].xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_scowr[i].xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_scowr_pipe, + sc->sc_scowr_size * UBT_NFRAMES, + USBD_FORCE_SHORT_XFER, UBT_NFRAMES, + &sc->sc_scowr[i].xfer); + if (error) goto bad; - } - sc->sc_scowr[i].buf = usbd_alloc_buffer(sc->sc_scowr[i].xfer, - sc->sc_scowr_size * UBT_NFRAMES); - if (sc->sc_scowr[i].buf == NULL) { - error = ENOMEM; - goto bad; - } + sc->sc_scowr[i].buf = + usbd_get_buffer(sc->sc_scowr[i].xfer); sc->sc_scowr[i].softc = sc; sc->sc_scowr[i].busy = 0; } @@ -1160,7 +1141,6 @@ ubt_xmit_acl_start(struct ubt_softc *sc) sc->sc_stats.byte_tx += len; usbd_setup_xfer(sc->sc_aclwr_xfer, - sc->sc_aclwr_pipe, sc, sc->sc_aclwr_buf, len, @@ -1321,7 +1301,6 @@ ubt_xmit_sco_start1(struct ubt_softc *sc } usbd_setup_isoc_xfer(isoc->xfer, - sc->sc_scowr_pipe, isoc, isoc->size, num, @@ -1456,7 +1435,6 @@ ubt_recv_acl_start(struct ubt_softc *sc) sc->sc_aclrd_busy = 1; usbd_setup_xfer(sc->sc_aclrd_xfer, - sc->sc_aclrd_pipe, sc, sc->sc_aclrd_buf, UBT_BUFSIZ_ACL, @@ -1555,7 +1533,6 @@ ubt_recv_sco_start1(struct ubt_softc *sc isoc->size[i] = sc->sc_scord_size; usbd_setup_isoc_xfer(isoc->xfer, - sc->sc_scord_pipe, isoc, isoc->size, UBT_NFRAMES, Index: sys/dev/usb/ucom.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ucom.c,v retrieving revision 1.108.2.8 diff -u -p -r1.108.2.8 ucom.c --- sys/dev/usb/ucom.c 19 Sep 2015 07:39:51 -0000 1.108.2.8 +++ sys/dev/usb/ucom.c 4 Oct 2015 08:34:43 -0000 @@ -287,6 +287,64 @@ ucom_attach(device_t parent, device_t se cv_init(&sc->sc_opencv, "ucomopen"); cv_init(&sc->sc_detachcv, "ucomdtch"); + SIMPLEQ_INIT(&sc->sc_ibuff_empty); + SIMPLEQ_INIT(&sc->sc_ibuff_full); + SIMPLEQ_INIT(&sc->sc_obuff_free); + SIMPLEQ_INIT(&sc->sc_obuff_full); + + DPRINTF("open pipes in=%d out=%d", sc->sc_bulkin_no, sc->sc_bulkout_no, + 0, 0); + + struct ucom_buffer *ub; + usbd_status err; + int error; + + /* Open the bulk pipes */ + err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no, + USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); + if (err) { + DPRINTF("open bulk in error (addr %d), err=%d", + sc->sc_bulkin_no, err, 0, 0); + error = EIO; + goto fail_0; + } + err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no, + USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); + if (err) { + DPRINTF("open bulk out error (addr %d), err=%d", + sc->sc_bulkout_no, err, 0, 0); + error = EIO; + goto fail_1; + } + + for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; + ub++) { + ub->ub_xfer = NULL; + } + for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; + ub++) { + ub->ub_xfer = NULL; + } + /* Allocate input buffers */ + for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; + ub++) { + error = usbd_create_xfer(sc->sc_bulkin_pipe, sc->sc_ibufsizepad, + USBD_SHORT_XFER_OK, 0, &ub->ub_xfer); + if (error) + goto fail_2; + ub->ub_data = usbd_get_buffer(ub->ub_xfer); + } + + for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; + ub++) { + error = usbd_create_xfer(sc->sc_bulkout_pipe, sc->sc_obufsize, + 0, 0, &ub->ub_xfer); + if (error) + goto fail_2; + ub->ub_data = usbd_get_buffer(ub->ub_xfer); + SIMPLEQ_INSERT_TAIL(&sc->sc_obuff_free, ub, ub_link); + } + tp = tty_alloc(); tp->t_oproc = ucomstart; tp->t_param = ucomparam; @@ -302,6 +360,26 @@ ucom_attach(device_t parent, device_t se if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); return; + +fail_2: + for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; + ub++) { + if (ub->ub_xfer) + usbd_destroy_xfer(ub->ub_xfer); + } + for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; + ub++) { + if (ub->ub_xfer) + usbd_destroy_xfer(ub->ub_xfer); + } + +fail_1: + usbd_close_pipe(sc->sc_bulkin_pipe); + +fail_0: + aprint_error_dev(self, "attach failed, error=%d\n", error); + + return; } int @@ -364,12 +442,12 @@ ucom_detach(device_t self, int flags) for (i = 0; i < UCOM_IN_BUFFS; i++) { if (sc->sc_ibuff[i].ub_xfer != NULL) - usbd_free_xfer(sc->sc_ibuff[i].ub_xfer); + usbd_destroy_xfer(sc->sc_ibuff[i].ub_xfer); } for (i = 0; i < UCOM_OUT_BUFFS; i++) { if (sc->sc_obuff[i].ub_xfer != NULL) - usbd_free_xfer(sc->sc_obuff[i].ub_xfer); + usbd_destroy_xfer(sc->sc_obuff[i].ub_xfer); } /* Detach the random source */ @@ -425,11 +503,9 @@ int ucomopen(dev_t dev, int flag, int mode, struct lwp *l) { int unit = UCOMUNIT(dev); - usbd_status err; struct ucom_softc *sc = device_lookup_private(&ucom_cd, unit); struct ucom_buffer *ub; struct tty *tp; - int i; int error; UCOMHIST_FUNC(); UCOMHIST_CALLED(); @@ -529,77 +605,19 @@ ucomopen(dev_t dev, int flag, int mode, ucom_dtr(sc, 1); ucom_rts(sc, 1); - DPRINTF("open pipes in=%d out=%d", sc->sc_bulkin_no, - sc->sc_bulkout_no, 0, 0); - - /* Open the bulk pipes */ - err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no, - USBD_EXCLUSIVE_USE, &sc->sc_bulkin_pipe); - if (err) { - DPRINTF("open bulk in error (addr %d), err=%d", - sc->sc_bulkin_no, err, 0, 0); - error = EIO; - goto fail_0; - } - err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no, - USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe); - if (err) { - DPRINTF("open bulk out error (addr %d), err=%d", - sc->sc_bulkout_no, err, 0, 0); - error = EIO; - goto fail_1; - } - sc->sc_rx_unblock = 0; sc->sc_rx_stopped = 0; sc->sc_tx_stopped = 0; memset(sc->sc_ibuff, 0, sizeof(sc->sc_ibuff)); memset(sc->sc_obuff, 0, sizeof(sc->sc_obuff)); - - SIMPLEQ_INIT(&sc->sc_ibuff_empty); - SIMPLEQ_INIT(&sc->sc_ibuff_full); - SIMPLEQ_INIT(&sc->sc_obuff_free); - SIMPLEQ_INIT(&sc->sc_obuff_full); - - /* Allocate input buffers */ for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; ub++) { - ub->ub_xfer = usbd_alloc_xfer(sc->sc_udev); - if (ub->ub_xfer == NULL) { - error = ENOMEM; - goto fail_2; - } - ub->ub_data = usbd_alloc_buffer(ub->ub_xfer, - sc->sc_ibufsizepad); - if (ub->ub_data == NULL) { - error = ENOMEM; - goto fail_2; - } - if (ucomsubmitread(sc, ub) != USBD_NORMAL_COMPLETION) { error = EIO; goto fail_2; } } - - for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; - ub++) { - ub->ub_xfer = usbd_alloc_xfer(sc->sc_udev); - if (ub->ub_xfer == NULL) { - error = ENOMEM; - goto fail_2; - } - ub->ub_data = usbd_alloc_buffer(ub->ub_xfer, - sc->sc_obufsize); - if (ub->ub_data == NULL) { - error = ENOMEM; - goto fail_2; - } - - SIMPLEQ_INSERT_TAIL(&sc->sc_obuff_free, ub, ub_link); - } - } sc->sc_opening = 0; cv_signal(&sc->sc_opencv); @@ -617,28 +635,8 @@ ucomopen(dev_t dev, int flag, int mode, fail_2: usbd_abort_pipe(sc->sc_bulkin_pipe); - for (i = 0; i < UCOM_IN_BUFFS; i++) { - if (sc->sc_ibuff[i].ub_xfer != NULL) { - usbd_free_xfer(sc->sc_ibuff[i].ub_xfer); - sc->sc_ibuff[i].ub_xfer = NULL; - sc->sc_ibuff[i].ub_data = NULL; - } - } usbd_abort_pipe(sc->sc_bulkout_pipe); - for (i = 0; i < UCOM_OUT_BUFFS; i++) { - if (sc->sc_obuff[i].ub_xfer != NULL) { - usbd_free_xfer(sc->sc_obuff[i].ub_xfer); - sc->sc_obuff[i].ub_xfer = NULL; - sc->sc_obuff[i].ub_data = NULL; - } - } - usbd_close_pipe(sc->sc_bulkout_pipe); - sc->sc_bulkout_pipe = NULL; -fail_1: - usbd_close_pipe(sc->sc_bulkin_pipe); - sc->sc_bulkin_pipe = NULL; -fail_0: mutex_enter(sc->sc_lock); sc->sc_opening = 0; cv_signal(&sc->sc_opencv); @@ -1281,8 +1279,7 @@ ucom_submit_write(struct ucom_softc *sc, KASSERT(mutex_owned(sc->sc_lock)); - usbd_setup_xfer(ub->ub_xfer, sc->sc_bulkout_pipe, - (void *)sc, ub->ub_data, ub->ub_len, + usbd_setup_xfer(ub->ub_xfer, sc, ub->ub_data, ub->ub_len, 0, USBD_NO_TIMEOUT, ucomwritecb); ucom_write_status(sc, ub, usbd_transfer(ub->ub_xfer)); @@ -1368,8 +1365,7 @@ ucomsubmitread(struct ucom_softc *sc, st { usbd_status err; - usbd_setup_xfer(ub->ub_xfer, sc->sc_bulkin_pipe, - (void *)sc, ub->ub_data, sc->sc_ibufsize, + usbd_setup_xfer(ub->ub_xfer, sc, ub->ub_data, sc->sc_ibufsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, ucomreadcb); if ((err = usbd_transfer(ub->ub_xfer)) != USBD_IN_PROGRESS) { @@ -1463,11 +1459,10 @@ ucomreadcb(struct usbd_xfer *xfer, void static void ucom_cleanup(struct ucom_softc *sc) { - struct ucom_buffer *ub; UCOMHIST_FUNC(); UCOMHIST_CALLED(); - DPRINTF("closing pipes", 0, 0, 0, 0); + DPRINTF("aborting pipes", 0, 0, 0, 0); KASSERT(mutex_owned(sc->sc_lock)); @@ -1477,7 +1472,6 @@ ucom_cleanup(struct ucom_softc *sc) sc->sc_bulkin_pipe = NULL; mutex_exit(sc->sc_lock); usbd_abort_pipe(bulkin_pipe); - usbd_close_pipe(bulkin_pipe); mutex_enter(sc->sc_lock); } if (sc->sc_bulkout_pipe != NULL) { @@ -1485,23 +1479,8 @@ ucom_cleanup(struct ucom_softc *sc) sc->sc_bulkout_pipe = NULL; mutex_exit(sc->sc_lock); usbd_abort_pipe(bulkout_pipe); - usbd_close_pipe(bulkout_pipe); mutex_enter(sc->sc_lock); } - for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; ub++) { - if (ub->ub_xfer != NULL) { - usbd_free_xfer(ub->ub_xfer); - ub->ub_xfer = NULL; - ub->ub_data = NULL; - } - } - for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; ub++){ - if (ub->ub_xfer != NULL) { - usbd_free_xfer(ub->ub_xfer); - ub->ub_xfer = NULL; - ub->ub_data = NULL; - } - } } #endif /* NUCOM > 0 */ Index: sys/dev/usb/ucycom.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ucycom.c,v retrieving revision 1.41.2.7 diff -u -p -r1.41.2.7 ucycom.c --- sys/dev/usb/ucycom.c 6 Apr 2015 15:18:13 -0000 1.41.2.7 +++ sys/dev/usb/ucycom.c 4 Oct 2015 08:34:43 -0000 @@ -576,10 +576,8 @@ ucycomstart(struct tty *tp) } #endif DPRINTFN(4,("ucycomstart: %d chars\n", len)); - usbd_setup_xfer(sc->sc_hdev.sc_parent->sc_oxfer, - sc->sc_hdev.sc_parent->sc_opipe, (void *)sc, - sc->sc_obuf, sc->sc_olen, 0 /* USBD_NO_COPY */, USBD_NO_TIMEOUT, - ucycomwritecb); + usbd_setup_xfer(sc->sc_hdev.sc_parent->sc_oxfer, sc, sc->sc_obuf, + sc->sc_olen, 0, USBD_NO_TIMEOUT, ucycomwritecb); /* What can we do on error? */ err = usbd_transfer(sc->sc_hdev.sc_parent->sc_oxfer); Index: sys/dev/usb/udl.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/udl.c,v retrieving revision 1.11.6.5 diff -u -p -r1.11.6.5 udl.c --- sys/dev/usb/udl.c 6 Apr 2015 15:18:13 -0000 1.11.6.5 +++ sys/dev/usb/udl.c 4 Oct 2015 08:34:44 -0000 @@ -835,20 +835,15 @@ udl_cmdq_alloc(struct udl_softc *sc) cmdq->cq_sc = sc; - cmdq->cq_xfer = usbd_alloc_xfer(sc->sc_udev); - if (cmdq->cq_xfer == NULL) { + int err = usbd_create_xfer(sc->sc_tx_pipeh, + UDL_CMD_BUFFER_SIZE, 0, 0, &cmdq->cq_xfer); + if (err) { aprint_error_dev(sc->sc_dev, "%s: can't allocate xfer handle!\n", __func__); goto error; } - cmdq->cq_buf = - usbd_alloc_buffer(cmdq->cq_xfer, UDL_CMD_BUFFER_SIZE); - if (cmdq->cq_buf == NULL) { - aprint_error_dev(sc->sc_dev, - "%s: can't allocate xfer buffer!\n", __func__); - goto error; - } + cmdq->cq_buf = usbd_get_buffer(cmdq->cq_xfer); TAILQ_INSERT_TAIL(&sc->sc_freecmd, cmdq, cq_chain); } @@ -870,7 +865,7 @@ udl_cmdq_free(struct udl_softc *sc) cmdq = &sc->sc_cmdq[i]; if (cmdq->cq_xfer != NULL) { - usbd_free_xfer(cmdq->cq_xfer); + usbd_destroy_xfer(cmdq->cq_xfer); cmdq->cq_xfer = NULL; cmdq->cq_buf = NULL; } @@ -1430,8 +1425,8 @@ udl_cmd_send(struct udl_softc *sc) len = UDL_CMD_BUFSIZE(sc); /* do xfer */ - error = usbd_bulk_transfer(cmdq->cq_xfer, sc->sc_tx_pipeh, - 0, USBD_NO_TIMEOUT, cmdq->cq_buf, &len); + error = usbd_bulk_transfer(cmdq->cq_xfer, sc->sc_tx_pipeh, 0, + USBD_NO_TIMEOUT, cmdq->cq_buf, &len); UDL_CMD_BUFINIT(sc); @@ -1482,7 +1477,7 @@ udl_cmd_send_async(struct udl_softc *sc) /* do xfer */ mutex_enter(&sc->sc_mtx); - usbd_setup_xfer(cmdq->cq_xfer, sc->sc_tx_pipeh, cmdq, cmdq->cq_buf, + usbd_setup_xfer(cmdq->cq_xfer, cmdq, cmdq->cq_buf, len, 0, USBD_NO_TIMEOUT, udl_cmd_send_async_cb); error = usbd_transfer(cmdq->cq_xfer); if (error != USBD_NORMAL_COMPLETION && error != USBD_IN_PROGRESS) { Index: sys/dev/usb/udsir.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/udsir.c,v retrieving revision 1.1.14.5 diff -u -p -r1.1.14.5 udsir.c --- sys/dev/usb/udsir.c 21 Mar 2015 11:33:37 -0000 1.1.14.5 +++ sys/dev/usb/udsir.c 4 Oct 2015 08:34:44 -0000 @@ -329,26 +329,19 @@ udsir_open(void *h, int flag, int mode, error = EIO; goto bad2; } - sc->sc_rd_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_rd_xfer == NULL) { - error = ENOMEM; - goto bad3; - } - sc->sc_wr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_wr_xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_rd_pipe, sc->sc_rd_maxpsz, + USBD_SHORT_XFER_OK, 0, &sc->sc_rd_xfer); + if (error) + goto bad3; + + error = usbd_create_xfer(sc->sc_wr_pipe, IRDA_MAX_FRAME_SIZE, + USBD_FORCE_SHORT_XFER, 0, &sc->sc_wr_xfer); + if (error) goto bad4; - } - sc->sc_rd_buf = usbd_alloc_buffer(sc->sc_rd_xfer, sc->sc_rd_maxpsz); - if (sc->sc_rd_buf == NULL) { - error = ENOMEM; - goto bad5; - } - sc->sc_wr_buf = usbd_alloc_buffer(sc->sc_wr_xfer, IRDA_MAX_FRAME_SIZE); - if (sc->sc_wr_buf == NULL) { - error = ENOMEM; - goto bad5; - } + + sc->sc_rd_buf = usbd_get_buffer(sc->sc_rd_xfer); + sc->sc_wr_buf = usbd_get_buffer(sc->sc_wr_xfer); + sc->sc_ur_buf = kmem_alloc(IRDA_MAX_FRAME_SIZE, KM_SLEEP); if (sc->sc_ur_buf == NULL) { error = ENOMEM; @@ -382,10 +375,10 @@ udsir_open(void *h, int flag, int mode, return 0; bad5: - usbd_free_xfer(sc->sc_wr_xfer); + usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; bad4: - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; bad3: usbd_close_pipe(sc->sc_wr_pipe); @@ -426,12 +419,12 @@ udsir_close(void *h, int flag, int mode, sc->sc_wr_pipe = NULL; } if (sc->sc_rd_xfer != NULL) { - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { - usbd_free_xfer(sc->sc_wr_xfer); + usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } @@ -604,8 +597,8 @@ udsir_write(void *h, struct uio *uio, in #endif err = usbd_intr_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, - USBD_FORCE_SHORT_XFER, UDSIR_WR_TIMEOUT, - wrbuf, &btlen); + USBD_FORCE_SHORT_XFER, UDSIR_WR_TIMEOUT, + wrbuf, &btlen); DPRINTFN(2, ("%s: err=%d\n", __func__, err)); if (err != USBD_NORMAL_COMPLETION) { if (err == USBD_INTERRUPTED) @@ -1044,9 +1037,8 @@ udsir_start_read(struct udsir_softc *sc) usbd_clear_endpoint_stall(sc->sc_rd_pipe); } - usbd_setup_xfer(sc->sc_rd_xfer, sc->sc_rd_pipe, sc, sc->sc_rd_buf, - sc->sc_rd_maxpsz, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, udsir_rd_cb); + usbd_setup_xfer(sc->sc_rd_xfer, sc, sc->sc_rd_buf, sc->sc_rd_maxpsz, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, udsir_rd_cb); err = usbd_transfer(sc->sc_rd_xfer); if (err != USBD_IN_PROGRESS) { DPRINTFN(0, ("%s: err=%d\n", __func__, (int)err)); Index: sys/dev/usb/ugen.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ugen.c,v retrieving revision 1.126.2.10 diff -u -p -r1.126.2.10 ugen.c --- sys/dev/usb/ugen.c 23 Jun 2015 12:03:29 -0000 1.126.2.10 +++ sys/dev/usb/ugen.c 4 Oct 2015 08:34:44 -0000 @@ -355,7 +355,6 @@ ugenopen(dev_t dev, int flag, int mode, int dir, isize; usbd_status err; struct usbd_xfer *xfer; - void *tbuf; int i, j; sc = device_lookup_private(&ugen_cd, unit); @@ -463,31 +462,25 @@ ugenopen(dev_t dev, int flag, int mode, } for (i = 0; i < UGEN_NISOREQS; ++i) { sce->isoreqs[i].sce = sce; - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) + err = usbd_create_xfer(sce->pipeh, + isize * UGEN_NISORFRMS, 0, UGEN_NISORFRMS, + &xfer); + if (err) goto bad; sce->isoreqs[i].xfer = xfer; - tbuf = usbd_alloc_buffer - (xfer, isize * UGEN_NISORFRMS); - if (tbuf == NULL) { - i++; - goto bad; - } - sce->isoreqs[i].dmabuf = tbuf; + sce->isoreqs[i].dmabuf = usbd_get_buffer(xfer); for (j = 0; j < UGEN_NISORFRMS; ++j) sce->isoreqs[i].sizes[j] = isize; - usbd_setup_isoc_xfer - (xfer, sce->pipeh, &sce->isoreqs[i], - sce->isoreqs[i].sizes, - UGEN_NISORFRMS, 0, - ugen_isoc_rintr); + usbd_setup_isoc_xfer(xfer, &sce->isoreqs[i], + sce->isoreqs[i].sizes, UGEN_NISORFRMS, 0, + ugen_isoc_rintr); (void)usbd_transfer(xfer); } DPRINTFN(5, ("ugenopen: isoc open done\n")); break; bad: while (--i >= 0) /* implicit buffer free */ - usbd_free_xfer(sce->isoreqs[i].xfer); + usbd_destroy_xfer(sce->isoreqs[i].xfer); usbd_close_pipe(sce->pipeh); sce->pipeh = NULL; kmem_free(sce->ibuf, isize * UGEN_NISOFRAMES); @@ -555,12 +548,12 @@ ugenclose(dev_t dev, int flag, int mode, break; case UE_ISOCHRONOUS: for (i = 0; i < UGEN_NISOREQS; ++i) - usbd_free_xfer(sce->isoreqs[i].xfer); + usbd_destroy_xfer(sce->isoreqs[i].xfer); msize = isize * UGEN_NISOFRAMES; break; case UE_BULK: if (sce->state & (UGEN_BULK_RA | UGEN_BULK_WB)) { - usbd_free_xfer(sce->ra_wb_xfer); + usbd_destroy_xfer(sce->ra_wb_xfer); msize = sce->ra_wb_bufsize; } break; @@ -699,8 +692,7 @@ ugen_do_read(struct ugen_softc *sc, int sce->ra_wb_used < sce->limit - sce->ibuf) { n = (sce->limit - sce->ibuf) - sce->ra_wb_used; - usbd_setup_xfer(xfer, - sce->pipeh, sce, NULL, + usbd_setup_xfer(xfer, sce, NULL, min(n, sce->ra_wb_xferlen), 0, USBD_NO_TIMEOUT, ugen_bulkra_intr); @@ -719,17 +711,17 @@ ugen_do_read(struct ugen_softc *sc, int mutex_exit(&sc->sc_lock); break; } - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return ENOMEM; + error = usbd_create_xfer(sce->pipeh, UGEN_BBSIZE, + sce->state & UGEN_SHORT_OK ? USBD_SHORT_XFER_OK : 0, + 0, &xfer); + if (error) + return error; while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) { DPRINTFN(1, ("ugenread: start transfer %d bytes\n",n)); tn = n; - err = usbd_bulk_transfer( - xfer, sce->pipeh, - sce->state & UGEN_SHORT_OK ? - USBD_SHORT_XFER_OK : 0, - sce->timeout, sc->sc_buffer, &tn); + err = usbd_bulk_transfer(xfer, sce->pipeh, + sce->state & UGEN_SHORT_OK ? USBD_SHORT_XFER_OK : 0, + sce->timeout, sc->sc_buffer, &tn); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -744,7 +736,7 @@ ugen_do_read(struct ugen_softc *sc, int if (error || tn < n) break; } - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); break; case UE_ISOCHRONOUS: mutex_enter(&sc->sc_lock); @@ -914,8 +906,7 @@ ugen_do_write(struct ugen_softc *sc, int if (n - tn > 0) memcpy(dbuf, sce->ibuf, n - tn); - usbd_setup_xfer(xfer, - sce->pipeh, sce, NULL, n, + usbd_setup_xfer(xfer, sce, NULL, n, 0, USBD_NO_TIMEOUT, ugen_bulkwb_intr); sce->state &= ~UGEN_RA_WB_STOP; @@ -933,16 +924,18 @@ ugen_do_write(struct ugen_softc *sc, int mutex_exit(&sc->sc_lock); break; } - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return EIO; + error = usbd_create_xfer(sce->pipeh, UGEN_BBSIZE, + sce->state & UGEN_SHORT_OK ? USBD_SHORT_XFER_OK : 0, + 0, &xfer); + if (error) + return error; while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) { error = uiomove(sc->sc_buffer, n, uio); if (error) break; DPRINTFN(1, ("ugenwrite: transfer %d bytes\n", n)); - err = usbd_bulk_transfer(xfer, sce->pipeh, 0, - sce->timeout, sc->sc_buffer, &n); + err = usbd_bulk_transfer(xfer, sce->pipeh, 0, sce->timeout, + sc->sc_buffer, &n); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -953,20 +946,21 @@ ugen_do_write(struct ugen_softc *sc, int break; } } - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); break; case UE_INTERRUPT: - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return EIO; + error = usbd_create_xfer(sce->pipeh, + UGETW(sce->edesc->wMaxPacketSize), 0, 0, &xfer); + if (error) + return error; while ((n = min(UGETW(sce->edesc->wMaxPacketSize), uio->uio_resid)) != 0) { error = uiomove(sc->sc_buffer, n, uio); if (error) break; DPRINTFN(1, ("ugenwrite: transfer %d bytes\n", n)); - err = usbd_intr_transfer(xfer, sce->pipeh, 0, - sce->timeout, sc->sc_buffer, &n); + err = usbd_intr_transfer(xfer, sce->pipeh, 0, sce->timeout, + sc->sc_buffer, &n); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -977,7 +971,7 @@ ugen_do_write(struct ugen_softc *sc, int break; } } - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); break; default: return ENXIO; @@ -1165,8 +1159,8 @@ ugen_isoc_rintr(struct usbd_xfer *xfer, req->sizes[i] = isize; } - usbd_setup_isoc_xfer(xfer, sce->pipeh, req, req->sizes, UGEN_NISORFRMS, - 0, ugen_isoc_rintr); + usbd_setup_isoc_xfer(xfer, req, req->sizes, UGEN_NISORFRMS, 0, + ugen_isoc_rintr); (void)usbd_transfer(xfer); mutex_enter(&sc->sc_lock); @@ -1223,8 +1217,7 @@ ugen_bulkra_intr(struct usbd_xfer *xfer, /* Set up the next request if necessary. */ n = (sce->limit - sce->ibuf) - sce->ra_wb_used; if (n > 0) { - usbd_setup_xfer(xfer, sce->pipeh, sce, NULL, - min(n, sce->ra_wb_xferlen), 0, + usbd_setup_xfer(xfer, sce, NULL, min(n, sce->ra_wb_xferlen), 0, USBD_NO_TIMEOUT, ugen_bulkra_intr); err = usbd_transfer(xfer); if (err != USBD_IN_PROGRESS) { @@ -1292,8 +1285,8 @@ ugen_bulkwb_intr(struct usbd_xfer *xfer, if (count - n > 0) memcpy(tbuf, sce->ibuf, count - n); - usbd_setup_xfer(xfer, sce->pipeh, sce, NULL, - count, 0, USBD_NO_TIMEOUT, ugen_bulkwb_intr); + usbd_setup_xfer(xfer, sce, NULL, count, 0, USBD_NO_TIMEOUT, + ugen_bulkwb_intr); err = usbd_transfer(xfer); if (err != USBD_IN_PROGRESS) { printf("usbd_bulkwb_intr: error=%d\n", err); @@ -1436,6 +1429,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int struct usb_string_desc *si; uint8_t conf, alt; int cdesclen; + int error; DPRINTFN(5, ("ugenioctl: cmd=%08lx\n", cmd)); if (sc->sc_dying) @@ -1485,19 +1479,11 @@ ugen_do_ioctl(struct ugen_softc *sc, int if (sce->ra_wb_bufsize == 0 || sce->ra_wb_reqsize == 0) /* shouldn't happen */ return EINVAL; - sce->ra_wb_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sce->ra_wb_xfer == NULL) - return ENOMEM; + error = usbd_create_xfer(sce->pipeh, + sce->ra_wb_reqsize, 0, 0, &sce->ra_wb_xfer); + if (error) + return error; sce->ra_wb_xferlen = sce->ra_wb_reqsize; - /* - * Set up a dmabuf because we reuse the xfer with - * the same (max) request length like isoc. - */ - if (usbd_alloc_buffer(sce->ra_wb_xfer, - sce->ra_wb_xferlen) == 0) { - usbd_free_xfer(sce->ra_wb_xfer); - return ENOMEM; - } sce->ibuf = kmem_alloc(sce->ra_wb_bufsize, KM_SLEEP); sce->fill = sce->cur = sce->ibuf; sce->limit = sce->ibuf + sce->ra_wb_bufsize; @@ -1505,17 +1491,15 @@ ugen_do_ioctl(struct ugen_softc *sc, int sce->state |= UGEN_BULK_RA; sce->state &= ~UGEN_RA_WB_STOP; /* Now start reading. */ - usbd_setup_xfer(sce->ra_wb_xfer, sce->pipeh, sce, - NULL, + usbd_setup_xfer(sce->ra_wb_xfer, sce, NULL, min(sce->ra_wb_xferlen, sce->ra_wb_bufsize), - 0, USBD_NO_TIMEOUT, - ugen_bulkra_intr); + 0, USBD_NO_TIMEOUT, ugen_bulkra_intr); err = usbd_transfer(sce->ra_wb_xfer); if (err != USBD_IN_PROGRESS) { sce->state &= ~UGEN_BULK_RA; kmem_free(sce->ibuf, sce->ra_wb_bufsize); sce->ibuf = NULL; - usbd_free_xfer(sce->ra_wb_xfer); + usbd_destroy_xfer(sce->ra_wb_xfer); return EIO; } } else { @@ -1525,7 +1509,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int sce->state &= ~UGEN_BULK_RA; usbd_abort_pipe(sce->pipeh); - usbd_free_xfer(sce->ra_wb_xfer); + usbd_destroy_xfer(sce->ra_wb_xfer); /* * XXX Discard whatever's in the buffer, but we * should keep it around and drain the buffer @@ -1553,19 +1537,9 @@ ugen_do_ioctl(struct ugen_softc *sc, int if (sce->ra_wb_bufsize == 0 || sce->ra_wb_reqsize == 0) /* shouldn't happen */ return EINVAL; - sce->ra_wb_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sce->ra_wb_xfer == NULL) - return ENOMEM; + error = usbd_create_xfer(sce->pipeh, sce->ra_wb_reqsize, + 0, 0, &sce->ra_wb_xfer); sce->ra_wb_xferlen = sce->ra_wb_reqsize; - /* - * Set up a dmabuf because we reuse the xfer with - * the same (max) request length like isoc. - */ - if (usbd_alloc_buffer(sce->ra_wb_xfer, - sce->ra_wb_xferlen) == 0) { - usbd_free_xfer(sce->ra_wb_xfer); - return ENOMEM; - } sce->ibuf = kmem_alloc(sce->ra_wb_bufsize, KM_SLEEP); sce->fill = sce->cur = sce->ibuf; sce->limit = sce->ibuf + sce->ra_wb_bufsize; @@ -1583,7 +1557,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int * drain the buffer instead. */ usbd_abort_pipe(sce->pipeh); - usbd_free_xfer(sce->ra_wb_xfer); + usbd_destroy_xfer(sce->ra_wb_xfer); kmem_free(sce->ibuf, sce->ra_wb_bufsize); sce->ibuf = NULL; } @@ -1741,7 +1715,6 @@ ugen_do_ioctl(struct ugen_softc *sc, int struct iovec iov; struct uio uio; struct usb_full_desc *fd = (struct usb_full_desc *)addr; - int error; cdesc = ugen_get_cdesc(sc, fd->ufd_config_index, &cdesclen); if (cdesc == NULL) @@ -1778,7 +1751,8 @@ ugen_do_ioctl(struct ugen_softc *sc, int struct uio uio; void *ptr = 0; usbd_status xerr; - int error = 0; + + error = 0; if (!(flag & FWRITE)) return EPERM; Index: sys/dev/usb/uhidev.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uhidev.c,v retrieving revision 1.61.4.9 diff -u -p -r1.61.4.9 uhidev.c --- sys/dev/usb/uhidev.c 29 Sep 2015 11:38:29 -0000 1.61.4.9 +++ sys/dev/usb/uhidev.c 4 Oct 2015 08:34:44 -0000 @@ -601,10 +601,10 @@ uhidev_open(struct uhidev *scd) } DPRINTF(("uhidev_open: sc->sc_opipe=%p\n", sc->sc_opipe)); - sc->sc_oxfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_oxfer == NULL) { + error = usbd_create_xfer(sc->sc_opipe, UHIDEV_OSIZE, 0, 0, + &sc->sc_oxfer); + if (error) { DPRINTF(("uhidev_open: couldn't allocate an xfer\n")); - error = ENOMEM; goto out3; } @@ -626,7 +626,7 @@ uhidev_open(struct uhidev *scd) out4: /* Free output xfer */ if (sc->sc_oxfer != NULL) - usbd_free_xfer(sc->sc_oxfer); + usbd_destroy_xfer(sc->sc_oxfer); out3: /* Abort output pipe */ usbd_close_pipe(sc->sc_opipe); @@ -691,7 +691,7 @@ uhidev_close(struct uhidev *scd) DPRINTF(("uhidev_close: close pipe\n")); if (sc->sc_oxfer != NULL) { - usbd_free_xfer(sc->sc_oxfer); + usbd_destroy_xfer(sc->sc_oxfer); sc->sc_oxfer = NULL; } @@ -750,6 +750,6 @@ uhidev_write(struct uhidev_softc *sc, vo DPRINTF(("\n")); } #endif - return usbd_intr_transfer(sc->sc_oxfer, sc->sc_opipe, 0, - USBD_NO_TIMEOUT, data, &len); + return usbd_intr_transfer(sc->sc_oxfer, sc->sc_opipe, 0, USBD_NO_TIMEOUT, + data, &len); } Index: sys/dev/usb/uhidev.h =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uhidev.h,v retrieving revision 1.15.4.6 diff -u -p -r1.15.4.6 uhidev.h --- sys/dev/usb/uhidev.h 6 Jun 2015 14:40:14 -0000 1.15.4.6 +++ sys/dev/usb/uhidev.h 4 Oct 2015 08:34:44 -0000 @@ -87,3 +87,5 @@ void uhidev_close(struct uhidev *); usbd_status uhidev_set_report(struct uhidev *, int, void *, int); usbd_status uhidev_get_report(struct uhidev *, int, void *, int); usbd_status uhidev_write(struct uhidev_softc *, void *, int); + +#define UHIDEV_OSIZE 64 Index: sys/dev/usb/uhso.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uhso.c,v retrieving revision 1.17.2.4 diff -u -p -r1.17.2.4 uhso.c --- sys/dev/usb/uhso.c 28 Sep 2015 16:24:19 -0000 1.17.2.4 +++ sys/dev/usb/uhso.c 4 Oct 2015 08:34:45 -0000 @@ -598,9 +598,9 @@ uhso_switch_mode(struct usbd_device *ude if (status != USBD_NORMAL_COMPLETION) return EIO; - xfer = usbd_alloc_xfer(udev); - if (xfer == NULL) - return ENOMEM; + int error = usbd_create_xfer(pipe, sizeof(cmd), 0, 0, &xfer); + if (error) + return error; USETDW(cmd.dCBWSignature, CBWSIGNATURE); USETDW(cmd.dCBWTag, 1); @@ -612,14 +612,14 @@ uhso_switch_mode(struct usbd_device *ude memset(&cmd.CBWCDB, 0, CBWCDBLENGTH); cmd.CBWCDB[0] = SCSI_REZERO_UNIT; - usbd_setup_xfer(xfer, pipe, NULL, &cmd, sizeof(cmd), + usbd_setup_xfer(xfer, NULL, &cmd, sizeof(cmd), USBD_SYNCHRONOUS, USBD_DEFAULT_TIMEOUT, NULL); status = usbd_transfer(xfer); usbd_abort_pipe(pipe); usbd_close_pipe(pipe); - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); return (status == USBD_NORMAL_COMPLETION ? 0 : EIO); } @@ -877,6 +877,23 @@ uhso_mux_init(struct uhso_port *hp) CLR(hp->hp_flags, UHSO_PORT_MUXBUSY | UHSO_PORT_MUXREADY); SET(hp->hp_status, TIOCM_DSR | TIOCM_CAR); + + struct uhso_softc *sc = hp->hp_sc; + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->sc_udev); + int error; + + error = usbd_create_xfer(pipe0, hp->hp_rsize, 0, 0, &hp->hp_rxfer); + if (error) + return error; + + hp->hp_rbuf = usbd_get_buffer(hp->hp_rxfer); + + error = usbd_create_xfer(pipe0, hp->hp_wsize, 0, 0, &hp->hp_wxfer); + if (error) + return error; + + hp->hp_wbuf = usbd_get_buffer(hp->hp_wxfer); + return 0; } @@ -1139,6 +1156,19 @@ uhso_bulk_init(struct uhso_port *hp) return EIO; } + int error = usbd_create_xfer(hp->hp_rpipe, hp->hp_rsize, + USBD_SHORT_XFER_OK, 0, &hp->hp_rxfer); + if (error) + return error; + + hp->hp_rbuf = usbd_get_buffer(hp->hp_rxfer); + + error = usbd_create_xfer(hp->hp_wpipe, hp->hp_wsize, 0, 0, + &hp->hp_wxfer); + if (error) + return error; + hp->hp_wbuf = usbd_get_buffer(hp->hp_wxfer); + return 0; } @@ -1182,8 +1212,8 @@ uhso_bulk_write(struct uhso_port *hp) DPRINTF(5, "hp=%p, wlen=%zd\n", hp, hp->hp_wlen); - usbd_setup_xfer(hp->hp_wxfer, hp->hp_wpipe, hp, hp->hp_wbuf, - hp->hp_wlen, 0, USBD_NO_TIMEOUT, hp->hp_write_cb); + usbd_setup_xfer(hp->hp_wxfer, hp, hp->hp_wbuf, hp->hp_wlen, 0, + USBD_NO_TIMEOUT, hp->hp_write_cb); status = usbd_transfer(hp->hp_wxfer); if (status != USBD_IN_PROGRESS) { @@ -1203,9 +1233,8 @@ uhso_bulk_read(struct uhso_port *hp) DPRINTF(5, "hp=%p\n", hp); - usbd_setup_xfer(hp->hp_rxfer, hp->hp_rpipe, hp, hp->hp_rbuf, - hp->hp_rsize, USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, hp->hp_read_cb); + usbd_setup_xfer(hp->hp_rxfer, hp, hp->hp_rbuf, hp->hp_rsize, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, hp->hp_read_cb); status = usbd_transfer(hp->hp_rxfer); if (status != USBD_IN_PROGRESS) { @@ -1473,7 +1502,6 @@ uhso_tty_open(dev_t dev, int flag, int m Static int uhso_tty_init(struct uhso_port *hp) { - struct uhso_softc *sc = hp->hp_sc; struct tty *tp = hp->hp_tp; struct termios t; int error; @@ -1509,22 +1537,6 @@ uhso_tty_init(struct uhso_port *hp) if (error != 0) return error; - hp->hp_rxfer = usbd_alloc_xfer(sc->sc_udev); - if (hp->hp_rxfer == NULL) - return ENOMEM; - - hp->hp_rbuf = usbd_alloc_buffer(hp->hp_rxfer, hp->hp_rsize); - if (hp->hp_rbuf == NULL) - return ENOMEM; - - hp->hp_wxfer = usbd_alloc_xfer(sc->sc_udev); - if (hp->hp_wxfer == NULL) - return ENOMEM; - - hp->hp_wbuf = usbd_alloc_buffer(hp->hp_wxfer, hp->hp_wsize); - if (hp->hp_wbuf == NULL) - return ENOMEM; - /* * Turn on DTR. We must always do this, even if carrier is not * present, because otherwise we'd have to use TIOCSDTR @@ -1581,13 +1593,13 @@ uhso_tty_clean(struct uhso_port *hp) (*hp->hp_clean)(hp); if (hp->hp_rxfer != NULL) { - usbd_free_xfer(hp->hp_rxfer); + usbd_destroy_xfer(hp->hp_rxfer); hp->hp_rxfer = NULL; hp->hp_rbuf = NULL; } if (hp->hp_wxfer != NULL) { - usbd_free_xfer(hp->hp_wxfer); + usbd_destroy_xfer(hp->hp_wxfer); hp->hp_wxfer = NULL; hp->hp_wbuf = NULL; } @@ -2253,22 +2265,6 @@ uhso_ifnet_init(struct uhso_port *hp) if (error != 0) return error; - hp->hp_rxfer = usbd_alloc_xfer(sc->sc_udev); - if (hp->hp_rxfer == NULL) - return ENOMEM; - - hp->hp_rbuf = usbd_alloc_buffer(hp->hp_rxfer, hp->hp_rsize); - if (hp->hp_rbuf == NULL) - return ENOMEM; - - hp->hp_wxfer = usbd_alloc_xfer(sc->sc_udev); - if (hp->hp_wxfer == NULL) - return ENOMEM; - - hp->hp_wbuf = usbd_alloc_buffer(hp->hp_wxfer, hp->hp_wsize); - if (hp->hp_wbuf == NULL) - return ENOMEM; - error = (*hp->hp_read)(hp); if (error != 0) return error; @@ -2285,13 +2281,13 @@ uhso_ifnet_clean(struct uhso_port *hp) (*hp->hp_clean)(hp); if (hp->hp_rxfer != NULL) { - usbd_free_xfer(hp->hp_rxfer); + usbd_destroy_xfer(hp->hp_rxfer); hp->hp_rxfer = NULL; hp->hp_rbuf = NULL; } if (hp->hp_wxfer != NULL) { - usbd_free_xfer(hp->hp_wxfer); + usbd_destroy_xfer(hp->hp_wxfer); hp->hp_wxfer = NULL; hp->hp_wbuf = NULL; } Index: sys/dev/usb/uirda.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uirda.c,v retrieving revision 1.38.6.7 diff -u -p -r1.38.6.7 uirda.c --- sys/dev/usb/uirda.c 21 Mar 2015 11:33:37 -0000 1.38.6.7 +++ sys/dev/usb/uirda.c 4 Oct 2015 08:34:45 -0000 @@ -378,29 +378,21 @@ uirda_open(void *h, int flag, int mode, error = EIO; goto bad2; } - sc->sc_rd_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_rd_xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_rd_pipe, + IRDA_MAX_FRAME_SIZE + sc->sc_hdszi, USBD_SHORT_XFER_OK, 0, + &sc->sc_rd_xfer); + if (error) goto bad3; - } - sc->sc_wr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_wr_xfer == NULL) { - error = ENOMEM; + sc->sc_rd_buf = usbd_get_buffer(sc->sc_rd_xfer); + + /* worst case ST-UIRDA length */ + error = usbd_create_xfer(sc->sc_wr_pipe, + IRDA_MAX_FRAME_SIZE + UIRDA_OUTPUT_HEADER_SIZE + 2 + 1, + USBD_FORCE_SHORT_XFER, 0, &sc->sc_wr_xfer); + if (error) goto bad4; - } - sc->sc_rd_buf = usbd_alloc_buffer(sc->sc_rd_xfer, - IRDA_MAX_FRAME_SIZE + sc->sc_hdszi); - if (sc->sc_rd_buf == NULL) { - error = ENOMEM; - goto bad5; - } - sc->sc_wr_buf = usbd_alloc_buffer(sc->sc_wr_xfer, - IRDA_MAX_FRAME_SIZE + UIRDA_OUTPUT_HEADER_SIZE + - 2 + 1 /* worst case ST-UIRDA */); - if (sc->sc_wr_buf == NULL) { - error = ENOMEM; - goto bad5; - } + sc->sc_wr_buf = usbd_get_buffer(sc->sc_wr_xfer); + sc->sc_rd_count = 0; sc->sc_rd_err = 0; sc->sc_params.speed = 0; @@ -413,11 +405,8 @@ uirda_open(void *h, int flag, int mode, return 0; -bad5: - usbd_free_xfer(sc->sc_wr_xfer); - sc->sc_wr_xfer = NULL; bad4: - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; bad3: usbd_close_pipe(sc->sc_wr_pipe); @@ -448,12 +437,12 @@ uirda_close(void *h, int flag, int mode, sc->sc_wr_pipe = NULL; } if (sc->sc_rd_xfer != NULL) { - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { - usbd_free_xfer(sc->sc_wr_xfer); + usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } @@ -548,25 +537,24 @@ uirda_write(void *h, struct uio *uio, in sc->sc_wr_buf[0] = UIRDA_EB_NO_CHANGE | UIRDA_NO_SPEED; error = uiomove(sc->sc_wr_buf + UIRDA_OUTPUT_HEADER_SIZE, n, uio); - if (!error) { - DPRINTFN(1, ("uirdawrite: transfer %d bytes\n", n)); + if (error) + goto done; - n += UIRDA_OUTPUT_HEADER_SIZE; - err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, - USBD_FORCE_SHORT_XFER, - UIRDA_WR_TIMEOUT, - sc->sc_wr_buf, &n); - DPRINTFN(2, ("uirdawrite: err=%d\n", err)); - if (err) { - if (err == USBD_INTERRUPTED) - error = EINTR; - else if (err == USBD_TIMEOUT) - error = ETIMEDOUT; - else - error = EIO; - } - } + DPRINTFN(1, ("uirdawrite: transfer %d bytes\n", n)); + n += UIRDA_OUTPUT_HEADER_SIZE; + err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, USBD_FORCE_SHORT_XFER, + UIRDA_WR_TIMEOUT, sc->sc_wr_buf, &n); + DPRINTFN(2, ("uirdawrite: err=%d\n", err)); + if (err) { + if (err == USBD_INTERRUPTED) + error = EINTR; + else if (err == USBD_TIMEOUT) + error = ETIMEDOUT; + else + error = EIO; + } +done: mutex_exit(&sc->sc_wr_buf_lk); if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); @@ -776,8 +764,8 @@ uirda_set_params(void *h, struct irda_pa sc->sc_wr_buf[0] = hdr; n = UIRDA_OUTPUT_HEADER_SIZE; err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, - USBD_FORCE_SHORT_XFER, UIRDA_WR_TIMEOUT, - sc->sc_wr_buf, &n); + USBD_FORCE_SHORT_XFER, UIRDA_WR_TIMEOUT, + sc->sc_wr_buf, &n); if (err) { aprint_error_dev(sc->sc_dev, "set failed, err=%d\n", err); @@ -886,10 +874,9 @@ uirda_start_read(struct uirda_softc *sc) usbd_clear_endpoint_stall(sc->sc_rd_pipe); } - usbd_setup_xfer(sc->sc_rd_xfer, sc->sc_rd_pipe, sc, sc->sc_rd_buf, - sc->sc_params.maxsize + sc->sc_hdszi, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, uirda_rd_cb); + usbd_setup_xfer(sc->sc_rd_xfer, sc, sc->sc_rd_buf, + sc->sc_params.maxsize + sc->sc_hdszi, USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, uirda_rd_cb); err = usbd_transfer(sc->sc_rd_xfer); if (err != USBD_IN_PROGRESS) { DPRINTF(("uirda_start_read: err=%d\n", err)); Index: sys/dev/usb/ulpt.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ulpt.c,v retrieving revision 1.95.4.7 diff -u -p -r1.95.4.7 ulpt.c --- sys/dev/usb/ulpt.c 21 Mar 2015 11:33:37 -0000 1.95.4.7 +++ sys/dev/usb/ulpt.c 4 Oct 2015 08:34:45 -0000 @@ -482,16 +482,11 @@ ulptopen(dev_t dev, int flag, int mode, error = EIO; goto err0; } - sc->sc_out_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_out_xfer == NULL) { - error = ENOMEM; - goto err1; - } - sc->sc_out_buf = usbd_alloc_buffer(sc->sc_out_xfer, ULPT_BSIZE); - if (sc->sc_out_buf == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_out_pipe, ULPT_BSIZE, 0, 0, + &sc->sc_out_xfer); + if (error) goto err2; - } + sc->sc_out_buf = usbd_get_buffer(sc->sc_out_xfer); if (ulptusein && sc->sc_in != -1) { DPRINTFN(2, ("ulpt_open: opening input pipe %d\n", sc->sc_in)); @@ -500,17 +495,11 @@ ulptopen(dev_t dev, int flag, int mode, error = EIO; goto err2; } - sc->sc_in_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_in_xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_in_pipe, ULPT_BSIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_in_xfer); + if (error) goto err3; - } - sc->sc_in_buf = usbd_alloc_buffer(sc->sc_in_xfer, ULPT_BSIZE); - if (sc->sc_in_buf == NULL) { - error = ENOMEM; - goto err4; - } - + sc->sc_in_buf = usbd_get_buffer(sc->sc_in_xfer); /* If it's not opened for read then set up a reader. */ if (!(flag & FREAD)) { DPRINTFN(2, ("ulpt_open: start read callout\n")); @@ -523,16 +512,13 @@ ulptopen(dev_t dev, int flag, int mode, sc->sc_state = ULPT_OPEN; goto done; - err4: - usbd_free_xfer(sc->sc_in_xfer); - sc->sc_in_xfer = NULL; err3: usbd_close_pipe(sc->sc_in_pipe); sc->sc_in_pipe = NULL; err2: - usbd_free_xfer(sc->sc_out_xfer); + usbd_destroy_xfer(sc->sc_out_xfer); sc->sc_out_xfer = NULL; - err1: + usbd_close_pipe(sc->sc_out_pipe); sc->sc_out_pipe = NULL; err0: @@ -593,7 +579,7 @@ ulptclose(dev_t dev, int flag, int mode, sc->sc_out_pipe = NULL; } if (sc->sc_out_xfer != NULL) { - usbd_free_xfer(sc->sc_out_xfer); + usbd_destroy_xfer(sc->sc_out_xfer); sc->sc_out_xfer = NULL; } @@ -603,7 +589,7 @@ ulptclose(dev_t dev, int flag, int mode, sc->sc_in_pipe = NULL; } if (sc->sc_in_xfer != NULL) { - usbd_free_xfer(sc->sc_in_xfer); + usbd_destroy_xfer(sc->sc_in_xfer); sc->sc_in_xfer = NULL; } @@ -631,8 +617,8 @@ ulpt_do_write(struct ulpt_softc *sc, str if (error) break; DPRINTFN(4, ("ulptwrite: transfer %d bytes\n", n)); - err = usbd_bulk_transfer(xfer, sc->sc_out_pipe, 0, - USBD_NO_TIMEOUT, bufp, &n); + err = usbd_bulk_transfer(xfer, sc->sc_out_pipe, 0, USBD_NO_TIMEOUT, + bufp, &n); if (err) { DPRINTFN(3, ("ulptwrite: error=%d\n", err)); error = EIO; @@ -720,8 +706,8 @@ ulpt_do_read(struct ulpt_softc *sc, stru n = nreq; DPRINTFN(4, ("ulptread: transfer %d bytes, nonblocking=%d timeout=%d\n", n, nonblocking, timeout)); - err = usbd_bulk_transfer(xfer, sc->sc_in_pipe, - USBD_SHORT_XFER_OK, timeout, bufp, &n); + err = usbd_bulk_transfer(xfer, sc->sc_in_pipe, USBD_SHORT_XFER_OK, + timeout, bufp, &n); DPRINTFN(4, ("ulptread: transfer complete nreq %d n %d nread %d err %d\n", nreq, n, nread, err)); @@ -883,9 +869,8 @@ ulpt_tick(void *xsc) if (sc == NULL || sc->sc_dying) return; - usbd_setup_xfer(sc->sc_in_xfer, sc->sc_in_pipe, sc, sc->sc_in_buf, - ULPT_BSIZE, USBD_SHORT_XFER_OK, - ULPT_READ_TIMO, ulpt_read_cb); + usbd_setup_xfer(sc->sc_in_xfer, sc, sc->sc_in_buf, ULPT_BSIZE, + USBD_SHORT_XFER_OK, ULPT_READ_TIMO, ulpt_read_cb); err = usbd_transfer(sc->sc_in_xfer); DPRINTFN(3, ("ulpt_tick: sc=%p err=%d\n", sc, err)); } Index: sys/dev/usb/umass.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umass.c,v retrieving revision 1.149.2.8 diff -u -p -r1.149.2.8 umass.c --- sys/dev/usb/umass.c 21 Mar 2015 11:33:37 -0000 1.149.2.8 +++ sys/dev/usb/umass.c 4 Oct 2015 08:34:46 -0000 @@ -577,65 +577,144 @@ umass_attach(device_t parent, device_t s /* initialisation of generic part */ sc->transfer_state = TSTATE_IDLE; - /* request a sufficient number of xfer handles */ for (i = 0; i < XFER_NR; i++) { - sc->transfer_xfer[i] = usbd_alloc_xfer(uiaa->uiaa_device); - if (sc->transfer_xfer[i] == NULL) { - aprint_error_dev(self, "Out of memory\n"); - umass_disco(sc); - return; - } + sc->transfer_xfer[i] = NULL; } + /* - * Allocate buffer for data transfer (it's huge), command and - * status data here as auto allocation cannot happen in interrupt - * context + * Create the transfers */ + struct usbd_pipe *pipe0 = usbd_get_pipe0(sc->sc_udev); switch (sc->sc_wire) { case UMASS_WPROTO_BBB: - sc->data_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_BBB_DATA], - UMASS_MAX_TRANSFER_SIZE); - sc->cmd_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_BBB_CBW], - UMASS_BBB_CBW_SIZE); - sc->s1_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_BBB_CSW1], - UMASS_BBB_CSW_SIZE); - sc->s2_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_BBB_CSW2], - UMASS_BBB_CSW_SIZE); + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKIN], + UMASS_MAX_TRANSFER_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_BBB_DATAIN]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKOUT], + UMASS_MAX_TRANSFER_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_BBB_DATAOUT]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKOUT], + UMASS_BBB_CBW_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_BBB_CBW]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKIN], + UMASS_BBB_CSW_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_BBB_CSW1]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKIN], + UMASS_BBB_CSW_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_BBB_CSW2]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_BBB_SCLEAR]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_BBB_DCLEAR]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_BBB_RESET1]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_BBB_RESET2]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_BBB_RESET3]); + if (err) + goto fail_create; break; case UMASS_WPROTO_CBI: case UMASS_WPROTO_CBI_I: - sc->data_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_CBI_DATA], - UMASS_MAX_TRANSFER_SIZE); - sc->cmd_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_CBI_CB], - sizeof(sc->cbl)); - sc->s1_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_CBI_STATUS], - sizeof(sc->sbl)); - sc->s2_buffer = usbd_alloc_buffer( - sc->transfer_xfer[XFER_CBI_RESET1], - sizeof(sc->cbl)); + err = usbd_create_xfer(pipe0, sizeof(sc->cbl), 0, 0, + &sc->transfer_xfer[XFER_CBI_CB]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKIN], + UMASS_MAX_TRANSFER_SIZE, USBD_SHORT_XFER_OK, 0, + &sc->transfer_xfer[XFER_CBI_DATAIN]); + if (err) + goto fail_create; + err = usbd_create_xfer(sc->sc_pipe[UMASS_BULKOUT], + UMASS_MAX_TRANSFER_SIZE, 0, 0, + &sc->transfer_xfer[XFER_CBI_DATAOUT]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, sizeof(sc->sbl), + 0, 0, &sc->transfer_xfer[XFER_CBI_STATUS]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_CBI_DCLEAR]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, 0, 0, 0, + &sc->transfer_xfer[XFER_CBI_SCLEAR]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, sizeof(sc->cbl), 0, 0, + &sc->transfer_xfer[XFER_CBI_RESET1]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, sizeof(sc->cbl), 0, 0, + &sc->transfer_xfer[XFER_CBI_RESET2]); + if (err) + goto fail_create; + err = usbd_create_xfer(pipe0, sizeof(sc->cbl), 0, 0, + &sc->transfer_xfer[XFER_CBI_RESET3]); + if (err) + goto fail_create; break; default: - break; - } - - if (sc->data_buffer == NULL || sc->cmd_buffer == NULL - || sc->s1_buffer == NULL || sc->s2_buffer == NULL) { - /* - * partially preallocated buffers are freed with - * the xfer structures - */ - aprint_error_dev(self, "no buffer memory\n"); + fail_create: + aprint_error_dev(self, "failed to create xfers\n"); umass_disco(sc); return; } + /* + * Record buffer pinters for data transfer (it's huge), command and + * status data here + */ + switch (sc->sc_wire) { + case UMASS_WPROTO_BBB: + sc->datain_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_BBB_DATAIN]); + sc->dataout_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_BBB_DATAOUT]); + sc->cmd_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_BBB_CBW]); + sc->s1_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_BBB_CSW1]); + sc->s2_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_BBB_CSW2]); + break; + case UMASS_WPROTO_CBI: + case UMASS_WPROTO_CBI_I: + sc->datain_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_CBI_DATAIN]); + sc->dataout_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_CBI_DATAOUT]); + sc->cmd_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_CBI_CB]); + sc->s1_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_CBI_STATUS]); + sc->s2_buffer = + usbd_get_buffer(sc->transfer_xfer[XFER_CBI_RESET1]); + break; + default: + break; + } + /* Initialise the wire protocol specific methods */ switch (sc->sc_wire) { case UMASS_WPROTO_BBB: @@ -800,7 +879,7 @@ umass_disco(struct umass_softc *sc) /* Free the xfers. */ for (i = 0; i < XFER_NR; i++) if (sc->transfer_xfer[i] != NULL) { - usbd_free_xfer(sc->transfer_xfer[i]); + usbd_destroy_xfer(sc->transfer_xfer[i]); sc->transfer_xfer[i] = NULL; } } @@ -823,8 +902,8 @@ umass_setup_transfer(struct umass_softc /* Initialiase a USB transfer and then schedule it */ - usbd_setup_xfer(xfer, pipe, (void *)sc, buffer, buflen, - flags, sc->timeout, sc->sc_methods->wire_state); + usbd_setup_xfer(xfer, sc, buffer, buflen, flags, sc->timeout, + sc->sc_methods->wire_state); USBHIST_LOG(umassdebug, "xfer %p, flags %d", xfer, flags, 0, 0); @@ -1118,19 +1197,19 @@ umass_bbb_state(struct usbd_xfer *xfer, sc->transfer_state = TSTATE_BBB_DATA; if (sc->transfer_dir == DIR_IN) { if (umass_setup_transfer(sc, sc->sc_pipe[UMASS_BULKIN], - sc->data_buffer, sc->transfer_datalen, + sc->datain_buffer, sc->transfer_datalen, USBD_SHORT_XFER_OK, - sc->transfer_xfer[XFER_BBB_DATA])) + sc->transfer_xfer[XFER_BBB_DATAIN])) umass_bbb_reset(sc, STATUS_WIRE_FAILED); return; } else if (sc->transfer_dir == DIR_OUT) { - memcpy(sc->data_buffer, sc->transfer_data, + memcpy(sc->dataout_buffer, sc->transfer_data, sc->transfer_datalen); if (umass_setup_transfer(sc, sc->sc_pipe[UMASS_BULKOUT], - sc->data_buffer, sc->transfer_datalen, + sc->dataout_buffer, sc->transfer_datalen, 0,/* fixed length transfer */ - sc->transfer_xfer[XFER_BBB_DATA])) + sc->transfer_xfer[XFER_BBB_DATAOUT])) umass_bbb_reset(sc, STATUS_WIRE_FAILED); return; @@ -1175,7 +1254,7 @@ umass_bbb_state(struct usbd_xfer *xfer, /* FALLTHROUGH, err == 0 (no data phase or successful) */ case TSTATE_BBB_DCLEAR: /* stall clear after data phase */ if (sc->transfer_dir == DIR_IN) - memcpy(sc->transfer_data, sc->data_buffer, + memcpy(sc->transfer_data, sc->datain_buffer, sc->transfer_actlen); DIF(UDMASS_BBB, if (sc->transfer_dir == DIR_IN) @@ -1577,19 +1656,19 @@ umass_cbi_state(struct usbd_xfer *xfer, sc->transfer_state = TSTATE_CBI_DATA; if (sc->transfer_dir == DIR_IN) { if (umass_setup_transfer(sc, sc->sc_pipe[UMASS_BULKIN], - sc->data_buffer, sc->transfer_datalen, - USBD_SHORT_XFER_OK, - sc->transfer_xfer[XFER_CBI_DATA])) + sc->datain_buffer, sc->transfer_datalen, + USBD_SHORT_XFER_OK, + sc->transfer_xfer[XFER_CBI_DATAIN])) umass_cbi_reset(sc, STATUS_WIRE_FAILED); return; } else if (sc->transfer_dir == DIR_OUT) { - memcpy(sc->data_buffer, sc->transfer_data, + memcpy(sc->dataout_buffer, sc->transfer_data, sc->transfer_datalen); if (umass_setup_transfer(sc, sc->sc_pipe[UMASS_BULKOUT], - sc->data_buffer, sc->transfer_datalen, - 0,/* fixed length transfer */ - sc->transfer_xfer[XFER_CBI_DATA])) + sc->dataout_buffer, sc->transfer_datalen, + 0, /* fixed length transfer */ + sc->transfer_xfer[XFER_CBI_DATAOUT])) umass_cbi_reset(sc, STATUS_WIRE_FAILED); return; @@ -1632,7 +1711,7 @@ umass_cbi_state(struct usbd_xfer *xfer, } if (sc->transfer_dir == DIR_IN) - memcpy(sc->transfer_data, sc->data_buffer, + memcpy(sc->transfer_data, sc->datain_buffer, sc->transfer_actlen); DIF(UDMASS_CBI, if (sc->transfer_dir == DIR_IN) Index: sys/dev/usb/umassvar.h =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umassvar.h,v retrieving revision 1.35.6.2 diff -u -p -r1.35.6.2 umassvar.h --- sys/dev/usb/umassvar.h 19 Mar 2015 17:26:43 -0000 1.35.6.2 +++ sys/dev/usb/umassvar.h 4 Oct 2015 08:34:46 -0000 @@ -198,34 +198,37 @@ struct umass_softc { /* xfer handles * Most of our operations are initiated from interrupt context, so - * we need to avoid using the one that is in use. We want to avoid + * we need to avoid using the one that is in use. We have to avoid * allocating them in the interrupt context as well. */ /* indices into array below */ #define XFER_BBB_CBW 0 /* Bulk-Only */ -#define XFER_BBB_DATA 1 -#define XFER_BBB_DCLEAR 2 -#define XFER_BBB_CSW1 3 -#define XFER_BBB_CSW2 4 -#define XFER_BBB_SCLEAR 5 -#define XFER_BBB_RESET1 6 -#define XFER_BBB_RESET2 7 -#define XFER_BBB_RESET3 8 +#define XFER_BBB_DATAIN 1 +#define XFER_BBB_DATAOUT 2 +#define XFER_BBB_DCLEAR 3 +#define XFER_BBB_CSW1 4 +#define XFER_BBB_CSW2 5 +#define XFER_BBB_SCLEAR 6 +#define XFER_BBB_RESET1 7 +#define XFER_BBB_RESET2 8 +#define XFER_BBB_RESET3 9 #define XFER_CBI_CB 0 /* CBI */ -#define XFER_CBI_DATA 1 -#define XFER_CBI_STATUS 2 -#define XFER_CBI_DCLEAR 3 -#define XFER_CBI_SCLEAR 4 -#define XFER_CBI_RESET1 5 -#define XFER_CBI_RESET2 6 -#define XFER_CBI_RESET3 7 +#define XFER_CBI_DATAIN 1 +#define XFER_CBI_DATAOUT 2 +#define XFER_CBI_STATUS 3 +#define XFER_CBI_DCLEAR 4 +#define XFER_CBI_SCLEAR 5 +#define XFER_CBI_RESET1 6 +#define XFER_CBI_RESET2 7 +#define XFER_CBI_RESET3 8 -#define XFER_NR 9 /* maximum number */ +#define XFER_NR 10 /* maximum number */ struct usbd_xfer * transfer_xfer[XFER_NR]; /* for ctrl xfers */ - void *data_buffer; + void *datain_buffer; + void *dataout_buffer; void *cmd_buffer; void *s1_buffer; void *s2_buffer; Index: sys/dev/usb/umidi.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/umidi.c,v retrieving revision 1.65.14.7 diff -u -p -r1.65.14.7 umidi.c --- sys/dev/usb/umidi.c 29 Sep 2015 11:38:29 -0000 1.65.14.7 +++ sys/dev/usb/umidi.c 4 Oct 2015 08:34:46 -0000 @@ -685,21 +685,17 @@ alloc_pipe(struct umidi_endpoint *ep) ep->next_schedule = 0; ep->soliciting = 0; ep->armed = 0; - ep->xfer = usbd_alloc_xfer(sc->sc_udev); - if (ep->xfer == NULL) { - err = USBD_NOMEM; - goto quit; - } - ep->buffer = usbd_alloc_buffer(ep->xfer, ep->buffer_size); - if (ep->buffer == NULL) { - usbd_free_xfer(ep->xfer); - err = USBD_NOMEM; - goto quit; - } - ep->next_slot = ep->buffer; err = usbd_open_pipe(sc->sc_iface, ep->addr, USBD_MPSAFE, &ep->pipe); if (err) - usbd_free_xfer(ep->xfer); + goto quit; + int error = usbd_create_xfer(ep->pipe, ep->buffer_size, + USBD_SHORT_XFER_OK, 0, &ep->xfer); + if (error) { + usbd_close_pipe(ep->pipe); + return USBD_NOMEM; + } + ep->buffer = usbd_get_buffer(ep->xfer); + ep->next_slot = ep->buffer; ep->solicit_cookie = softint_establish(SOFTINT_CLOCK | SOFTINT_MPSAFE, out_solicit, ep); quit: return err; @@ -711,7 +707,7 @@ free_pipe(struct umidi_endpoint *ep) DPRINTF(("%s: free_pipe %p\n", device_xname(ep->sc->sc_dev), ep)); usbd_abort_pipe(ep->pipe); usbd_close_pipe(ep->pipe); - usbd_free_xfer(ep->xfer); + usbd_destroy_xfer(ep->xfer); softint_disestablish(ep->solicit_cookie); } @@ -1653,11 +1649,8 @@ static const int packet_length[16] = { static usbd_status start_input_transfer(struct umidi_endpoint *ep) { - usbd_setup_xfer(ep->xfer, ep->pipe, - (void *)ep, - ep->buffer, ep->buffer_size, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, in_intr); + usbd_setup_xfer(ep->xfer, ep, ep->buffer, ep->buffer_size, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, in_intr); return usbd_transfer(ep->xfer); } @@ -1671,10 +1664,9 @@ start_output_transfer(struct umidi_endpo length = (ep->next_slot - ep->buffer) * sizeof(*ep->buffer); DPRINTFN(200,("umidi out transfer: start %p end %p length %u\n", ep->buffer, ep->next_slot, length)); - usbd_setup_xfer(ep->xfer, ep->pipe, - (void *)ep, - ep->buffer, length, - 0, USBD_NO_TIMEOUT, out_intr); + + usbd_setup_xfer(ep->xfer, ep, ep->buffer, length, 0, + USBD_NO_TIMEOUT, out_intr); rv = usbd_transfer(ep->xfer); /* Index: sys/dev/usb/urio.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/urio.c,v retrieving revision 1.42.4.7 diff -u -p -r1.42.4.7 urio.c --- sys/dev/usb/urio.c 21 Mar 2015 11:33:37 -0000 1.42.4.7 +++ sys/dev/usb/urio.c 4 Oct 2015 08:34:46 -0000 @@ -344,14 +344,11 @@ urioread(dev_t dev, struct uio *uio, int if (sc->sc_dying) return EIO; - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return ENOMEM; - bufp = usbd_alloc_buffer(xfer, URIO_BSIZE); - if (bufp == NULL) { - usbd_free_xfer(xfer); - return ENOMEM; + error = usbd_create_xfer(sc->sc_in_pipe, URIO_BSIZE, 0, 0, &xfer); + if (error) { + return error; } + bufp = usbd_get_buffer(xfer); sc->sc_refcnt++; @@ -359,7 +356,7 @@ urioread(dev_t dev, struct uio *uio, int DPRINTFN(1, ("urioread: start transfer %d bytes\n", n)); tn = n; err = usbd_bulk_transfer(xfer, sc->sc_in_pipe, 0, - URIO_RW_TIMEOUT, bufp, &tn); + URIO_RW_TIMEOUT, bufp, &tn); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -376,7 +373,7 @@ urioread(dev_t dev, struct uio *uio, int if (error || tn < n) break; } - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); @@ -402,15 +399,11 @@ uriowrite(dev_t dev, struct uio *uio, in if (sc->sc_dying) return EIO; - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == NULL) - return ENOMEM; - bufp = usbd_alloc_buffer(xfer, URIO_BSIZE); - if (bufp == NULL) { - usbd_free_xfer(xfer); - return ENOMEM; + error = usbd_create_xfer(sc->sc_out_pipe, URIO_BSIZE, 0, 0, &xfer); + if (error) { + return error; } - + bufp = usbd_get_buffer(xfer); sc->sc_refcnt++; while ((n = min(URIO_BSIZE, uio->uio_resid)) != 0) { @@ -421,7 +414,7 @@ uriowrite(dev_t dev, struct uio *uio, in DPRINTFN(1, ("uriowrite: transfer %d bytes\n", n)); err = usbd_bulk_transfer(xfer, sc->sc_out_pipe, 0, - URIO_RW_TIMEOUT, bufp, &n); + URIO_RW_TIMEOUT, bufp, &n); DPRINTFN(2, ("uriowrite: err=%d\n", err)); if (err) { if (err == USBD_INTERRUPTED) @@ -434,7 +427,7 @@ uriowrite(dev_t dev, struct uio *uio, in } } - usbd_free_xfer(xfer); + usbd_destroy_xfer(xfer); if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); Index: sys/dev/usb/usbdi.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/usbdi.c,v retrieving revision 1.162.2.28 diff -u -p -r1.162.2.28 usbdi.c --- sys/dev/usb/usbdi.c 22 Sep 2015 12:06:01 -0000 1.162.2.28 +++ sys/dev/usb/usbdi.c 4 Oct 2015 08:34:47 -0000 @@ -65,6 +65,10 @@ Static usbd_status usbd_ar_pipe(struct u Static void usbd_start_next(struct usbd_pipe *); Static usbd_status usbd_open_pipe_ival (struct usbd_interface *, uint8_t, uint8_t, struct usbd_pipe **, int); +static void *usbd_alloc_buffer(struct usbd_xfer *, uint32_t); +static void usbd_free_buffer(struct usbd_xfer *); +static struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *); +static usbd_status usbd_free_xfer(struct usbd_xfer *); #if defined(USB_DEBUG) void @@ -206,19 +210,11 @@ usbd_open_pipe_intr(struct usbd_interfac &ipipe, ival); if (err) return err; - xfer = usbd_alloc_xfer(iface->ui_dev); - if (xfer == NULL) { - err = USBD_NOMEM; + err = usbd_create_xfer(ipipe, len, flags, 0, &xfer); + if (err) goto bad1; - } - void *buf = usbd_alloc_buffer(xfer, len); - if (buf == NULL) { - err = USBD_NOMEM; - goto bad2; - } - usbd_setup_xfer(xfer, ipipe, priv, buffer, len, flags, - USBD_NO_TIMEOUT, cb); + usbd_setup_xfer(xfer, priv, buffer, len, flags, USBD_NO_TIMEOUT, cb); ipipe->up_intrxfer = xfer; ipipe->up_repeat = 1; err = usbd_transfer(xfer); @@ -230,8 +226,8 @@ usbd_open_pipe_intr(struct usbd_interfac bad3: ipipe->up_intrxfer = NULL; ipipe->up_repeat = 0; - bad2: - usbd_free_xfer(xfer); + + usbd_destroy_xfer(xfer); bad1: usbd_close_pipe(ipipe); return err; @@ -375,7 +371,7 @@ usbd_sync_transfer_sig(struct usbd_xfer return usbd_transfer(xfer); } -void * +static void * usbd_alloc_buffer(struct usbd_xfer *xfer, uint32_t size) { KASSERT(xfer->ux_buf == NULL); @@ -408,7 +404,7 @@ usbd_alloc_buffer(struct usbd_xfer *xfer return xfer->ux_buf; } -void +static void usbd_free_buffer(struct usbd_xfer *xfer) { KASSERT(xfer->ux_buf != NULL); @@ -441,7 +437,14 @@ usbd_get_buffer(struct usbd_xfer *xfer) return xfer->ux_buf; } -struct usbd_xfer * +struct usbd_pipe * +usbd_get_pipe0(struct usbd_device *dev) +{ + + return dev->ud_pipe0; +} + +static struct usbd_xfer * usbd_alloc_xfer(struct usbd_device *dev) { struct usbd_xfer *xfer; @@ -463,7 +466,7 @@ usbd_alloc_xfer(struct usbd_device *dev) return xfer; } -usbd_status +static usbd_status usbd_free_xfer(struct usbd_xfer *xfer) { USBHIST_FUNC(); USBHIST_CALLED(usbdebug); @@ -484,13 +487,49 @@ usbd_free_xfer(struct usbd_xfer *xfer) return USBD_NORMAL_COMPLETION; } -void -usbd_setup_xfer(struct usbd_xfer *xfer, struct usbd_pipe *pipe, - void *priv, void *buffer, uint32_t length, - uint16_t flags, uint32_t timeout, - usbd_callback callback) +int usbd_create_xfer(struct usbd_pipe *pipe, size_t len, int flags, + int nframes, struct usbd_xfer **xp) { + KASSERT(xp != NULL); + + if (len < 0) + return EINVAL; + if (flags < 0) + return EINVAL; + if (nframes < 0) + return EINVAL; + + struct usbd_xfer *xfer = usbd_alloc_xfer(pipe->up_dev); + if (xfer == NULL); + return ENOMEM; + + if (len) { + void *buf = usbd_alloc_buffer(xfer, len); + if (!buf) { + usbd_free_xfer(xfer); + return ENOMEM; + } + } xfer->ux_pipe = pipe; + xfer->ux_flags = flags; + xfer->ux_nframes = nframes; + + *xp = xfer; + return 0; +} + +void usbd_destroy_xfer(struct usbd_xfer *xfer) +{ + + usbd_free_xfer(xfer); +} + +void +usbd_setup_xfer(struct usbd_xfer *xfer, void *priv, void *buffer, uint32_t length, + uint16_t flags, uint32_t timeout, usbd_callback callback) +{ + KASSERT(xfer->ux_pipe); + xfer->ux_priv = priv; xfer->ux_buffer = buffer; xfer->ux_length = length; @@ -505,10 +544,8 @@ usbd_setup_xfer(struct usbd_xfer *xfer, void usbd_setup_default_xfer(struct usbd_xfer *xfer, struct usbd_device *dev, - void *priv, uint32_t timeout, - usb_device_request_t *req, void *buffer, - uint32_t length, uint16_t flags, - usbd_callback callback) + void *priv, uint32_t timeout, usb_device_request_t *req, void *buffer, + uint32_t length, uint16_t flags, usbd_callback callback) { xfer->ux_pipe = dev->ud_pipe0; xfer->ux_priv = priv; @@ -525,11 +562,9 @@ usbd_setup_default_xfer(struct usbd_xfer } void -usbd_setup_isoc_xfer(struct usbd_xfer *xfer, struct usbd_pipe *pipe, - void *priv, uint16_t *frlengths, - uint32_t nframes, uint16_t flags, usbd_callback callback) +usbd_setup_isoc_xfer(struct usbd_xfer *xfer, void *priv, uint16_t *frlengths, + uint32_t nframes, uint16_t flags, usbd_callback callback) { - xfer->ux_pipe = pipe; xfer->ux_priv = priv; xfer->ux_buffer = NULL; xfer->ux_length = 0; Index: sys/dev/usb/usbdi.h =================================================================== RCS file: /cvsroot/src/sys/dev/usb/usbdi.h,v retrieving revision 1.90.4.7 diff -u -p -r1.90.4.7 usbdi.h --- sys/dev/usb/usbdi.h 29 Sep 2015 11:38:29 -0000 1.90.4.7 +++ sys/dev/usb/usbdi.h 4 Oct 2015 08:34:47 -0000 @@ -91,19 +91,23 @@ usbd_status usbd_open_pipe(struct usbd_i uint8_t, struct usbd_pipe **); usbd_status usbd_close_pipe(struct usbd_pipe *); usbd_status usbd_transfer(struct usbd_xfer *); -struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *); -usbd_status usbd_free_xfer(struct usbd_xfer *); -void usbd_setup_xfer(struct usbd_xfer *, struct usbd_pipe *, - void *, void *, - uint32_t, uint16_t, uint32_t, - usbd_callback); + +void *usbd_get_buffer(struct usbd_xfer *); +struct usbd_pipe *usbd_get_pipe0(struct usbd_device *); + +int usbd_create_xfer(struct usbd_pipe *, size_t, int, int, struct usbd_xfer **); +void usbd_destroy_xfer(struct usbd_xfer *); + +void usbd_setup_xfer(struct usbd_xfer *, void *, void *, + uint32_t, uint16_t, uint32_t, usbd_callback); + void usbd_setup_default_xfer(struct usbd_xfer *, struct usbd_device *, - void *, uint32_t, - usb_device_request_t *, void *, - uint32_t, uint16_t, usbd_callback); -void usbd_setup_isoc_xfer(struct usbd_xfer *, struct usbd_pipe *, - void *, uint16_t *, - uint32_t, uint16_t, usbd_callback); + void *, uint32_t, usb_device_request_t *, void *, + uint32_t, uint16_t, usbd_callback); + +void usbd_setup_isoc_xfer(struct usbd_xfer *, void *, uint16_t *, + uint32_t, uint16_t, usbd_callback); + void usbd_get_xfer_status(struct usbd_xfer *, void **, void **, uint32_t *, usbd_status *); usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor @@ -121,9 +125,6 @@ usbd_status usbd_device2interface_handle uint8_t, struct usbd_interface **); struct usbd_device *usbd_pipe2device_handle(struct usbd_pipe *); -void *usbd_alloc_buffer(struct usbd_xfer *, uint32_t); -void usbd_free_buffer(struct usbd_xfer *); -void *usbd_get_buffer(struct usbd_xfer *); usbd_status usbd_sync_transfer(struct usbd_xfer *); usbd_status usbd_sync_transfer_sig(struct usbd_xfer *); usbd_status usbd_open_pipe_intr(struct usbd_interface *, uint8_t, Index: sys/dev/usb/usbdi_util.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/usbdi_util.c,v retrieving revision 1.63.2.11 diff -u -p -r1.63.2.11 usbdi_util.c --- sys/dev/usb/usbdi_util.c 29 Sep 2015 11:38:29 -0000 1.63.2.11 +++ sys/dev/usb/usbdi_util.c 4 Oct 2015 08:34:47 -0000 @@ -476,14 +476,13 @@ usbd_get_config(struct usbd_device *dev, usbd_status usbd_bulk_transfer(struct usbd_xfer *xfer, struct usbd_pipe *pipe, - uint16_t flags, uint32_t timeout, void *buf, - uint32_t *size) + uint16_t flags, uint32_t timeout, void *buf, uint32_t *size) { usbd_status err; USBHIST_FUNC(); USBHIST_CALLED(usbdebug); - usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL); + usbd_setup_xfer(xfer, 0, buf, *size, flags, timeout, NULL); DPRINTFN(1, "start transfer %d bytes", *size, 0, 0, 0); err = usbd_sync_transfer_sig(xfer); @@ -499,14 +498,13 @@ usbd_bulk_transfer(struct usbd_xfer *xfe usbd_status usbd_intr_transfer(struct usbd_xfer *xfer, struct usbd_pipe *pipe, - uint16_t flags, uint32_t timeout, void *buf, - uint32_t *size) + uint16_t flags, uint32_t timeout, void *buf, uint32_t *size) { usbd_status err; USBHIST_FUNC(); USBHIST_CALLED(usbdebug); - usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL); + usbd_setup_xfer(xfer, 0, buf, *size, flags, timeout, NULL); DPRINTFN(1, "start transfer %d bytes", *size, 0, 0, 0); err = usbd_sync_transfer_sig(xfer); Index: sys/dev/usb/uscanner.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uscanner.c,v retrieving revision 1.75.4.7 diff -u -p -r1.75.4.7 uscanner.c --- sys/dev/usb/uscanner.c 21 Mar 2015 11:33:37 -0000 1.75.4.7 +++ sys/dev/usb/uscanner.c 4 Oct 2015 08:34:47 -0000 @@ -384,10 +384,6 @@ uscanneropen(dev_t dev, int flag, int mo sc->sc_state |= USCANNER_OPEN; - sc->sc_bulkin_buffer = kmem_alloc(USCANNER_BUFFERSIZE, KM_SLEEP); - sc->sc_bulkout_buffer = kmem_alloc(USCANNER_BUFFERSIZE, KM_SLEEP); - /* No need to check buffers for NULL since we have WAITOK */ - sc->sc_bulkin_bufferlen = USCANNER_BUFFERSIZE; sc->sc_bulkout_bufferlen = USCANNER_BUFFERSIZE; @@ -413,16 +409,21 @@ uscanneropen(dev_t dev, int flag, int mo } } - sc->sc_bulkin_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_bulkin_xfer == NULL) { + int error = usbd_create_xfer(sc->sc_bulkin_pipe, USCANNER_BUFFERSIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_bulkin_xfer); + if (error) { uscanner_do_close(sc); - return ENOMEM; + return error; } - sc->sc_bulkout_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_bulkout_xfer == NULL) { + sc->sc_bulkin_buffer = usbd_get_buffer(sc->sc_bulkin_xfer); + + error = usbd_create_xfer(sc->sc_bulkout_pipe, USCANNER_BUFFERSIZE, 0, + 0, &sc->sc_bulkout_xfer); + if (error) { uscanner_do_close(sc); - return ENOMEM; + return error; } + sc->sc_bulkout_buffer = usbd_get_buffer(sc->sc_bulkout_xfer); return 0; /* success */ } @@ -454,11 +455,11 @@ void uscanner_do_close(struct uscanner_softc *sc) { if (sc->sc_bulkin_xfer) { - usbd_free_xfer(sc->sc_bulkin_xfer); + usbd_destroy_xfer(sc->sc_bulkin_xfer); sc->sc_bulkin_xfer = NULL; } if (sc->sc_bulkout_xfer) { - usbd_free_xfer(sc->sc_bulkout_xfer); + usbd_destroy_xfer(sc->sc_bulkout_xfer); sc->sc_bulkout_xfer = NULL; } @@ -503,10 +504,8 @@ uscanner_do_read(struct uscanner_softc * DPRINTFN(1, ("uscannerread: start transfer %d bytes\n",n)); tn = n; - err = usbd_bulk_transfer( - sc->sc_bulkin_xfer, sc->sc_bulkin_pipe, - USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, - sc->sc_bulkin_buffer, &tn); + err = usbd_bulk_transfer(sc->sc_bulkin_xfer, sc->sc_bulkin_pipe, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, sc->sc_bulkin_buffer, &tn); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -558,10 +557,9 @@ uscanner_do_write(struct uscanner_softc if (error) break; DPRINTFN(1, ("uscanner_do_write: transfer %d bytes\n", n)); - err = usbd_bulk_transfer( - sc->sc_bulkout_xfer, sc->sc_bulkout_pipe, - 0, USBD_NO_TIMEOUT, - sc->sc_bulkout_buffer, &n); + err = usbd_bulk_transfer(sc->sc_bulkout_xfer, + sc->sc_bulkout_pipe, 0, USBD_NO_TIMEOUT, + sc->sc_bulkout_buffer, &n); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; Index: sys/dev/usb/usscanner.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/usscanner.c,v retrieving revision 1.38.6.9 diff -u -p -r1.38.6.9 usscanner.c --- sys/dev/usb/usscanner.c 29 Sep 2015 11:38:29 -0000 1.38.6.9 +++ sys/dev/usb/usscanner.c 4 Oct 2015 08:34:47 -0000 @@ -109,8 +109,10 @@ struct usscanner_softc { struct usbd_xfer * sc_cmd_xfer; void *sc_cmd_buffer; - struct usbd_xfer * sc_data_xfer; - void *sc_data_buffer; + struct usbd_xfer * sc_datain_xfer; + void *sc_datain_buffer; + struct usbd_xfer * sc_dataout_xfer; + void *sc_dataout_buffer; int sc_state; #define UAS_IDLE 0 @@ -181,6 +183,7 @@ usscanner_attach(device_t parent, device usb_endpoint_descriptor_t *ed; uint8_t epcount; int i; + int error; DPRINTFN(10,("usscanner_attach: sc=%p\n", sc)); @@ -262,44 +265,45 @@ usscanner_attach(device_t parent, device return; } - sc->sc_cmd_xfer = usbd_alloc_xfer(uaa->uaa_device); - if (sc->sc_cmd_xfer == NULL) { - aprint_error_dev(self, "alloc cmd xfer failed, err=%d\n", err); + /* XXX too big */ + error = usbd_create_xfer(sc->sc_out_pipe, USSCANNER_MAX_TRANSFER_SIZE, + 0, 0, &sc->sc_cmd_xfer); + if (error) { + aprint_error_dev(self, "alloc cmd xfer failed, error=%d\n", + error); usscanner_cleanup(sc); return; } - /* XXX too big */ - sc->sc_cmd_buffer = usbd_alloc_buffer(sc->sc_cmd_xfer, - USSCANNER_MAX_TRANSFER_SIZE); - if (sc->sc_cmd_buffer == NULL) { - aprint_error_dev(self, "alloc cmd buffer failed, err=%d\n", - err); + sc->sc_cmd_buffer = usbd_get_buffer(sc->sc_cmd_xfer); + + error = usbd_create_xfer(sc->sc_intr_pipe, 1, USBD_SHORT_XFER_OK, + 0, &sc->sc_intr_xfer); + if (error) { + aprint_error_dev(self, "alloc intr xfer failed, error=%d\n", + error); usscanner_cleanup(sc); return; } - sc->sc_intr_xfer = usbd_alloc_xfer (uaa->uaa_device); - if (sc->sc_intr_xfer == NULL) { - aprint_error_dev(self, "alloc intr xfer failed, err=%d\n", err); - usscanner_cleanup(sc); - return; - } - - sc->sc_data_xfer = usbd_alloc_xfer(uaa->uaa_device); - if (sc->sc_data_xfer == NULL) { - aprint_error_dev(self, "alloc data xfer failed, err=%d\n", err); + error = usbd_create_xfer(sc->sc_in_pipe, USSCANNER_MAX_TRANSFER_SIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_datain_xfer); + if (error) { + aprint_error_dev(self, "alloc data xfer failed, error=%d\n", + error); usscanner_cleanup(sc); return; } - sc->sc_data_buffer = usbd_alloc_buffer(sc->sc_data_xfer, - USSCANNER_MAX_TRANSFER_SIZE); - if (sc->sc_data_buffer == NULL) { - aprint_error_dev(self, "alloc data buffer failed, err=%d\n", - err); + sc->sc_datain_buffer = usbd_get_buffer(sc->sc_datain_xfer); + + error = usbd_create_xfer(sc->sc_out_pipe, USSCANNER_MAX_TRANSFER_SIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_dataout_xfer); + if (error) { + aprint_error_dev(self, "alloc data xfer failed, err=%d\n", err); usscanner_cleanup(sc); return; } + sc->sc_dataout_buffer = usbd_get_buffer(sc->sc_dataout_xfer); /* * Fill in the adapter. @@ -403,12 +407,16 @@ usscanner_cleanup(struct usscanner_softc sc->sc_out_pipe = NULL; } if (sc->sc_cmd_xfer != NULL) { - usbd_free_xfer(sc->sc_cmd_xfer); + usbd_destroy_xfer(sc->sc_cmd_xfer); sc->sc_cmd_xfer = NULL; } - if (sc->sc_data_xfer != NULL) { - usbd_free_xfer(sc->sc_data_xfer); - sc->sc_data_xfer = NULL; + if (sc->sc_datain_xfer != NULL) { + usbd_destroy_xfer(sc->sc_datain_xfer); + sc->sc_datain_xfer = NULL; + } + if (sc->sc_dataout_xfer != NULL) { + usbd_destroy_xfer(sc->sc_dataout_xfer); + sc->sc_dataout_xfer = NULL; } } @@ -450,7 +458,8 @@ usscanner_sense(struct usscanner_softc * sc->sc_state = UAS_SENSECMD; memcpy(sc->sc_cmd_buffer, &sense_cmd, sizeof(sense_cmd)); - usbd_setup_xfer(sc->sc_cmd_xfer, sc->sc_out_pipe, sc, sc->sc_cmd_buffer, + + usbd_setup_xfer(sc->sc_cmd_xfer, sc, sc->sc_cmd_buffer, sizeof(sense_cmd), 0, USSCANNER_TIMEOUT, usscanner_sensecmd_cb); err = usbd_transfer(sc->sc_cmd_xfer); @@ -511,8 +520,8 @@ usscanner_data_cb(struct usbd_xfer *xfer switch (status) { case USBD_NORMAL_COMPLETION: - if (xs->xs_control & XS_CTL_DATA_IN) - memcpy(xs->data, sc->sc_data_buffer, len); + //if (xs->xs_control & XS_CTL_DATA_IN) + // memcpy(xs->data, sc->sc_data_buffer, len); xs->error = XS_NOERROR; break; case USBD_TIMEOUT: @@ -551,7 +560,7 @@ usscanner_sensedata_cb(struct usbd_xfer switch (status) { case USBD_NORMAL_COMPLETION: - memcpy(&xs->sense, sc->sc_data_buffer, len); + memcpy(&xs->sense, sc->sc_datain_buffer, len); if (len < sizeof(xs->sense)) xs->error = XS_SHORTSENSE; break; @@ -577,9 +586,8 @@ usscanner_done(struct usscanner_softc *s DPRINTFN(10,("usscanner_done: error=%d\n", sc->sc_xs->error)); sc->sc_state = UAS_STATUS; - usbd_setup_xfer(sc->sc_intr_xfer, sc->sc_intr_pipe, sc, &sc->sc_status, - 1, USBD_SHORT_XFER_OK, - USSCANNER_TIMEOUT, usscanner_intr_cb); + usbd_setup_xfer(sc->sc_intr_xfer, sc, &sc->sc_status, 1, + USBD_SHORT_XFER_OK, USSCANNER_TIMEOUT, usscanner_intr_cb); err = usbd_transfer(sc->sc_intr_xfer); if (err == USBD_IN_PROGRESS) return; @@ -619,11 +627,10 @@ usscanner_sensecmd_cb(struct usbd_xfer * } sc->sc_state = UAS_SENSEDATA; - usbd_setup_xfer(sc->sc_data_xfer, sc->sc_in_pipe, sc, - sc->sc_data_buffer, + usbd_setup_xfer(sc->sc_datain_xfer, sc, sc->sc_datain_buffer, sizeof(xs->sense), USBD_SHORT_XFER_OK, USSCANNER_TIMEOUT, usscanner_sensedata_cb); - err = usbd_transfer(sc->sc_data_xfer); + err = usbd_transfer(sc->sc_datain_xfer); if (err == USBD_IN_PROGRESS) return; xs->error = XS_DRIVER_STUFFUP; @@ -637,7 +644,7 @@ usscanner_cmd_cb(struct usbd_xfer *xfer, { struct usscanner_softc *sc = priv; struct scsipi_xfer *xs = sc->sc_xs; - struct usbd_pipe *pipe; + struct usbd_xfer *dxfer; usbd_status err; DPRINTFN(10, ("usscanner_cmd_cb status=%d\n", status)); @@ -675,18 +682,16 @@ usscanner_cmd_cb(struct usbd_xfer *xfer, if (xs->xs_control & XS_CTL_DATA_IN) { DPRINTFN(4, ("usscanner_cmd_cb: data in len=%d\n", xs->datalen)); - pipe = sc->sc_in_pipe; + dxfer = sc->sc_datain_xfer; } else { DPRINTFN(4, ("usscanner_cmd_cb: data out len=%d\n", xs->datalen)); - memcpy(sc->sc_data_buffer, xs->data, xs->datalen); - pipe = sc->sc_out_pipe; + dxfer = sc->sc_dataout_xfer; } sc->sc_state = UAS_DATA; - usbd_setup_xfer(sc->sc_data_xfer, pipe, sc, sc->sc_data_buffer, - xs->datalen, USBD_SHORT_XFER_OK, - xs->timeout, usscanner_data_cb); - err = usbd_transfer(sc->sc_data_xfer); + usbd_setup_xfer(dxfer, sc, xs->data, xs->datalen, + USBD_SHORT_XFER_OK, xs->timeout, usscanner_data_cb); + err = usbd_transfer(dxfer); if (err == USBD_IN_PROGRESS) return; xs->error = XS_DRIVER_STUFFUP; @@ -749,9 +754,8 @@ usscanner_scsipi_request(struct scsipi_c sc->sc_state = UAS_CMD; sc->sc_xs = xs; memcpy(sc->sc_cmd_buffer, xs->cmd, xs->cmdlen); - usbd_setup_xfer(sc->sc_cmd_xfer, sc->sc_out_pipe, sc, - sc->sc_cmd_buffer, xs->cmdlen, 0, - USSCANNER_TIMEOUT, usscanner_cmd_cb); + usbd_setup_xfer(sc->sc_cmd_xfer, sc, sc->sc_cmd_buffer, + xs->cmdlen, 0, USSCANNER_TIMEOUT, usscanner_cmd_cb); err = usbd_transfer(sc->sc_cmd_xfer); if (err != USBD_IN_PROGRESS) { xs->error = XS_DRIVER_STUFFUP; Index: sys/dev/usb/ustir.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/ustir.c,v retrieving revision 1.33.10.8 diff -u -p -r1.33.10.8 ustir.c --- sys/dev/usb/ustir.c 21 Mar 2015 11:33:37 -0000 1.33.10.8 +++ sys/dev/usb/ustir.c 4 Oct 2015 08:34:47 -0000 @@ -648,10 +648,9 @@ ustir_start_read(struct ustir_softc *sc) usbd_clear_endpoint_stall(sc->sc_rd_pipe); } - usbd_setup_xfer(sc->sc_rd_xfer, sc->sc_rd_pipe, sc, sc->sc_rd_buf, - sc->sc_params.maxsize, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, ustir_rd_cb); + usbd_setup_xfer(sc->sc_rd_xfer, sc, sc->sc_rd_buf, + sc->sc_params.maxsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, + ustir_rd_cb); err = usbd_transfer(sc->sc_rd_xfer); if (err != USBD_IN_PROGRESS) { DPRINTFN(0, ("%s: err=%d\n", __func__, (int)err)); @@ -695,28 +694,19 @@ ustir_open(void *h, int flag, int mode, error = EIO; goto bad2; } - sc->sc_rd_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_rd_xfer == NULL) { - error = ENOMEM; + error = usbd_create_xfer(sc->sc_rd_pipe, IRDA_MAX_FRAME_SIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_rd_xfer); + if (error) goto bad3; - } - sc->sc_wr_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_wr_xfer == NULL) { - error = ENOMEM; + sc->sc_rd_buf = usbd_get_buffer(sc->sc_rd_xfer); + + error = usbd_create_xfer(sc->sc_wr_pipe, + IRDA_MAX_FRAME_SIZE + STIR_OUTPUT_HEADER_SIZE, + USBD_FORCE_SHORT_XFER, 0, &sc->sc_wr_xfer); + if (error) goto bad4; - } - sc->sc_rd_buf = usbd_alloc_buffer(sc->sc_rd_xfer, - IRDA_MAX_FRAME_SIZE); - if (sc->sc_rd_buf == NULL) { - error = ENOMEM; - goto bad5; - } - sc->sc_wr_buf = usbd_alloc_buffer(sc->sc_wr_xfer, - IRDA_MAX_FRAME_SIZE + STIR_OUTPUT_HEADER_SIZE); - if (sc->sc_wr_buf == NULL) { - error = ENOMEM; - goto bad5; - } + sc->sc_wr_buf = usbd_get_buffer(sc->sc_wr_xfer); + sc->sc_ur_buf = kmem_alloc(IRDA_MAX_FRAME_SIZE, KM_SLEEP); if (sc->sc_ur_buf == NULL) { error = ENOMEM; @@ -751,10 +741,10 @@ ustir_open(void *h, int flag, int mode, return 0; bad5: - usbd_free_xfer(sc->sc_wr_xfer); + usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; bad4: - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; bad3: usbd_close_pipe(sc->sc_wr_pipe); @@ -796,12 +786,12 @@ ustir_close(void *h, int flag, int mode, sc->sc_wr_pipe = NULL; } if (sc->sc_rd_xfer != NULL) { - usbd_free_xfer(sc->sc_rd_xfer); + usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { - usbd_free_xfer(sc->sc_wr_xfer); + usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } @@ -984,9 +974,7 @@ ustir_write(void *h, struct uio *uio, in #endif err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe, - USBD_FORCE_SHORT_XFER, - USTIR_WR_TIMEOUT, - wrbuf, &btlen); + USBD_FORCE_SHORT_XFER, USTIR_WR_TIMEOUT, wrbuf, &btlen); DPRINTFN(2, ("%s: err=%d\n", __func__, err)); if (err != USBD_NORMAL_COMPLETION) { if (err == USBD_INTERRUPTED) Index: sys/dev/usb/utoppy.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/utoppy.c,v retrieving revision 1.24.4.8 diff -u -p -r1.24.4.8 utoppy.c --- sys/dev/usb/utoppy.c 28 Apr 2015 06:55:26 -0000 1.24.4.8 +++ sys/dev/usb/utoppy.c 4 Oct 2015 08:34:48 -0000 @@ -281,39 +281,52 @@ utoppy_attach(device_t parent, device_t sc->sc_iface = iface; sc->sc_udev = dev; - sc->sc_out_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_out_xfer == NULL) { - aprint_error_dev(self, "could not allocate bulk out xfer\n"); - goto fail0; + sc->sc_out_pipe = NULL; + sc->sc_in_pipe = NULL; + + if (usbd_open_pipe(sc->sc_iface, sc->sc_out, 0, &sc->sc_out_pipe)) { + DPRINTF(UTOPPY_DBG_OPEN, ("%s: usbd_open_pipe(OUT) failed\n", + device_xname(sc->sc_dev))); + aprint_error_dev(self, "could not open OUT pipe\n"); + sc->sc_dying = 1; + return; } - sc->sc_out_buf = usbd_alloc_buffer(sc->sc_out_xfer, UTOPPY_FRAG_SIZE); - if (sc->sc_out_buf == NULL) { - aprint_error_dev(self, "could not allocate bulk out buffer\n"); - goto fail1; + if (usbd_open_pipe(sc->sc_iface, sc->sc_in, 0, &sc->sc_in_pipe)) { + DPRINTF(UTOPPY_DBG_OPEN, ("%s: usbd_open_pipe(IN) failed\n", + device_xname(sc->sc_dev))); + aprint_error_dev(self, "could not open IN pipe\n"); + + usbd_close_pipe(sc->sc_out_pipe); + sc->sc_out_pipe = NULL; + sc->sc_dying = 1; + return; + } + + int error; + error = usbd_create_xfer(sc->sc_out_pipe, UTOPPY_FRAG_SIZE, 0, 0, + &sc->sc_out_xfer); + if (error) { + aprint_error_dev(self, "could not allocate bulk out xfer\n"); + goto fail0; } - sc->sc_in_xfer = usbd_alloc_xfer(sc->sc_udev); - if (sc->sc_in_xfer == NULL) { + error = usbd_create_xfer(sc->sc_in_pipe, UTOPPY_FRAG_SIZE, + USBD_SHORT_XFER_OK, 0, &sc->sc_in_xfer); + if (error) { aprint_error_dev(self, "could not allocate bulk in xfer\n"); goto fail1; } - sc->sc_in_buf = usbd_alloc_buffer(sc->sc_in_xfer, UTOPPY_FRAG_SIZE); - if (sc->sc_in_buf == NULL) { - aprint_error_dev(self, "could not allocate bulk in buffer\n"); - goto fail2; - } + sc->sc_out_buf = usbd_get_buffer(sc->sc_out_xfer); + sc->sc_in_buf = usbd_get_buffer(sc->sc_in_xfer); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); return; - fail2: usbd_free_xfer(sc->sc_in_xfer); - sc->sc_in_xfer = NULL; - - fail1: usbd_free_xfer(sc->sc_out_xfer); + fail1: usbd_destroy_xfer(sc->sc_out_xfer); sc->sc_out_xfer = NULL; fail0: sc->sc_dying = 1; @@ -348,9 +361,9 @@ utoppy_detach(device_t self, int flags) usbd_abort_pipe(sc->sc_in_pipe); if (sc->sc_in_xfer != NULL) - usbd_free_xfer(sc->sc_in_xfer); + usbd_destroy_xfer(sc->sc_in_xfer); if (sc->sc_out_xfer != NULL) - usbd_free_xfer(sc->sc_out_xfer); + usbd_destroy_xfer(sc->sc_out_xfer); s = splusb(); if (--sc->sc_refcnt >= 0) @@ -527,7 +540,7 @@ utoppy_bulk_transfer(struct usbd_xfer *x { usbd_status err; - usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, NULL); + usbd_setup_xfer(xfer, 0, buf, *size, flags, timeout, NULL); err = usbd_sync_transfer_sig(xfer); @@ -1346,25 +1359,6 @@ utoppyopen(dev_t dev, int flag, int mode sc->sc_refcnt++; sc->sc_state = UTOPPY_STATE_OPENING; sc->sc_turbo_mode = 0; - sc->sc_out_pipe = NULL; - sc->sc_in_pipe = NULL; - - if (usbd_open_pipe(sc->sc_iface, sc->sc_out, 0, &sc->sc_out_pipe)) { - DPRINTF(UTOPPY_DBG_OPEN, ("%s: utoppyopen: usbd_open_pipe(OUT) " - "failed\n", device_xname(sc->sc_dev))); - error = EIO; - goto done; - } - - if (usbd_open_pipe(sc->sc_iface, sc->sc_in, 0, &sc->sc_in_pipe)) { - DPRINTF(UTOPPY_DBG_OPEN, ("%s: utoppyopen: usbd_open_pipe(IN) " - "failed\n", device_xname(sc->sc_dev))); - error = EIO; - usbd_close_pipe(sc->sc_out_pipe); - sc->sc_out_pipe = NULL; - goto done; - } - sc->sc_out_data = kmem_alloc(UTOPPY_BSIZE + 1, KM_SLEEP); if (sc->sc_out_data == NULL) { error = ENOMEM; @@ -1385,16 +1379,9 @@ utoppyopen(dev_t dev, int flag, int mode if ((error = utoppy_check_ready(sc)) != 0) { DPRINTF(UTOPPY_DBG_OPEN, ("%s: utoppyopen: utoppy_check_ready()" " returned %d\n", device_xname(sc->sc_dev), error)); - error: - usbd_abort_pipe(sc->sc_out_pipe); - usbd_close_pipe(sc->sc_out_pipe); - sc->sc_out_pipe = NULL; - usbd_abort_pipe(sc->sc_in_pipe); - usbd_close_pipe(sc->sc_in_pipe); - sc->sc_in_pipe = NULL; } - done: + error: sc->sc_state = error ? UTOPPY_STATE_CLOSED : UTOPPY_STATE_IDLE; DPRINTF(UTOPPY_DBG_OPEN, ("%s: utoppyopen: done. error %d, new state " Index: sys/dev/usb/uvideo.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/uvideo.c,v retrieving revision 1.41.2.8 diff -u -p -r1.41.2.8 uvideo.c --- sys/dev/usb/uvideo.c 21 Mar 2015 11:33:37 -0000 1.41.2.8 +++ sys/dev/usb/uvideo.c 4 Oct 2015 08:34:48 -0000 @@ -1467,6 +1467,7 @@ uvideo_stream_start_xfer(struct uvideo_s uint32_t uframe_len; /* bytes per usb frame (TODO: or microframe?) */ uint32_t nframes; /* number of usb frames (TODO: or microframs?) */ int i, ret; + int error; struct uvideo_alternate *alt, *alt_maybe; usbd_status err; @@ -1476,23 +1477,6 @@ uvideo_stream_start_xfer(struct uvideo_s ret = 0; bx = &vs->vs_xfer.bulk; - bx->bx_xfer = usbd_alloc_xfer(sc->sc_udev); - if (bx->bx_xfer == NULL) { - DPRINTF(("uvideo: couldn't allocate xfer\n")); - return ENOMEM; - } - DPRINTF(("uvideo: xfer %p\n", bx->bx_xfer)); - - bx->bx_buflen = vs->vs_max_payload_size; - - DPRINTF(("uvideo: allocating %u byte buffer\n", bx->bx_buflen)); - bx->bx_buffer = usbd_alloc_buffer(bx->bx_xfer, bx->bx_buflen); - - if (bx->bx_buffer == NULL) { - DPRINTF(("uvideo: couldn't allocate buffer\n")); - return ENOMEM; - } - err = usbd_open_pipe(vs->vs_iface, bx->bx_endpt, 0, &bx->bx_pipe); if (err != USBD_NORMAL_COMPLETION) { @@ -1502,6 +1486,17 @@ uvideo_stream_start_xfer(struct uvideo_s } DPRINTF(("uvideo: pipe %p\n", bx->bx_pipe)); + error = usbd_create_xfer(bx->bx_pipe, vs->vs_max_payload_size, + USBD_SHORT_XFER_OK, 0, &bx->bx_xfer); + if (error) { + DPRINTF(("uvideo: couldn't allocate xfer\n")); + return error; + } + DPRINTF(("uvideo: xfer %p\n", bx->bx_xfer)); + + bx->bx_buflen = vs->vs_max_payload_size; + bx->bx_buffer = usbd_get_buffer(bx->bx_xfer); + mutex_enter(&bx->bx_lock); if (bx->bx_running == false) { bx->bx_running = true; @@ -1602,23 +1597,13 @@ uvideo_stream_start_xfer(struct uvideo_s for (i = 0; i < UVIDEO_NXFERS; i++) { struct uvideo_isoc *isoc = &ix->ix_i[i]; - isoc->i_xfer = usbd_alloc_xfer(sc->sc_udev); - if (isoc->i_xfer == NULL) { - DPRINTF(("uvideo: failed to alloc xfer: %s" - " (%d)\n", - usbd_errstr(err), err)); - return ENOMEM; - } - - isoc->i_buf = usbd_alloc_buffer(isoc->i_xfer, - nframes * uframe_len); + error = usbd_create_xfer(ix->ix_pipe, + nframes * uframe_len, 0, ix->ix_nframes, + &isoc->i_xfer); + if (error) + return error; - if (isoc->i_buf == NULL) { - DPRINTF(("uvideo: failed to alloc buf: %s" - " (%d)\n", - usbd_errstr(err), err)); - return ENOMEM; - } + isoc->i_buf = usbd_get_buffer(isoc->i_xfer); } uvideo_stream_recv_isoc_start(vs); @@ -1662,7 +1647,7 @@ uvideo_stream_stop_xfer(struct uvideo_st } if (bx->bx_xfer) { - usbd_free_xfer(bx->bx_xfer); + usbd_destroy_xfer(bx->bx_xfer); bx->bx_xfer = NULL; } @@ -1680,8 +1665,7 @@ uvideo_stream_stop_xfer(struct uvideo_st for (i = 0; i < UVIDEO_NXFERS; i++) { struct uvideo_isoc *isoc = &ix->ix_i[i]; if (isoc->i_xfer != NULL) { - usbd_free_buffer(isoc->i_xfer); - usbd_free_xfer(isoc->i_xfer); + usbd_destroy_xfer(isoc->i_xfer); isoc->i_xfer = NULL; } @@ -1740,7 +1724,6 @@ uvideo_stream_recv_isoc_start1(struct uv isoc->i_frlengths[i] = ix->ix_uframe_len; usbd_setup_isoc_xfer(isoc->i_xfer, - ix->ix_pipe, isoc, isoc->i_frlengths, ix->ix_nframes, @@ -1852,8 +1835,7 @@ uvideo_stream_recv_bulk_transfer(void *a while (bx->bx_running) { len = bx->bx_buflen; err = usbd_bulk_transfer(bx->bx_xfer, bx->bx_pipe, - USBD_SHORT_XFER_OK, - USBD_NO_TIMEOUT, + USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT, bx->bx_buffer, &len); if (err == USBD_NORMAL_COMPLETION) {