From 95f13176f56de2d56ebb014bf8b5d39de209c08a Mon Sep 17 00:00:00 2001 From: zbb Date: Wed, 16 Sep 2015 23:34:51 +0000 Subject: [PATCH] Add domain support to PCI bus allocation When the system has more than a single PCI domain, the bus numbers are not unique, thus they cannot be used for "pci" device numbering. Change bus numbers to -1 (i.e. to-be-determined automatically) wherever the code did not care about domains. Reviewed by: jhb Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3406 --- sys/arm/versatile/versatile_pci.c | 2 +- sys/arm/xscale/i80321/i80321_pci.c | 2 +- sys/arm/xscale/i8134x/i81342_pci.c | 2 +- sys/dev/acpica/acpi_pcib.c | 2 +- sys/dev/pci/pci_pci.c | 2 +- sys/dev/xen/pcifront/pcifront.c | 2 +- sys/mips/adm5120/admpci.c | 2 +- sys/mips/atheros/ar71xx_pci.c | 2 +- sys/mips/atheros/ar724x_pci.c | 2 +- sys/mips/atheros/qca955x_pci.c | 2 +- sys/mips/cavium/octopci.c | 2 +- sys/mips/idt/idtpci.c | 2 +- sys/mips/malta/gt_pci.c | 2 +- sys/mips/nlm/xlp_pci.c | 2 +- sys/mips/rmi/xlr_pci.c | 2 +- sys/powerpc/ofw/ofw_pci.c | 2 +- sys/x86/pci/pci_bus.c | 2 +- sys/x86/pci/qpi.c | 2 +- sys/x86/x86/mptable_pci.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/arm/versatile/versatile_pci.c b/sys/arm/versatile/versatile_pci.c index 10f31190cefb..f5ef6e94ec2c 100644 --- a/sys/arm/versatile/versatile_pci.c +++ b/sys/arm/versatile/versatile_pci.c @@ -266,7 +266,7 @@ versatile_pci_attach(device_t dev) versatile_pci_conf_write_4((slot << 11) + PCIR_COMMAND, val); } - device_add_child(dev, "pci", 0); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/arm/xscale/i80321/i80321_pci.c b/sys/arm/xscale/i80321/i80321_pci.c index 4e2814830004..5f78577e8704 100644 --- a/sys/arm/xscale/i80321/i80321_pci.c +++ b/sys/arm/xscale/i80321/i80321_pci.c @@ -117,7 +117,7 @@ i80321_pci_attach(device_t dev) if (rman_init(&sc->sc_irq_rman) != 0 || rman_manage_region(&sc->sc_irq_rman, 26, 32) != 0) panic("i80321_pci_probe: failed to set up IRQ rman"); - device_add_child(dev, "pci",busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/arm/xscale/i8134x/i81342_pci.c b/sys/arm/xscale/i8134x/i81342_pci.c index 68d2fbf4ea14..d9d978c8a4bc 100644 --- a/sys/arm/xscale/i8134x/i81342_pci.c +++ b/sys/arm/xscale/i8134x/i81342_pci.c @@ -209,7 +209,7 @@ i81342_pci_attach(device_t dev) } bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_ISR, bus_space_read_4(sc->sc_st, sc->sc_atu_sh, ATU_ISR) & ATUX_ISR_ERRMSK); - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c index 93dada5703ef..c2c24992f89a 100644 --- a/sys/dev/acpica/acpi_pcib.c +++ b/sys/dev/acpica/acpi_pcib.c @@ -150,7 +150,7 @@ acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno) /* * Attach the PCI bus proper. */ - if (device_add_child(dev, "pci", busno) == NULL) { + if (device_add_child(dev, "pci", -1) == NULL) { device_printf(device_get_parent(dev), "couldn't attach pci bus\n"); return_VALUE(ENXIO); } diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 5b925c8a02e8..11a4bcac7950 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -1082,7 +1082,7 @@ pcib_attach(device_t dev) pcib_attach_common(dev); sc = device_get_softc(dev); if (sc->bus.sec != 0) { - child = device_add_child(dev, "pci", sc->bus.sec); + child = device_add_child(dev, "pci", -1); if (child != NULL) return(bus_generic_attach(dev)); } diff --git a/sys/dev/xen/pcifront/pcifront.c b/sys/dev/xen/pcifront/pcifront.c index 1730bf8fc09f..833e38bd7e2f 100644 --- a/sys/dev/xen/pcifront/pcifront.c +++ b/sys/dev/xen/pcifront/pcifront.c @@ -559,7 +559,7 @@ xpcib_attach(device_t dev) DPRINTF("xpcib attach (bus=%d)\n", sc->bus); - device_add_child(dev, "pci", sc->bus); + device_add_child(dev, "pci", -1); return bus_generic_attach(dev); } diff --git a/sys/mips/adm5120/admpci.c b/sys/mips/adm5120/admpci.c index 616d3bd683db..e8a14a12c436 100644 --- a/sys/mips/adm5120/admpci.c +++ b/sys/mips/adm5120/admpci.c @@ -181,7 +181,7 @@ admpci_attach(device_t dev) panic("bus_space_map failed"); } - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/atheros/ar71xx_pci.c b/sys/mips/atheros/ar71xx_pci.c index 7ef0e1553148..dc6afc46f503 100644 --- a/sys/mips/atheros/ar71xx_pci.c +++ b/sys/mips/atheros/ar71xx_pci.c @@ -462,7 +462,7 @@ ar71xx_pci_attach(device_t dev) ar71xx_pci_slot_fixup(dev, 0, 18, 0); #endif /* AR71XX_ATH_EEPROM */ - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/atheros/ar724x_pci.c b/sys/mips/atheros/ar724x_pci.c index 283bd9b7efeb..a6e0389bfa2c 100644 --- a/sys/mips/atheros/ar724x_pci.c +++ b/sys/mips/atheros/ar724x_pci.c @@ -429,7 +429,7 @@ ar724x_pci_attach(device_t dev) | PCIM_CMD_SERRESPEN | PCIM_CMD_BACKTOBACK | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN, 2); - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/atheros/qca955x_pci.c b/sys/mips/atheros/qca955x_pci.c index 02322970e203..dfc8c6b083d3 100644 --- a/sys/mips/atheros/qca955x_pci.c +++ b/sys/mips/atheros/qca955x_pci.c @@ -362,7 +362,7 @@ qca955x_pci_attach(device_t dev) | PCIM_CMD_SERRESPEN | PCIM_CMD_BACKTOBACK | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN, 2); - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/cavium/octopci.c b/sys/mips/cavium/octopci.c index ae92063f9229..f6d73bdc65cc 100644 --- a/sys/mips/cavium/octopci.c +++ b/sys/mips/cavium/octopci.c @@ -205,7 +205,7 @@ octopci_attach(device_t dev) subbus = octopci_init_bus(dev, sc->sc_bus); octopci_write_config(dev, sc->sc_bus, 0, 0, PCIR_SUBBUS_1, subbus, 1); - device_add_child(dev, "pci", device_get_unit(dev)); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/idt/idtpci.c b/sys/mips/idt/idtpci.c index 7e003fd6feed..d962e6872a36 100644 --- a/sys/mips/idt/idtpci.c +++ b/sys/mips/idt/idtpci.c @@ -275,7 +275,7 @@ idtpci_attach(device_t dev) PCI_IRQ_END) != 0) panic("idtpci_attach: failed to set up IRQ rman"); - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/malta/gt_pci.c b/sys/mips/malta/gt_pci.c index 3acc9b05bdf6..add9c07540f1 100644 --- a/sys/mips/malta/gt_pci.c +++ b/sys/mips/malta/gt_pci.c @@ -415,7 +415,7 @@ gt_pci_attach(device_t dev) } /* Initialize memory and i/o rmans. */ - device_add_child(dev, "pci", busno); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/mips/nlm/xlp_pci.c b/sys/mips/nlm/xlp_pci.c index c06629fba085..fee23cdd402d 100644 --- a/sys/mips/nlm/xlp_pci.c +++ b/sys/mips/nlm/xlp_pci.c @@ -314,7 +314,7 @@ xlp_pcib_attach(device_t dev) for (link = 0; link < 4; link++) xlp_pcib_hardware_swap_enable(node, link); - device_add_child(dev, "pci", 0); + device_add_child(dev, "pci", -1); bus_generic_attach(dev); return (0); } diff --git a/sys/mips/rmi/xlr_pci.c b/sys/mips/rmi/xlr_pci.c index feea696d9b35..b41a5588ecf5 100644 --- a/sys/mips/rmi/xlr_pci.c +++ b/sys/mips/rmi/xlr_pci.c @@ -306,7 +306,7 @@ xlr_pcib_attach(device_t dev) 0xff, 0x7fffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0) panic("%s: bus_dma_tag_create failed", __func__); } - device_add_child(dev, "pci", 0); + device_add_child(dev, "pci", -1); bus_generic_attach(dev); return (0); } diff --git a/sys/powerpc/ofw/ofw_pci.c b/sys/powerpc/ofw/ofw_pci.c index 8543035d9152..d9ea5c05d0a0 100644 --- a/sys/powerpc/ofw/ofw_pci.c +++ b/sys/powerpc/ofw/ofw_pci.c @@ -240,7 +240,7 @@ ofw_pci_attach(device_t dev) return (error); } - device_add_child(dev, "pci", device_get_unit(dev)); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c index f64659eec2ad..821265dd12e6 100644 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -524,7 +524,7 @@ legacy_pcib_attach(device_t dev) device_probe_and_attach(pir); } #endif - device_add_child(dev, "pci", bus); + device_add_child(dev, "pci", -1); return bus_generic_attach(dev); } diff --git a/sys/x86/pci/qpi.c b/sys/x86/pci/qpi.c index ae29daa1d349..2650986ea5a7 100644 --- a/sys/x86/pci/qpi.c +++ b/sys/x86/pci/qpi.c @@ -218,7 +218,7 @@ static int qpi_pcib_attach(device_t dev) { - device_add_child(dev, "pci", pcib_get_bus(dev)); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); } diff --git a/sys/x86/x86/mptable_pci.c b/sys/x86/x86/mptable_pci.c index 3e2c1cbe145f..31165ae9d2dd 100644 --- a/sys/x86/x86/mptable_pci.c +++ b/sys/x86/x86/mptable_pci.c @@ -69,7 +69,7 @@ mptable_hostb_attach(device_t dev) #ifdef NEW_PCIB mptable_pci_host_res_init(dev); #endif - device_add_child(dev, "pci", pcib_get_bus(dev)); + device_add_child(dev, "pci", -1); return (bus_generic_attach(dev)); }