blob: 0a9eaa736d94fb858cb97a2bc141421eacb4f001 [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;
Stefan Assmanna9322f62008-06-11 16:35:14 +020025int noioapicquirk;
Stefan Assmann91979792008-06-11 16:35:15 +020026int noioapicreroute = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027int pcibios_last_bus = -1;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -080028unsigned long pirq_table_addr;
29struct pci_bus *pci_root_bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030struct pci_raw_ops *raw_pci_ops;
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050031struct pci_raw_ops *raw_pci_ext_ops;
32
33int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
34 int reg, int len, u32 *val)
35{
36 if (reg < 256 && raw_pci_ops)
37 return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
38 if (raw_pci_ext_ops)
39 return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
40 return -EINVAL;
41}
42
43int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
44 int reg, int len, u32 val)
45{
46 if (reg < 256 && raw_pci_ops)
47 return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
48 if (raw_pci_ext_ops)
49 return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
50 return -EINVAL;
51}
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
54{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050055 return raw_pci_read(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040056 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
58
59static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
60{
Matthew Wilcoxb6ce0682008-02-10 09:45:28 -050061 return raw_pci_write(pci_domain_nr(bus), bus->number,
Jeff Garzika79e4192007-10-11 16:58:30 -040062 devfn, where, size, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
64
65struct pci_ops pci_root_ops = {
66 .read = pci_read,
67 .write = pci_write,
68};
69
70/*
71 * legacy, numa, and acpi all want to call pcibios_scan_root
72 * from their initcalls. This flag prevents that.
73 */
74int pcibios_scanned;
75
76/*
77 * This interrupt-safe spinlock protects all accesses to PCI
78 * configuration space.
79 */
80DEFINE_SPINLOCK(pci_config_lock);
81
Yinghai Lu13a6ddb2008-03-27 01:31:18 -070082static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
83{
84 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
85 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
86 return 0;
87}
88
89static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = {
90/*
91 * Systems where PCI IO resource ISA alignment can be skipped
92 * when the ISA enable bit in the bridge control is not set
93 */
94 {
95 .callback = can_skip_ioresource_align,
96 .ident = "IBM System x3800",
97 .matches = {
98 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
99 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
100 },
101 },
102 {
103 .callback = can_skip_ioresource_align,
104 .ident = "IBM System x3850",
105 .matches = {
106 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
107 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
108 },
109 },
110 {
111 .callback = can_skip_ioresource_align,
112 .ident = "IBM System x3950",
113 .matches = {
114 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
115 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
116 },
117 },
118 {}
119};
120
121void __init dmi_check_skip_isa_align(void)
122{
123 dmi_check_system(can_skip_pciprobe_dmi_table);
124}
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126/*
127 * Called after each bus is probed, but before its children
128 * are examined.
129 */
130
131void __devinit pcibios_fixup_bus(struct pci_bus *b)
132{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 pci_read_bridge_bases(b);
134}
135
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800136/*
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500137 * Only use DMI information to set this if nothing was passed
138 * on the kernel command line (which was parsed earlier).
139 */
140
Jeff Garzik18552562007-10-03 15:15:40 -0400141static int __devinit set_bf_sort(const struct dmi_system_id *d)
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500142{
143 if (pci_bf_sort == pci_bf_sort_default) {
144 pci_bf_sort = pci_dmi_bf;
145 printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
146 }
147 return 0;
148}
149
150/*
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800151 * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
152 */
153#ifdef __i386__
Jeff Garzik18552562007-10-03 15:15:40 -0400154static int __devinit assign_all_busses(const struct dmi_system_id *d)
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800155{
156 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
157 printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
158 " (pci=assign-busses)\n", d->ident);
159 return 0;
160}
161#endif
162
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500163static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
164#ifdef __i386__
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800165/*
166 * Laptops which need pci=assign-busses to see Cardbus cards
167 */
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800168 {
169 .callback = assign_all_busses,
170 .ident = "Samsung X20 Laptop",
171 .matches = {
172 DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
173 DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
174 },
175 },
176#endif /* __i386__ */
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500177 {
178 .callback = set_bf_sort,
179 .ident = "Dell PowerEdge 1950",
180 .matches = {
181 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
182 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
183 },
184 },
185 {
186 .callback = set_bf_sort,
187 .ident = "Dell PowerEdge 1955",
188 .matches = {
189 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
190 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
191 },
192 },
193 {
194 .callback = set_bf_sort,
195 .ident = "Dell PowerEdge 2900",
196 .matches = {
197 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
198 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
199 },
200 },
201 {
202 .callback = set_bf_sort,
203 .ident = "Dell PowerEdge 2950",
204 .matches = {
205 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
206 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
207 },
208 },
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800209 {
210 .callback = set_bf_sort,
Matt Domschf7a9dae2007-03-23 23:58:07 -0500211 .ident = "Dell PowerEdge R900",
212 .matches = {
213 DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
214 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
215 },
216 },
217 {
218 .callback = set_bf_sort,
Andy Gospodarekf52383d2007-02-05 16:36:10 -0800219 .ident = "HP ProLiant BL20p G3",
220 .matches = {
221 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
222 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
223 },
224 },
225 {
226 .callback = set_bf_sort,
227 .ident = "HP ProLiant BL20p G4",
228 .matches = {
229 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
230 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
231 },
232 },
233 {
234 .callback = set_bf_sort,
235 .ident = "HP ProLiant BL30p G1",
236 .matches = {
237 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
238 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
239 },
240 },
241 {
242 .callback = set_bf_sort,
243 .ident = "HP ProLiant BL25p G1",
244 .matches = {
245 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
246 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
247 },
248 },
249 {
250 .callback = set_bf_sort,
251 .ident = "HP ProLiant BL35p G1",
252 .matches = {
253 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
254 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
255 },
256 },
257 {
258 .callback = set_bf_sort,
259 .ident = "HP ProLiant BL45p G1",
260 .matches = {
261 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
262 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
263 },
264 },
265 {
266 .callback = set_bf_sort,
267 .ident = "HP ProLiant BL45p G2",
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
271 },
272 },
273 {
274 .callback = set_bf_sort,
275 .ident = "HP ProLiant BL460c G1",
276 .matches = {
277 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
278 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
279 },
280 },
281 {
282 .callback = set_bf_sort,
283 .ident = "HP ProLiant BL465c G1",
284 .matches = {
285 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
286 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
287 },
288 },
289 {
290 .callback = set_bf_sort,
291 .ident = "HP ProLiant BL480c G1",
292 .matches = {
293 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
294 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
295 },
296 },
297 {
298 .callback = set_bf_sort,
299 .ident = "HP ProLiant BL685c G1",
300 .matches = {
301 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
302 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
303 },
304 },
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200305 {
306 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400307 .ident = "HP ProLiant DL360",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200308 .matches = {
309 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400310 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200311 },
312 },
313 {
314 .callback = set_bf_sort,
Tony Camuso8d64c782008-05-15 14:40:14 -0400315 .ident = "HP ProLiant DL380",
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200316 .matches = {
317 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camuso8d64c782008-05-15 14:40:14 -0400318 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
Michal Schmidt8f8ae1a2007-10-17 18:04:35 +0200319 },
320 },
Juha Laiho5b1ea822007-09-13 21:21:34 +0300321#ifdef __i386__
322 {
323 .callback = assign_all_busses,
324 .ident = "Compaq EVO N800c",
325 .matches = {
326 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
327 DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
328 },
329 },
330#endif
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100331 {
332 .callback = set_bf_sort,
Tony Camusoa1676072008-05-15 14:40:14 -0400333 .ident = "HP ProLiant DL360",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100334 .matches = {
335 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camusoa1676072008-05-15 14:40:14 -0400336 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100337 },
338 },
339 {
340 .callback = set_bf_sort,
Tony Camusoa1676072008-05-15 14:40:14 -0400341 .ident = "HP ProLiant DL380",
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100342 .matches = {
343 DMI_MATCH(DMI_SYS_VENDOR, "HP"),
Tony Camusoa1676072008-05-15 14:40:14 -0400344 DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
Michal Schmidtc82bc5a2007-11-26 20:42:19 +0100345 },
346 },
Bernhard Kaindl8c4b2cf2006-02-18 01:36:55 -0800347 {}
348};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
Yinghai Lu0df18ff2008-04-14 15:40:37 -0700350void __init dmi_check_pciprobe(void)
351{
352 dmi_check_system(pciprobe_dmi_table);
353}
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355struct pci_bus * __devinit pcibios_scan_root(int busnum)
356{
357 struct pci_bus *bus = NULL;
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300358 struct pci_sysdata *sd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 while ((bus = pci_find_next_bus(bus)) != NULL) {
361 if (bus->number == busnum) {
362 /* Already scanned */
363 return bus;
364 }
365 }
366
Muli Ben-Yehuda08f1c192007-07-22 00:23:39 +0300367 /* Allocate per-root-bus (not per bus) arch-specific data.
368 * TODO: leak; this memory is never freed.
369 * It's arguable whether it's worth the trouble to care.
370 */
371 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
372 if (!sd) {
373 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
374 return NULL;
375 }
376
Yinghai Lu871d5f82008-02-19 03:20:09 -0800377 sd->node = get_mp_bus_to_node(busnum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
Yinghai Lu871d5f82008-02-19 03:20:09 -0800379 printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
380 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
381 if (!bus)
382 kfree(sd);
383
384 return bus;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
387extern u8 pci_cache_line_size;
388
389static int __init pcibios_init(void)
390{
391 struct cpuinfo_x86 *c = &boot_cpu_data;
392
393 if (!raw_pci_ops) {
Daniel Marjamäkiadcb89072005-11-23 15:44:49 -0800394 printk(KERN_WARNING "PCI: System does not support PCI\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 return 0;
396 }
397
398 /*
399 * Assume PCI cacheline size of 32 bytes for all x86s except K7/K8
400 * and P4. It's also good for 386/486s (which actually have 16)
401 * as quite a few PCI devices do not support smaller values.
402 */
403 pci_cache_line_size = 32 >> 2;
404 if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
405 pci_cache_line_size = 64 >> 2; /* K7 & K8 */
406 else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
407 pci_cache_line_size = 128 >> 2; /* P4 */
408
409 pcibios_resource_survey();
410
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500411 if (pci_bf_sort >= pci_force_bf)
412 pci_sort_breadthfirst();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 return 0;
414}
415
416subsys_initcall(pcibios_init);
417
418char * __devinit pcibios_setup(char *str)
419{
420 if (!strcmp(str, "off")) {
421 pci_probe = 0;
422 return NULL;
Matt Domsch6b4b78f2006-09-29 15:23:23 -0500423 } else if (!strcmp(str, "bfsort")) {
424 pci_bf_sort = pci_force_bf;
425 return NULL;
426 } else if (!strcmp(str, "nobfsort")) {
427 pci_bf_sort = pci_force_nobf;
428 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 }
430#ifdef CONFIG_PCI_BIOS
431 else if (!strcmp(str, "bios")) {
432 pci_probe = PCI_PROBE_BIOS;
433 return NULL;
434 } else if (!strcmp(str, "nobios")) {
435 pci_probe &= ~PCI_PROBE_BIOS;
436 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 } else if (!strcmp(str, "biosirq")) {
438 pci_probe |= PCI_BIOS_IRQ_SCAN;
439 return NULL;
jayalk@intworks.biz120bb422005-03-21 20:20:42 -0800440 } else if (!strncmp(str, "pirqaddr=", 9)) {
441 pirq_table_addr = simple_strtoul(str+9, NULL, 0);
442 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 }
444#endif
445#ifdef CONFIG_PCI_DIRECT
446 else if (!strcmp(str, "conf1")) {
447 pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
448 return NULL;
449 }
450 else if (!strcmp(str, "conf2")) {
451 pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
452 return NULL;
453 }
454#endif
455#ifdef CONFIG_PCI_MMCONFIG
456 else if (!strcmp(str, "nommconf")) {
457 pci_probe &= ~PCI_PROBE_MMCONF;
458 return NULL;
459 }
Yinghai Lu5f0b2972008-04-14 16:08:25 -0700460 else if (!strcmp(str, "check_enable_amd_mmconf")) {
461 pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
462 return NULL;
463 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464#endif
465 else if (!strcmp(str, "noacpi")) {
466 acpi_noirq_set();
467 return NULL;
468 }
Andi Kleen0637a702006-09-26 10:52:41 +0200469 else if (!strcmp(str, "noearly")) {
470 pci_probe |= PCI_PROBE_NOEARLY;
471 return NULL;
472 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473#ifndef CONFIG_X86_VISWS
474 else if (!strcmp(str, "usepirqmask")) {
475 pci_probe |= PCI_USE_PIRQ_MASK;
476 return NULL;
477 } else if (!strncmp(str, "irqmask=", 8)) {
478 pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
479 return NULL;
480 } else if (!strncmp(str, "lastbus=", 8)) {
481 pcibios_last_bus = simple_strtol(str+8, NULL, 0);
482 return NULL;
483 }
484#endif
485 else if (!strcmp(str, "rom")) {
486 pci_probe |= PCI_ASSIGN_ROMS;
487 return NULL;
488 } else if (!strcmp(str, "assign-busses")) {
489 pci_probe |= PCI_ASSIGN_ALL_BUSSES;
490 return NULL;
Gary Hade62f420f2007-10-03 15:56:51 -0700491 } else if (!strcmp(str, "use_crs")) {
492 pci_probe |= PCI_USE__CRS;
493 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 } else if (!strcmp(str, "routeirq")) {
495 pci_routeirq = 1;
496 return NULL;
Yinghai Lu13a6ddb2008-03-27 01:31:18 -0700497 } else if (!strcmp(str, "skip_isa_align")) {
498 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
499 return NULL;
Stefan Assmanna9322f62008-06-11 16:35:14 +0200500 } else if (!strcmp(str, "noioapicquirk")) {
501 noioapicquirk = 1;
502 return NULL;
Stefan Assmann91979792008-06-11 16:35:15 +0200503 } else if (!strcmp(str, "ioapicreroute")) {
504 if (noioapicreroute != -1)
505 noioapicreroute = 0;
506 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 }
508 return str;
509}
510
511unsigned int pcibios_assign_all_busses(void)
512{
513 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
514}
515
516int pcibios_enable_device(struct pci_dev *dev, int mask)
517{
518 int err;
519
Bjorn Helgaasb81d9882008-03-04 11:57:01 -0700520 if ((err = pci_enable_resources(dev, mask)) < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 return err;
522
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200523 if (!dev->msi_enabled)
524 return pcibios_enable_irq(dev);
525 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526}
David Shaohua Li87bec662005-07-27 23:02:00 -0400527
528void pcibios_disable_device (struct pci_dev *dev)
529{
Eric W. Biedermanbba6f6f2007-03-28 15:36:09 +0200530 if (!dev->msi_enabled && pcibios_disable_irq)
David Shaohua Li87bec662005-07-27 23:02:00 -0400531 pcibios_disable_irq(dev);
532}
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700533
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200534struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700535{
536 struct pci_bus *bus = NULL;
537 struct pci_sysdata *sd;
538
539 /*
540 * Allocate per-root-bus (not per bus) arch-specific data.
541 * TODO: leak; this memory is never freed.
542 * It's arguable whether it's worth the trouble to care.
543 */
544 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
545 if (!sd) {
546 printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
547 return NULL;
548 }
Yinghai Lu871d5f82008-02-19 03:20:09 -0800549 sd->node = node;
550 bus = pci_scan_bus(busno, ops, sd);
Muli Ben-Yehuda73c59af2007-08-10 13:01:19 -0700551 if (!bus)
552 kfree(sd);
553
554 return bus;
555}
Yinghai Lu871d5f82008-02-19 03:20:09 -0800556
Sam Ravnborg98db6f12008-04-29 22:38:48 +0200557struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
Yinghai Lu871d5f82008-02-19 03:20:09 -0800558{
559 return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
560}