Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Low-Level PCI Support for PC |
| 3 | * |
| 4 | * (c) 1999--2000 Martin Mares <mj@ucw.cz> |
| 5 | */ |
| 6 | |
| 7 | #include <linux/sched.h> |
| 8 | #include <linux/pci.h> |
Jiang Liu | 8901650 | 2013-04-12 05:44:23 +0000 | [diff] [blame] | 9 | #include <linux/pci-acpi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/ioport.h> |
| 11 | #include <linux/init.h> |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 12 | #include <linux/dmi.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | #include <asm/acpi.h> |
| 16 | #include <asm/segment.h> |
| 17 | #include <asm/io.h> |
| 18 | #include <asm/smp.h> |
Jaswinder Singh Rajput | 8248771 | 2008-12-27 18:32:28 +0530 | [diff] [blame] | 19 | #include <asm/pci_x86.h> |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 20 | #include <asm/setup.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | |
| 23 | PCI_PROBE_MMCONF; |
| 24 | |
Adrian Bunk | 2b290da | 2006-11-16 13:16:23 +0100 | [diff] [blame] | 25 | static int pci_bf_sort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | int pci_routeirq; |
Stefan Assmann | a9322f6 | 2008-06-11 16:35:14 +0200 | [diff] [blame] | 27 | int noioapicquirk; |
Stefan Assmann | 41b9eb2 | 2008-07-15 13:48:55 +0200 | [diff] [blame] | 28 | #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS |
| 29 | int noioapicreroute = 0; |
| 30 | #else |
Stefan Assmann | 9197979 | 2008-06-11 16:35:15 +0200 | [diff] [blame] | 31 | int noioapicreroute = 1; |
Stefan Assmann | 41b9eb2 | 2008-07-15 13:48:55 +0200 | [diff] [blame] | 32 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | int pcibios_last_bus = -1; |
jayalk@intworks.biz | 120bb42 | 2005-03-21 20:20:42 -0800 | [diff] [blame] | 34 | unsigned long pirq_table_addr; |
Jan Beulich | 72da0b0 | 2011-09-15 08:58:51 +0100 | [diff] [blame] | 35 | const struct pci_raw_ops *__read_mostly raw_pci_ops; |
| 36 | const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 37 | |
| 38 | int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, |
| 39 | int reg, int len, u32 *val) |
| 40 | { |
Matthew Wilcox | beef312 | 2008-07-11 15:21:17 -0600 | [diff] [blame] | 41 | if (domain == 0 && reg < 256 && raw_pci_ops) |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 42 | return raw_pci_ops->read(domain, bus, devfn, reg, len, val); |
| 43 | if (raw_pci_ext_ops) |
| 44 | return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); |
| 45 | return -EINVAL; |
| 46 | } |
| 47 | |
| 48 | int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, |
| 49 | int reg, int len, u32 val) |
| 50 | { |
Matthew Wilcox | beef312 | 2008-07-11 15:21:17 -0600 | [diff] [blame] | 51 | if (domain == 0 && reg < 256 && raw_pci_ops) |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 52 | return raw_pci_ops->write(domain, bus, devfn, reg, len, val); |
| 53 | if (raw_pci_ext_ops) |
| 54 | return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); |
| 55 | return -EINVAL; |
| 56 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) |
| 59 | { |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 60 | return raw_pci_read(pci_domain_nr(bus), bus->number, |
Jeff Garzik | a79e419 | 2007-10-11 16:58:30 -0400 | [diff] [blame] | 61 | devfn, where, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) |
| 65 | { |
Matthew Wilcox | b6ce068 | 2008-02-10 09:45:28 -0500 | [diff] [blame] | 66 | return raw_pci_write(pci_domain_nr(bus), bus->number, |
Jeff Garzik | a79e419 | 2007-10-11 16:58:30 -0400 | [diff] [blame] | 67 | devfn, where, size, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | struct pci_ops pci_root_ops = { |
| 71 | .read = pci_read, |
| 72 | .write = pci_write, |
| 73 | }; |
| 74 | |
| 75 | /* |
Thomas Gleixner | df65c1b | 2017-03-16 22:50:07 +0100 | [diff] [blame] | 76 | * This interrupt-safe spinlock protects all accesses to PCI configuration |
| 77 | * space, except for the mmconfig (ECAM) based operations. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | */ |
Thomas Gleixner | d19f61f | 2010-02-17 14:35:25 +0000 | [diff] [blame] | 79 | DEFINE_RAW_SPINLOCK(pci_config_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 81 | static int __init can_skip_ioresource_align(const struct dmi_system_id *d) |
Yinghai Lu | 13a6ddb | 2008-03-27 01:31:18 -0700 | [diff] [blame] | 82 | { |
| 83 | pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; |
| 84 | printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); |
| 85 | return 0; |
| 86 | } |
| 87 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 88 | static const struct dmi_system_id can_skip_pciprobe_dmi_table[] __initconst = { |
Yinghai Lu | 13a6ddb | 2008-03-27 01:31:18 -0700 | [diff] [blame] | 89 | /* |
| 90 | * Systems where PCI IO resource ISA alignment can be skipped |
| 91 | * when the ISA enable bit in the bridge control is not set |
| 92 | */ |
| 93 | { |
| 94 | .callback = can_skip_ioresource_align, |
| 95 | .ident = "IBM System x3800", |
| 96 | .matches = { |
| 97 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), |
| 98 | DMI_MATCH(DMI_PRODUCT_NAME, "x3800"), |
| 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | .callback = can_skip_ioresource_align, |
| 103 | .ident = "IBM System x3850", |
| 104 | .matches = { |
| 105 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), |
| 106 | DMI_MATCH(DMI_PRODUCT_NAME, "x3850"), |
| 107 | }, |
| 108 | }, |
| 109 | { |
| 110 | .callback = can_skip_ioresource_align, |
| 111 | .ident = "IBM System x3950", |
| 112 | .matches = { |
| 113 | DMI_MATCH(DMI_SYS_VENDOR, "IBM"), |
| 114 | DMI_MATCH(DMI_PRODUCT_NAME, "x3950"), |
| 115 | }, |
| 116 | }, |
| 117 | {} |
| 118 | }; |
| 119 | |
| 120 | void __init dmi_check_skip_isa_align(void) |
| 121 | { |
| 122 | dmi_check_system(can_skip_pciprobe_dmi_table); |
| 123 | } |
| 124 | |
Greg Kroah-Hartman | a18e369 | 2012-12-21 14:02:53 -0800 | [diff] [blame] | 125 | static void pcibios_fixup_device_resources(struct pci_dev *dev) |
Gary Hade | bb71ad8 | 2008-05-12 13:57:46 -0700 | [diff] [blame] | 126 | { |
| 127 | struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE]; |
Mike Habeck | 7bd1c36 | 2010-05-12 11:14:32 -0700 | [diff] [blame] | 128 | struct resource *bar_r; |
| 129 | int bar; |
| 130 | |
| 131 | if (pci_probe & PCI_NOASSIGN_BARS) { |
| 132 | /* |
| 133 | * If the BIOS did not assign the BAR, zero out the |
Andrea Gelmini | 386ed2ab | 2016-06-10 19:05:09 -0500 | [diff] [blame] | 134 | * resource so the kernel doesn't attempt to assign |
Mike Habeck | 7bd1c36 | 2010-05-12 11:14:32 -0700 | [diff] [blame] | 135 | * it later on in pci_assign_unassigned_resources |
| 136 | */ |
| 137 | for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) { |
| 138 | bar_r = &dev->resource[bar]; |
| 139 | if (bar_r->start == 0 && bar_r->end != 0) { |
| 140 | bar_r->flags = 0; |
| 141 | bar_r->end = 0; |
| 142 | } |
| 143 | } |
| 144 | } |
Gary Hade | bb71ad8 | 2008-05-12 13:57:46 -0700 | [diff] [blame] | 145 | |
| 146 | if (pci_probe & PCI_NOASSIGN_ROMS) { |
| 147 | if (rom_r->parent) |
| 148 | return; |
| 149 | if (rom_r->start) { |
| 150 | /* we deal with BIOS assigned ROM later */ |
| 151 | return; |
| 152 | } |
| 153 | rom_r->start = rom_r->end = rom_r->flags = 0; |
| 154 | } |
| 155 | } |
| 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | /* |
| 158 | * Called after each bus is probed, but before its children |
| 159 | * are examined. |
| 160 | */ |
| 161 | |
Greg Kroah-Hartman | a18e369 | 2012-12-21 14:02:53 -0800 | [diff] [blame] | 162 | void pcibios_fixup_bus(struct pci_bus *b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | { |
Gary Hade | bb71ad8 | 2008-05-12 13:57:46 -0700 | [diff] [blame] | 164 | struct pci_dev *dev; |
| 165 | |
Bjorn Helgaas | 237865f | 2015-09-15 13:18:04 -0500 | [diff] [blame] | 166 | pci_read_bridge_bases(b); |
Gary Hade | bb71ad8 | 2008-05-12 13:57:46 -0700 | [diff] [blame] | 167 | list_for_each_entry(dev, &b->devices, bus_list) |
| 168 | pcibios_fixup_device_resources(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Jiang Liu | 8901650 | 2013-04-12 05:44:23 +0000 | [diff] [blame] | 171 | void pcibios_add_bus(struct pci_bus *bus) |
| 172 | { |
| 173 | acpi_pci_add_bus(bus); |
| 174 | } |
| 175 | |
| 176 | void pcibios_remove_bus(struct pci_bus *bus) |
| 177 | { |
| 178 | acpi_pci_remove_bus(bus); |
| 179 | } |
| 180 | |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 181 | /* |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 182 | * Only use DMI information to set this if nothing was passed |
| 183 | * on the kernel command line (which was parsed earlier). |
| 184 | */ |
| 185 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 186 | static int __init set_bf_sort(const struct dmi_system_id *d) |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 187 | { |
| 188 | if (pci_bf_sort == pci_bf_sort_default) { |
| 189 | pci_bf_sort = pci_dmi_bf; |
| 190 | printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident); |
| 191 | } |
| 192 | return 0; |
| 193 | } |
| 194 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 195 | static void __init read_dmi_type_b1(const struct dmi_header *dm, |
| 196 | void *private_data) |
Narendra_K@Dell.com | 6e8af08 | 2010-12-14 09:57:12 -0800 | [diff] [blame] | 197 | { |
Jean Delvare | f5ab3b7 | 2017-06-02 16:13:11 +0200 | [diff] [blame] | 198 | u8 *data = (u8 *)dm + 4; |
Narendra_K@Dell.com | 6e8af08 | 2010-12-14 09:57:12 -0800 | [diff] [blame] | 199 | |
| 200 | if (dm->type != 0xB1) |
| 201 | return; |
Jean Delvare | f5ab3b7 | 2017-06-02 16:13:11 +0200 | [diff] [blame] | 202 | if ((((*(u32 *)data) >> 9) & 0x03) == 0x01) |
| 203 | set_bf_sort((const struct dmi_system_id *)private_data); |
Narendra_K@Dell.com | 6e8af08 | 2010-12-14 09:57:12 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 206 | static int __init find_sort_method(const struct dmi_system_id *d) |
Narendra_K@Dell.com | 6e8af08 | 2010-12-14 09:57:12 -0800 | [diff] [blame] | 207 | { |
Jean Delvare | f5ab3b7 | 2017-06-02 16:13:11 +0200 | [diff] [blame] | 208 | dmi_walk(read_dmi_type_b1, (void *)d); |
| 209 | return 0; |
Narendra_K@Dell.com | 6e8af08 | 2010-12-14 09:57:12 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 212 | /* |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 213 | * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus) |
| 214 | */ |
| 215 | #ifdef __i386__ |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 216 | static int __init assign_all_busses(const struct dmi_system_id *d) |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 217 | { |
| 218 | pci_probe |= PCI_ASSIGN_ALL_BUSSES; |
| 219 | printk(KERN_INFO "%s detected: enabling PCI bus# renumbering" |
| 220 | " (pci=assign-busses)\n", d->ident); |
| 221 | return 0; |
| 222 | } |
| 223 | #endif |
| 224 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 225 | static int __init set_scan_all(const struct dmi_system_id *d) |
Bjorn Helgaas | 284f5f9 | 2012-04-30 15:21:02 -0600 | [diff] [blame] | 226 | { |
| 227 | printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n", |
| 228 | d->ident); |
| 229 | pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS); |
| 230 | return 0; |
| 231 | } |
| 232 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 233 | static const struct dmi_system_id pciprobe_dmi_table[] __initconst = { |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 234 | #ifdef __i386__ |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 235 | /* |
| 236 | * Laptops which need pci=assign-busses to see Cardbus cards |
| 237 | */ |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 238 | { |
| 239 | .callback = assign_all_busses, |
| 240 | .ident = "Samsung X20 Laptop", |
| 241 | .matches = { |
| 242 | DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"), |
| 243 | DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"), |
| 244 | }, |
| 245 | }, |
| 246 | #endif /* __i386__ */ |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 247 | { |
| 248 | .callback = set_bf_sort, |
| 249 | .ident = "Dell PowerEdge 1950", |
| 250 | .matches = { |
| 251 | DMI_MATCH(DMI_SYS_VENDOR, "Dell"), |
| 252 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"), |
| 253 | }, |
| 254 | }, |
| 255 | { |
| 256 | .callback = set_bf_sort, |
| 257 | .ident = "Dell PowerEdge 1955", |
| 258 | .matches = { |
| 259 | DMI_MATCH(DMI_SYS_VENDOR, "Dell"), |
| 260 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"), |
| 261 | }, |
| 262 | }, |
| 263 | { |
| 264 | .callback = set_bf_sort, |
| 265 | .ident = "Dell PowerEdge 2900", |
| 266 | .matches = { |
| 267 | DMI_MATCH(DMI_SYS_VENDOR, "Dell"), |
| 268 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"), |
| 269 | }, |
| 270 | }, |
| 271 | { |
| 272 | .callback = set_bf_sort, |
| 273 | .ident = "Dell PowerEdge 2950", |
| 274 | .matches = { |
| 275 | DMI_MATCH(DMI_SYS_VENDOR, "Dell"), |
| 276 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"), |
| 277 | }, |
| 278 | }, |
Andy Gospodarek | f52383d | 2007-02-05 16:36:10 -0800 | [diff] [blame] | 279 | { |
| 280 | .callback = set_bf_sort, |
Matt Domsch | f7a9dae | 2007-03-23 23:58:07 -0500 | [diff] [blame] | 281 | .ident = "Dell PowerEdge R900", |
| 282 | .matches = { |
| 283 | DMI_MATCH(DMI_SYS_VENDOR, "Dell"), |
| 284 | DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"), |
| 285 | }, |
| 286 | }, |
| 287 | { |
Narendra_K@Dell.com | 9b373ed | 2011-03-18 10:22:14 -0700 | [diff] [blame] | 288 | .callback = find_sort_method, |
| 289 | .ident = "Dell System", |
| 290 | .matches = { |
| 291 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), |
| 292 | }, |
| 293 | }, |
| 294 | { |
Matt Domsch | f7a9dae | 2007-03-23 23:58:07 -0500 | [diff] [blame] | 295 | .callback = set_bf_sort, |
Andy Gospodarek | f52383d | 2007-02-05 16:36:10 -0800 | [diff] [blame] | 296 | .ident = "HP ProLiant BL20p G3", |
| 297 | .matches = { |
| 298 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 299 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"), |
| 300 | }, |
| 301 | }, |
| 302 | { |
| 303 | .callback = set_bf_sort, |
| 304 | .ident = "HP ProLiant BL20p G4", |
| 305 | .matches = { |
| 306 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 307 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"), |
| 308 | }, |
| 309 | }, |
| 310 | { |
| 311 | .callback = set_bf_sort, |
| 312 | .ident = "HP ProLiant BL30p G1", |
| 313 | .matches = { |
| 314 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 315 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"), |
| 316 | }, |
| 317 | }, |
| 318 | { |
| 319 | .callback = set_bf_sort, |
| 320 | .ident = "HP ProLiant BL25p G1", |
| 321 | .matches = { |
| 322 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 323 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"), |
| 324 | }, |
| 325 | }, |
| 326 | { |
| 327 | .callback = set_bf_sort, |
| 328 | .ident = "HP ProLiant BL35p G1", |
| 329 | .matches = { |
| 330 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 331 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"), |
| 332 | }, |
| 333 | }, |
| 334 | { |
| 335 | .callback = set_bf_sort, |
| 336 | .ident = "HP ProLiant BL45p G1", |
| 337 | .matches = { |
| 338 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 339 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"), |
| 340 | }, |
| 341 | }, |
| 342 | { |
| 343 | .callback = set_bf_sort, |
| 344 | .ident = "HP ProLiant BL45p G2", |
| 345 | .matches = { |
| 346 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 347 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"), |
| 348 | }, |
| 349 | }, |
| 350 | { |
| 351 | .callback = set_bf_sort, |
| 352 | .ident = "HP ProLiant BL460c G1", |
| 353 | .matches = { |
| 354 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 355 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"), |
| 356 | }, |
| 357 | }, |
| 358 | { |
| 359 | .callback = set_bf_sort, |
| 360 | .ident = "HP ProLiant BL465c G1", |
| 361 | .matches = { |
| 362 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 363 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"), |
| 364 | }, |
| 365 | }, |
| 366 | { |
| 367 | .callback = set_bf_sort, |
| 368 | .ident = "HP ProLiant BL480c G1", |
| 369 | .matches = { |
| 370 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 371 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"), |
| 372 | }, |
| 373 | }, |
| 374 | { |
| 375 | .callback = set_bf_sort, |
| 376 | .ident = "HP ProLiant BL685c G1", |
| 377 | .matches = { |
| 378 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 379 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"), |
| 380 | }, |
| 381 | }, |
Michal Schmidt | 8f8ae1a | 2007-10-17 18:04:35 +0200 | [diff] [blame] | 382 | { |
| 383 | .callback = set_bf_sort, |
Tony Camuso | 8d64c781 | 2008-05-15 14:40:14 -0400 | [diff] [blame] | 384 | .ident = "HP ProLiant DL360", |
Michal Schmidt | 8f8ae1a | 2007-10-17 18:04:35 +0200 | [diff] [blame] | 385 | .matches = { |
| 386 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
Tony Camuso | 8d64c781 | 2008-05-15 14:40:14 -0400 | [diff] [blame] | 387 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"), |
Michal Schmidt | 8f8ae1a | 2007-10-17 18:04:35 +0200 | [diff] [blame] | 388 | }, |
| 389 | }, |
| 390 | { |
| 391 | .callback = set_bf_sort, |
Tony Camuso | 8d64c781 | 2008-05-15 14:40:14 -0400 | [diff] [blame] | 392 | .ident = "HP ProLiant DL380", |
Michal Schmidt | 8f8ae1a | 2007-10-17 18:04:35 +0200 | [diff] [blame] | 393 | .matches = { |
| 394 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
Tony Camuso | 8d64c781 | 2008-05-15 14:40:14 -0400 | [diff] [blame] | 395 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"), |
Michal Schmidt | 8f8ae1a | 2007-10-17 18:04:35 +0200 | [diff] [blame] | 396 | }, |
| 397 | }, |
Juha Laiho | 5b1ea82 | 2007-09-13 21:21:34 +0300 | [diff] [blame] | 398 | #ifdef __i386__ |
| 399 | { |
| 400 | .callback = assign_all_busses, |
| 401 | .ident = "Compaq EVO N800c", |
| 402 | .matches = { |
| 403 | DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), |
| 404 | DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"), |
| 405 | }, |
| 406 | }, |
| 407 | #endif |
Michal Schmidt | c82bc5a | 2007-11-26 20:42:19 +0100 | [diff] [blame] | 408 | { |
| 409 | .callback = set_bf_sort, |
Jesse Barnes | 739db07 | 2008-07-07 09:55:26 -0700 | [diff] [blame] | 410 | .ident = "HP ProLiant DL385 G2", |
Michal Schmidt | c82bc5a | 2007-11-26 20:42:19 +0100 | [diff] [blame] | 411 | .matches = { |
| 412 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
Jesse Barnes | 739db07 | 2008-07-07 09:55:26 -0700 | [diff] [blame] | 413 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"), |
Michal Schmidt | c82bc5a | 2007-11-26 20:42:19 +0100 | [diff] [blame] | 414 | }, |
| 415 | }, |
| 416 | { |
| 417 | .callback = set_bf_sort, |
Jesse Barnes | 739db07 | 2008-07-07 09:55:26 -0700 | [diff] [blame] | 418 | .ident = "HP ProLiant DL585 G2", |
Michal Schmidt | c82bc5a | 2007-11-26 20:42:19 +0100 | [diff] [blame] | 419 | .matches = { |
| 420 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
Jesse Barnes | 739db07 | 2008-07-07 09:55:26 -0700 | [diff] [blame] | 421 | DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"), |
Michal Schmidt | c82bc5a | 2007-11-26 20:42:19 +0100 | [diff] [blame] | 422 | }, |
| 423 | }, |
Bjorn Helgaas | 284f5f9 | 2012-04-30 15:21:02 -0600 | [diff] [blame] | 424 | { |
| 425 | .callback = set_scan_all, |
| 426 | .ident = "Stratus/NEC ftServer", |
| 427 | .matches = { |
Myron Stowe | 1278998 | 2012-12-26 10:39:23 -0700 | [diff] [blame] | 428 | DMI_MATCH(DMI_SYS_VENDOR, "Stratus"), |
| 429 | DMI_MATCH(DMI_PRODUCT_NAME, "ftServer"), |
Bjorn Helgaas | 284f5f9 | 2012-04-30 15:21:02 -0600 | [diff] [blame] | 430 | }, |
| 431 | }, |
Charlotte Richardson | 51ac3d2 | 2015-02-02 09:36:23 -0600 | [diff] [blame] | 432 | { |
| 433 | .callback = set_scan_all, |
| 434 | .ident = "Stratus/NEC ftServer", |
| 435 | .matches = { |
| 436 | DMI_MATCH(DMI_SYS_VENDOR, "NEC"), |
| 437 | DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R32"), |
| 438 | }, |
| 439 | }, |
| 440 | { |
| 441 | .callback = set_scan_all, |
| 442 | .ident = "Stratus/NEC ftServer", |
| 443 | .matches = { |
| 444 | DMI_MATCH(DMI_SYS_VENDOR, "NEC"), |
| 445 | DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R31"), |
| 446 | }, |
| 447 | }, |
Bernhard Kaindl | 8c4b2cf | 2006-02-18 01:36:55 -0800 | [diff] [blame] | 448 | {} |
| 449 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Yinghai Lu | 0df18ff | 2008-04-14 15:40:37 -0700 | [diff] [blame] | 451 | void __init dmi_check_pciprobe(void) |
| 452 | { |
| 453 | dmi_check_system(pciprobe_dmi_table); |
| 454 | } |
| 455 | |
Bjorn Helgaas | 49886cf | 2014-01-28 16:40:36 -0700 | [diff] [blame] | 456 | void pcibios_scan_root(int busnum) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | { |
Bjorn Helgaas | 289a24a | 2014-01-24 11:52:25 -0700 | [diff] [blame] | 458 | struct pci_bus *bus; |
| 459 | struct pci_sysdata *sd; |
| 460 | LIST_HEAD(resources); |
| 461 | |
| 462 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); |
| 463 | if (!sd) { |
| 464 | printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); |
Bjorn Helgaas | 49886cf | 2014-01-28 16:40:36 -0700 | [diff] [blame] | 465 | return; |
Bjorn Helgaas | 289a24a | 2014-01-24 11:52:25 -0700 | [diff] [blame] | 466 | } |
Bjorn Helgaas | 6616dbd | 2014-01-24 11:54:51 -0700 | [diff] [blame] | 467 | sd->node = x86_pci_root_bus_node(busnum); |
Bjorn Helgaas | 289a24a | 2014-01-24 11:52:25 -0700 | [diff] [blame] | 468 | x86_pci_root_bus_resources(busnum, &resources); |
| 469 | printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); |
| 470 | bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); |
| 471 | if (!bus) { |
| 472 | pci_free_resource_list(&resources); |
| 473 | kfree(sd); |
Yijing Wang | b97ea28 | 2015-03-16 11:18:56 +0800 | [diff] [blame] | 474 | return; |
Bjorn Helgaas | 289a24a | 2014-01-24 11:52:25 -0700 | [diff] [blame] | 475 | } |
Yijing Wang | b97ea28 | 2015-03-16 11:18:56 +0800 | [diff] [blame] | 476 | pci_bus_add_devices(bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
Yinghai Lu | c57ca65 | 2012-04-02 18:31:54 -0700 | [diff] [blame] | 478 | |
Alex Nixon | 44de339 | 2010-03-18 14:28:12 -0400 | [diff] [blame] | 479 | void __init pcibios_set_cache_line_size(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | { |
| 481 | struct cpuinfo_x86 *c = &boot_cpu_data; |
| 482 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | /* |
Dave Jones | 76b1a87 | 2009-10-14 16:31:39 -0400 | [diff] [blame] | 484 | * Set PCI cacheline size to that of the CPU if the CPU has reported it. |
| 485 | * (For older CPUs that don't support cpuid, we se it to 32 bytes |
| 486 | * It's also good for 386/486s (which actually have 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | * as quite a few PCI devices do not support smaller values. |
| 488 | */ |
Dave Jones | 76b1a87 | 2009-10-14 16:31:39 -0400 | [diff] [blame] | 489 | if (c->x86_clflush_size > 0) { |
| 490 | pci_dfl_cache_line_size = c->x86_clflush_size >> 2; |
| 491 | printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n", |
| 492 | pci_dfl_cache_line_size << 2); |
| 493 | } else { |
| 494 | pci_dfl_cache_line_size = 32 >> 2; |
| 495 | printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n"); |
| 496 | } |
Alex Nixon | 44de339 | 2010-03-18 14:28:12 -0400 | [diff] [blame] | 497 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | |
Alex Nixon | 44de339 | 2010-03-18 14:28:12 -0400 | [diff] [blame] | 499 | int __init pcibios_init(void) |
| 500 | { |
Adrian-Ken Rueegsegger | 35a6ae0 | 2016-03-23 11:34:29 +0100 | [diff] [blame] | 501 | if (!raw_pci_ops && !raw_pci_ext_ops) { |
Alex Nixon | 44de339 | 2010-03-18 14:28:12 -0400 | [diff] [blame] | 502 | printk(KERN_WARNING "PCI: System does not support PCI\n"); |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | pcibios_set_cache_line_size(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | pcibios_resource_survey(); |
| 508 | |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 509 | if (pci_bf_sort >= pci_force_bf) |
| 510 | pci_sort_breadthfirst(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | return 0; |
| 512 | } |
| 513 | |
Mathias Krause | 4ac9cbf | 2014-08-25 23:26:35 +0200 | [diff] [blame] | 514 | char *__init pcibios_setup(char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { |
| 516 | if (!strcmp(str, "off")) { |
| 517 | pci_probe = 0; |
| 518 | return NULL; |
Matt Domsch | 6b4b78fe | 2006-09-29 15:23:23 -0500 | [diff] [blame] | 519 | } else if (!strcmp(str, "bfsort")) { |
| 520 | pci_bf_sort = pci_force_bf; |
| 521 | return NULL; |
| 522 | } else if (!strcmp(str, "nobfsort")) { |
| 523 | pci_bf_sort = pci_force_nobf; |
| 524 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } |
| 526 | #ifdef CONFIG_PCI_BIOS |
| 527 | else if (!strcmp(str, "bios")) { |
| 528 | pci_probe = PCI_PROBE_BIOS; |
| 529 | return NULL; |
| 530 | } else if (!strcmp(str, "nobios")) { |
| 531 | pci_probe &= ~PCI_PROBE_BIOS; |
| 532 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | } else if (!strcmp(str, "biosirq")) { |
| 534 | pci_probe |= PCI_BIOS_IRQ_SCAN; |
| 535 | return NULL; |
jayalk@intworks.biz | 120bb42 | 2005-03-21 20:20:42 -0800 | [diff] [blame] | 536 | } else if (!strncmp(str, "pirqaddr=", 9)) { |
| 537 | pirq_table_addr = simple_strtoul(str+9, NULL, 0); |
| 538 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | } |
| 540 | #endif |
| 541 | #ifdef CONFIG_PCI_DIRECT |
| 542 | else if (!strcmp(str, "conf1")) { |
| 543 | pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS; |
| 544 | return NULL; |
| 545 | } |
| 546 | else if (!strcmp(str, "conf2")) { |
| 547 | pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS; |
| 548 | return NULL; |
| 549 | } |
| 550 | #endif |
| 551 | #ifdef CONFIG_PCI_MMCONFIG |
| 552 | else if (!strcmp(str, "nommconf")) { |
| 553 | pci_probe &= ~PCI_PROBE_MMCONF; |
| 554 | return NULL; |
| 555 | } |
Yinghai Lu | 5f0b297 | 2008-04-14 16:08:25 -0700 | [diff] [blame] | 556 | else if (!strcmp(str, "check_enable_amd_mmconf")) { |
| 557 | pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; |
| 558 | return NULL; |
| 559 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | #endif |
| 561 | else if (!strcmp(str, "noacpi")) { |
| 562 | acpi_noirq_set(); |
| 563 | return NULL; |
| 564 | } |
Andi Kleen | 0637a70 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 565 | else if (!strcmp(str, "noearly")) { |
| 566 | pci_probe |= PCI_PROBE_NOEARLY; |
| 567 | return NULL; |
| 568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | else if (!strcmp(str, "usepirqmask")) { |
| 570 | pci_probe |= PCI_USE_PIRQ_MASK; |
| 571 | return NULL; |
| 572 | } else if (!strncmp(str, "irqmask=", 8)) { |
| 573 | pcibios_irq_mask = simple_strtol(str+8, NULL, 0); |
| 574 | return NULL; |
| 575 | } else if (!strncmp(str, "lastbus=", 8)) { |
| 576 | pcibios_last_bus = simple_strtol(str+8, NULL, 0); |
| 577 | return NULL; |
H. Peter Anvin | c5f9ee3 | 2014-02-25 12:05:34 -0800 | [diff] [blame] | 578 | } else if (!strcmp(str, "rom")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | pci_probe |= PCI_ASSIGN_ROMS; |
| 580 | return NULL; |
Gary Hade | bb71ad8 | 2008-05-12 13:57:46 -0700 | [diff] [blame] | 581 | } else if (!strcmp(str, "norom")) { |
| 582 | pci_probe |= PCI_NOASSIGN_ROMS; |
| 583 | return NULL; |
Mike Habeck | 7bd1c36 | 2010-05-12 11:14:32 -0700 | [diff] [blame] | 584 | } else if (!strcmp(str, "nobar")) { |
| 585 | pci_probe |= PCI_NOASSIGN_BARS; |
| 586 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | } else if (!strcmp(str, "assign-busses")) { |
| 588 | pci_probe |= PCI_ASSIGN_ALL_BUSSES; |
| 589 | return NULL; |
Linus Torvalds | 236e946 | 2009-06-24 16:23:03 -0700 | [diff] [blame] | 590 | } else if (!strcmp(str, "use_crs")) { |
| 591 | pci_probe |= PCI_USE__CRS; |
Gary Hade | 62f420f | 2007-10-03 15:56:51 -0700 | [diff] [blame] | 592 | return NULL; |
Bjorn Helgaas | 7bc5e3f | 2010-02-23 10:24:41 -0700 | [diff] [blame] | 593 | } else if (!strcmp(str, "nocrs")) { |
| 594 | pci_probe |= PCI_ROOT_NO_CRS; |
| 595 | return NULL; |
=?UTF-8?q?Christian=20K=C3=B6nig?= | f32ab75 | 2018-01-11 14:23:29 +0100 | [diff] [blame] | 596 | #ifdef CONFIG_PHYS_ADDR_T_64BIT |
| 597 | } else if (!strcmp(str, "big_root_window")) { |
| 598 | pci_probe |= PCI_BIG_ROOT_WINDOW; |
| 599 | return NULL; |
| 600 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | } else if (!strcmp(str, "routeirq")) { |
| 602 | pci_routeirq = 1; |
| 603 | return NULL; |
Yinghai Lu | 13a6ddb | 2008-03-27 01:31:18 -0700 | [diff] [blame] | 604 | } else if (!strcmp(str, "skip_isa_align")) { |
| 605 | pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; |
| 606 | return NULL; |
Stefan Assmann | a9322f6 | 2008-06-11 16:35:14 +0200 | [diff] [blame] | 607 | } else if (!strcmp(str, "noioapicquirk")) { |
| 608 | noioapicquirk = 1; |
| 609 | return NULL; |
Stefan Assmann | 9197979 | 2008-06-11 16:35:15 +0200 | [diff] [blame] | 610 | } else if (!strcmp(str, "ioapicreroute")) { |
| 611 | if (noioapicreroute != -1) |
| 612 | noioapicreroute = 0; |
| 613 | return NULL; |
Stefan Assmann | 41b9eb2 | 2008-07-15 13:48:55 +0200 | [diff] [blame] | 614 | } else if (!strcmp(str, "noioapicreroute")) { |
| 615 | if (noioapicreroute != -1) |
| 616 | noioapicreroute = 1; |
| 617 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | } |
| 619 | return str; |
| 620 | } |
| 621 | |
| 622 | unsigned int pcibios_assign_all_busses(void) |
| 623 | { |
| 624 | return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; |
| 625 | } |
| 626 | |
Keith Busch | d9c3d6f | 2016-01-12 13:18:08 -0700 | [diff] [blame] | 627 | #if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS) |
| 628 | static LIST_HEAD(dma_domain_list); |
| 629 | static DEFINE_SPINLOCK(dma_domain_list_lock); |
| 630 | |
| 631 | void add_dma_domain(struct dma_domain *domain) |
| 632 | { |
| 633 | spin_lock(&dma_domain_list_lock); |
| 634 | list_add(&domain->node, &dma_domain_list); |
| 635 | spin_unlock(&dma_domain_list_lock); |
| 636 | } |
| 637 | EXPORT_SYMBOL_GPL(add_dma_domain); |
| 638 | |
| 639 | void del_dma_domain(struct dma_domain *domain) |
| 640 | { |
| 641 | spin_lock(&dma_domain_list_lock); |
| 642 | list_del(&domain->node); |
| 643 | spin_unlock(&dma_domain_list_lock); |
| 644 | } |
| 645 | EXPORT_SYMBOL_GPL(del_dma_domain); |
| 646 | |
| 647 | static void set_dma_domain_ops(struct pci_dev *pdev) |
| 648 | { |
| 649 | struct dma_domain *domain; |
| 650 | |
| 651 | spin_lock(&dma_domain_list_lock); |
| 652 | list_for_each_entry(domain, &dma_domain_list, node) { |
| 653 | if (pci_domain_nr(pdev->bus) == domain->domain_nr) { |
Bart Van Assche | 5657933 | 2017-01-20 13:04:02 -0800 | [diff] [blame] | 654 | pdev->dev.dma_ops = domain->dma_ops; |
Keith Busch | d9c3d6f | 2016-01-12 13:18:08 -0700 | [diff] [blame] | 655 | break; |
| 656 | } |
| 657 | } |
| 658 | spin_unlock(&dma_domain_list_lock); |
| 659 | } |
| 660 | #else |
| 661 | static void set_dma_domain_ops(struct pci_dev *pdev) {} |
| 662 | #endif |
| 663 | |
Keith Busch | 3161832 | 2016-09-13 09:05:40 -0600 | [diff] [blame] | 664 | static void set_dev_domain_options(struct pci_dev *pdev) |
| 665 | { |
| 666 | if (is_vmd(pdev->bus)) |
| 667 | pdev->hotplug_user_indicators = 1; |
| 668 | } |
| 669 | |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 670 | int pcibios_add_device(struct pci_dev *dev) |
| 671 | { |
| 672 | struct setup_data *data; |
| 673 | struct pci_setup_rom *rom; |
| 674 | u64 pa_data; |
| 675 | |
| 676 | pa_data = boot_params.hdr.setup_data; |
| 677 | while (pa_data) { |
Tom Lendacky | f7750a7 | 2017-07-17 16:10:00 -0500 | [diff] [blame] | 678 | data = memremap(pa_data, sizeof(*rom), MEMREMAP_WB); |
Matt Fleming | 65694c5 | 2013-06-05 15:15:41 +0100 | [diff] [blame] | 679 | if (!data) |
| 680 | return -ENOMEM; |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 681 | |
| 682 | if (data->type == SETUP_PCI) { |
| 683 | rom = (struct pci_setup_rom *)data; |
| 684 | |
| 685 | if ((pci_domain_nr(dev->bus) == rom->segment) && |
| 686 | (dev->bus->number == rom->bus) && |
| 687 | (PCI_SLOT(dev->devfn) == rom->device) && |
| 688 | (PCI_FUNC(dev->devfn) == rom->function) && |
| 689 | (dev->vendor == rom->vendor) && |
| 690 | (dev->device == rom->devid)) { |
Bjorn Helgaas | dbd3fc3 | 2012-12-10 11:24:42 -0700 | [diff] [blame] | 691 | dev->rom = pa_data + |
| 692 | offsetof(struct pci_setup_rom, romdata); |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 693 | dev->romlen = rom->pcilen; |
| 694 | } |
| 695 | } |
| 696 | pa_data = data->next; |
Tom Lendacky | f7750a7 | 2017-07-17 16:10:00 -0500 | [diff] [blame] | 697 | memunmap(data); |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 698 | } |
Keith Busch | d9c3d6f | 2016-01-12 13:18:08 -0700 | [diff] [blame] | 699 | set_dma_domain_ops(dev); |
Keith Busch | 3161832 | 2016-09-13 09:05:40 -0600 | [diff] [blame] | 700 | set_dev_domain_options(dev); |
Matthew Garrett | f9a37be0 | 2012-12-05 14:33:27 -0700 | [diff] [blame] | 701 | return 0; |
| 702 | } |
| 703 | |
Jiang Liu | 991de2e | 2015-06-10 16:54:59 +0800 | [diff] [blame] | 704 | int pcibios_enable_device(struct pci_dev *dev, int mask) |
| 705 | { |
Bjorn Helgaas | 6c777e8 | 2016-02-17 12:26:42 -0600 | [diff] [blame] | 706 | int err; |
| 707 | |
| 708 | if ((err = pci_enable_resources(dev, mask)) < 0) |
| 709 | return err; |
| 710 | |
| 711 | if (!pci_dev_msi_enabled(dev)) |
| 712 | return pcibios_enable_irq(dev); |
| 713 | return 0; |
| 714 | } |
| 715 | |
| 716 | void pcibios_disable_device (struct pci_dev *dev) |
| 717 | { |
| 718 | if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq) |
| 719 | pcibios_disable_irq(dev); |
Jiang Liu | 991de2e | 2015-06-10 16:54:59 +0800 | [diff] [blame] | 720 | } |
| 721 | |
Rui Wang | 153654d | 2017-02-28 21:34:28 +0800 | [diff] [blame] | 722 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC |
| 723 | void pcibios_release_device(struct pci_dev *dev) |
| 724 | { |
| 725 | if (atomic_dec_return(&dev->enable_cnt) >= 0) |
| 726 | pcibios_disable_device(dev); |
| 727 | |
| 728 | } |
| 729 | #endif |
| 730 | |
Taku Izumi | 642c92d | 2012-10-30 15:26:18 +0900 | [diff] [blame] | 731 | int pci_ext_cfg_avail(void) |
Andrew Patterson | 0ef5f8f | 2008-11-10 15:30:50 -0700 | [diff] [blame] | 732 | { |
| 733 | if (raw_pci_ext_ops) |
| 734 | return 1; |
| 735 | else |
| 736 | return 0; |
| 737 | } |