]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
xhci: add support for suspend/resume
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 8 Nov 2013 10:43:20 +0000 (11:43 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 26 Nov 2013 08:21:17 +0000 (09:21 +0100)
The OS can ask the xhci controller to save and restore its
internal state, which is used by the OS when the system is
suspended and resumed.

This patch handles writes to the save + restore bits in the
command register.  Only thing it does is updating the
restore error bit in the status register to signal an error
on restore.  The guest OS should do a full reinitialization
after resume then.

This is the minimal patch which gets S3 going with xhci.
Implementing full save/restore support is TBD.

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

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-xhci.c

index c3377eebeafe345f975c2485101ffd2770bc657d..220e99dc355365aebc0bdf897af318481d24ad48 100644 (file)
@@ -3025,6 +3025,14 @@ static void xhci_oper_write(void *ptr, hwaddr reg,
         } else if (!(val & USBCMD_RS) && (xhci->usbcmd & USBCMD_RS)) {
             xhci_stop(xhci);
         }
+        if (val & USBCMD_CSS) {
+            /* save state */
+            xhci->usbsts &= ~USBSTS_SRE;
+        }
+        if (val & USBCMD_CRS) {
+            /* restore state */
+            xhci->usbsts |= USBSTS_SRE;
+        }
         xhci->usbcmd = val & 0xc0f;
         xhci_mfwrap_update(xhci);
         if (val & USBCMD_HCRST) {