From patchwork Thu Sep 2 09:25:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6/6] pci bridge: implement secondary bus reset. Date: Wed, 01 Sep 2010 23:25:09 -0000 From: Isaku Yamahata X-Patchwork-Id: 63458 Message-Id: <4821b8bf2cda185d49f5261787265455503a9d2f.1283417726.git.yamahata@valinux.co.jp> To: qemu-devel@nongnu.org Cc: gleb@redhat.com, glommer@redhat.com, blauwirbel@gmail.com, yamahata@valinux.co.jp, alex.williamson@redhat.com, avi@redhat.com, pbonzini@redhat.com implement secondary bus reset. Signed-off-by: Isaku Yamahata --- hw/pci.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index e23ac1b..183f595 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1626,6 +1626,9 @@ static void pci_bridge_update_mappings(PCIBus *b) static void pci_bridge_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len) { + PCIBridge *s = container_of(d, PCIBridge, dev); + uint16_t bridge_control = pci_get_word(d->config + PCI_BRIDGE_CONTROL); + pci_default_write_config(d, address, val, len); if (/* io base/limit */ @@ -1634,10 +1637,18 @@ static void pci_bridge_write_config(PCIDevice *d, /* memory base/limit, prefetchable base/limit and io base/limit upper 16 */ ranges_overlap(address, len, PCI_MEMORY_BASE, 20)) { - PCIBridge *s = container_of(d, PCIBridge, dev); PCIBus *secondary_bus = &s->bus; pci_bridge_update_mappings(secondary_bus); } + + if (ranges_overlap(address, len, PCI_BRIDGE_CONTROL, 2)) { + uint16_t new = pci_get_word(d->config + PCI_BRIDGE_CONTROL); + if (!(bridge_control & PCI_BRIDGE_CTL_BUS_RESET) && + (new & PCI_BRIDGE_CTL_BUS_RESET)) { + /* 0 -> 1 */ + pci_bus_reset(&s->bus); + } + } } PCIBus *pci_find_bus(PCIBus *bus, int bus_num)