mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
pci: Abolish pci_find_root_bus()
pci_find_root_bus() takes a domain parameter. Currently PCI root buses with domain other than 0 can't be created, so this is more or less a long winded way of retrieving the main PCI root bus. Numbered domains don't actually properly cover the (non x86) possibilities for multiple PCI root buses, so this patch for now enforces the domain == 0 restriction in other places to replace pci_find_root_bus() with an explicit pci_find_primary_bus(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
6ac363b50c
commit
1ef7a2a2af
4 changed files with 42 additions and 15 deletions
19
hw/pci/pci.c
19
hw/pci/pci.c
|
@ -246,12 +246,12 @@ static void pci_host_bus_register(int domain, PCIBus *bus)
|
|||
QLIST_INSERT_HEAD(&host_buses, host, next);
|
||||
}
|
||||
|
||||
PCIBus *pci_find_root_bus(int domain)
|
||||
PCIBus *pci_find_primary_bus(void)
|
||||
{
|
||||
struct PCIHostBus *host;
|
||||
|
||||
QLIST_FOREACH(host, &host_buses, next) {
|
||||
if (host->domain == domain) {
|
||||
if (host->domain == 0) {
|
||||
return host->bus;
|
||||
}
|
||||
}
|
||||
|
@ -583,20 +583,31 @@ int pci_parse_devaddr(const char *addr, int *domp, int *busp,
|
|||
|
||||
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
|
||||
{
|
||||
PCIBus *root = pci_find_primary_bus();
|
||||
int dom, bus;
|
||||
unsigned slot;
|
||||
|
||||
if (!root) {
|
||||
fprintf(stderr, "No primary PCI bus\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!devaddr) {
|
||||
*devfnp = -1;
|
||||
return pci_find_bus_nr(pci_find_root_bus(0), 0);
|
||||
return pci_find_bus_nr(root, 0);
|
||||
}
|
||||
|
||||
if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dom != 0) {
|
||||
fprintf(stderr, "No support for non-zero PCI domains\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*devfnp = PCI_DEVFN(slot, 0);
|
||||
return pci_find_bus_nr(pci_find_root_bus(dom), bus);
|
||||
return pci_find_bus_nr(root, bus);
|
||||
}
|
||||
|
||||
static void pci_init_cmask(PCIDevice *dev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue