pci: Rename root bus initialization functions for clarity

pci_bus_init(), pci_bus_new_inplace(), pci_bus_new() and pci_register_bus()
are misleadingly named.  They're not used for initializing *any* PCI bus,
but only for a root PCI bus.

Non-root buses - i.e. ones under a logical PCI to PCI bridge - are instead
created with a direct qbus_create_inplace() (see pci_bridge_initfn()).

This patch renames the functions to make it clear they're only used for
a root bus.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
David Gibson 2017-11-29 19:46:22 +11:00 committed by Michael S. Tsirkin
parent 4426f06102
commit 1115ff6d26
20 changed files with 117 additions and 112 deletions

View File

@ -881,7 +881,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
memory_region_add_subregion(addr_space, 0x801fc000000ULL, memory_region_add_subregion(addr_space, 0x801fc000000ULL,
&s->pchip.reg_io); &s->pchip.reg_io);
b = pci_register_bus(dev, "pci", b = pci_register_root_bus(dev, "pci",
typhoon_set_irq, sys_map_irq, s, typhoon_set_irq, sys_map_irq, s,
&s->pchip.reg_mem, &s->pchip.reg_io, &s->pchip.reg_mem, &s->pchip.reg_io,
0, 64, TYPE_PCI_BUS); 0, 64, TYPE_PCI_BUS);

View File

@ -1171,7 +1171,7 @@ PCIBus *gt64120_register(qemu_irq *pic)
phb = PCI_HOST_BRIDGE(dev); phb = PCI_HOST_BRIDGE(dev);
memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", UINT32_MAX); memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", UINT32_MAX);
address_space_init(&d->pci0_mem_as, &d->pci0_mem, "pci0-mem"); address_space_init(&d->pci0_mem_as, &d->pci0_mem, "pci0-mem");
phb->bus = pci_register_bus(dev, "pci", phb->bus = pci_register_root_bus(dev, "pci",
gt64120_pci_set_irq, gt64120_pci_map_irq, gt64120_pci_set_irq, gt64120_pci_map_irq,
pic, pic,
&d->pci0_mem, &d->pci0_mem,

View File

@ -230,9 +230,9 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
ds = qdev_create(NULL, TYPE_PXB_HOST); ds = qdev_create(NULL, TYPE_PXB_HOST);
if (pcie) { if (pcie) {
bus = pci_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS); bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS);
} else { } else {
bus = pci_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS); bus = pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS);
bds = qdev_create(BUS(bus), "pci-bridge"); bds = qdev_create(BUS(bus), "pci-bridge");
bds->id = dev_name; bds->id = dev_name;
qdev_prop_set_uint8(bds, PCI_BRIDGE_DEV_PROP_CHASSIS_NR, pxb->bus_nr); qdev_prop_set_uint8(bds, PCI_BRIDGE_DEV_PROP_CHASSIS_NR, pxb->bus_nr);

View File

@ -714,7 +714,7 @@ PCIBus *pci_apb_init(hwaddr special_base,
dev = qdev_create(NULL, TYPE_APB); dev = qdev_create(NULL, TYPE_APB);
d = APB_DEVICE(dev); d = APB_DEVICE(dev);
phb = PCI_HOST_BRIDGE(dev); phb = PCI_HOST_BRIDGE(dev);
phb->bus = pci_register_bus(DEVICE(phb), "pci", phb->bus = pci_register_root_bus(DEVICE(phb), "pci",
pci_apb_set_irq, pci_apb_map_irq, d, pci_apb_set_irq, pci_apb_map_irq, d,
&d->pci_mmio, &d->pci_mmio,
&d->pci_ioport, &d->pci_ioport,

View File

@ -714,9 +714,9 @@ static int bonito_pcihost_initfn(SysBusDevice *dev)
{ {
PCIHostState *phb = PCI_HOST_BRIDGE(dev); PCIHostState *phb = PCI_HOST_BRIDGE(dev);
phb->bus = pci_register_bus(DEVICE(dev), "pci", phb->bus = pci_register_root_bus(DEVICE(dev), "pci",
pci_bonito_set_irq, pci_bonito_map_irq, dev, pci_bonito_set_irq, pci_bonito_map_irq,
get_system_memory(), get_system_io(), dev, get_system_memory(), get_system_io(),
0x28, 32, TYPE_PCI_BUS); 0x28, 32, TYPE_PCI_BUS);
return 0; return 0;

View File

@ -89,7 +89,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp)
s->irq_num[i] = -1; s->irq_num[i] = -1;
} }
pci->bus = pci_register_bus(dev, "pcie.0", gpex_set_irq, pci->bus = pci_register_root_bus(dev, "pcie.0", gpex_set_irq,
pci_swizzle_map_irq_fn, s, &s->io_mmio, pci_swizzle_map_irq_fn, s, &s->io_mmio,
&s->io_ioport, 0, 4, TYPE_PCIE_BUS); &s->io_ioport, 0, 4, TYPE_PCIE_BUS);

View File

@ -82,7 +82,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic,
memory_region_add_subregion(address_space_mem, 0x80000000ULL, memory_region_add_subregion(address_space_mem, 0x80000000ULL,
&d->pci_hole); &d->pci_hole);
phb->bus = pci_register_bus(dev, NULL, phb->bus = pci_register_root_bus(dev, NULL,
pci_grackle_set_irq, pci_grackle_set_irq,
pci_grackle_map_irq, pci_grackle_map_irq,
pic, pic,

View File

@ -361,7 +361,7 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
dev = qdev_create(NULL, host_type); dev = qdev_create(NULL, host_type);
s = PCI_HOST_BRIDGE(dev); s = PCI_HOST_BRIDGE(dev);
b = pci_bus_new(dev, NULL, pci_address_space, b = pci_root_bus_new(dev, NULL, pci_address_space,
address_space_io, 0, TYPE_PCI_BUS); address_space_io, 0, TYPE_PCI_BUS);
s->bus = b; s->bus = b;
object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL); object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL);

View File

@ -465,7 +465,7 @@ static int e500_pcihost_initfn(SysBusDevice *dev)
/* PIO lives at the bottom of our bus space */ /* PIO lives at the bottom of our bus space */
memory_region_add_subregion_overlap(&s->busmem, 0, &s->pio, -2); memory_region_add_subregion_overlap(&s->busmem, 0, &s->pio, -2);
b = pci_register_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq, b = pci_register_root_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq,
mpc85xx_pci_map_irq, s, &s->busmem, &s->pio, mpc85xx_pci_map_irq, s, &s->busmem, &s->pio,
PCI_DEVFN(s->first_slot, 0), 4, TYPE_PCI_BUS); PCI_DEVFN(s->first_slot, 0), 4, TYPE_PCI_BUS);
h->bus = b; h->bus = b;

View File

@ -269,7 +269,7 @@ static void raven_pcihost_initfn(Object *obj)
memory_region_add_subregion_overlap(address_space_mem, 0x80000000, memory_region_add_subregion_overlap(address_space_mem, 0x80000000,
&s->pci_io_non_contiguous, 1); &s->pci_io_non_contiguous, 1);
memory_region_add_subregion(address_space_mem, 0xc0000000, &s->pci_memory); memory_region_add_subregion(address_space_mem, 0xc0000000, &s->pci_memory);
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), NULL, pci_root_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), NULL,
&s->pci_memory, &s->pci_io, 0, TYPE_PCI_BUS); &s->pci_memory, &s->pci_io, 0, TYPE_PCI_BUS);
/* Bus master address space */ /* Bus master address space */

View File

@ -51,8 +51,9 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem); sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4); sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
pci->bus = pci_bus_new(DEVICE(s), "pcie.0", pci->bus = pci_root_bus_new(DEVICE(s), "pcie.0",
s->mch.pci_address_space, s->mch.address_space_io, s->mch.pci_address_space,
s->mch.address_space_io,
0, TYPE_PCIE_BUS); 0, TYPE_PCIE_BUS);
PC_MACHINE(qdev_get_machine())->bus = pci->bus; PC_MACHINE(qdev_get_machine())->bus = pci->bus;
qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus)); qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus));

View File

@ -233,7 +233,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
memory_region_add_subregion(address_space_mem, 0x80000000ULL, memory_region_add_subregion(address_space_mem, 0x80000000ULL,
&d->pci_hole); &d->pci_hole);
h->bus = pci_register_bus(dev, NULL, h->bus = pci_register_root_bus(dev, NULL,
pci_unin_set_irq, pci_unin_map_irq, pci_unin_set_irq, pci_unin_map_irq,
pic, pic,
&d->pci_mmio, &d->pci_mmio,
@ -299,7 +299,7 @@ PCIBus *pci_pmac_u3_init(qemu_irq *pic,
memory_region_add_subregion(address_space_mem, 0x80000000ULL, memory_region_add_subregion(address_space_mem, 0x80000000ULL,
&d->pci_hole); &d->pci_hole);
h->bus = pci_register_bus(dev, NULL, h->bus = pci_register_root_bus(dev, NULL,
pci_unin_set_irq, pci_unin_map_irq, pci_unin_set_irq, pci_unin_map_irq,
pic, pic,
&d->pci_mmio, &d->pci_mmio,

View File

@ -399,7 +399,7 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp)
memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32); memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32);
memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32); memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32);
pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), dev, "pci", pci_root_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), dev, "pci",
&s->pci_mem_space, &s->pci_io_space, &s->pci_mem_space, &s->pci_io_space,
PCI_DEVFN(11, 0), TYPE_PCI_BUS); PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus; h->bus = &s->pci_bus;

View File

@ -129,7 +129,7 @@ static void xilinx_pcie_host_realize(DeviceState *dev, Error **errp)
sysbus_init_mmio(sbd, &pex->mmio); sysbus_init_mmio(sbd, &pex->mmio);
sysbus_init_mmio(sbd, &s->mmio); sysbus_init_mmio(sbd, &s->mmio);
pci->bus = pci_register_bus(dev, s->name, xilinx_pcie_set_irq, pci->bus = pci_register_root_bus(dev, s->name, xilinx_pcie_set_irq,
pci_swizzle_map_irq_fn, s, &s->mmio, pci_swizzle_map_irq_fn, s, &s->mmio,
&s->io, 0, 4, TYPE_PCIE_BUS); &s->io, 0, 4, TYPE_PCIE_BUS);

View File

@ -376,7 +376,7 @@ const char *pci_root_bus_path(PCIDevice *dev)
return rootbus->qbus.name; return rootbus->qbus.name;
} }
static void pci_bus_init(PCIBus *bus, DeviceState *parent, static void pci_root_bus_init(PCIBus *bus, DeviceState *parent,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min) uint8_t devfn_min)
@ -403,17 +403,18 @@ bool pci_bus_is_root(PCIBus *bus)
return PCI_BUS_GET_CLASS(bus)->is_root(bus); return PCI_BUS_GET_CLASS(bus)->is_root(bus);
} }
void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent, void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name, const char *name,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, const char *typename) uint8_t devfn_min, const char *typename)
{ {
qbus_create_inplace(bus, bus_size, typename, parent, name); qbus_create_inplace(bus, bus_size, typename, parent, name);
pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_min); pci_root_bus_init(bus, parent, address_space_mem, address_space_io,
devfn_min);
} }
PCIBus *pci_bus_new(DeviceState *parent, const char *name, PCIBus *pci_root_bus_new(DeviceState *parent, const char *name,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, const char *typename) uint8_t devfn_min, const char *typename)
@ -421,7 +422,8 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name,
PCIBus *bus; PCIBus *bus;
bus = PCI_BUS(qbus_create(typename, parent, name)); bus = PCI_BUS(qbus_create(typename, parent, name));
pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_min); pci_root_bus_init(bus, parent, address_space_mem, address_space_io,
devfn_min);
return bus; return bus;
} }
@ -435,16 +437,17 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0])); bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0]));
} }
PCIBus *pci_register_bus(DeviceState *parent, const char *name, PCIBus *pci_register_root_bus(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
void *irq_opaque, void *irq_opaque,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, int nirq, const char *typename) uint8_t devfn_min, int nirq,
const char *typename)
{ {
PCIBus *bus; PCIBus *bus;
bus = pci_bus_new(parent, name, address_space_mem, bus = pci_root_bus_new(parent, name, address_space_mem,
address_space_io, devfn_min, typename); address_space_io, devfn_min, typename);
pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq); pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq);
return bus; return bus;

View File

@ -314,7 +314,7 @@ static int ppc4xx_pcihost_initfn(SysBusDevice *dev)
sysbus_init_irq(dev, &s->irq[i]); sysbus_init_irq(dev, &s->irq[i]);
} }
b = pci_register_bus(DEVICE(dev), NULL, ppc4xx_pci_set_irq, b = pci_register_root_bus(DEVICE(dev), NULL, ppc4xx_pci_set_irq,
ppc4xx_pci_map_irq, s->irq, get_system_memory(), ppc4xx_pci_map_irq, s->irq, get_system_memory(),
get_system_io(), 0, 4, TYPE_PCI_BUS); get_system_io(), 0, 4, TYPE_PCI_BUS);
h->bus = b; h->bus = b;

View File

@ -1621,7 +1621,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, memory_region_add_subregion(get_system_memory(), sphb->io_win_addr,
&sphb->iowindow); &sphb->iowindow);
bus = pci_register_bus(dev, NULL, bus = pci_register_root_bus(dev, NULL,
pci_spapr_set_irq, pci_spapr_map_irq, sphb, pci_spapr_set_irq, pci_spapr_map_irq, sphb,
&sphb->memspace, &sphb->iospace, &sphb->memspace, &sphb->iospace,
PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS); PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS);

View File

@ -554,7 +554,7 @@ static int s390_pcihost_init(SysBusDevice *dev)
DPRINTF("host_init\n"); DPRINTF("host_init\n");
b = pci_register_bus(DEVICE(dev), NULL, b = pci_register_root_bus(DEVICE(dev), NULL,
s390_pci_set_irq, s390_pci_map_irq, NULL, s390_pci_set_irq, s390_pci_map_irq, NULL,
get_system_memory(), get_system_io(), 0, 64, get_system_memory(), get_system_io(), 0, 64,
TYPE_PCI_BUS); TYPE_PCI_BUS);

View File

@ -131,7 +131,7 @@ static int sh_pci_device_init(SysBusDevice *dev)
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
sysbus_init_irq(dev, &s->irq[i]); sysbus_init_irq(dev, &s->irq[i]);
} }
phb->bus = pci_register_bus(DEVICE(dev), "pci", phb->bus = pci_register_root_bus(DEVICE(dev), "pci",
sh_pci_set_irq, sh_pci_map_irq, sh_pci_set_irq, sh_pci_map_irq,
s->irq, s->irq,
get_system_memory(), get_system_memory(),

View File

@ -400,12 +400,12 @@ typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin);
bool pci_bus_is_express(PCIBus *bus); bool pci_bus_is_express(PCIBus *bus);
bool pci_bus_is_root(PCIBus *bus); bool pci_bus_is_root(PCIBus *bus);
void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent, void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name, const char *name,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, const char *typename); uint8_t devfn_min, const char *typename);
PCIBus *pci_bus_new(DeviceState *parent, const char *name, PCIBus *pci_root_bus_new(DeviceState *parent, const char *name,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, const char *typename); uint8_t devfn_min, const char *typename);
@ -414,12 +414,13 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
int pci_bus_get_irq_level(PCIBus *bus, int irq_num); int pci_bus_get_irq_level(PCIBus *bus, int irq_num);
/* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */ /* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */
int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin); int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin);
PCIBus *pci_register_bus(DeviceState *parent, const char *name, PCIBus *pci_register_root_bus(DeviceState *parent, const char *name,
pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
void *irq_opaque, void *irq_opaque,
MemoryRegion *address_space_mem, MemoryRegion *address_space_mem,
MemoryRegion *address_space_io, MemoryRegion *address_space_io,
uint8_t devfn_min, int nirq, const char *typename); uint8_t devfn_min, int nirq,
const char *typename);
void pci_bus_set_route_irq_fn(PCIBus *, pci_route_irq_fn); void pci_bus_set_route_irq_fn(PCIBus *, pci_route_irq_fn);
PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin); PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin);
bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new); bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new);