@@ -304,14 +304,14 @@ void qdev_unplug(DeviceState *dev, Error **errp)
}
}
-static int qdev_reset_one(DeviceState *dev, void *opaque)
+int qdev_reset_one(DeviceState *dev, void *opaque)
{
device_reset(dev);
return 0;
}
-static int qbus_reset_one(BusState *bus, void *opaque)
+int qbus_reset_one(BusState *bus, void *opaque)
{
BusClass *bc = BUS_GET_CLASS(bus);
if (bc->reset) {
@@ -257,6 +257,15 @@ void pci_device_reset(PCIDevice *dev)
pci_do_device_reset(dev);
}
+int pcibus_pre_reset(BusState *qbus, void *opaque)
+{
+ PCIBus *pci_bus = DO_UPCAST(PCIBus, qbus, qbus);
+
+ pci_bus->in_hot_reset = true;
+
+ return 0;
+}
+
/*
* Trigger pci bus reset under a given bus.
* Called via qbus_reset_all on RST# assert, after the devices
@@ -276,6 +285,8 @@ static void pcibus_reset(BusState *qbus)
for (i = 0; i < bus->nirq; i++) {
assert(bus->irq_count[i] == 0);
}
+
+ bus->in_hot_reset = false;
}
static void pci_host_bus_register(PCIBus *bus, DeviceState *parent)
@@ -269,7 +269,10 @@ void pci_bridge_write_config(PCIDevice *d,
newctl = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
if (~oldctl & newctl & PCI_BRIDGE_CTL_BUS_RESET) {
/* Trigger hot reset on 0->1 transition. */
- qbus_reset_all(&s->sec_bus.qbus);
+ qbus_walk_children(&s->sec_bus.qbus, NULL,
+ pcibus_pre_reset,
+ qdev_reset_one,
+ qbus_reset_one, &s->sec_bus.qbus);
}
}
@@ -39,8 +39,13 @@ struct PCIBus {
Keep a count of the number of devices with raised IRQs. */
int nirq;
int *irq_count;
+
+ /* The bus need to do a hot reset */
+ bool in_hot_reset;
};
+int pcibus_pre_reset(BusState *qbus, void *opaque);
+
typedef struct PCIBridgeWindows PCIBridgeWindows;
/*
@@ -401,4 +401,7 @@ static inline bool qbus_is_hotpluggable(BusState *bus)
void device_listener_register(DeviceListener *listener);
void device_listener_unregister(DeviceListener *listener);
+int qdev_reset_one(DeviceState *dev, void *opaque);
+int qbus_reset_one(BusState *bus, void *opaque);
+
#endif