f7153f0
From d1b07becc481e09225cfe905ec357807ae07f095 Mon Sep 17 00:00:00 2001
f7153f0
From: Gerd Hoffmann <address@hidden>
f7153f0
Date: Tue, 16 Feb 2016 15:15:04 +0100
f7153f0
Subject: [PATCH] ohci timer fix
f7153f0
f7153f0
Signed-off-by: Gerd Hoffmann <address@hidden>
f7153f0
---
f7153f0
 hw/usb/hcd-ohci.c | 31 +++++--------------------------
f7153f0
 1 file changed, 5 insertions(+), 26 deletions(-)
f7153f0
f7153f0
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
f7153f0
index bed55dd..3d1270d 100644
f7153f0
--- a/tools/qemu-xen/hw/usb/hcd-ohci.c
f7153f0
+++ b/tools/qemu-xen/hw/usb/hcd-ohci.c
f7153f0
@@ -1347,16 +1347,6 @@ static void ohci_frame_boundary(void *opaque)
f7153f0
  */
f7153f0
 static int ohci_bus_start(OHCIState *ohci)
f7153f0
 {
f7153f0
-    ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
f7153f0
-                    ohci_frame_boundary,
f7153f0
-                    ohci);
f7153f0
-
f7153f0
-    if (ohci->eof_timer == NULL) {
f7153f0
-        trace_usb_ohci_bus_eof_timer_failed(ohci->name);
f7153f0
-        ohci_die(ohci);
f7153f0
-        return 0;
f7153f0
-    }
f7153f0
-
f7153f0
     trace_usb_ohci_start(ohci->name);
f7153f0
 
f7153f0
     ohci_sof(ohci);
f7153f0
@@ -1373,11 +1363,7 @@ static int ohci_bus_start(OHCIState *ohci)
f7153f0
 static void ohci_bus_stop(OHCIState *ohci)
f7153f0
 {
f7153f0
     trace_usb_ohci_stop(ohci->name);
f7153f0
-    if (ohci->eof_timer) {
f7153f0
-        timer_del(ohci->eof_timer);
f7153f0
-        timer_free(ohci->eof_timer);
f7153f0
-    }
f7153f0
-    ohci->eof_timer = NULL;
f7153f0
+    timer_del(ohci->eof_timer);
f7153f0
 }
f7153f0
 
f7153f0
 /* Sets a flag in a port status register but only set it if the port is
f7153f0
@@ -1907,6 +1893,9 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
e2943f8
     usb_packet_init(&ohci->usb_packet);
e2943f8
 
f7153f0
     ohci->async_td = 0;
e2943f8
+
f7153f0
+    ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
f7153f0
+                                   ohci_frame_boundary, ohci);
f7153f0
 }
f7153f0
 
e2943f8
 #define TYPE_PCI_OHCI "pci-ohci"
f7153f0
@@ -2041,23 +2030,13 @@ static bool ohci_eof_timer_needed(void *opaque)
f7153f0
 {
f7153f0
     OHCIState *ohci = opaque;
f7153f0
 
f7153f0
-    return ohci->eof_timer != NULL;
f7153f0
-}
f7153f0
-
f7153f0
-static int ohci_eof_timer_pre_load(void *opaque)
f7153f0
-{
f7153f0
-    OHCIState *ohci = opaque;
f7153f0
-
f7153f0
-    ohci_bus_start(ohci);
f7153f0
-
f7153f0
-    return 0;
f7153f0
+    return timer_pending(ohci->eof_timer);
f7153f0
 }
f7153f0
 
f7153f0
 static const VMStateDescription vmstate_ohci_eof_timer = {
f7153f0
     .name = "ohci-core/eof-timer",
f7153f0
     .version_id = 1,
f7153f0
     .minimum_version_id = 1,
f7153f0
-    .pre_load = ohci_eof_timer_pre_load,
e2943f8
     .needed = ohci_eof_timer_needed,
f7153f0
     .fields = (VMStateField[]) {
e2943f8
         VMSTATE_TIMER_PTR(eof_timer, OHCIState),
f7153f0
-- 
f7153f0
1.8.3.1
f7153f0