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> 989016506SJiang Liu #include <linux/pci-acpi.h> 10fb9aa6f1SThomas Gleixner #include <linux/ioport.h> 11fb9aa6f1SThomas Gleixner #include <linux/init.h> 12fb9aa6f1SThomas Gleixner #include <linux/dmi.h> 135a0e3ad6STejun Heo #include <linux/slab.h> 14fb9aa6f1SThomas Gleixner 15284f5f9dSBjorn Helgaas #include <asm-generic/pci-bridge.h> 16fb9aa6f1SThomas Gleixner #include <asm/acpi.h> 17fb9aa6f1SThomas Gleixner #include <asm/segment.h> 18fb9aa6f1SThomas Gleixner #include <asm/io.h> 19fb9aa6f1SThomas Gleixner #include <asm/smp.h> 2082487711SJaswinder Singh Rajput #include <asm/pci_x86.h> 21f9a37be0SMatthew Garrett #include <asm/setup.h> 22fb9aa6f1SThomas Gleixner 23fb9aa6f1SThomas Gleixner unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 24fb9aa6f1SThomas Gleixner PCI_PROBE_MMCONF; 25fb9aa6f1SThomas Gleixner 26e3f2baebSYinghai Lu unsigned int pci_early_dump_regs; 27fb9aa6f1SThomas Gleixner static int pci_bf_sort; 286e8af08dSNarendra_K@Dell.com static int smbios_type_b1_flag; 29fb9aa6f1SThomas Gleixner int pci_routeirq; 30a9322f64SStefan Assmann int noioapicquirk; 3141b9eb26SStefan Assmann #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS 3241b9eb26SStefan Assmann int noioapicreroute = 0; 3341b9eb26SStefan Assmann #else 349197979bSStefan Assmann int noioapicreroute = 1; 3541b9eb26SStefan Assmann #endif 36fb9aa6f1SThomas Gleixner int pcibios_last_bus = -1; 37fb9aa6f1SThomas Gleixner unsigned long pirq_table_addr; 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 84a18e3690SGreg Kroah-Hartman static int 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 91a18e3690SGreg Kroah-Hartman static const struct dmi_system_id can_skip_pciprobe_dmi_table[] = { 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 128a18e3690SGreg Kroah-Hartman static void 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 165a18e3690SGreg Kroah-Hartman void 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 17489016506SJiang Liu void pcibios_add_bus(struct pci_bus *bus) 17589016506SJiang Liu { 17689016506SJiang Liu acpi_pci_add_bus(bus); 17789016506SJiang Liu } 17889016506SJiang Liu 17989016506SJiang Liu void pcibios_remove_bus(struct pci_bus *bus) 18089016506SJiang Liu { 18189016506SJiang Liu acpi_pci_remove_bus(bus); 18289016506SJiang Liu } 18389016506SJiang Liu 184fb9aa6f1SThomas Gleixner /* 185fb9aa6f1SThomas Gleixner * Only use DMI information to set this if nothing was passed 186fb9aa6f1SThomas Gleixner * on the kernel command line (which was parsed earlier). 187fb9aa6f1SThomas Gleixner */ 188fb9aa6f1SThomas Gleixner 189a18e3690SGreg Kroah-Hartman static int set_bf_sort(const struct dmi_system_id *d) 190fb9aa6f1SThomas Gleixner { 191fb9aa6f1SThomas Gleixner if (pci_bf_sort == pci_bf_sort_default) { 192fb9aa6f1SThomas Gleixner pci_bf_sort = pci_dmi_bf; 193fb9aa6f1SThomas Gleixner printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident); 194fb9aa6f1SThomas Gleixner } 195fb9aa6f1SThomas Gleixner return 0; 196fb9aa6f1SThomas Gleixner } 197fb9aa6f1SThomas Gleixner 198a18e3690SGreg Kroah-Hartman static void read_dmi_type_b1(const struct dmi_header *dm, 1996e8af08dSNarendra_K@Dell.com void *private_data) 2006e8af08dSNarendra_K@Dell.com { 2016e8af08dSNarendra_K@Dell.com u8 *d = (u8 *)dm + 4; 2026e8af08dSNarendra_K@Dell.com 2036e8af08dSNarendra_K@Dell.com if (dm->type != 0xB1) 2046e8af08dSNarendra_K@Dell.com return; 2056e8af08dSNarendra_K@Dell.com switch (((*(u32 *)d) >> 9) & 0x03) { 2066e8af08dSNarendra_K@Dell.com case 0x00: 2076e8af08dSNarendra_K@Dell.com printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n"); 2086e8af08dSNarendra_K@Dell.com break; 2096e8af08dSNarendra_K@Dell.com case 0x01: /* set pci=bfsort */ 2106e8af08dSNarendra_K@Dell.com smbios_type_b1_flag = 1; 2116e8af08dSNarendra_K@Dell.com break; 2126e8af08dSNarendra_K@Dell.com case 0x02: /* do not set pci=bfsort */ 2136e8af08dSNarendra_K@Dell.com smbios_type_b1_flag = 2; 2146e8af08dSNarendra_K@Dell.com break; 2156e8af08dSNarendra_K@Dell.com default: 2166e8af08dSNarendra_K@Dell.com break; 2176e8af08dSNarendra_K@Dell.com } 2186e8af08dSNarendra_K@Dell.com } 2196e8af08dSNarendra_K@Dell.com 220a18e3690SGreg Kroah-Hartman static int find_sort_method(const struct dmi_system_id *d) 2216e8af08dSNarendra_K@Dell.com { 2226e8af08dSNarendra_K@Dell.com dmi_walk(read_dmi_type_b1, NULL); 2236e8af08dSNarendra_K@Dell.com 2246e8af08dSNarendra_K@Dell.com if (smbios_type_b1_flag == 1) { 2256e8af08dSNarendra_K@Dell.com set_bf_sort(d); 2266e8af08dSNarendra_K@Dell.com return 0; 2276e8af08dSNarendra_K@Dell.com } 2286e8af08dSNarendra_K@Dell.com return -1; 2296e8af08dSNarendra_K@Dell.com } 2306e8af08dSNarendra_K@Dell.com 231fb9aa6f1SThomas Gleixner /* 232fb9aa6f1SThomas Gleixner * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) 233fb9aa6f1SThomas Gleixner */ 234fb9aa6f1SThomas Gleixner #ifdef __i386__ 235a18e3690SGreg Kroah-Hartman static int assign_all_busses(const struct dmi_system_id *d) 236fb9aa6f1SThomas Gleixner { 237fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 238fb9aa6f1SThomas Gleixner printk(KERN_INFO "%s detected: enabling PCI bus# renumbering" 239fb9aa6f1SThomas Gleixner " (pci=assign-busses)\n", d->ident); 240fb9aa6f1SThomas Gleixner return 0; 241fb9aa6f1SThomas Gleixner } 242fb9aa6f1SThomas Gleixner #endif 243fb9aa6f1SThomas Gleixner 244a18e3690SGreg Kroah-Hartman static int set_scan_all(const struct dmi_system_id *d) 245284f5f9dSBjorn Helgaas { 246284f5f9dSBjorn Helgaas printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n", 247284f5f9dSBjorn Helgaas d->ident); 248284f5f9dSBjorn Helgaas pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS); 249284f5f9dSBjorn Helgaas return 0; 250284f5f9dSBjorn Helgaas } 251284f5f9dSBjorn Helgaas 252a18e3690SGreg Kroah-Hartman static const struct dmi_system_id pciprobe_dmi_table[] = { 253fb9aa6f1SThomas Gleixner #ifdef __i386__ 254fb9aa6f1SThomas Gleixner /* 255fb9aa6f1SThomas Gleixner * Laptops which need pci=assign-busses to see Cardbus cards 256fb9aa6f1SThomas Gleixner */ 257fb9aa6f1SThomas Gleixner { 258fb9aa6f1SThomas Gleixner .callback = assign_all_busses, 259fb9aa6f1SThomas Gleixner .ident = "Samsung X20 Laptop", 260fb9aa6f1SThomas Gleixner .matches = { 261fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"), 262fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"), 263fb9aa6f1SThomas Gleixner }, 264fb9aa6f1SThomas Gleixner }, 265fb9aa6f1SThomas Gleixner #endif /* __i386__ */ 266fb9aa6f1SThomas Gleixner { 267fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 268fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1950", 269fb9aa6f1SThomas Gleixner .matches = { 270fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 271fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), 272fb9aa6f1SThomas Gleixner }, 273fb9aa6f1SThomas Gleixner }, 274fb9aa6f1SThomas Gleixner { 275fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 276fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 1955", 277fb9aa6f1SThomas Gleixner .matches = { 278fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 279fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"), 280fb9aa6f1SThomas Gleixner }, 281fb9aa6f1SThomas Gleixner }, 282fb9aa6f1SThomas Gleixner { 283fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 284fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2900", 285fb9aa6f1SThomas Gleixner .matches = { 286fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 287fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"), 288fb9aa6f1SThomas Gleixner }, 289fb9aa6f1SThomas Gleixner }, 290fb9aa6f1SThomas Gleixner { 291fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 292fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge 2950", 293fb9aa6f1SThomas Gleixner .matches = { 294fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 295fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"), 296fb9aa6f1SThomas Gleixner }, 297fb9aa6f1SThomas Gleixner }, 298fb9aa6f1SThomas Gleixner { 299fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 300fb9aa6f1SThomas Gleixner .ident = "Dell PowerEdge R900", 301fb9aa6f1SThomas Gleixner .matches = { 302fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "Dell"), 303fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"), 304fb9aa6f1SThomas Gleixner }, 305fb9aa6f1SThomas Gleixner }, 306fb9aa6f1SThomas Gleixner { 3079b373ed1SNarendra_K@Dell.com .callback = find_sort_method, 3089b373ed1SNarendra_K@Dell.com .ident = "Dell System", 3099b373ed1SNarendra_K@Dell.com .matches = { 3109b373ed1SNarendra_K@Dell.com DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), 3119b373ed1SNarendra_K@Dell.com }, 3129b373ed1SNarendra_K@Dell.com }, 3139b373ed1SNarendra_K@Dell.com { 314fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 315fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G3", 316fb9aa6f1SThomas Gleixner .matches = { 317fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 318fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"), 319fb9aa6f1SThomas Gleixner }, 320fb9aa6f1SThomas Gleixner }, 321fb9aa6f1SThomas Gleixner { 322fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 323fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL20p G4", 324fb9aa6f1SThomas Gleixner .matches = { 325fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 326fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"), 327fb9aa6f1SThomas Gleixner }, 328fb9aa6f1SThomas Gleixner }, 329fb9aa6f1SThomas Gleixner { 330fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 331fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL30p G1", 332fb9aa6f1SThomas Gleixner .matches = { 333fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 334fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"), 335fb9aa6f1SThomas Gleixner }, 336fb9aa6f1SThomas Gleixner }, 337fb9aa6f1SThomas Gleixner { 338fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 339fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL25p G1", 340fb9aa6f1SThomas Gleixner .matches = { 341fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 342fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"), 343fb9aa6f1SThomas Gleixner }, 344fb9aa6f1SThomas Gleixner }, 345fb9aa6f1SThomas Gleixner { 346fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 347fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL35p G1", 348fb9aa6f1SThomas Gleixner .matches = { 349fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 350fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"), 351fb9aa6f1SThomas Gleixner }, 352fb9aa6f1SThomas Gleixner }, 353fb9aa6f1SThomas Gleixner { 354fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 355fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G1", 356fb9aa6f1SThomas Gleixner .matches = { 357fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 358fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"), 359fb9aa6f1SThomas Gleixner }, 360fb9aa6f1SThomas Gleixner }, 361fb9aa6f1SThomas Gleixner { 362fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 363fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL45p G2", 364fb9aa6f1SThomas Gleixner .matches = { 365fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 366fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"), 367fb9aa6f1SThomas Gleixner }, 368fb9aa6f1SThomas Gleixner }, 369fb9aa6f1SThomas Gleixner { 370fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 371fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL460c G1", 372fb9aa6f1SThomas Gleixner .matches = { 373fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 374fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"), 375fb9aa6f1SThomas Gleixner }, 376fb9aa6f1SThomas Gleixner }, 377fb9aa6f1SThomas Gleixner { 378fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 379fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL465c G1", 380fb9aa6f1SThomas Gleixner .matches = { 381fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 382fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"), 383fb9aa6f1SThomas Gleixner }, 384fb9aa6f1SThomas Gleixner }, 385fb9aa6f1SThomas Gleixner { 386fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 387fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL480c G1", 388fb9aa6f1SThomas Gleixner .matches = { 389fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 390fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"), 391fb9aa6f1SThomas Gleixner }, 392fb9aa6f1SThomas Gleixner }, 393fb9aa6f1SThomas Gleixner { 394fb9aa6f1SThomas Gleixner .callback = set_bf_sort, 395fb9aa6f1SThomas Gleixner .ident = "HP ProLiant BL685c G1", 396fb9aa6f1SThomas Gleixner .matches = { 397fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_SYS_VENDOR, "HP"), 398fb9aa6f1SThomas Gleixner DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"), 399fb9aa6f1SThomas Gleixner }, 400fb9aa6f1SThomas Gleixner }, 4018f8ae1a7SMichal Schmidt { 4028f8ae1a7SMichal Schmidt .callback = set_bf_sort, 4038d64c781STony Camuso .ident = "HP ProLiant DL360", 4048f8ae1a7SMichal Schmidt .matches = { 4058f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 4068d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"), 4078f8ae1a7SMichal Schmidt }, 4088f8ae1a7SMichal Schmidt }, 4098f8ae1a7SMichal Schmidt { 4108f8ae1a7SMichal Schmidt .callback = set_bf_sort, 4118d64c781STony Camuso .ident = "HP ProLiant DL380", 4128f8ae1a7SMichal Schmidt .matches = { 4138f8ae1a7SMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 4148d64c781STony Camuso DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"), 4158f8ae1a7SMichal Schmidt }, 4168f8ae1a7SMichal Schmidt }, 4175b1ea82fSJuha Laiho #ifdef __i386__ 4185b1ea82fSJuha Laiho { 4195b1ea82fSJuha Laiho .callback = assign_all_busses, 4205b1ea82fSJuha Laiho .ident = "Compaq EVO N800c", 4215b1ea82fSJuha Laiho .matches = { 4225b1ea82fSJuha Laiho DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), 4235b1ea82fSJuha Laiho DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"), 4245b1ea82fSJuha Laiho }, 4255b1ea82fSJuha Laiho }, 4265b1ea82fSJuha Laiho #endif 427c82bc5adSMichal Schmidt { 428c82bc5adSMichal Schmidt .callback = set_bf_sort, 429739db07fSJesse Barnes .ident = "HP ProLiant DL385 G2", 430c82bc5adSMichal Schmidt .matches = { 431c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 432739db07fSJesse Barnes DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"), 433c82bc5adSMichal Schmidt }, 434c82bc5adSMichal Schmidt }, 435c82bc5adSMichal Schmidt { 436c82bc5adSMichal Schmidt .callback = set_bf_sort, 437739db07fSJesse Barnes .ident = "HP ProLiant DL585 G2", 438c82bc5adSMichal Schmidt .matches = { 439c82bc5adSMichal Schmidt DMI_MATCH(DMI_SYS_VENDOR, "HP"), 440739db07fSJesse Barnes DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"), 441c82bc5adSMichal Schmidt }, 442c82bc5adSMichal Schmidt }, 443284f5f9dSBjorn Helgaas { 444284f5f9dSBjorn Helgaas .callback = set_scan_all, 445284f5f9dSBjorn Helgaas .ident = "Stratus/NEC ftServer", 446284f5f9dSBjorn Helgaas .matches = { 4471278998fSMyron Stowe DMI_MATCH(DMI_SYS_VENDOR, "Stratus"), 4481278998fSMyron Stowe DMI_MATCH(DMI_PRODUCT_NAME, "ftServer"), 449284f5f9dSBjorn Helgaas }, 450284f5f9dSBjorn Helgaas }, 451fb9aa6f1SThomas Gleixner {} 452fb9aa6f1SThomas Gleixner }; 453fb9aa6f1SThomas Gleixner 4540df18ff3SYinghai Lu void __init dmi_check_pciprobe(void) 4550df18ff3SYinghai Lu { 4560df18ff3SYinghai Lu dmi_check_system(pciprobe_dmi_table); 4570df18ff3SYinghai Lu } 4580df18ff3SYinghai Lu 45949886cf4SBjorn Helgaas void pcibios_scan_root(int busnum) 460fb9aa6f1SThomas Gleixner { 461289a24a6SBjorn Helgaas struct pci_bus *bus; 462289a24a6SBjorn Helgaas struct pci_sysdata *sd; 463289a24a6SBjorn Helgaas LIST_HEAD(resources); 464289a24a6SBjorn Helgaas 465289a24a6SBjorn Helgaas sd = kzalloc(sizeof(*sd), GFP_KERNEL); 466289a24a6SBjorn Helgaas if (!sd) { 467289a24a6SBjorn Helgaas printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); 46849886cf4SBjorn Helgaas return; 469289a24a6SBjorn Helgaas } 470289a24a6SBjorn Helgaas sd->node = get_mp_bus_to_node(busnum); 471289a24a6SBjorn Helgaas x86_pci_root_bus_resources(busnum, &resources); 472289a24a6SBjorn Helgaas printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); 473289a24a6SBjorn Helgaas bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); 474289a24a6SBjorn Helgaas if (!bus) { 475289a24a6SBjorn Helgaas pci_free_resource_list(&resources); 476289a24a6SBjorn Helgaas kfree(sd); 477289a24a6SBjorn Helgaas } 478fb9aa6f1SThomas Gleixner } 479fb9aa6f1SThomas Gleixner 48044de3395SAlex Nixon void __init pcibios_set_cache_line_size(void) 481fb9aa6f1SThomas Gleixner { 482fb9aa6f1SThomas Gleixner struct cpuinfo_x86 *c = &boot_cpu_data; 483fb9aa6f1SThomas Gleixner 484fb9aa6f1SThomas Gleixner /* 48576b1a87bSDave Jones * Set PCI cacheline size to that of the CPU if the CPU has reported it. 48676b1a87bSDave Jones * (For older CPUs that don't support cpuid, we se it to 32 bytes 48776b1a87bSDave Jones * It's also good for 386/486s (which actually have 16) 488fb9aa6f1SThomas Gleixner * as quite a few PCI devices do not support smaller values. 489fb9aa6f1SThomas Gleixner */ 49076b1a87bSDave Jones if (c->x86_clflush_size > 0) { 49176b1a87bSDave Jones pci_dfl_cache_line_size = c->x86_clflush_size >> 2; 49276b1a87bSDave Jones printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n", 49376b1a87bSDave Jones pci_dfl_cache_line_size << 2); 49476b1a87bSDave Jones } else { 495ac1aa47bSJesse Barnes pci_dfl_cache_line_size = 32 >> 2; 49676b1a87bSDave Jones printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n"); 49776b1a87bSDave Jones } 49844de3395SAlex Nixon } 499fb9aa6f1SThomas Gleixner 50044de3395SAlex Nixon int __init pcibios_init(void) 50144de3395SAlex Nixon { 50244de3395SAlex Nixon if (!raw_pci_ops) { 50344de3395SAlex Nixon printk(KERN_WARNING "PCI: System does not support PCI\n"); 50444de3395SAlex Nixon return 0; 50544de3395SAlex Nixon } 50644de3395SAlex Nixon 50744de3395SAlex Nixon pcibios_set_cache_line_size(); 508fb9aa6f1SThomas Gleixner pcibios_resource_survey(); 509fb9aa6f1SThomas Gleixner 510fb9aa6f1SThomas Gleixner if (pci_bf_sort >= pci_force_bf) 511fb9aa6f1SThomas Gleixner pci_sort_breadthfirst(); 512fb9aa6f1SThomas Gleixner return 0; 513fb9aa6f1SThomas Gleixner } 514fb9aa6f1SThomas Gleixner 51515fa325bSMyron Stowe char * __init pcibios_setup(char *str) 516fb9aa6f1SThomas Gleixner { 517fb9aa6f1SThomas Gleixner if (!strcmp(str, "off")) { 518fb9aa6f1SThomas Gleixner pci_probe = 0; 519fb9aa6f1SThomas Gleixner return NULL; 520fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "bfsort")) { 521fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_bf; 522fb9aa6f1SThomas Gleixner return NULL; 523fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobfsort")) { 524fb9aa6f1SThomas Gleixner pci_bf_sort = pci_force_nobf; 525fb9aa6f1SThomas Gleixner return NULL; 526fb9aa6f1SThomas Gleixner } 527fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_BIOS 528fb9aa6f1SThomas Gleixner else if (!strcmp(str, "bios")) { 529fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_BIOS; 530fb9aa6f1SThomas Gleixner return NULL; 531fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "nobios")) { 532fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_BIOS; 533fb9aa6f1SThomas Gleixner return NULL; 534fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "biosirq")) { 535fb9aa6f1SThomas Gleixner pci_probe |= PCI_BIOS_IRQ_SCAN; 536fb9aa6f1SThomas Gleixner return NULL; 537fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "pirqaddr=", 9)) { 538fb9aa6f1SThomas Gleixner pirq_table_addr = simple_strtoul(str+9, NULL, 0); 539fb9aa6f1SThomas Gleixner return NULL; 540fb9aa6f1SThomas Gleixner } 541fb9aa6f1SThomas Gleixner #endif 542fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_DIRECT 543fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf1")) { 544fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS; 545fb9aa6f1SThomas Gleixner return NULL; 546fb9aa6f1SThomas Gleixner } 547fb9aa6f1SThomas Gleixner else if (!strcmp(str, "conf2")) { 548fb9aa6f1SThomas Gleixner pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS; 549fb9aa6f1SThomas Gleixner return NULL; 550fb9aa6f1SThomas Gleixner } 551fb9aa6f1SThomas Gleixner #endif 552fb9aa6f1SThomas Gleixner #ifdef CONFIG_PCI_MMCONFIG 553fb9aa6f1SThomas Gleixner else if (!strcmp(str, "nommconf")) { 554fb9aa6f1SThomas Gleixner pci_probe &= ~PCI_PROBE_MMCONF; 555fb9aa6f1SThomas Gleixner return NULL; 556fb9aa6f1SThomas Gleixner } 5575f0b2976SYinghai Lu else if (!strcmp(str, "check_enable_amd_mmconf")) { 5585f0b2976SYinghai Lu pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; 5595f0b2976SYinghai Lu return NULL; 5605f0b2976SYinghai Lu } 561fb9aa6f1SThomas Gleixner #endif 562fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noacpi")) { 563fb9aa6f1SThomas Gleixner acpi_noirq_set(); 564fb9aa6f1SThomas Gleixner return NULL; 565fb9aa6f1SThomas Gleixner } 566fb9aa6f1SThomas Gleixner else if (!strcmp(str, "noearly")) { 567fb9aa6f1SThomas Gleixner pci_probe |= PCI_PROBE_NOEARLY; 568fb9aa6f1SThomas Gleixner return NULL; 569fb9aa6f1SThomas Gleixner } 570fb9aa6f1SThomas Gleixner #ifndef CONFIG_X86_VISWS 571fb9aa6f1SThomas Gleixner else if (!strcmp(str, "usepirqmask")) { 572fb9aa6f1SThomas Gleixner pci_probe |= PCI_USE_PIRQ_MASK; 573fb9aa6f1SThomas Gleixner return NULL; 574fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "irqmask=", 8)) { 575fb9aa6f1SThomas Gleixner pcibios_irq_mask = simple_strtol(str+8, NULL, 0); 576fb9aa6f1SThomas Gleixner return NULL; 577fb9aa6f1SThomas Gleixner } else if (!strncmp(str, "lastbus=", 8)) { 578fb9aa6f1SThomas Gleixner pcibios_last_bus = simple_strtol(str+8, NULL, 0); 579fb9aa6f1SThomas Gleixner return NULL; 580fb9aa6f1SThomas Gleixner } 581fb9aa6f1SThomas Gleixner #endif 582fb9aa6f1SThomas Gleixner else if (!strcmp(str, "rom")) { 583fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ROMS; 584fb9aa6f1SThomas Gleixner return NULL; 585bb71ad88SGary Hade } else if (!strcmp(str, "norom")) { 586bb71ad88SGary Hade pci_probe |= PCI_NOASSIGN_ROMS; 587bb71ad88SGary Hade return NULL; 5887bd1c365SMike Habeck } else if (!strcmp(str, "nobar")) { 5897bd1c365SMike Habeck pci_probe |= PCI_NOASSIGN_BARS; 5907bd1c365SMike Habeck return NULL; 591fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "assign-busses")) { 592fb9aa6f1SThomas Gleixner pci_probe |= PCI_ASSIGN_ALL_BUSSES; 593fb9aa6f1SThomas Gleixner return NULL; 594236e946bSLinus Torvalds } else if (!strcmp(str, "use_crs")) { 595236e946bSLinus Torvalds pci_probe |= PCI_USE__CRS; 59662f420f8SGary Hade return NULL; 5977bc5e3f2SBjorn Helgaas } else if (!strcmp(str, "nocrs")) { 5987bc5e3f2SBjorn Helgaas pci_probe |= PCI_ROOT_NO_CRS; 5997bc5e3f2SBjorn Helgaas return NULL; 600e3f2baebSYinghai Lu } else if (!strcmp(str, "earlydump")) { 601e3f2baebSYinghai Lu pci_early_dump_regs = 1; 602e3f2baebSYinghai Lu return NULL; 603fb9aa6f1SThomas Gleixner } else if (!strcmp(str, "routeirq")) { 604fb9aa6f1SThomas Gleixner pci_routeirq = 1; 605fb9aa6f1SThomas Gleixner return NULL; 60613a6ddb0SYinghai Lu } else if (!strcmp(str, "skip_isa_align")) { 60713a6ddb0SYinghai Lu pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; 60813a6ddb0SYinghai Lu return NULL; 609a9322f64SStefan Assmann } else if (!strcmp(str, "noioapicquirk")) { 610a9322f64SStefan Assmann noioapicquirk = 1; 611a9322f64SStefan Assmann return NULL; 6129197979bSStefan Assmann } else if (!strcmp(str, "ioapicreroute")) { 6139197979bSStefan Assmann if (noioapicreroute != -1) 6149197979bSStefan Assmann noioapicreroute = 0; 6159197979bSStefan Assmann return NULL; 61641b9eb26SStefan Assmann } else if (!strcmp(str, "noioapicreroute")) { 61741b9eb26SStefan Assmann if (noioapicreroute != -1) 61841b9eb26SStefan Assmann noioapicreroute = 1; 61941b9eb26SStefan Assmann return NULL; 620fb9aa6f1SThomas Gleixner } 621fb9aa6f1SThomas Gleixner return str; 622fb9aa6f1SThomas Gleixner } 623fb9aa6f1SThomas Gleixner 624fb9aa6f1SThomas Gleixner unsigned int pcibios_assign_all_busses(void) 625fb9aa6f1SThomas Gleixner { 626fb9aa6f1SThomas Gleixner return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 627fb9aa6f1SThomas Gleixner } 628fb9aa6f1SThomas Gleixner 629f9a37be0SMatthew Garrett int pcibios_add_device(struct pci_dev *dev) 630f9a37be0SMatthew Garrett { 631f9a37be0SMatthew Garrett struct setup_data *data; 632f9a37be0SMatthew Garrett struct pci_setup_rom *rom; 633f9a37be0SMatthew Garrett u64 pa_data; 634f9a37be0SMatthew Garrett 635f9a37be0SMatthew Garrett pa_data = boot_params.hdr.setup_data; 636f9a37be0SMatthew Garrett while (pa_data) { 63765694c5aSMatt Fleming data = ioremap(pa_data, sizeof(*rom)); 63865694c5aSMatt Fleming if (!data) 63965694c5aSMatt Fleming return -ENOMEM; 640f9a37be0SMatthew Garrett 641f9a37be0SMatthew Garrett if (data->type == SETUP_PCI) { 642f9a37be0SMatthew Garrett rom = (struct pci_setup_rom *)data; 643f9a37be0SMatthew Garrett 644f9a37be0SMatthew Garrett if ((pci_domain_nr(dev->bus) == rom->segment) && 645f9a37be0SMatthew Garrett (dev->bus->number == rom->bus) && 646f9a37be0SMatthew Garrett (PCI_SLOT(dev->devfn) == rom->device) && 647f9a37be0SMatthew Garrett (PCI_FUNC(dev->devfn) == rom->function) && 648f9a37be0SMatthew Garrett (dev->vendor == rom->vendor) && 649f9a37be0SMatthew Garrett (dev->device == rom->devid)) { 650dbd3fc33SBjorn Helgaas dev->rom = pa_data + 651dbd3fc33SBjorn Helgaas offsetof(struct pci_setup_rom, romdata); 652f9a37be0SMatthew Garrett dev->romlen = rom->pcilen; 653f9a37be0SMatthew Garrett } 654f9a37be0SMatthew Garrett } 655f9a37be0SMatthew Garrett pa_data = data->next; 65665694c5aSMatt Fleming iounmap(data); 657f9a37be0SMatthew Garrett } 658f9a37be0SMatthew Garrett return 0; 659f9a37be0SMatthew Garrett } 660f9a37be0SMatthew Garrett 661fb9aa6f1SThomas Gleixner int pcibios_enable_device(struct pci_dev *dev, int mask) 662fb9aa6f1SThomas Gleixner { 663fb9aa6f1SThomas Gleixner int err; 664fb9aa6f1SThomas Gleixner 665b81d988cSBjorn Helgaas if ((err = pci_enable_resources(dev, mask)) < 0) 666fb9aa6f1SThomas Gleixner return err; 667fb9aa6f1SThomas Gleixner 66816cf0ebcSRafael J. Wysocki if (!pci_dev_msi_enabled(dev)) 669fb9aa6f1SThomas Gleixner return pcibios_enable_irq(dev); 670fb9aa6f1SThomas Gleixner return 0; 671fb9aa6f1SThomas Gleixner } 672fb9aa6f1SThomas Gleixner 673fb9aa6f1SThomas Gleixner void pcibios_disable_device (struct pci_dev *dev) 674fb9aa6f1SThomas Gleixner { 67516cf0ebcSRafael J. Wysocki if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq) 676fb9aa6f1SThomas Gleixner pcibios_disable_irq(dev); 677fb9aa6f1SThomas Gleixner } 678fb9aa6f1SThomas Gleixner 679642c92daSTaku Izumi int pci_ext_cfg_avail(void) 6800ef5f8f6SAndrew Patterson { 6810ef5f8f6SAndrew Patterson if (raw_pci_ext_ops) 6820ef5f8f6SAndrew Patterson return 1; 6830ef5f8f6SAndrew Patterson else 6840ef5f8f6SAndrew Patterson return 0; 6850ef5f8f6SAndrew Patterson } 6860ef5f8f6SAndrew Patterson 6872547089cSJesse Barnes /* 6882547089cSJesse Barnes * NUMA info for PCI busses 6892547089cSJesse Barnes * 6902547089cSJesse Barnes * Early arch code is responsible for filling in reasonable values here. 6912547089cSJesse Barnes * A node id of "-1" means "use current node". In other words, if a bus 6922547089cSJesse Barnes * has a -1 node id, it's not tightly coupled to any particular chunk 6932547089cSJesse Barnes * of memory (as is the case on some Nehalem systems). 6942547089cSJesse Barnes */ 6952547089cSJesse Barnes #ifdef CONFIG_NUMA 6962547089cSJesse Barnes 6972547089cSJesse Barnes #define BUS_NR 256 6982547089cSJesse Barnes 6992547089cSJesse Barnes #ifdef CONFIG_X86_64 7002547089cSJesse Barnes 7012547089cSJesse Barnes static int mp_bus_to_node[BUS_NR] = { 7022547089cSJesse Barnes [0 ... BUS_NR - 1] = -1 7032547089cSJesse Barnes }; 7042547089cSJesse Barnes 7052547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node) 7062547089cSJesse Barnes { 7072547089cSJesse Barnes if (busnum >= 0 && busnum < BUS_NR) 7082547089cSJesse Barnes mp_bus_to_node[busnum] = node; 7092547089cSJesse Barnes } 7102547089cSJesse Barnes 7112547089cSJesse Barnes int get_mp_bus_to_node(int busnum) 7122547089cSJesse Barnes { 7132547089cSJesse Barnes int node = -1; 7142547089cSJesse Barnes 7152547089cSJesse Barnes if (busnum < 0 || busnum > (BUS_NR - 1)) 7162547089cSJesse Barnes return node; 7172547089cSJesse Barnes 7182547089cSJesse Barnes node = mp_bus_to_node[busnum]; 7192547089cSJesse Barnes 7202547089cSJesse Barnes /* 7212547089cSJesse Barnes * let numa_node_id to decide it later in dma_alloc_pages 7222547089cSJesse Barnes * if there is no ram on that node 7232547089cSJesse Barnes */ 7242547089cSJesse Barnes if (node != -1 && !node_online(node)) 7252547089cSJesse Barnes node = -1; 7262547089cSJesse Barnes 7272547089cSJesse Barnes return node; 7282547089cSJesse Barnes } 7292547089cSJesse Barnes 7302547089cSJesse Barnes #else /* CONFIG_X86_32 */ 7312547089cSJesse Barnes 73276baeebfSJesse Barnes static int mp_bus_to_node[BUS_NR] = { 7332547089cSJesse Barnes [0 ... BUS_NR - 1] = -1 7342547089cSJesse Barnes }; 7352547089cSJesse Barnes 7362547089cSJesse Barnes void set_mp_bus_to_node(int busnum, int node) 7372547089cSJesse Barnes { 7382547089cSJesse Barnes if (busnum >= 0 && busnum < BUS_NR) 7392547089cSJesse Barnes mp_bus_to_node[busnum] = (unsigned char) node; 7402547089cSJesse Barnes } 7412547089cSJesse Barnes 7422547089cSJesse Barnes int get_mp_bus_to_node(int busnum) 7432547089cSJesse Barnes { 7442547089cSJesse Barnes int node; 7452547089cSJesse Barnes 7462547089cSJesse Barnes if (busnum < 0 || busnum > (BUS_NR - 1)) 7472547089cSJesse Barnes return 0; 7482547089cSJesse Barnes node = mp_bus_to_node[busnum]; 7492547089cSJesse Barnes return node; 7502547089cSJesse Barnes } 7512547089cSJesse Barnes 7522547089cSJesse Barnes #endif /* CONFIG_X86_32 */ 7532547089cSJesse Barnes 7542547089cSJesse Barnes #endif /* CONFIG_NUMA */ 755