Skip to contentSkip to conversation

usb-hub: clear PORT_STAT_SUSPEND on wakeup

PATCH New Ladi Prosek 1 participant 3 messages May 11, 2017

lore
Share & tools
lore
#0 lore raw

cover usb-hub: clear PORT_STAT_SUSPEND on wakeup

Two small usb patches. Patch 2 fixes a problem with xhci on Windows, patch 1 addresses a minor code issue I found when debugging it.

Ladi Prosek (2):
xhci: fix logging
usb-hub: clear PORT_STAT_SUSPEND on wakeup

 hw/usb/dev-hub.c  | 1 +
 hw/usb/hcd-xhci.c | 7 ++-----
 2 files changed, 3 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/2 xhci: fix logging

slotid and epid were deleted from XHCITransfer in commit d6fcb29. Also deleting one unused forward declaration.

---
 hw/usb/hcd-xhci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci.c +2 -5
index a2d3143..d3d47bf 100644
@@ -1790,9 +1790,6 @@ static void xhci_stall_ep(XHCITransfer *xfer)
     }
 }
 
-static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer,
-                       XHCIEPContext *epctx);
-
 static int xhci_setup_packet(XHCITransfer *xfer)
 {
     USBEndpoint *ep;
@@ -1806,7 +1803,7 @@ static int xhci_setup_packet(XHCITransfer *xfer)
         ep = xhci_epid_to_usbep(xfer->epctx);
         if (!ep) {
             DPRINTF("xhci: slot %d has no device\n",
-                    xfer->slotid);
+                    xfer->epctx->slotid);
             return -1;
         }
     }
@@ -1980,7 +1977,7 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx
 {
     uint64_t mfindex;
 
-    DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", xfer->slotid, xfer->epid);
+    DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", epctx->slotid, epctx->epid);
 
     xfer->in_xfer = epctx->type>>2;
 
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/2 usb-hub: clear PORT_STAT_SUSPEND on wakeup

In reply to Ladi Prosek

The spec says:

Suspend: (PORT_SUSPEND) This field indicates whether or not the device on this port is suspended. Setting this field causes the device to suspend by not propagating bus traffic downstream. This field may be reset by a request or by resume signaling from the device attached to the port.

I can't find any specific statement like "the PORT_SUSPEND field is reset automatically on remote wakeup", but without this patch, the only way to reset it is via the ClearPortFeature request so the ".. or by resume signaling from the device" clause is clearly not implemented on the remote wakeup path.

The default xhci Windows driver does not issue the ClearPortFeature request and suspended devices attached to a hub don't properly get out of the suspended state. Interestingly, the default uhci Windows driver *does* issue the ClearPortFeature request and does not exhibit this problem.

---
 hw/usb/dev-hub.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-hub.c +1 -0
index 9fe7333..47b7519 100644
@@ -208,6 +208,7 @@ static void usb_hub_wakeup(USBPort *port1)
     USBHubPort *port = &s->ports[port1->index];
 
     if (port->wPortStatus & PORT_STAT_SUSPEND) {
+        port->wPortStatus &= ~PORT_STAT_SUSPEND;
         port->wPortChange |= PORT_STAT_C_SUSPEND;
         usb_wakeup(s->intr, 0);
     }
Signature · 1 line
2.9.3