Patchwork [v2] pci: fix pci domain registering.

login
register
mail settings
Submitter Isaku Yamahata
Date June 18, 2010, 6:51 a.m.
Message ID <20100618065133.GE14658@valinux.co.jp>
Download mbox | patch
Permalink /patch/56139/
State New
Headers show

Comments

Isaku Yamahata - June 18, 2010, 6:51 a.m.
Only pci host bus must be registered as root bus.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
Changes v1 -> v2
- rebased to head.

---
 hw/pci.c      |    8 ++------
 hw/pci.h      |    1 +
 hw/piix_pci.c |    1 +
 3 files changed, 4 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 7787005..ef17eb4 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -178,7 +178,7 @@  static void pci_bus_reset(void *opaque)
     }
 }
 
-static void pci_host_bus_register(int domain, PCIBus *bus)
+void pci_host_bus_register(int domain, PCIBus *bus)
 {
     struct PCIHostBus *host;
     host = qemu_mallocz(sizeof(*host));
@@ -225,11 +225,7 @@  void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
 {
     qbus_create_inplace(&bus->qbus, &pci_bus_info, parent, name);
     bus->devfn_min = devfn_min;
-
-    /* host bridge */
     QLIST_INIT(&bus->child);
-    pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
-
     vmstate_register(-1, &vmstate_pcibus, bus);
     qemu_register_reset(pci_bus_reset, bus);
 }
@@ -273,6 +269,7 @@  PCIBus *pci_register_bus(DeviceState *parent, const char *name,
     PCIBus *bus;
 
     bus = pci_bus_new(parent, name, devfn_min);
+    pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
     pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq);
     return bus;
 }
@@ -287,7 +284,6 @@  static void pci_register_secondary_bus(PCIBus *parent,
     bus->map_irq = map_irq;
     bus->parent_dev = dev;
 
-    QLIST_INIT(&bus->child);
     QLIST_INSERT_HEAD(&parent->child, bus, sibling);
 }
 
diff --git a/hw/pci.h b/hw/pci.h
index 3a15bd4..6a2bc6a 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -217,6 +217,7 @@  PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
                                const char *default_devaddr);
 int pci_bus_num(PCIBus *s);
 void pci_for_each_device(PCIBus *bus, int bus_num, void (*fn)(PCIBus *bus, PCIDevice *d));
+void pci_host_bus_register(int domain, PCIBus *bus);
 PCIBus *pci_find_root_bus(int domain);
 int pci_find_domain(const PCIBus *bus);
 PCIBus *pci_find_bus(PCIBus *bus, int bus_num);
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index d14d05e..16645cd 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -227,6 +227,7 @@  PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *
     dev = qdev_create(NULL, "i440FX-pcihost");
     s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
     b = pci_bus_new(&s->busdev.qdev, NULL, 0);
+    pci_host_bus_register(0, b);        /* pci domain 0 */
     s->bus = b;
     qdev_init_nofail(dev);