]> Git Repo - qemu.git/commitdiff
nec-usb-xhci: set the device state to USB_STATE_DEFAULT
authorZhang Shuaiyi <[email protected]>
Thu, 30 Jun 2016 03:50:40 +0000 (23:50 -0400)
committerGerd Hoffmann <[email protected]>
Tue, 12 Jul 2016 08:23:59 +0000 (10:23 +0200)
This patch is a rough fix to "hw/usb/core.c:401: usb_handle_packet:
 Assertion `dev->state == 3' failed.". Qemu will crash when a usb3
device redirect to Windows7 VM via nec-usb-xhci.

In extensible-host-controler-interface-usb-xhci.pdf P94(4.6.5
Address Device):
    • If the Block Set Address Request (BSR) flag = ‘1’
        • If the slot is in the Enabled state:
            ...
            • Set the Slot State in the Output Slot Context to Default.

BSR = ‘1’: Enabled state to Default state; BSR = ‘0’: Default state
to Addressed state. Try to call usb_device_reset to set device state
to USB_STATE_DEFAULT in xhci_address_slot wether bsr is zero.

Signed-off-by: Zhang Shuaiyi <[email protected]>
Message-id: 1467258640[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
hw/usb/hcd-xhci.c

index 1a3377f03889cc848d4a2049e43bf9f18bc2224c..976bfb06598bad248effe3b358d349df7ef8f35f 100644 (file)
@@ -2364,6 +2364,8 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
     slot->uport = uport;
     slot->ctx = octx;
 
+    /* Make sure device is in USB_STATE_DEFAULT state */
+    usb_device_reset(dev);
     if (bsr) {
         slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;
     } else {
@@ -2371,7 +2373,6 @@ static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
         uint8_t buf[1];
 
         slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid;
-        usb_device_reset(dev);
         memset(&p, 0, sizeof(p));
         usb_packet_addbuf(&p, buf, sizeof(buf));
         usb_packet_setup(&p, USB_TOKEN_OUT,
This page took 0.02464 seconds and 4 git commands to generate.