From 6cdaa1ea0e593e262634a8896849bdeb887fffc0 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 29 Feb 2012 12:39:29 +0100
Subject: [PATCH 14/35] usb-ehci: Clear the portstatus powner bit on device
 disconnect

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1330519171-24231-15-git-send-email-kraxel@redhat.com>
Patchwork-id: 37765
O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 14/16] usb-ehci: Clear the portstatus powner bit on device disconnect
Bugzilla: 758104
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>

From: Hans de Goede <hdegoede@redhat.com>

According to the EHCI spec port ownerhsip should revert to the EHCI controller
on device disconnect. This fixes the problem of a port getting stuck on USB 1
when using redirection and plugging in a USB 2 device after a USB 1 device
has been redirected.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit f76e1d814241794467366d70d3d77849a6fd5ab0)
---
 hw/usb-ehci.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/usb-ehci.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index a95c76a..d78d9ee 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -753,6 +753,11 @@ static void ehci_detach(USBPort *port)
         USBPort *companion = s->companion_ports[port->index];
         companion->ops->detach(companion);
         companion->dev = NULL;
+        /*
+         * EHCI spec 4.2.2: "When a disconnect occurs... On the event,
+         * the port ownership is returned immediately to the EHCI controller."
+         */
+        *portsc &= ~PORTSC_POWNER;
         return;
     }
 
-- 
1.7.7.6

