9ae3a8
From 1d59e428d7754c0fc331092d265254a0b3473546 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Wed, 11 Dec 2013 10:04:22 +0100
9ae3a8
Subject: [PATCH 1/5] xhci: add support for suspend/resume
9ae3a8
9ae3a8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Message-id: <1386756262-29763-2-git-send-email-kraxel@redhat.com>
9ae3a8
Patchwork-id: 56161
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 1/1] xhci: add support for suspend/resume
9ae3a8
Bugzilla: 1012365
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
The OS can ask the xhci controller to save and restore its
9ae3a8
internal state, which is used by the OS when the system is
9ae3a8
suspended and resumed.
9ae3a8
9ae3a8
This patch handles writes to the save + restore bits in the
9ae3a8
command register.  Only thing it does is updating the
9ae3a8
restore error bit in the status register to signal an error
9ae3a8
on restore.  The guest OS should do a full reinitialization
9ae3a8
after resume then.
9ae3a8
9ae3a8
This is the minimal patch which gets S3 going with xhci.
9ae3a8
Implementing full save/restore support is TBD.
9ae3a8
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=1012365
9ae3a8
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit f1f8bc218a422081f36f0b325b3de5e6a5078b74)
9ae3a8
---
9ae3a8
 hw/usb/hcd-xhci.c | 8 ++++++++
9ae3a8
 1 file changed, 8 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/usb/hcd-xhci.c |    8 ++++++++
9ae3a8
 1 files changed, 8 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
9ae3a8
index 9d7315f..87ba7af 100644
9ae3a8
--- a/hw/usb/hcd-xhci.c
9ae3a8
+++ b/hw/usb/hcd-xhci.c
9ae3a8
@@ -2976,6 +2976,14 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
9ae3a8
         } else if (!(val & USBCMD_RS) && (xhci->usbcmd & USBCMD_RS)) {
9ae3a8
             xhci_stop(xhci);
9ae3a8
         }
9ae3a8
+        if (val & USBCMD_CSS) {
9ae3a8
+            /* save state */
9ae3a8
+            xhci->usbsts &= ~USBSTS_SRE;
9ae3a8
+        }
9ae3a8
+        if (val & USBCMD_CRS) {
9ae3a8
+            /* restore state */
9ae3a8
+            xhci->usbsts |= USBSTS_SRE;
9ae3a8
+        }
9ae3a8
         xhci->usbcmd = val & 0xc0f;
9ae3a8
         xhci_mfwrap_update(xhci);
9ae3a8
         if (val & USBCMD_HCRST) {
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8