]> xenbits.xensource.com Git - seabios.git/commitdiff
xhci: Verify the device is still present in xhci_cmd_submit()
authorKevin O'Connor <kevin@koconnor.net>
Tue, 3 Oct 2017 15:29:12 +0000 (11:29 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 10 Oct 2017 00:54:13 +0000 (20:54 -0400)
Make sure the USB device is still present before altering the xhci
"slot" for it.  It appears some controllers will hang if a request is
sent to a port no longer connected.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/usb-xhci.c

index 0f717c6ca1e6f293a1311819cd5143b6f64f532f..08d1e321c179b8022feff765788e10928a82df83 100644 (file)
@@ -780,6 +780,17 @@ static void xhci_trb_queue(struct xhci_ring *ring,
 static int xhci_cmd_submit(struct usb_xhci_s *xhci, struct xhci_inctx *inctx
                            , u32 flags)
 {
+    if (inctx) {
+        struct xhci_slotctx *slot = (void*)&inctx[1 << xhci->context64];
+        u32 port = ((slot->ctx[1] >> 16) & 0xff) - 1;
+        u32 portsc = readl(&xhci->pr[port].portsc);
+        if (!(portsc & XHCI_PORTSC_CCS)) {
+            // Device no longer connected?!
+            xhci_print_port_state(1, __func__, port, portsc);
+            return -1;
+        }
+    }
+
     mutex_lock(&xhci->cmds->lock);
     xhci_trb_queue(xhci->cmds, inctx, 0, flags);
     xhci_doorbell(xhci, 0, 0);