Skip to contentSkip to conversation

ehci: clear suspend bit on detach

PATCH In review Gerd Hoffmann 2 participants 2 messages Oct 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ehci: clear suspend bit on detach

When a device is detached, clear the suspend bit (PORTSC_SUSPEND) in the port status register.

The specs are not *that* clear what is supposed to happen in case a suspended device is unplugged. But the enable bit (PORTSC_PED) is cleared, and the specs mention setting suspend with enable being unset is undefined behavior. So clearing them both looks reasonable, and it actually fixes the reported bug.

https://bugzilla.redhat.com/show_bug.cgi?id=1268879

---
 hw/usb/hcd-ehci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ehci.c +1 -1
index 64a54c6..4e2161b 100644
@@ -726,7 +726,7 @@ static void ehci_detach(USBPort *port)
     ehci_queues_rip_device(s, port->dev, 0);
     ehci_queues_rip_device(s, port->dev, 1);
 
-    *portsc &= ~(PORTSC_CONNECT|PORTSC_PED);
+    *portsc &= ~(PORTSC_CONNECT|PORTSC_PED|PORTSC_SUSPEND);
     *portsc |= PORTSC_CSC;
 
     ehci_raise_irq(s, USBSTS_PCD);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 9 lines · Gerd Hoffmann

When a device is detached, clear the suspend bit (PORTSC_SUSPEND) in the port status register.

The specs are not *that* clear what is supposed to happen in case a suspended device is unplugged. But the enable bit (PORTSC_PED) is cleared, and the specs mention setting suspend with enable being unset is undefined behavior. So clearing them both looks reasonable, and it actually fixes the reported bug.

Quoted 4 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1268879

Thanks for fixing this. Patch looks good to me:

Regards,

Hans

Quoted 18 lines
---
  hw/usb/hcd-ehci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-ehci.c +1 -1
index 64a54c6..4e2161b 100644
@@ -726,7 +726,7 @@ static void ehci_detach(USBPort *port)
      ehci_queues_rip_device(s, port->dev, 0);
      ehci_queues_rip_device(s, port->dev, 1);
 
-    *portsc &= ~(PORTSC_CONNECT|PORTSC_PED);
+    *portsc &= ~(PORTSC_CONNECT|PORTSC_PED|PORTSC_SUSPEND);
      *portsc |= PORTSC_CSC;
 
      ehci_raise_irq(s, USBSTS_PCD);