blob: 20b9f59f95df85203009cce11d688f2510cbeab3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
9#include <linux/ioport.h>
10#include <linux/init.h>
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -080011#include <linux/dmi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13#include <asm/acpi.h>
14#include <asm/segment.h>
15#include <asm/io.h>
16#include <asm/smp.h>
17
18#include "pci.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
21 PCI_PROBE_MMCONF;
22
Adrian Bunk2b290da2006-11-16 13:16:23 +010023static int pci_bf_sort;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024int pci_routeirq;
25int pcibios_last_bus = -1;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -080026unsigned long pirq_table_addr;
27struct pci_bus *pci_root_bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028struct pci_raw_ops *raw_pci_ops;
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050029struct pci_raw_ops *raw_pci_ext_ops;
30
31int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
32 int reg, int len, u32 *val)
33{
34 if (reg < 256 && raw_pci_ops)
35 return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
36 if (raw_pci_ext_ops)
37 return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
38 return -EINVAL;
39}
40
41int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
42 int reg, int len, u32 val)
43{
44 if (reg < 256 && raw_pci_ops)
45 return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
46 if (raw_pci_ext_ops)
47 return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
48 return -EINVAL;
49}
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
52{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050053 return raw_pci_read(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040054 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055}
56
57static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
58{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050059 return raw_pci_write(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040060 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061}
62
63struct pci_ops pci_root_ops = {
64 .read = pci_read,
65 .write = pci_write,
66};
67
68/*
69 * legacy, numa, and acpi all want to call pcibios_scan_root
70 * from their initcalls. This flag prevents that.
71 */
72int pcibios_scanned;
73
74/*
75 * This interrupt-safe spinlock protects all accesses to PCI
76 * configuration space.
77 */
78DEFINE_SPINLOCK(pci_config_lock);
79
Yinghai Lu13a6ddb2008-03-27 01:31:18 -070080static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
81{
82 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
83 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
84 return 0;
85}
86
87static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = {
88/*
89 * Systems where PCI IO resource ISA alignment can be skipped
90 * when the ISA enable bit in the bridge control is not set
91 */
92 {
93 .callback = can_skip_ioresource_align,
94 .ident = "IBM System x3800",
95 .matches = {
96 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
97 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
98 },
99 },
100 {
101 .callback = can_skip_ioresource_align,
102 .ident = "IBM System x3850",
103 .matches = {
104 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
105 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
106 },
107 },
108 {
109 .callback = can_skip_ioresource_align,
110 .ident = "IBM System x3950",
111 .matches = {
112 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
113 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
114 },
115 },
116 {}
117};
118
119void __init dmi_check_skip_isa_align(void)
120{
121 dmi_check_system(can_skip_pciprobe_dmi_table);
122}
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124/*
125 * Called after each bus is probed, but before its children
126 * are examined.
127 */
128
129void __devinit pcibios_fixup_bus(struct pci_bus *b)
130{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 pci_read_bridge_bases(b);
132}
133
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800134/*
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500135 * Only use DMI information to set this if nothing was passed
136 * on the kernel command line (which was parsed earlier).
137 */
138
Jeff Garzik18552562007-10-03 15:15:40 -0400139static int __devinit set_bf_sort(const struct dmi_system_id *d)
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500140{
141 if (pci_bf_sort == pci_bf_sort_default) {
142 pci_bf_sort = pci_dmi_bf;
143 printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
144 }
145 return 0;
146}
147
148/*
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800149 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
150 */
151#ifdef __i386__
Jeff Garzik18552562007-10-03 15:15:40 -0400152static int __devinit assign_all_busses(const struct dmi_system_id *d)
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800153{
154 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
155 printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
156 " (pci=assign-busses)\n", d->ident);
157 return 0;
158}
159#endif
160
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500161static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
162#ifdef __i386__
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800163/*
164 * Laptops which need pci=assign-busses to see Cardbus cards
165 */
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800166 {
167 .callback = assign_all_busses,
168 .ident = "Samsung X20 Laptop",
169 .matches = {
170 DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
171 DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
172 },
173 },
174#endif /* __i386__ */
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500175 {
176 .callback = set_bf_sort,
177 .ident = "Dell PowerEdge 1950",
178 .matches = {
179 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
180 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
181 },
182 },
183 {
184 .callback = set_bf_sort,
185 .ident = "Dell PowerEdge 1955",
186 .matches = {
187 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
188 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
189 },
190 },
191 {
192 .callback = set_bf_sort,
193 .ident = "Dell PowerEdge 2900",
194 .matches = {
195 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
196 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
197 },
198 },
199 {
200 .callback = set_bf_sort,
201 .ident = "Dell PowerEdge 2950",
202 .matches = {
203 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
204 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
205 },
206 },
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800207 {
208 .callback = set_bf_sort,
Matt Domschf7a9dae2007-03-23 23:58:07 -0500209 .ident = "Dell PowerEdge R900",
210 .matches = {
211 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
212 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
213 },
214 },
215 {
216 .callback = set_bf_sort,
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800217 .ident = "HP ProLiant BL20p G3",
218 .matches = {
219 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
220 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
221 },
222 },
223 {
224 .callback = set_bf_sort,
225 .ident = "HP ProLiant BL20p G4",
226 .matches = {
227 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
228 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
229 },
230 },
231 {
232 .callback = set_bf_sort,
233 .ident = "HP ProLiant BL30p G1",
234 .matches = {
235 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
236 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
237 },
238 },
239 {
240 .callback = set_bf_sort,
241 .ident = "HP ProLiant BL25p G1",
242 .matches = {
243 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
244 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
245 },
246 },
247 {
248 .callback = set_bf_sort,
249 .ident = "HP ProLiant BL35p G1",
250 .matches = {
251 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
252 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
253 },
254 },
255 {
256 .callback = set_bf_sort,
257 .ident = "HP ProLiant BL45p G1",
258 .matches = {
259 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
260 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
261 },
262 },
263 {
264 .callback = set_bf_sort,
265 .ident = "HP ProLiant BL45p G2",
266 .matches = {
267 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
268 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
269 },
270 },
271 {
272 .callback = set_bf_sort,
273 .ident = "HP ProLiant BL460c G1",
274 .matches = {
275 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
276 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
277 },
278 },
279 {
280 .callback = set_bf_sort,
281 .ident = "HP ProLiant BL465c G1",
282 .matches = {
283 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
284 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
285 },
286 },
287 {
288 .callback = set_bf_sort,
289 .ident = "HP ProLiant BL480c G1",
290 .matches = {
291 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
292 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
293 },
294 },
295 {
296 .callback = set_bf_sort,
297 .ident = "HP ProLiant BL685c G1",
298 .matches = {
299 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
300 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
301 },
302 },
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200303 {
304 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400305 .ident = "HP ProLiant DL360",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200306 .matches = {
307 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400308 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200309 },
310 },
311 {
312 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400313 .ident = "HP ProLiant DL380",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200314 .matches = {
315 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400316 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200317 },
318 },
Juha Laiho5b1ea822007-09-13 21:21:34 +0300319#ifdef __i386__
320 {
321 .callback = assign_all_busses,
322 .ident = "Compaq EVO N800c",
323 .matches = {
324 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
325 DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
326 },
327 },
328#endif
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100329 {
330 .callback = set_bf_sort,
Jesse Barnes739db072008-07-07 09:55:26 -0700331 .ident = "HP ProLiant DL385 G2",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100332 .matches = {
333 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Jesse Barnes739db072008-07-07 09:55:26 -0700334 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100335 },
336 },
337 {
338 .callback = set_bf_sort,
Jesse Barnes739db072008-07-07 09:55:26 -0700339 .ident = "HP ProLiant DL585 G2",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100340 .matches = {
341 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Jesse Barnes739db072008-07-07 09:55:26 -0700342 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100343 },
344 },
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800345 {}
346};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
Yinghai Lu0df18ff2008-04-14 15:40:37 -0700348void __init dmi_check_pciprobe(void)
349{
350 dmi_check_system(pciprobe_dmi_table);
351}
352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353struct pci_bus * __devinit pcibios_scan_root(int busnum)
354{
355 struct pci_bus *bus = NULL;
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300356 struct pci_sysdata *sd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358 while ((bus = pci_find_next_bus(bus)) != NULL) {
359 if (bus->number == busnum) {
360 /* Already scanned */
361 return bus;
362 }
363 }
364
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300365 /* Allocate per-root-bus (not per bus) arch-specific data.
366 * TODO: leak; this memory is never freed.
367 * It's arguable whether it's worth the trouble to care.
368 */
369 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
370 if (!sd) {
371 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
372 return NULL;
373 }
374
Yinghai Lu871d5f82008-02-19 03:20:09 -0800375 sd->node = get_mp_bus_to_node(busnum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376
Yinghai Lu871d5f82008-02-19 03:20:09 -0800377 printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
378 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
379 if (!bus)
380 kfree(sd);
381
382 return bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383}
384
385extern u8 pci_cache_line_size;
386
Robert Richter8dd779b2008-07-02 22:50:29 +0200387int __init pcibios_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
389 struct cpuinfo_x86 *c = &boot_cpu_data;
390
391 if (!raw_pci_ops) {
Daniel Marjamäkiadcb89072005-11-23 15:44:49 -0800392 printk(KERN_WARNING "PCI: System does not support PCI\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 return 0;
394 }
395
396 /*
397 * Assume PCI cacheline size of 32 bytes for all x86s except K7/K8
398 * and P4. It's also good for 386/486s (which actually have 16)
399 * as quite a few PCI devices do not support smaller values.
400 */
401 pci_cache_line_size = 32 >> 2;
402 if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
403 pci_cache_line_size = 64 >> 2; /* K7 & K8 */
404 else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
405 pci_cache_line_size = 128 >> 2; /* P4 */
406
407 pcibios_resource_survey();
408
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500409 if (pci_bf_sort >= pci_force_bf)
410 pci_sort_breadthfirst();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 return 0;
412}
413
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414char * __devinit pcibios_setup(char *str)
415{
416 if (!strcmp(str, "off")) {
417 pci_probe = 0;
418 return NULL;
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500419 } else if (!strcmp(str, "bfsort")) {
420 pci_bf_sort = pci_force_bf;
421 return NULL;
422 } else if (!strcmp(str, "nobfsort")) {
423 pci_bf_sort = pci_force_nobf;
424 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 }
426#ifdef CONFIG_PCI_BIOS
427 else if (!strcmp(str, "bios")) {
428 pci_probe = PCI_PROBE_BIOS;
429 return NULL;
430 } else if (!strcmp(str, "nobios")) {
431 pci_probe &= ~PCI_PROBE_BIOS;
432 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 } else if (!strcmp(str, "biosirq")) {
434 pci_probe |= PCI_BIOS_IRQ_SCAN;
435 return NULL;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -0800436 } else if (!strncmp(str, "pirqaddr=", 9)) {
437 pirq_table_addr = simple_strtoul(str+9, NULL, 0);
438 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 }
440#endif
441#ifdef CONFIG_PCI_DIRECT
442 else if (!strcmp(str, "conf1")) {
443 pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
444 return NULL;
445 }
446 else if (!strcmp(str, "conf2")) {
447 pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
448 return NULL;
449 }
450#endif
451#ifdef CONFIG_PCI_MMCONFIG
452 else if (!strcmp(str, "nommconf")) {
453 pci_probe &= ~PCI_PROBE_MMCONF;
454 return NULL;
455 }
Yinghai Lu5f0b2972008-04-14 16:08:25 -0700456 else if (!strcmp(str, "check_enable_amd_mmconf")) {
457 pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
458 return NULL;
459 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460#endif
461 else if (!strcmp(str, "noacpi")) {
462 acpi_noirq_set();
463 return NULL;
464 }
Andi Kleen0637a702006-09-26 10:52:41 +0200465 else if (!strcmp(str, "noearly")) {
466 pci_probe |= PCI_PROBE_NOEARLY;
467 return NULL;
468 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469#ifndef CONFIG_X86_VISWS
470 else if (!strcmp(str, "usepirqmask")) {
471 pci_probe |= PCI_USE_PIRQ_MASK;
472 return NULL;
473 } else if (!strncmp(str, "irqmask=", 8)) {
474 pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
475 return NULL;
476 } else if (!strncmp(str, "lastbus=", 8)) {
477 pcibios_last_bus = simple_strtol(str+8, NULL, 0);
478 return NULL;
479 }
480#endif
481 else if (!strcmp(str, "rom")) {
482 pci_probe |= PCI_ASSIGN_ROMS;
483 return NULL;
484 } else if (!strcmp(str, "assign-busses")) {
485 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
486 return NULL;
Gary Hade62f420f2007-10-03 15:56:51 -0700487 } else if (!strcmp(str, "use_crs")) {
488 pci_probe |= PCI_USE__CRS;
489 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 } else if (!strcmp(str, "routeirq")) {
491 pci_routeirq = 1;
492 return NULL;
Yinghai Lu13a6ddb2008-03-27 01:31:18 -0700493 } else if (!strcmp(str, "skip_isa_align")) {
494 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
495 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 }
497 return str;
498}
499
500unsigned int pcibios_assign_all_busses(void)
501{
502 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
503}
504
505int pcibios_enable_device(struct pci_dev *dev, int mask)
506{
507 int err;
508
Bjorn Helgaasb81d9882008-03-04 11:57:01 -0700509 if ((err = pci_enable_resources(dev, mask)) < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 return err;
511
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200512 if (!dev->msi_enabled)
513 return pcibios_enable_irq(dev);
514 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515}
David Shaohua Li87bec662005-07-27 23:02:00 -0400516
517void pcibios_disable_device (struct pci_dev *dev)
518{
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200519 if (!dev->msi_enabled && pcibios_disable_irq)
David Shaohua Li87bec662005-07-27 23:02:00 -0400520 pcibios_disable_irq(dev);
521}
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700522
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200523struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700524{
525 struct pci_bus *bus = NULL;
526 struct pci_sysdata *sd;
527
528 /*
529 * Allocate per-root-bus (not per bus) arch-specific data.
530 * TODO: leak; this memory is never freed.
531 * It's arguable whether it's worth the trouble to care.
532 */
533 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
534 if (!sd) {
535 printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
536 return NULL;
537 }
Yinghai Lu871d5f82008-02-19 03:20:09 -0800538 sd->node = node;
539 bus = pci_scan_bus(busno, ops, sd);
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700540 if (!bus)
541 kfree(sd);
542
543 return bus;
544}
Yinghai Lu871d5f82008-02-19 03:20:09 -0800545
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200546struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
Yinghai Lu871d5f82008-02-19 03:20:09 -0800547{
548 return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
549}