On Wed, Jan 09, 2013 at 12:12:55PM +0100, Paolo Bonzini wrote: > Il 09/01/2013 12:09, Michael S. Tsirkin ha scritto: > > On Wed, Jan 09, 2013 at 11:53:00AM +0100, Paolo Bonzini wrote: > >> Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto: > >>>> It's possible. I'll move the SCSI bus away from qdev reset. > >>>> Anthony/Michael, can you help doing the same with PCIDevice? And > >>>> perhaps Peter and Andreas with sysbus? > >>> > >>> I'm not sure what would you like to change with PCIDevice. > >> > >> Replace the DeviceState reset method with one in PCIDevice, and call it > >> from the PCI bus reset. > >> > >> Paolo > > > > You are talking about the call to qdev_reset_all(&dev->qdev) > > in pci_device_reset > > Yes. > > > , and you want to detect, there, that device is a bridge > > and replace qdev_reset_all(&dev->qdev) with cast and call to pci_bus_reset > > for the secondary bus? > > The bridge would call pci_bus_reset for its secondary bus in the > PCIDevice reset method. > > I.e. all bus navigation would have to be explicit in the reset > callbacks. I'm going to do that for the SCSI HBAs. > > Paolo
OK you mean like this this? Completely untested - if you and Anthony think we need this change please let me know and I'll test and repost. --> pci: make secondary bus reset explicit Signed-off-by: Michael S. Tsirkin <m...@redhat.com> --- diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 94840c4..ad81040 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -172,7 +172,7 @@ void pci_device_reset(PCIDevice *dev) { int r; - qdev_reset_all(&dev->qdev); + device_reset(&dev->qdev); dev->irq_state = 0; pci_update_irq_status(dev); diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 995842a..a08b479 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -258,10 +258,12 @@ void pci_bridge_disable_base_limit(PCIDevice *dev) pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0); } -/* reset bridge specific configuration registers */ +/* reset bridge specific configuration registers. + * Propagate reset on the secondary bus. */ void pci_bridge_reset(DeviceState *qdev) { PCIDevice *dev = PCI_DEVICE(qdev); + PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); uint8_t *conf = dev->config; conf[PCI_PRIMARY_BUS] = 0; @@ -295,6 +297,8 @@ void pci_bridge_reset(DeviceState *qdev) pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0); pci_set_word(conf + PCI_BRIDGE_CONTROL, 0); + + pci_bus_reset(&br->sec_bus); } /* default qdev initialization function for PCI-to-PCI bridge */