Author: grehan
Date: Thu Jul 16 02:53:13 2020
New Revision: 363239
URL: https://svnweb.freebsd.org/changeset/base/363239

Log:
  MFC r362644
  
  Prevent calling USB backends multiple times.

Modified:
  stable/12/usr.sbin/bhyve/pci_xhci.c
  stable/12/usr.sbin/bhyve/usb_mouse.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/pci_xhci.c
==============================================================================
--- stable/12/usr.sbin/bhyve/pci_xhci.c Wed Jul 15 22:42:50 2020        
(r363238)
+++ stable/12/usr.sbin/bhyve/pci_xhci.c Thu Jul 16 02:53:13 2020        
(r363239)
@@ -1838,6 +1838,9 @@ retry:
 
        DPRINTF(("pci_xhci[%d]: xfer->ndata %u", __LINE__, xfer->ndata));
 
+       if (xfer->ndata <= 0)
+               goto errout;
+
        if (epid == 1) {
                err = USB_ERR_NOT_STARTED;
                if (dev->dev_ue->ue_request != NULL)
@@ -1852,6 +1855,7 @@ retry:
 
        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)

Modified: stable/12/usr.sbin/bhyve/usb_mouse.c
==============================================================================
--- stable/12/usr.sbin/bhyve/usb_mouse.c        Wed Jul 15 22:42:50 2020        
(r363238)
+++ stable/12/usr.sbin/bhyve/usb_mouse.c        Thu Jul 16 02:53:13 2020        
(r363239)
@@ -388,7 +388,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
                                 "sizeof(umouse_dev_desc) %lu",
                                 len, sizeof(umouse_dev_desc)));
                        if ((value & 0xFF) != 0) {
-                               err = USB_ERR_IOERROR;
+                               err = USB_ERR_STALLED;
                                goto done;
                        }
                        if (len > sizeof(umouse_dev_desc)) {
@@ -403,7 +403,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
                case UDESC_CONFIG:
                        DPRINTF(("umouse: (->UDESC_CONFIG)"));
                        if ((value & 0xFF) != 0) {
-                               err = USB_ERR_IOERROR;
+                               err = USB_ERR_STALLED;
                                goto done;
                        }
                        if (len > sizeof(umouse_confd)) {
@@ -472,7 +472,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
 
                default:
                        DPRINTF(("umouse: unknown(%d)->ERROR", value >> 8));
-                       err = USB_ERR_IOERROR;
+                       err = USB_ERR_STALLED;
                        goto done;
                }
                eshort = data->blen > 0;
@@ -496,7 +496,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
                        break;
                default:
                        DPRINTF(("umouse: IO ERROR"));
-                       err = USB_ERR_IOERROR;
+                       err = USB_ERR_STALLED;
                        goto done;
                }
                eshort = data->blen > 0;
@@ -507,7 +507,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
                if (index != 0) {
                        DPRINTF(("umouse get_interface, invalid index %d",
                                index));
-                       err = USB_ERR_IOERROR;
+                       err = USB_ERR_STALLED;
                        goto done;
                }
 
@@ -578,7 +578,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
        case UREQ(UR_SET_FEATURE, UT_WRITE_INTERFACE):
        case UREQ(UR_SET_FEATURE, UT_WRITE_ENDPOINT):
                DPRINTF(("umouse: (UR_CLEAR_FEATURE, UT_WRITE_INTERFACE)"));
-               err = USB_ERR_IOERROR;
+               err = USB_ERR_STALLED;
                goto done;
 
        case UREQ(UR_SET_INTERFACE, UT_WRITE_INTERFACE):
@@ -617,7 +617,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
                        memcpy(data->buf, &sc->um_report, len);
                        data->bdone += len;
                } else {
-                       err = USB_ERR_IOERROR;
+                       err = USB_ERR_STALLED;
                        goto done;
                }
                eshort = data->blen > 0;
@@ -659,7 +659,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
 
        default:
                DPRINTF(("**** umouse request unhandled"));
-               err = USB_ERR_IOERROR;
+               err = USB_ERR_STALLED;
                break;
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to