git: 055648ccb721 - stable/13 - bhyve: Simplify control flow in the xhci device model
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Nov 2022 13:53:28 UTC
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=055648ccb72174c7827e36ac15eafd860471968c commit 055648ccb72174c7827e36ac15eafd860471968c Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-11-14 20:08:45 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-11-21 13:48:48 +0000 bhyve: Simplify control flow in the xhci device model We only need to call pci_xhci_xfer_complete() when handling a transfer to the control endpoint, so move that code into the epid == 1 block and eliminate a goto. Also remove an unneeded reinitialization of setup_trb. No functional change intended. MFC after: 1 week Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D37287 (cherry picked from commit c4c368fb3ecc426660f79b1c25f18d0401ff96fc) --- usr.sbin/bhyve/pci_xhci.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c index 4bd0715d14ce..5502f95c3b46 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -1726,7 +1726,7 @@ pci_xhci_handle_transfer(struct pci_xhci_softc *sc, DPRINTF(("pci_xhci handle_transfer slot %u", slot)); retry: - err = 0; + err = XHCI_TRB_ERROR_INVALID; do_retry = 0; do_intr = 0; setup_trb = NULL; @@ -1850,24 +1850,26 @@ retry: goto errout; if (epid == 1) { - err = USB_ERR_NOT_STARTED; + int usberr; + if (dev->dev_ue->ue_request != NULL) - err = dev->dev_ue->ue_request(dev->dev_sc, xfer); - setup_trb = NULL; + usberr = dev->dev_ue->ue_request(dev->dev_sc, xfer); + else + usberr = USB_ERR_NOT_STARTED; + err = USB_TO_XHCI_ERR(usberr); + if (err == XHCI_TRB_ERROR_SUCCESS || + err == XHCI_TRB_ERROR_STALL || + err == XHCI_TRB_ERROR_SHORT_PKT) { + err = pci_xhci_xfer_complete(sc, xfer, slot, epid, + &do_intr); + if (err != XHCI_TRB_ERROR_SUCCESS) + do_retry = 0; + } + } else { /* handle data transfer */ pci_xhci_try_usb_xfer(sc, dev, devep, ep_ctx, slot, epid); err = XHCI_TRB_ERROR_SUCCESS; - goto errout; - } - - err = USB_TO_XHCI_ERR(err); - if ((err == XHCI_TRB_ERROR_SUCCESS) || - (err == XHCI_TRB_ERROR_STALL) || - (err == XHCI_TRB_ERROR_SHORT_PKT)) { - err = pci_xhci_xfer_complete(sc, xfer, slot, epid, &do_intr); - if (err != XHCI_TRB_ERROR_SUCCESS) - do_retry = 0; } errout: