@@ -384,6 +384,8 @@ static void pci_pbm_reset(DeviceState *d)
unsigned int i;
APBState *s = container_of(d, APBState, busdev.qdev);
+ qdev_reset_default(d);
+
for (i = 0; i < 8; i++) {
s->pci_irq_map[i] &= PBM_PCI_IMR_MASK;
}
@@ -40,12 +40,14 @@
static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
static char *pcibus_get_dev_path(DeviceState *dev);
+static void pci_bus_reset_fn(BusState *qbus);
struct BusInfo pci_bus_info = {
.name = "PCI",
.size = sizeof(PCIBus),
.print_dev = pcibus_dev_print,
.get_dev_path = pcibus_get_dev_path,
+ .reset = pci_bus_reset_fn,
.props = (Property[]) {
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
@@ -170,23 +172,11 @@ void pci_device_reset(PCIDevice *dev)
}
/*
- * There are two paths to reset pci device. Each resets does partially.
- * qemu_system_reset()
- * -> pci_device_reset() with bus
- * -> pci_device_reset_default() which resets pci common part.
- * -> DeviceState::reset: each device specific reset hanlder
- * which resets device specific part.
- *
* TODO:
- * It requires two execution paths to reset the device fully.
- * It is confusing and prone to error. Each device should know all
- * its states.
+ * Each device should know all its states.
* So move this part to each device specific callback.
*/
-
- /* For now qdev_reset() is called directly by qemu_system_reset() */
- /* qdev_reset(&dev->qdev); */
-
+ qdev_reset(&dev->qdev);
pci_device_reset_default(dev);
}
@@ -208,9 +198,9 @@ void pci_bus_reset(PCIBus *bus)
}
}
-static void pci_bus_reset_fn(void *opaque)
+static void pci_bus_reset_fn(BusState *qbus)
{
- pci_bus_reset(opaque);
+ pci_bus_reset(DO_UPCAST(PCIBus, qbus, qbus));
}
static void pci_host_bus_register(int domain, PCIBus *bus)
@@ -267,7 +257,6 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
vmstate_register(NULL, -1, &vmstate_pcibus, bus);
- qemu_register_reset(pci_bus_reset_fn, bus);
}
PCIBus *pci_bus_new(DeviceState *parent, const char *name, int devfn_min)
@@ -158,6 +158,8 @@ void pci_bridge_reset_reg(PCIDevice *dev)
void pci_bridge_reset(DeviceState *qdev)
{
PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
+ PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev);
+ pci_bus_reset(&br->sec_bus);
pci_bridge_reset_reg(dev);
}
use qbus bus reset callback. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> --- hw/apb_pci.c | 2 ++ hw/pci.c | 23 ++++++----------------- hw/pci_bridge.c | 2 ++ 3 files changed, 10 insertions(+), 17 deletions(-)