1fb9aa6f1SThomas Gleixner /* 2fb9aa6f1SThomas Gleixner * Low-Level PCI Support for PC 3fb9aa6f1SThomas Gleixner * 4fb9aa6f1SThomas Gleixner * (c) 1999--2000 Martin Mares <mj@ucw.cz> 5fb9aa6f1SThomas Gleixner */ 6fb9aa6f1SThomas Gleixner 7fb9aa6f1SThomas Gleixner #include <linux/sched.h> 8fb9aa6f1SThomas Gleixner #include <linux/pci.h> 9fb9aa6f1SThomas Gleixner #include <linux/ioport.h> 10fb9aa6f1SThomas Gleixner #include <linux/init.h> 11fb9aa6f1SThomas Gleixner #include <linux/dmi.h> 125a0e3ad6STejun Heo #include <linux/slab.h> 13fb9aa6f1SThomas Gleixner 14284f5f9dSBjorn Helgaas #include <asm-generic/pci-bridge.h> 15fb9aa6f1SThomas Gleixner #include <asm/acpi.h> 16fb9aa6f1SThomas Gleixner #include <asm/segment.h> 17fb9aa6f1SThomas Gleixner #include <asm/io.h> 18fb9aa6f1SThomas Gleixner #include <asm/smp.h> 1982487711SJaswinder Singh Rajput #include <asm/pci_x86.h> 20f9a37be0SMatthew Garrett #include <asm/setup.h> 21fb9aa6f1SThomas Gleixner 22fb9aa6f1SThomas Gleixner unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 23fb9aa6f1SThomas Gleixner PCI_PROBE_MMCONF; 24fb9aa6f1SThomas Gleixner 25e3f2baebSYinghai Lu unsigned int pci_early_dump_regs; 26fb9aa6f1SThomas Gleixner static int pci_bf_sort; 276e8af08dSNarendra_K@Dell.com static int smbios_type_b1_flag; 28fb9aa6f1SThomas Gleixner int pci_routeirq; 29a9322f64SStefan Assmann int noioapicquirk; 3041b9eb26SStefan Assmann #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS 3141b9eb26SStefan Assmann int noioapicreroute = 0; 3241b9eb26SStefan Assmann #else 339197979bSStefan Assmann int noioapicreroute = 1; 3441b9eb26SStefan Assmann #endif 35fb9aa6f1SThomas Gleixner int pcibios_last_bus = -1; 36fb9aa6f1SThomas Gleixner unsigned long pirq_table_addr; 37fb9aa6f1SThomas Gleixner struct pci_bus *pci_root_bus; 3872da0b07SJan Beulich const struct pci_raw_ops *__read_mostly raw_pci_ops; 3972da0b07SJan Beulich const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; 40b6ce068aSMatthew Wilcox 41b6ce068aSMatthew Wilcox int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, 42b6ce068aSMatthew Wilcox int reg, int len, u32 *val) 43b6ce068aSMatthew Wilcox { 44beef3129SMatthew Wilcox if (domain == 0 && reg < 256 && raw_pci_ops) 45b6ce068aSMatthew Wilcox return raw_pci_ops->read(domain, bus, devfn, reg, len, val); 46b6ce068aSMatthew Wilcox if (raw_pci_ext_ops) 47b6ce068aSMatthew Wilcox return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); 48b6ce068aSMatthew Wilcox return -EINVAL; 49b6ce068aSMatthew Wilcox } 50b6ce068aSMatthew Wilcox 51b6ce068aSMatthew Wilcox int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, 52b6ce068aSMatthew Wilcox int reg, int len, u32 val) 53b6ce068aSMatthew Wilcox { 54beef3129SMatthew Wilcox if (domain == 0 && reg < 256 && raw_pci_ops) 55b6ce068aSMatthew Wilcox return raw_pci_ops->write(domain, bus, devfn, reg, len, val); 56b6ce068aSMatthew Wilcox if (raw_pci_ext_ops) 57b6ce068aSMatthew Wilcox return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); 58b6ce068aSMatthew Wilcox return -EINVAL; 59b6ce068aSMatthew Wilcox } 60fb9aa6f1SThomas Gleixner 61fb9aa6f1SThomas Gleixner static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) 62fb9aa6f1SThomas Gleixner { 63b6ce068aSMatthew Wilcox return raw_pci_read(pci_domain_nr(bus), bus->number, 64a79e4198SJeff Garzik devfn, where, size, value); 65fb9aa6f1SThomas Gleixner } 66fb9aa6f1SThomas Gleixner 67fb9aa6f1SThomas Gleixner static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) 68fb9aa6f1SThomas Gleixner { 69b6ce068aSMatthew Wilcox return raw_pci_write(pci_domain_nr(bus), bus->number, 70a79e4198SJeff Garzik devfn, where, size, value); 71fb9aa6f1SThomas Gleixner } 72fb9aa6f1SThomas Gleixner 73fb9aa6f1SThomas Gleixner struct pci_ops pci_root_ops = { 74fb9aa6f1SThomas Gleixner .read = pci_read, 75fb9aa6f1SThomas Gleixner .write = pci_write, 76fb9aa6f1SThomas Gleixner }; 77fb9aa6f1SThomas Gleixner 78fb9aa6f1SThomas Gleixner /* 79fb9aa6f1SThomas Gleixner * This interrupt-safe spinlock protects all accesses to PCI 80fb9aa6f1SThomas Gleixner * configuration space. 81fb9aa6f1SThomas Gleixner */ 82d19f61f0SThomas Gleixner DEFINE_RAW_SPINLOCK(pci_config_lock); 83fb9aa6f1SThomas Gleixner 8413a6ddb0SYinghai Lu static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d) 8513a6ddb0SYinghai Lu { 8613a6ddb0SYinghai Lu pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; 8713a6ddb0SYinghai Lu printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); 8813a6ddb0SYinghai Lu return 0; 8913a6ddb0SYinghai Lu } 9013a6ddb0SYinghai Lu 91821508d4SJan Beulich static const struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitconst = { 9213a6ddb0SYinghai Lu /* 9313a6ddb0SYinghai Lu * Systems where PCI IO resource ISA alignment can be skipped 9413a6ddb0SYinghai Lu * when the ISA enable bit in the bridge control is not set 9513a6ddb0SYinghai Lu */ 9613a6ddb0SYinghai Lu { 9713a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 9813a6ddb0SYinghai Lu .ident = "IBM System x3800", 9913a6ddb0SYinghai Lu .matches = { 10013a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 10113a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), 10213a6ddb0SYinghai Lu }, 10313a6ddb0SYinghai Lu }, 10413a6ddb0SYinghai Lu { 10513a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 10613a6ddb0SYinghai Lu .ident = "IBM System x3850", 10713a6ddb0SYinghai Lu .matches = { 10813a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 10913a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3850"), 11013a6ddb0SYinghai Lu }, 11113a6ddb0SYinghai Lu }, 11213a6ddb0SYinghai Lu { 11313a6ddb0SYinghai Lu .callback = can_skip_ioresource_align, 11413a6ddb0SYinghai Lu .ident = "IBM System x3950", 11513a6ddb0SYinghai Lu .matches = { 11613a6ddb0SYinghai Lu DMI_MATCH(DMI_SYS_VENDOR, "IBM"), 11713a6ddb0SYinghai Lu DMI_MATCH(DMI_PRODUCT_NAME, "x3950"), 11813a6ddb0SYinghai Lu }, 11913a6ddb0SYinghai Lu }, 12013a6ddb0SYinghai Lu {} 12113a6ddb0SYinghai Lu }; 12213a6ddb0SYinghai Lu 12313a6ddb0SYinghai Lu void __init dmi_check_skip_isa_align(void) 12413a6ddb0SYinghai Lu { 12513a6ddb0SYinghai Lu dmi_check_system(can_skip_pciprobe_dmi_table); 12613a6ddb0SYinghai Lu } 12713a6ddb0SYinghai Lu 128bb71ad88SGary Hade static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) 129bb71ad88SGary Hade { 130bb71ad88SGary Hade struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE]; 1317bd1c365SMike Habeck struct resource *bar_r; 1327bd1c365SMike Habeck int bar; 1337bd1c365SMike Habeck 1347bd1c365SMike Habeck if (pci_probe & PCI_NOASSIGN_BARS) { 1357bd1c365SMike Habeck /* 1367bd1c365SMike Habeck * If the BIOS did not assign the BAR, zero out the 1377bd1c365SMike Habeck * resource so the kernel doesn't attmept to assign 1387bd1c365SMike Habeck * it later on in pci_assign_unassigned_resources 1397bd1c365SMike Habeck */ 1407bd1c365SMike Habeck for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) { 1417bd1c365SMike Habeck bar_r = &dev->resource[bar]; 1427bd1c365SMike Habeck if (bar_r->start == 0 && bar_r->end != 0) { 1437bd1c365SMike Habeck bar_r->flags = 0; 1447bd1c365SMike Habeck bar_r->end = 0; 1457bd1c365SMike Habeck } 1467bd1c365SMike Habeck } 1477bd1c365SMike Habeck } 148bb71ad88SGary Hade 149bb71ad88SGary Hade if (pci_probe & PCI_NOASSIGN_ROMS) { 150bb71ad88SGary Hade if (rom_r->parent) 151bb71ad88SGary Hade return; 152bb71ad88SGary Hade if (rom_r->start) { 153bb71ad88SGary Hade /* we deal with BIOS assigned ROM later */ 154bb71ad88SGary Hade return; 155bb71ad88SGary Hade } 156bb71ad88SGary Hade rom_r->start = rom_r->end = rom_r->flags = 0; 157bb71ad88SGary Hade } 158bb71ad88SGary Hade } 159bb71ad88SGary Hade 160fb9aa6f1SThomas Gleixner /* 161fb9aa6f1SThomas Gleixner * Called after each bus is probed, but before its children 162fb9aa6f1SThomas Gleixner * are examined. 163fb9aa6f1SThomas Gleixner */ 164fb9aa6f1SThomas Gleixner 165fb9aa6f1SThomas Gleixner void __devinit pcibios_fixup_bus(struct pci_bus *b) 166fb9aa6f1SThomas Gleixner { 167bb71ad88SGary Hade struct pci_dev *dev; 168bb71ad88SGary Hade 169fb9aa6f1SThomas Gleixner pci_read_bridge_bases(b); 170bb71ad88SGary Hade list_for_each_entry(dev, &b->devices, bus_list) 171bb71ad88SGary Hade pcibios_fixup_device_resources(dev); 172fb9aa6f1SThomas Gleixner } 173fb9aa6f1SThomas Gleixner 174fb9aa6f1SThomas Gleixner /* 175fb9aa6f1SThomas Gleixner * Only use DMI information to set this if nothing was passed 176fb9aa6f1SThomas Gleixner * on the kernel command line (which was parsed earlier). 177fb9aa6f1SThomas Gleixner */ 178fb9aa6f1SThomas Gleixner 17919ad7ae4SLinus Torvalds static int __devinit set_bf_sort(const struct dmi_system_id *d) 180fb9aa6f1SThomas Gleixner { 181fb9aa6f1SThomas Gleixner if (pci_bf_sort == pci_bf_sort_default) { 182fb9aa6f1SThomas Gleixner pci_bf_sort = pci_dmi_bf; 183fb9aa6f1SThomas Gleixner printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident); 184fb9aa6f1SThomas Gleixner } 185fb9aa6f1SThomas Gleixner return 0; 186fb9aa6f1SThomas Gleixner } 187fb9aa6f1SThomas Gleixner 1886e8af08dSNarendra_K@Dell.com static void __devinit read_dmi_type_b1(const struct dmi_header *dm, 1896e8af08dSNarendra_K@Dell.com void *private_data) 1906e8af08dSNarendra_K@Dell.com { 1916e8af08dSNarendra_K@Dell.com u8 *d = (u8 *)dm + 4; 1926e8af08dSNarendra_K@Dell.com 1936e8af08dSNarendra_K@Dell.com if (dm->type != 0xB1) 1946e8af08dSNarendra_K@Dell.com return; 1956e8af08dSNarendra_K@Dell.com switch (((*(u32 *)d) >> 9) & 0x03) { 1966e8af08dSNarendra_K@Dell.com case 0x00: 1976e8af08dSNarendra_K@Dell.com printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n"); 1986e8af08dSNarendra_K@Dell.com break; 1996e8af08dSNarendra_K@Dell.com case 0x01: /* set pci=bfsort */ 2006e8af08dSNarendra_K@Dell.com smbios_type_b1_flag = 1; 2016e8af08dSNarendra_K@Dell.com break; 2026e8af08dSNarendra_K@Dell.com case 0x02: /* do not set pci=bfsort */ 2036e8af08dSNarendra_K@Dell.com smbios_type_b1_flag = 2; 2046e8af08dSNarendra_K@Dell.com break; 2056e8af08dSNarendra_K@Dell.com default: 2066e8af08dSNarendra_K@Dell.com break; 2076e8af08dSNarendra_K@Dell.com } 2086e8af08dSNarendra_K@Dell.com } 2096e8af08dSNarendra_K@Dell.com 2106e8af08dSNarendra_K@Dell.com static int __devinit find_sort_method(const struct dmi_system_id *d) 2116e8af08dSNarendra_K@Dell.com { 2126e8af08dSNarendra_K@Dell.com dmi_walk(read_dmi_type_b1, NULL); 2136e8af08dSNarendra_K@Dell.com 2146e8af08dSNarendra_K@Dell.com if (smbios_type_b1_flag == 1) { 2156e8af08dSNarendra_K@Dell.com set_bf_sort(d); 2166e8af08dSNarendra_K@Dell.com return 0; 2176e8af08dSNarendra_K@Dell.com } 2186e8af08dSNarendra_K@Dell.com return -1; 2196e8af08dSNarendra_K@Dell.com } 2206e8af08dSNarendra_K@Dell.com 221fb9aa6f1SThomas Gleixner /* 222fb9aa6f1SThomas Gleixner * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) 223fb9aa6f1SThomas Gleixner */ 224fb9aa6f1SThomas Gleixner #ifdef __i386__ 22519ad7ae4SLinus Torvalds static int __devinit assign_all_busses(const struct dmi_system_id *d) 226fb9aa6f1SThomas Gleixner { 227fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 228fb9aa6f1SThomas Gleixner printk(KERN_INFO "%s detected: enabling PCI bus# renumbering" 229fb9aa6f1SThomas Gleixner " (pci=assign-busses)\n", d->ident); 230fb9aa6f1SThomas Gleixner return 0; 231fb9aa6f1SThomas Gleixner } 232fb9aa6f1SThomas Gleixner #endif 233fb9aa6f1SThomas Gleixner 234284f5f9dSBjorn Helgaas static int __devinit set_scan_all(const struct dmi_system_id *d) 235284f5f9dSBjorn Helgaas { 236284f5f9dSBjorn Helgaas printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n", 237284f5f9dSBjorn Helgaas d->ident); 238284f5f9dSBjorn Helgaas pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS); 239284f5f9dSBjorn Helgaas return 0; 240284f5f9dSBjorn Helgaas } 241284f5f9dSBjorn Helgaas 242821508d4SJan Beulich static const struct dmi_system_id __devinitconst pciprobe_dmi_table[] = { 243fb9aa6f1SThomas Gleixner #ifdef __i386__ 244fb9aa6f1SThomas Gleixner /* 245fb9aa6f1SThomas Gleixner * Laptops which need pci=assign-busses to see Cardbus cards 246fb9aa6f1SThomas Gleixner */ 247fb9aa6f1SThomas Gleixner { 248fb9aa6f1SThomas Gleixner .callback = assign_all_busses, 249fb9aa6f1SThomas Gleixner .ident = "Samsung X20 Laptop", 250fb9aa6f1SThomas Gleixner .matches = { 251fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"), 252fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"), 253fb9aa6f1SThomas Gleixner }, 254fb9aa6f1SThomas Gleixner }, 255fb9aa6f1SThomas Gleixner #endif /* __i386__ */ 256fb9aa6f1SThomas Gleixner { 257fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 258fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1950", 259fb9aa6f1SThomas Gleixner .matches = { 260fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 261fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), 262fb9aa6f1SThomas Gleixner }, 263fb9aa6f1SThomas Gleixner }, 264fb9aa6f1SThomas Gleixner { 265fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 266fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1955", 267fb9aa6f1SThomas Gleixner .matches = { 268fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 269fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"), 270fb9aa6f1SThomas Gleixner }, 271fb9aa6f1SThomas Gleixner }, 272fb9aa6f1SThomas Gleixner { 273fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 274fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2900", 275fb9aa6f1SThomas Gleixner .matches = { 276fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 277fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"), 278fb9aa6f1SThomas Gleixner }, 279fb9aa6f1SThomas Gleixner }, 280fb9aa6f1SThomas Gleixner { 281fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 282fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2950", 283fb9aa6f1SThomas Gleixner .matches = { 284fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 285fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"), 286fb9aa6f1SThomas Gleixner }, 287fb9aa6f1SThomas Gleixner }, 288fb9aa6f1SThomas Gleixner { 289fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 290fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge R900", 291fb9aa6f1SThomas Gleixner .matches = { 292fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 293fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"), 294fb9aa6f1SThomas Gleixner }, 295fb9aa6f1SThomas Gleixner }, 296fb9aa6f1SThomas Gleixner { 2979b373ed1SNarendra_K@Dell.com .callback = find_sort_method, 2989b373ed1SNarendra_K@Dell.com .ident = "Dell System", 2999b373ed1SNarendra_K@Dell.com .matches = { 3009b373ed1SNarendra_K@Dell.com DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), 3019b373ed1SNarendra_K@Dell.com }, 3029b373ed1SNarendra_K@Dell.com }, 3039b373ed1SNarendra_K@Dell.com { 304fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 305fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G3", 306fb9aa6f1SThomas Gleixner .matches = { 307fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 308fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"), 309fb9aa6f1SThomas Gleixner }, 310fb9aa6f1SThomas Gleixner }, 311fb9aa6f1SThomas Gleixner { 312fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 313fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G4", 314fb9aa6f1SThomas Gleixner .matches = { 315fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 316fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"), 317fb9aa6f1SThomas Gleixner }, 318fb9aa6f1SThomas Gleixner }, 319fb9aa6f1SThomas Gleixner { 320fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 321fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL30p G1", 322fb9aa6f1SThomas Gleixner .matches = { 323fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 324fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"), 325fb9aa6f1SThomas Gleixner }, 326fb9aa6f1SThomas Gleixner }, 327fb9aa6f1SThomas Gleixner { 328fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 329fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL25p G1", 330fb9aa6f1SThomas Gleixner .matches = { 331fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 332fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"), 333fb9aa6f1SThomas Gleixner }, 334fb9aa6f1SThomas Gleixner }, 335fb9aa6f1SThomas Gleixner { 336fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 337fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL35p G1", 338fb9aa6f1SThomas Gleixner .matches = { 339fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 340fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"), 341fb9aa6f1SThomas Gleixner }, 342fb9aa6f1SThomas Gleixner }, 343fb9aa6f1SThomas Gleixner { 344fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 345fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G1", 346fb9aa6f1SThomas Gleixner .matches = { 347fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 348fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"), 349fb9aa6f1SThomas Gleixner }, 350fb9aa6f1SThomas Gleixner }, 351fb9aa6f1SThomas Gleixner { 352fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 353fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G2", 354fb9aa6f1SThomas Gleixner .matches = { 355fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 356fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"), 357fb9aa6f1SThomas Gleixner }, 358fb9aa6f1SThomas Gleixner }, 359fb9aa6f1SThomas Gleixner { 360fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 361fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL460c G1", 362fb9aa6f1SThomas Gleixner .matches = { 363fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 364fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"), 365fb9aa6f1SThomas Gleixner }, 366fb9aa6f1SThomas Gleixner }, 367fb9aa6f1SThomas Gleixner { 368fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 369fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL465c G1", 370fb9aa6f1SThomas Gleixner .matches = { 371fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 372fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"), 373fb9aa6f1SThomas Gleixner }, 374fb9aa6f1SThomas Gleixner }, 375fb9aa6f1SThomas Gleixner { 376fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 377fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL480c G1", 378fb9aa6f1SThomas Gleixner .matches = { 379fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 380fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"), 381fb9aa6f1SThomas Gleixner }, 382fb9aa6f1SThomas Gleixner }, 383fb9aa6f1SThomas Gleixner { 384fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 385fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL685c G1", 386fb9aa6f1SThomas Gleixner .matches = { 387fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 388fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"), 389fb9aa6f1SThomas Gleixner }, 390fb9aa6f1SThomas Gleixner }, 3918f8ae1a7SMichal Schmidt { 3928f8ae1a7SMichal Schmidt .callback = set_bf_sort, 3938d64c781STony Camuso .ident = "HP ProLiant DL360", 3948f8ae1a7SMichal Schmidt .matches = { 3958f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 3968d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"), 3978f8ae1a7SMichal Schmidt }, 3988f8ae1a7SMichal Schmidt }, 3998f8ae1a7SMichal Schmidt { 4008f8ae1a7SMichal Schmidt .callback = set_bf_sort, 4018d64c781STony Camuso .ident = "HP ProLiant DL380", 4028f8ae1a7SMichal Schmidt .matches = { 4038f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 4048d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"), 4058f8ae1a7SMichal Schmidt }, 4068f8ae1a7SMichal Schmidt }, 4075b1ea82fSJuha Laiho #ifdef __i386__ 4085b1ea82fSJuha Laiho { 4095b1ea82fSJuha Laiho .callback = assign_all_busses, 4105b1ea82fSJuha Laiho .ident = "Compaq EVO N800c", 4115b1ea82fSJuha Laiho .matches = { 4125b1ea82fSJuha Laiho DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), 4135b1ea82fSJuha Laiho DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"), 4145b1ea82fSJuha Laiho }, 4155b1ea82fSJuha Laiho }, 4165b1ea82fSJuha Laiho #endif 417c82bc5adSMichal Schmidt { 418c82bc5adSMichal Schmidt .callback = set_bf_sort, 419739db07fSJesse Barnes .ident = "HP ProLiant DL385 G2", 420c82bc5adSMichal Schmidt .matches = { 421c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 422739db07fSJesse Barnes DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"), 423c82bc5adSMichal Schmidt }, 424c82bc5adSMichal Schmidt }, 425c82bc5adSMichal Schmidt { 426c82bc5adSMichal Schmidt .callback = set_bf_sort, 427739db07fSJesse Barnes .ident = "HP ProLiant DL585 G2", 428c82bc5adSMichal Schmidt .matches = { 429c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 430739db07fSJesse Barnes DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"), 431c82bc5adSMichal Schmidt }, 432c82bc5adSMichal Schmidt }, 433284f5f9dSBjorn Helgaas { 434284f5f9dSBjorn Helgaas .callback = set_scan_all, 435284f5f9dSBjorn Helgaas .ident = "Stratus/NEC ftServer", 436284f5f9dSBjorn Helgaas .matches = { 437284f5f9dSBjorn Helgaas DMI_MATCH(DMI_SYS_VENDOR, "ftServer"), 438284f5f9dSBjorn Helgaas }, 439284f5f9dSBjorn Helgaas }, 440fb9aa6f1SThomas Gleixner {} 441fb9aa6f1SThomas Gleixner }; 442fb9aa6f1SThomas Gleixner 4430df18ff3SYinghai Lu void __init dmi_check_pciprobe(void) 4440df18ff3SYinghai Lu { 4450df18ff3SYinghai Lu dmi_check_system(pciprobe_dmi_table); 4460df18ff3SYinghai Lu } 4470df18ff3SYinghai Lu 448fb9aa6f1SThomas Gleixner struct pci_bus * __devinit pcibios_scan_root(int busnum) 449fb9aa6f1SThomas Gleixner { 450fb9aa6f1SThomas Gleixner struct pci_bus *bus = NULL; 451fb9aa6f1SThomas Gleixner 452fb9aa6f1SThomas Gleixner while ((bus = pci_find_next_bus(bus)) != NULL) { 453fb9aa6f1SThomas Gleixner if (bus->number == busnum) { 454fb9aa6f1SThomas Gleixner /* Already scanned */ 455fb9aa6f1SThomas Gleixner return bus; 456fb9aa6f1SThomas Gleixner } 457fb9aa6f1SThomas Gleixner } 458fb9aa6f1SThomas Gleixner 459c57ca65aSYinghai Lu return pci_scan_bus_on_node(busnum, &pci_root_ops, 460c57ca65aSYinghai Lu get_mp_bus_to_node(busnum)); 461fb9aa6f1SThomas Gleixner } 462fb9aa6f1SThomas Gleixner 46344de3395SAlex Nixon void __init pcibios_set_cache_line_size(void) 464fb9aa6f1SThomas Gleixner { 465fb9aa6f1SThomas Gleixner struct cpuinfo_x86 *c = &boot_cpu_data; 466fb9aa6f1SThomas Gleixner 467fb9aa6f1SThomas Gleixner /* 46876b1a87bSDave Jones * Set PCI cacheline size to that of the CPU if the CPU has reported it. 46976b1a87bSDave Jones * (For older CPUs that don't support cpuid, we se it to 32 bytes 47076b1a87bSDave Jones * It's also good for 386/486s (which actually have 16) 471fb9aa6f1SThomas Gleixner * as quite a few PCI devices do not support smaller values. 472fb9aa6f1SThomas Gleixner */ 47376b1a87bSDave Jones if (c->x86_clflush_size > 0) { 47476b1a87bSDave Jones pci_dfl_cache_line_size = c->x86_clflush_size >> 2; 47576b1a87bSDave Jones printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n", 47676b1a87bSDave Jones pci_dfl_cache_line_size << 2); 47776b1a87bSDave Jones } else { 478ac1aa47bSJesse Barnes pci_dfl_cache_line_size = 32 >> 2; 47976b1a87bSDave Jones printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n"); 48076b1a87bSDave Jones } 48144de3395SAlex Nixon } 482fb9aa6f1SThomas Gleixner 48344de3395SAlex Nixon int __init pcibios_init(void) 48444de3395SAlex Nixon { 48544de3395SAlex Nixon if (!raw_pci_ops) { 48644de3395SAlex Nixon printk(KERN_WARNING "PCI: System does not support PCI\n"); 48744de3395SAlex Nixon return 0; 48844de3395SAlex Nixon } 48944de3395SAlex Nixon 49044de3395SAlex Nixon pcibios_set_cache_line_size(); 491fb9aa6f1SThomas Gleixner pcibios_resource_survey(); 492fb9aa6f1SThomas Gleixner 493fb9aa6f1SThomas Gleixner if (pci_bf_sort >= pci_force_bf) 494fb9aa6f1SThomas Gleixner pci_sort_breadthfirst(); 495fb9aa6f1SThomas Gleixner return 0; 496fb9aa6f1SThomas Gleixner } 497fb9aa6f1SThomas Gleixner 49815fa325bSMyron Stowe char * __init pcibios_setup(char *str) 499fb9aa6f1SThomas Gleixner { 500fb9aa6f1SThomas Gleixner if (!strcmp(str, "off")) { 501fb9aa6f1SThomas Gleixner pci_probe = 0; 502fb9aa6f1SThomas Gleixner return NULL; 503fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "bfsort")) { 504fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_bf; 505fb9aa6f1SThomas Gleixner return NULL; 506fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobfsort")) { 507fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_nobf; 508fb9aa6f1SThomas Gleixner return NULL; 509fb9aa6f1SThomas Gleixner } 510fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_BIOS 511fb9aa6f1SThomas Gleixner else if (!strcmp(str, "bios")) { 512fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_BIOS; 513fb9aa6f1SThomas Gleixner return NULL; 514fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobios")) { 515fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_BIOS; 516fb9aa6f1SThomas Gleixner return NULL; 517fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "biosirq")) { 518fb9aa6f1SThomas Gleixner pci_probe |= PCI_BIOS_IRQ_SCAN; 519fb9aa6f1SThomas Gleixner return NULL; 520fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "pirqaddr=", 9)) { 521fb9aa6f1SThomas Gleixner pirq_table_addr = simple_strtoul(str+9, NULL, 0); 522fb9aa6f1SThomas Gleixner return NULL; 523fb9aa6f1SThomas Gleixner } 524fb9aa6f1SThomas Gleixner #endif 525fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_DIRECT 526fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf1")) { 527fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS; 528fb9aa6f1SThomas Gleixner return NULL; 529fb9aa6f1SThomas Gleixner } 530fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf2")) { 531fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS; 532fb9aa6f1SThomas Gleixner return NULL; 533fb9aa6f1SThomas Gleixner } 534fb9aa6f1SThomas Gleixner #endif 535fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_MMCONFIG 536fb9aa6f1SThomas Gleixner else if (!strcmp(str, "nommconf")) { 537fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_MMCONF; 538fb9aa6f1SThomas Gleixner return NULL; 539fb9aa6f1SThomas Gleixner } 5405f0b2976SYinghai Lu else if (!strcmp(str, "check_enable_amd_mmconf")) { 5415f0b2976SYinghai Lu pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; 5425f0b2976SYinghai Lu return NULL; 5435f0b2976SYinghai Lu } 544fb9aa6f1SThomas Gleixner #endif 545fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noacpi")) { 546fb9aa6f1SThomas Gleixner acpi_noirq_set(); 547fb9aa6f1SThomas Gleixner return NULL; 548fb9aa6f1SThomas Gleixner } 549fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noearly")) { 550fb9aa6f1SThomas Gleixner pci_probe |= PCI_PROBE_NOEARLY; 551fb9aa6f1SThomas Gleixner return NULL; 552fb9aa6f1SThomas Gleixner } 553fb9aa6f1SThomas Gleixner #ifndef CONFIG_X86_VISWS 554fb9aa6f1SThomas Gleixner else if (!strcmp(str, "usepirqmask")) { 555fb9aa6f1SThomas Gleixner pci_probe |= PCI_USE_PIRQ_MASK; 556fb9aa6f1SThomas Gleixner return NULL; 557fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "irqmask=", 8)) { 558fb9aa6f1SThomas Gleixner pcibios_irq_mask = simple_strtol(str+8, NULL, 0); 559fb9aa6f1SThomas Gleixner return NULL; 560fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "lastbus=", 8)) { 561fb9aa6f1SThomas Gleixner pcibios_last_bus = simple_strtol(str+8, NULL, 0); 562fb9aa6f1SThomas Gleixner return NULL; 563fb9aa6f1SThomas Gleixner } 564fb9aa6f1SThomas Gleixner #endif 565fb9aa6f1SThomas Gleixner else if (!strcmp(str, "rom")) { 566fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ROMS; 567fb9aa6f1SThomas Gleixner return NULL; 568bb71ad88SGary Hade } else if (!strcmp(str, "norom")) { 569bb71ad88SGary Hade pci_probe |= PCI_NOASSIGN_ROMS; 570bb71ad88SGary Hade return NULL; 5717bd1c365SMike Habeck } else if (!strcmp(str, "nobar")) { 5727bd1c365SMike Habeck pci_probe |= PCI_NOASSIGN_BARS; 5737bd1c365SMike Habeck return NULL; 574fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "assign-busses")) { 575fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 576fb9aa6f1SThomas Gleixner return NULL; 577236e946bSLinus Torvalds } else if (!strcmp(str, "use_crs")) { 578236e946bSLinus Torvalds pci_probe |= PCI_USE__CRS; 57962f420f8SGary Hade return NULL; 5807bc5e3f2SBjorn Helgaas } else if (!strcmp(str, "nocrs")) { 5817bc5e3f2SBjorn Helgaas pci_probe |= PCI_ROOT_NO_CRS; 5827bc5e3f2SBjorn Helgaas return NULL; 583e3f2baebSYinghai Lu } else if (!strcmp(str, "earlydump")) { 584e3f2baebSYinghai Lu pci_early_dump_regs = 1; 585e3f2baebSYinghai Lu return NULL; 586fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "routeirq")) { 587fb9aa6f1SThomas Gleixner pci_routeirq = 1; 588fb9aa6f1SThomas Gleixner return NULL; 58913a6ddb0SYinghai Lu } else if (!strcmp(str, "skip_isa_align")) { 59013a6ddb0SYinghai Lu pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; 59113a6ddb0SYinghai Lu return NULL; 592a9322f64SStefan Assmann } else if (!strcmp(str, "noioapicquirk")) { 593a9322f64SStefan Assmann noioapicquirk = 1; 594a9322f64SStefan Assmann return NULL; 5959197979bSStefan Assmann } else if (!strcmp(str, "ioapicreroute")) { 5969197979bSStefan Assmann if (noioapicreroute != -1) 5979197979bSStefan Assmann noioapicreroute = 0; 5989197979bSStefan Assmann return NULL; 59941b9eb26SStefan Assmann } else if (!strcmp(str, "noioapicreroute")) { 60041b9eb26SStefan Assmann if (noioapicreroute != -1) 60141b9eb26SStefan Assmann noioapicreroute = 1; 60241b9eb26SStefan Assmann return NULL; 603fb9aa6f1SThomas Gleixner } 604fb9aa6f1SThomas Gleixner return str; 605fb9aa6f1SThomas Gleixner } 606fb9aa6f1SThomas Gleixner 607fb9aa6f1SThomas Gleixner unsigned int pcibios_assign_all_busses(void) 608fb9aa6f1SThomas Gleixner { 609fb9aa6f1SThomas Gleixner return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 610fb9aa6f1SThomas Gleixner } 611fb9aa6f1SThomas Gleixner 612f9a37be0SMatthew Garrett int pcibios_add_device(struct pci_dev *dev) 613f9a37be0SMatthew Garrett { 614f9a37be0SMatthew Garrett struct setup_data *data; 615f9a37be0SMatthew Garrett struct pci_setup_rom *rom; 616f9a37be0SMatthew Garrett u64 pa_data; 617f9a37be0SMatthew Garrett 618f9a37be0SMatthew Garrett pa_data = boot_params.hdr.setup_data; 619f9a37be0SMatthew Garrett while (pa_data) { 620f9a37be0SMatthew Garrett data = phys_to_virt(pa_data); 621f9a37be0SMatthew Garrett 622f9a37be0SMatthew Garrett if (data->type == SETUP_PCI) { 623f9a37be0SMatthew Garrett rom = (struct pci_setup_rom *)data; 624f9a37be0SMatthew Garrett 625f9a37be0SMatthew Garrett if ((pci_domain_nr(dev->bus) == rom->segment) && 626f9a37be0SMatthew Garrett (dev->bus->number == rom->bus) && 627f9a37be0SMatthew Garrett (PCI_SLOT(dev->devfn) == rom->device) && 628f9a37be0SMatthew Garrett (PCI_FUNC(dev->devfn) == rom->function) && 629f9a37be0SMatthew Garrett (dev->vendor == rom->vendor) && 630f9a37be0SMatthew Garrett (dev->device == rom->devid)) { 631dbd3fc33SBjorn Helgaas dev->rom = pa_data + 632dbd3fc33SBjorn Helgaas offsetof(struct pci_setup_rom, romdata); 633f9a37be0SMatthew Garrett dev->romlen = rom->pcilen; 634f9a37be0SMatthew Garrett } 635f9a37be0SMatthew Garrett } 636f9a37be0SMatthew Garrett pa_data = data->next; 637f9a37be0SMatthew Garrett } 638f9a37be0SMatthew Garrett return 0; 639f9a37be0SMatthew Garrett } 640f9a37be0SMatthew Garrett 641fb9aa6f1SThomas Gleixner int pcibios_enable_device(struct pci_dev *dev, int mask) 642fb9aa6f1SThomas Gleixner { 643fb9aa6f1SThomas Gleixner int err; 644fb9aa6f1SThomas Gleixner 645b81d988cSBjorn Helgaas if ((err = pci_enable_resources(dev, mask)) < 0) 646fb9aa6f1SThomas Gleixner return err; 647fb9aa6f1SThomas Gleixner 64816cf0ebcSRafael J. Wysocki if (!pci_dev_msi_enabled(dev)) 649fb9aa6f1SThomas Gleixner return pcibios_enable_irq(dev); 650fb9aa6f1SThomas Gleixner return 0; 651fb9aa6f1SThomas Gleixner } 652fb9aa6f1SThomas Gleixner 653fb9aa6f1SThomas Gleixner void pcibios_disable_device (struct pci_dev *dev) 654fb9aa6f1SThomas Gleixner { 65516cf0ebcSRafael J. Wysocki if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq) 656fb9aa6f1SThomas Gleixner pcibios_disable_irq(dev); 657fb9aa6f1SThomas Gleixner } 658fb9aa6f1SThomas Gleixner 6590ef5f8f6SAndrew Patterson int pci_ext_cfg_avail(struct pci_dev *dev) 6600ef5f8f6SAndrew Patterson { 6610ef5f8f6SAndrew Patterson if (raw_pci_ext_ops) 6620ef5f8f6SAndrew Patterson return 1; 6630ef5f8f6SAndrew Patterson else 6640ef5f8f6SAndrew Patterson return 0; 6650ef5f8f6SAndrew Patterson } 6660ef5f8f6SAndrew Patterson 66798db6f19SSam Ravnborg struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) 668fb9aa6f1SThomas Gleixner { 6692cd6975aSBjorn Helgaas LIST_HEAD(resources); 670fb9aa6f1SThomas Gleixner struct pci_bus *bus = NULL; 671fb9aa6f1SThomas Gleixner struct pci_sysdata *sd; 672fb9aa6f1SThomas Gleixner 673fb9aa6f1SThomas Gleixner /* 674fb9aa6f1SThomas Gleixner * Allocate per-root-bus (not per bus) arch-specific data. 675fb9aa6f1SThomas Gleixner * TODO: leak; this memory is never freed. 676fb9aa6f1SThomas Gleixner * It's arguable whether it's worth the trouble to care. 677fb9aa6f1SThomas Gleixner */ 678fb9aa6f1SThomas Gleixner sd = kzalloc(sizeof(*sd), GFP_KERNEL); 679fb9aa6f1SThomas Gleixner if (!sd) { 680fb9aa6f1SThomas Gleixner printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno); 681fb9aa6f1SThomas Gleixner return NULL; 682fb9aa6f1SThomas Gleixner } 683871d5f8dSYinghai Lu sd->node = node; 6842cd6975aSBjorn Helgaas x86_pci_root_bus_resources(busno, &resources); 685c57ca65aSYinghai Lu printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno); 6862cd6975aSBjorn Helgaas bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources); 6872cd6975aSBjorn Helgaas if (!bus) { 6882cd6975aSBjorn Helgaas pci_free_resource_list(&resources); 689fb9aa6f1SThomas Gleixner kfree(sd); 6902cd6975aSBjorn Helgaas } 691fb9aa6f1SThomas Gleixner 692fb9aa6f1SThomas Gleixner return bus; 693fb9aa6f1SThomas Gleixner } 694871d5f8dSYinghai Lu 69598db6f19SSam Ravnborg struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno) 696871d5f8dSYinghai Lu { 697871d5f8dSYinghai Lu return pci_scan_bus_on_node(busno, &pci_root_ops, -1); 698871d5f8dSYinghai Lu } 6992547089cSJesse Barnes 7002547089cSJesse Barnes /* 7012547089cSJesse Barnes * NUMA info for PCI busses 7022547089cSJesse Barnes * 7032547089cSJesse Barnes * Early arch code is responsible for filling in reasonable values here. 7042547089cSJesse Barnes * A node id of "-1" means "use current node". In other words, if a bus 7052547089cSJesse Barnes * has a -1 node id, it's not tightly coupled to any particular chunk 7062547089cSJesse Barnes * of memory (as is the case on some Nehalem systems). 7072547089cSJesse Barnes */ 7082547089cSJesse Barnes #ifdef CONFIG_NUMA 7092547089cSJesse Barnes 7102547089cSJesse Barnes #define BUS_NR 256 7112547089cSJesse Barnes 7122547089cSJesse Barnes #ifdef CONFIG_X86_64 7132547089cSJesse Barnes 7142547089cSJesse Barnes static int mp_bus_to_node[BUS_NR] = { 7152547089cSJesse Barnes [0 ... BUS_NR - 1] = -1 7162547089cSJesse Barnes }; 7172547089cSJesse Barnes 7182547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node) 7192547089cSJesse Barnes { 7202547089cSJesse Barnes if (busnum >= 0 && busnum < BUS_NR) 7212547089cSJesse Barnes mp_bus_to_node[busnum] = node; 7222547089cSJesse Barnes } 7232547089cSJesse Barnes 7242547089cSJesse Barnes int get_mp_bus_to_node(int busnum) 7252547089cSJesse Barnes { 7262547089cSJesse Barnes int node = -1; 7272547089cSJesse Barnes 7282547089cSJesse Barnes if (busnum < 0 || busnum > (BUS_NR - 1)) 7292547089cSJesse Barnes return node; 7302547089cSJesse Barnes 7312547089cSJesse Barnes node = mp_bus_to_node[busnum]; 7322547089cSJesse Barnes 7332547089cSJesse Barnes /* 7342547089cSJesse Barnes * let numa_node_id to decide it later in dma_alloc_pages 7352547089cSJesse Barnes * if there is no ram on that node 7362547089cSJesse Barnes */ 7372547089cSJesse Barnes if (node != -1 && !node_online(node)) 7382547089cSJesse Barnes node = -1; 7392547089cSJesse Barnes 7402547089cSJesse Barnes return node; 7412547089cSJesse Barnes } 7422547089cSJesse Barnes 7432547089cSJesse Barnes #else /* CONFIG_X86_32 */ 7442547089cSJesse Barnes 74576baeebfSJesse Barnes static int mp_bus_to_node[BUS_NR] = { 7462547089cSJesse Barnes [0 ... BUS_NR - 1] = -1 7472547089cSJesse Barnes }; 7482547089cSJesse Barnes 7492547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node) 7502547089cSJesse Barnes { 7512547089cSJesse Barnes if (busnum >= 0 && busnum < BUS_NR) 7522547089cSJesse Barnes mp_bus_to_node[busnum] = (unsigned char) node; 7532547089cSJesse Barnes } 7542547089cSJesse Barnes 7552547089cSJesse Barnes int get_mp_bus_to_node(int busnum) 7562547089cSJesse Barnes { 7572547089cSJesse Barnes int node; 7582547089cSJesse Barnes 7592547089cSJesse Barnes if (busnum < 0 || busnum > (BUS_NR - 1)) 7602547089cSJesse Barnes return 0; 7612547089cSJesse Barnes node = mp_bus_to_node[busnum]; 7622547089cSJesse Barnes return node; 7632547089cSJesse Barnes } 7642547089cSJesse Barnes 7652547089cSJesse Barnes #endif /* CONFIG_X86_32 */ 7662547089cSJesse Barnes 7672547089cSJesse Barnes #endif /* CONFIG_NUMA */ 768