git: c4c368fb3ecc - main - bhyve: Simplify control flow in the xhci device model
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 14 Nov 2022 20:09:41 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=c4c368fb3ecc426660f79b1c25f18d0401ff96fc
commit c4c368fb3ecc426660f79b1c25f18d0401ff96fc
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-11-14 20:08:45 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-11-14 20:08:45 +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
---
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 8eff332099df..0d8122ee8c90 100644
--- a/usr.sbin/bhyve/pci_xhci.c
+++ b/usr.sbin/bhyve/pci_xhci.c
@@ -1725,7 +1725,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;
@@ -1849,24 +1849,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: