[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 05/18] hw/usb/hcd-ohci: Add an auto-hub property and leave it off



Add auto-hub and leave it off. hw_compat_11_1 turns it on for
pci-ohci and sysbus-ohci, so an older machine type keeps the hub it
has today and a guest saved by an older QEMU still loads.

pc87560-ohci is its own PCI front end, not a pci-ohci, so it defines
the property itself.

A companion OHCI adds its ports to the EHCI bus instead of making one,
so there the EHCI property decides.

Suggested-by: Gerd Hoffmann <kraxel@xxxxxxxxxx>
Signed-off-by: Jamin Lin <jamin_lin@xxxxxxxxxxxxxx>
---
 hw/usb/hcd-ohci.h        | 1 +
 hw/core/machine.c        | 2 ++
 hw/usb/hcd-ohci-pci.c    | 1 +
 hw/usb/hcd-ohci-sysbus.c | 1 +
 hw/usb/hcd-ohci.c        | 1 +
 hw/usb/pc87560-ohci.c    | 1 +
 6 files changed, 7 insertions(+)

diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
index d079f8d24e..43240622ef 100644
--- a/hw/usb/hcd-ohci.h
+++ b/hw/usb/hcd-ohci.h
@@ -98,6 +98,7 @@ struct OHCIState {
 
     bool big_endian;
     bool consistency_check;
+    bool auto_hub;
 };
 
 #define TYPE_SYSBUS_OHCI "sysbus-ohci"
diff --git a/hw/core/machine.c b/hw/core/machine.c
index f79337e7d7..22d2b83459 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -47,6 +47,8 @@ GlobalProperty hw_compat_11_1[] = {
     { "pci-ehci-usb", "auto-hub", "on" },
     { "base-xhci", "auto-hub", "on" },
     { "pci-uhci-usb", "auto-hub", "on" },
+    { "sysbus-ohci", "auto-hub", "on" },
+    { "pci-ohci", "auto-hub", "on" },
 };
 const size_t hw_compat_11_1_len = G_N_ELEMENTS(hw_compat_11_1);
 
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
index 70c9e9ac4f..11c754a948 100644
--- a/hw/usb/hcd-ohci-pci.c
+++ b/hw/usb/hcd-ohci-pci.c
@@ -112,6 +112,7 @@ static const Property ohci_pci_properties[] = {
     DEFINE_PROP_STRING("masterbus", OHCIPCIState, masterbus),
     DEFINE_PROP_UINT32("num-ports", OHCIPCIState, num_ports, 3),
     DEFINE_PROP_UINT32("firstport", OHCIPCIState, firstport, 0),
+    DEFINE_PROP_BOOL("auto-hub", OHCIPCIState, state.auto_hub, false),
 };
 
 static const VMStateDescription vmstate_ohci = {
diff --git a/hw/usb/hcd-ohci-sysbus.c b/hw/usb/hcd-ohci-sysbus.c
index 4f51eebccb..69f38b9fce 100644
--- a/hw/usb/hcd-ohci-sysbus.c
+++ b/hw/usb/hcd-ohci-sysbus.c
@@ -61,6 +61,7 @@ static const Property ohci_sysbus_properties[] = {
     DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
     DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
     DEFINE_PROP_UINT64("dma-offset", OHCISysBusState, dma_offset, 0),
+    DEFINE_PROP_BOOL("auto-hub", OHCISysBusState, ohci.auto_hub, false),
 };
 
 static void ohci_sysbus_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 5e5fe41f47..2c25829b76 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1987,6 +1987,7 @@ void usb_ohci_init(OHCIState *ohci, DeviceState *dev, 
uint32_t num_ports,
         }
     } else {
         usb_bus_new(&ohci->bus, sizeof(ohci->bus), &ohci_bus_ops, dev);
+        ohci->bus.auto_hub = ohci->auto_hub;
         for (i = 0; i < num_ports; i++) {
             usb_register_port(&ohci->bus, &ohci->rhport[i].port,
                               ohci, i, &ohci_port_ops,
diff --git a/hw/usb/pc87560-ohci.c b/hw/usb/pc87560-ohci.c
index cc00f6e936..66c1e62d48 100644
--- a/hw/usb/pc87560-ohci.c
+++ b/hw/usb/pc87560-ohci.c
@@ -296,6 +296,7 @@ static const Property ohci_pci_properties[] = {
     DEFINE_PROP_STRING("masterbus", OHCIPCIState, masterbus),
     DEFINE_PROP_UINT32("num-ports", OHCIPCIState, num_ports, 3),
     DEFINE_PROP_UINT32("firstport", OHCIPCIState, firstport, 0),
+    DEFINE_PROP_BOOL("auto-hub", OHCIPCIState, state.auto_hub, false),
 };
 
 static const VMStateDescription vmstate_ohci = {
-- 
2.43.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.