218e99
From 6e80e82c534ca31d46e556ab10b83ebbd381a627 Mon Sep 17 00:00:00 2001
218e99
From: Gerd Hoffmann <kraxel@redhat.com>
218e99
Date: Fri, 30 Aug 2013 09:39:37 +0200
218e99
Subject: [PATCH 08/29] xhci: implement warm port reset
218e99
218e99
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
218e99
Message-id: <1377855577-11693-2-git-send-email-kraxel@redhat.com>
218e99
Patchwork-id: 53942
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH 1/1] xhci: implement warm port reset
218e99
Bugzilla: 949514
218e99
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
218e99
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
218e99
Without this patch windows can't do port resets for usb3 devices.
218e99
218e99
https://bugzilla.redhat.com/show_bug.cgi?id=949514
218e99
218e99
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
218e99
(cherry picked from commit dad5b9ea0895c227bc9d48b7f0a6fa51eaaa8661)
218e99
218e99
Note: the upstream commit message is incomplete.  This patch also
218e99
fixes cold port reset with USB_SPEED_SUPER.
218e99
---
218e99
 hw/usb/hcd-xhci.c | 13 +++++++++++--
218e99
 1 file changed, 11 insertions(+), 2 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/usb/hcd-xhci.c |   13 +++++++++++--
218e99
 1 files changed, 11 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
218e99
index 3d3d6c3..233f3b6 100644
218e99
--- a/hw/usb/hcd-xhci.c
218e99
+++ b/hw/usb/hcd-xhci.c
218e99
@@ -2655,7 +2655,7 @@ static void xhci_port_update(XHCIPort *port, int is_detach)
218e99
     xhci_port_notify(port, PORTSC_CSC);
218e99
 }
218e99
 
218e99
-static void xhci_port_reset(XHCIPort *port)
218e99
+static void xhci_port_reset(XHCIPort *port, bool warm_reset)
218e99
 {
218e99
     trace_usb_xhci_port_reset(port->portnr);
218e99
 
218e99
@@ -2666,6 +2666,11 @@ static void xhci_port_reset(XHCIPort *port)
218e99
     usb_device_reset(port->uport->dev);
218e99
 
218e99
     switch (port->uport->dev->speed) {
218e99
+    case USB_SPEED_SUPER:
218e99
+        if (warm_reset) {
218e99
+            port->portsc |= PORTSC_WRC;
218e99
+        }
218e99
+        /* fall through */
218e99
     case USB_SPEED_LOW:
218e99
     case USB_SPEED_FULL:
218e99
     case USB_SPEED_HIGH:
218e99
@@ -2828,8 +2833,12 @@ static void xhci_port_write(void *ptr, hwaddr reg,
218e99
     switch (reg) {
218e99
     case 0x00: /* PORTSC */
218e99
         /* write-1-to-start bits */
218e99
+        if (val & PORTSC_WPR) {
218e99
+            xhci_port_reset(port, true);
218e99
+            break;
218e99
+        }
218e99
         if (val & PORTSC_PR) {
218e99
-            xhci_port_reset(port);
218e99
+            xhci_port_reset(port, false);
218e99
             break;
218e99
         }
218e99
 
218e99
-- 
218e99
1.7.1
218e99