common.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*
  2. * Low-Level PCI Support for PC
  3. *
  4. * (c) 1999--2000 Martin Mares <mj@ucw.cz>
  5. */
  6. #include <linux/sched.h>
  7. #include <linux/pci.h>
  8. #include <linux/ioport.h>
  9. #include <linux/init.h>
  10. #include <linux/dmi.h>
  11. #include <linux/slab.h>
  12. #include <asm-generic/pci-bridge.h>
  13. #include <asm/acpi.h>
  14. #include <asm/segment.h>
  15. #include <asm/io.h>
  16. #include <asm/smp.h>
  17. #include <asm/pci_x86.h>
  18. unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
  19. PCI_PROBE_MMCONF;
  20. unsigned int pci_early_dump_regs;
  21. static int pci_bf_sort;
  22. static int smbios_type_b1_flag;
  23. int pci_routeirq;
  24. int noioapicquirk;
  25. #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
  26. int noioapicreroute = 0;
  27. #else
  28. int noioapicreroute = 1;
  29. #endif
  30. int pcibios_last_bus = -1;
  31. unsigned long pirq_table_addr;
  32. struct pci_bus *pci_root_bus;
  33. const struct pci_raw_ops *__read_mostly raw_pci_ops;
  34. const struct pci_raw_ops *__read_mostly raw_pci_ext_ops;
  35. int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn,
  36. int reg, int len, u32 *val)
  37. {
  38. if (domain == 0 && reg < 256 && raw_pci_ops)
  39. return raw_pci_ops->read(domain, bus, devfn, reg, len, val);
  40. if (raw_pci_ext_ops)
  41. return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val);
  42. return -EINVAL;
  43. }
  44. int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn,
  45. int reg, int len, u32 val)
  46. {
  47. if (domain == 0 && reg < 256 && raw_pci_ops)
  48. return raw_pci_ops->write(domain, bus, devfn, reg, len, val);
  49. if (raw_pci_ext_ops)
  50. return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val);
  51. return -EINVAL;
  52. }
  53. static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
  54. {
  55. return raw_pci_read(pci_domain_nr(bus), bus->number,
  56. devfn, where, size, value);
  57. }
  58. static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
  59. {
  60. return raw_pci_write(pci_domain_nr(bus), bus->number,
  61. devfn, where, size, value);
  62. }
  63. struct pci_ops pci_root_ops = {
  64. .read = pci_read,
  65. .write = pci_write,
  66. };
  67. /*
  68. * This interrupt-safe spinlock protects all accesses to PCI
  69. * configuration space.
  70. */
  71. DEFINE_RAW_SPINLOCK(pci_config_lock);
  72. static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
  73. {
  74. pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
  75. printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
  76. return 0;
  77. }
  78. static const struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitconst = {
  79. /*
  80. * Systems where PCI IO resource ISA alignment can be skipped
  81. * when the ISA enable bit in the bridge control is not set
  82. */
  83. {
  84. .callback = can_skip_ioresource_align,
  85. .ident = "IBM System x3800",
  86. .matches = {
  87. DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
  88. DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
  89. },
  90. },
  91. {
  92. .callback = can_skip_ioresource_align,
  93. .ident = "IBM System x3850",
  94. .matches = {
  95. DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
  96. DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
  97. },
  98. },
  99. {
  100. .callback = can_skip_ioresource_align,
  101. .ident = "IBM System x3950",
  102. .matches = {
  103. DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
  104. DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
  105. },
  106. },
  107. {}
  108. };
  109. void __init dmi_check_skip_isa_align(void)
  110. {
  111. dmi_check_system(can_skip_pciprobe_dmi_table);
  112. }
  113. static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
  114. {
  115. struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE];
  116. struct resource *bar_r;
  117. int bar;
  118. if (pci_probe & PCI_NOASSIGN_BARS) {
  119. /*
  120. * If the BIOS did not assign the BAR, zero out the
  121. * resource so the kernel doesn't attmept to assign
  122. * it later on in pci_assign_unassigned_resources
  123. */
  124. for (bar = 0; bar <= PCI_STD_RESOURCE_END; bar++) {
  125. bar_r = &dev->resource[bar];
  126. if (bar_r->start == 0 && bar_r->end != 0) {
  127. bar_r->flags = 0;
  128. bar_r->end = 0;
  129. }
  130. }
  131. }
  132. if (pci_probe & PCI_NOASSIGN_ROMS) {
  133. if (rom_r->parent)
  134. return;
  135. if (rom_r->start) {
  136. /* we deal with BIOS assigned ROM later */
  137. return;
  138. }
  139. rom_r->start = rom_r->end = rom_r->flags = 0;
  140. }
  141. }
  142. /*
  143. * Called after each bus is probed, but before its children
  144. * are examined.
  145. */
  146. void __devinit pcibios_fixup_bus(struct pci_bus *b)
  147. {
  148. struct pci_dev *dev;
  149. pci_read_bridge_bases(b);
  150. list_for_each_entry(dev, &b->devices, bus_list)
  151. pcibios_fixup_device_resources(dev);
  152. }
  153. /*
  154. * Only use DMI information to set this if nothing was passed
  155. * on the kernel command line (which was parsed earlier).
  156. */
  157. static int __devinit set_bf_sort(const struct dmi_system_id *d)
  158. {
  159. if (pci_bf_sort == pci_bf_sort_default) {
  160. pci_bf_sort = pci_dmi_bf;
  161. printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
  162. }
  163. return 0;
  164. }
  165. static void __devinit read_dmi_type_b1(const struct dmi_header *dm,
  166. void *private_data)
  167. {
  168. u8 *d = (u8 *)dm + 4;
  169. if (dm->type != 0xB1)
  170. return;
  171. switch (((*(u32 *)d) >> 9) & 0x03) {
  172. case 0x00:
  173. printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n");
  174. break;
  175. case 0x01: /* set pci=bfsort */
  176. smbios_type_b1_flag = 1;
  177. break;
  178. case 0x02: /* do not set pci=bfsort */
  179. smbios_type_b1_flag = 2;
  180. break;
  181. default:
  182. break;
  183. }
  184. }
  185. static int __devinit find_sort_method(const struct dmi_system_id *d)
  186. {
  187. dmi_walk(read_dmi_type_b1, NULL);
  188. if (smbios_type_b1_flag == 1) {
  189. set_bf_sort(d);
  190. return 0;
  191. }
  192. return -1;
  193. }
  194. /*
  195. * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
  196. */
  197. #ifdef __i386__
  198. static int __devinit assign_all_busses(const struct dmi_system_id *d)
  199. {
  200. pci_probe |= PCI_ASSIGN_ALL_BUSSES;
  201. printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
  202. " (pci=assign-busses)\n", d->ident);
  203. return 0;
  204. }
  205. #endif
  206. static int __devinit set_scan_all(const struct dmi_system_id *d)
  207. {
  208. printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n",
  209. d->ident);
  210. pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
  211. return 0;
  212. }
  213. static const struct dmi_system_id __devinitconst pciprobe_dmi_table[] = {
  214. #ifdef __i386__
  215. /*
  216. * Laptops which need pci=assign-busses to see Cardbus cards
  217. */
  218. {
  219. .callback = assign_all_busses,
  220. .ident = "Samsung X20 Laptop",
  221. .matches = {
  222. DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
  223. DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
  224. },
  225. },
  226. #endif /* __i386__ */
  227. {
  228. .callback = set_bf_sort,
  229. .ident = "Dell PowerEdge 1950",
  230. .matches = {
  231. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  232. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
  233. },
  234. },
  235. {
  236. .callback = set_bf_sort,
  237. .ident = "Dell PowerEdge 1955",
  238. .matches = {
  239. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  240. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
  241. },
  242. },
  243. {
  244. .callback = set_bf_sort,
  245. .ident = "Dell PowerEdge 2900",
  246. .matches = {
  247. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  248. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
  249. },
  250. },
  251. {
  252. .callback = set_bf_sort,
  253. .ident = "Dell PowerEdge 2950",
  254. .matches = {
  255. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  256. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
  257. },
  258. },
  259. {
  260. .callback = set_bf_sort,
  261. .ident = "Dell PowerEdge R900",
  262. .matches = {
  263. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  264. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
  265. },
  266. },
  267. {
  268. .callback = find_sort_method,
  269. .ident = "Dell System",
  270. .matches = {
  271. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  272. },
  273. },
  274. {
  275. .callback = set_bf_sort,
  276. .ident = "HP ProLiant BL20p G3",
  277. .matches = {
  278. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  279. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
  280. },
  281. },
  282. {
  283. .callback = set_bf_sort,
  284. .ident = "HP ProLiant BL20p G4",
  285. .matches = {
  286. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  287. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
  288. },
  289. },
  290. {
  291. .callback = set_bf_sort,
  292. .ident = "HP ProLiant BL30p G1",
  293. .matches = {
  294. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  295. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
  296. },
  297. },
  298. {
  299. .callback = set_bf_sort,
  300. .ident = "HP ProLiant BL25p G1",
  301. .matches = {
  302. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  303. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
  304. },
  305. },
  306. {
  307. .callback = set_bf_sort,
  308. .ident = "HP ProLiant BL35p G1",
  309. .matches = {
  310. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  311. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
  312. },
  313. },
  314. {
  315. .callback = set_bf_sort,
  316. .ident = "HP ProLiant BL45p G1",
  317. .matches = {
  318. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  319. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
  320. },
  321. },
  322. {
  323. .callback = set_bf_sort,
  324. .ident = "HP ProLiant BL45p G2",
  325. .matches = {
  326. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  327. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
  328. },
  329. },
  330. {
  331. .callback = set_bf_sort,
  332. .ident = "HP ProLiant BL460c G1",
  333. .matches = {
  334. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  335. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
  336. },
  337. },
  338. {
  339. .callback = set_bf_sort,
  340. .ident = "HP ProLiant BL465c G1",
  341. .matches = {
  342. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  343. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
  344. },
  345. },
  346. {
  347. .callback = set_bf_sort,
  348. .ident = "HP ProLiant BL480c G1",
  349. .matches = {
  350. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  351. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
  352. },
  353. },
  354. {
  355. .callback = set_bf_sort,
  356. .ident = "HP ProLiant BL685c G1",
  357. .matches = {
  358. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  359. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
  360. },
  361. },
  362. {
  363. .callback = set_bf_sort,
  364. .ident = "HP ProLiant DL360",
  365. .matches = {
  366. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  367. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
  368. },
  369. },
  370. {
  371. .callback = set_bf_sort,
  372. .ident = "HP ProLiant DL380",
  373. .matches = {
  374. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  375. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
  376. },
  377. },
  378. #ifdef __i386__
  379. {
  380. .callback = assign_all_busses,
  381. .ident = "Compaq EVO N800c",
  382. .matches = {
  383. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  384. DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
  385. },
  386. },
  387. #endif
  388. {
  389. .callback = set_bf_sort,
  390. .ident = "HP ProLiant DL385 G2",
  391. .matches = {
  392. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  393. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
  394. },
  395. },
  396. {
  397. .callback = set_bf_sort,
  398. .ident = "HP ProLiant DL585 G2",
  399. .matches = {
  400. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  401. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
  402. },
  403. },
  404. {
  405. .callback = set_scan_all,
  406. .ident = "Stratus/NEC ftServer",
  407. .matches = {
  408. DMI_MATCH(DMI_SYS_VENDOR, "ftServer"),
  409. },
  410. },
  411. {}
  412. };
  413. void __init dmi_check_pciprobe(void)
  414. {
  415. dmi_check_system(pciprobe_dmi_table);
  416. }
  417. struct pci_bus * __devinit pcibios_scan_root(int busnum)
  418. {
  419. struct pci_bus *bus = NULL;
  420. while ((bus = pci_find_next_bus(bus)) != NULL) {
  421. if (bus->number == busnum) {
  422. /* Already scanned */
  423. return bus;
  424. }
  425. }
  426. return pci_scan_bus_on_node(busnum, &pci_root_ops,
  427. get_mp_bus_to_node(busnum));
  428. }
  429. void __init pcibios_set_cache_line_size(void)
  430. {
  431. struct cpuinfo_x86 *c = &boot_cpu_data;
  432. /*
  433. * Set PCI cacheline size to that of the CPU if the CPU has reported it.
  434. * (For older CPUs that don't support cpuid, we se it to 32 bytes
  435. * It's also good for 386/486s (which actually have 16)
  436. * as quite a few PCI devices do not support smaller values.
  437. */
  438. if (c->x86_clflush_size > 0) {
  439. pci_dfl_cache_line_size = c->x86_clflush_size >> 2;
  440. printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n",
  441. pci_dfl_cache_line_size << 2);
  442. } else {
  443. pci_dfl_cache_line_size = 32 >> 2;
  444. printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
  445. }
  446. }
  447. int __init pcibios_init(void)
  448. {
  449. if (!raw_pci_ops) {
  450. printk(KERN_WARNING "PCI: System does not support PCI\n");
  451. return 0;
  452. }
  453. pcibios_set_cache_line_size();
  454. pcibios_resource_survey();
  455. if (pci_bf_sort >= pci_force_bf)
  456. pci_sort_breadthfirst();
  457. return 0;
  458. }
  459. char * __init pcibios_setup(char *str)
  460. {
  461. if (!strcmp(str, "off")) {
  462. pci_probe = 0;
  463. return NULL;
  464. } else if (!strcmp(str, "bfsort")) {
  465. pci_bf_sort = pci_force_bf;
  466. return NULL;
  467. } else if (!strcmp(str, "nobfsort")) {
  468. pci_bf_sort = pci_force_nobf;
  469. return NULL;
  470. }
  471. #ifdef CONFIG_PCI_BIOS
  472. else if (!strcmp(str, "bios")) {
  473. pci_probe = PCI_PROBE_BIOS;
  474. return NULL;
  475. } else if (!strcmp(str, "nobios")) {
  476. pci_probe &= ~PCI_PROBE_BIOS;
  477. return NULL;
  478. } else if (!strcmp(str, "biosirq")) {
  479. pci_probe |= PCI_BIOS_IRQ_SCAN;
  480. return NULL;
  481. } else if (!strncmp(str, "pirqaddr=", 9)) {
  482. pirq_table_addr = simple_strtoul(str+9, NULL, 0);
  483. return NULL;
  484. }
  485. #endif
  486. #ifdef CONFIG_PCI_DIRECT
  487. else if (!strcmp(str, "conf1")) {
  488. pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
  489. return NULL;
  490. }
  491. else if (!strcmp(str, "conf2")) {
  492. pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
  493. return NULL;
  494. }
  495. #endif
  496. #ifdef CONFIG_PCI_MMCONFIG
  497. else if (!strcmp(str, "nommconf")) {
  498. pci_probe &= ~PCI_PROBE_MMCONF;
  499. return NULL;
  500. }
  501. else if (!strcmp(str, "check_enable_amd_mmconf")) {
  502. pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
  503. return NULL;
  504. }
  505. #endif
  506. else if (!strcmp(str, "noacpi")) {
  507. acpi_noirq_set();
  508. return NULL;
  509. }
  510. else if (!strcmp(str, "noearly")) {
  511. pci_probe |= PCI_PROBE_NOEARLY;
  512. return NULL;
  513. }
  514. #ifndef CONFIG_X86_VISWS
  515. else if (!strcmp(str, "usepirqmask")) {
  516. pci_probe |= PCI_USE_PIRQ_MASK;
  517. return NULL;
  518. } else if (!strncmp(str, "irqmask=", 8)) {
  519. pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
  520. return NULL;
  521. } else if (!strncmp(str, "lastbus=", 8)) {
  522. pcibios_last_bus = simple_strtol(str+8, NULL, 0);
  523. return NULL;
  524. }
  525. #endif
  526. else if (!strcmp(str, "rom")) {
  527. pci_probe |= PCI_ASSIGN_ROMS;
  528. return NULL;
  529. } else if (!strcmp(str, "norom")) {
  530. pci_probe |= PCI_NOASSIGN_ROMS;
  531. return NULL;
  532. } else if (!strcmp(str, "nobar")) {
  533. pci_probe |= PCI_NOASSIGN_BARS;
  534. return NULL;
  535. } else if (!strcmp(str, "assign-busses")) {
  536. pci_probe |= PCI_ASSIGN_ALL_BUSSES;
  537. return NULL;
  538. } else if (!strcmp(str, "use_crs")) {
  539. pci_probe |= PCI_USE__CRS;
  540. return NULL;
  541. } else if (!strcmp(str, "nocrs")) {
  542. pci_probe |= PCI_ROOT_NO_CRS;
  543. return NULL;
  544. } else if (!strcmp(str, "earlydump")) {
  545. pci_early_dump_regs = 1;
  546. return NULL;
  547. } else if (!strcmp(str, "routeirq")) {
  548. pci_routeirq = 1;
  549. return NULL;
  550. } else if (!strcmp(str, "skip_isa_align")) {
  551. pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
  552. return NULL;
  553. } else if (!strcmp(str, "noioapicquirk")) {
  554. noioapicquirk = 1;
  555. return NULL;
  556. } else if (!strcmp(str, "ioapicreroute")) {
  557. if (noioapicreroute != -1)
  558. noioapicreroute = 0;
  559. return NULL;
  560. } else if (!strcmp(str, "noioapicreroute")) {
  561. if (noioapicreroute != -1)
  562. noioapicreroute = 1;
  563. return NULL;
  564. }
  565. return str;
  566. }
  567. unsigned int pcibios_assign_all_busses(void)
  568. {
  569. return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
  570. }
  571. int pcibios_enable_device(struct pci_dev *dev, int mask)
  572. {
  573. int err;
  574. if ((err = pci_enable_resources(dev, mask)) < 0)
  575. return err;
  576. if (!pci_dev_msi_enabled(dev))
  577. return pcibios_enable_irq(dev);
  578. return 0;
  579. }
  580. void pcibios_disable_device (struct pci_dev *dev)
  581. {
  582. if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq)
  583. pcibios_disable_irq(dev);
  584. }
  585. int pci_ext_cfg_avail(struct pci_dev *dev)
  586. {
  587. if (raw_pci_ext_ops)
  588. return 1;
  589. else
  590. return 0;
  591. }
  592. struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
  593. {
  594. LIST_HEAD(resources);
  595. struct pci_bus *bus = NULL;
  596. struct pci_sysdata *sd;
  597. /*
  598. * Allocate per-root-bus (not per bus) arch-specific data.
  599. * TODO: leak; this memory is never freed.
  600. * It's arguable whether it's worth the trouble to care.
  601. */
  602. sd = kzalloc(sizeof(*sd), GFP_KERNEL);
  603. if (!sd) {
  604. printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
  605. return NULL;
  606. }
  607. sd->node = node;
  608. x86_pci_root_bus_resources(busno, &resources);
  609. printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno);
  610. bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
  611. if (!bus) {
  612. pci_free_resource_list(&resources);
  613. kfree(sd);
  614. }
  615. return bus;
  616. }
  617. struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
  618. {
  619. return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
  620. }
  621. /*
  622. * NUMA info for PCI busses
  623. *
  624. * Early arch code is responsible for filling in reasonable values here.
  625. * A node id of "-1" means "use current node". In other words, if a bus
  626. * has a -1 node id, it's not tightly coupled to any particular chunk
  627. * of memory (as is the case on some Nehalem systems).
  628. */
  629. #ifdef CONFIG_NUMA
  630. #define BUS_NR 256
  631. #ifdef CONFIG_X86_64
  632. static int mp_bus_to_node[BUS_NR] = {
  633. [0 ... BUS_NR - 1] = -1
  634. };
  635. void set_mp_bus_to_node(int busnum, int node)
  636. {
  637. if (busnum >= 0 && busnum < BUS_NR)
  638. mp_bus_to_node[busnum] = node;
  639. }
  640. int get_mp_bus_to_node(int busnum)
  641. {
  642. int node = -1;
  643. if (busnum < 0 || busnum > (BUS_NR - 1))
  644. return node;
  645. node = mp_bus_to_node[busnum];
  646. /*
  647. * let numa_node_id to decide it later in dma_alloc_pages
  648. * if there is no ram on that node
  649. */
  650. if (node != -1 && !node_online(node))
  651. node = -1;
  652. return node;
  653. }
  654. #else /* CONFIG_X86_32 */
  655. static int mp_bus_to_node[BUS_NR] = {
  656. [0 ... BUS_NR - 1] = -1
  657. };
  658. void set_mp_bus_to_node(int busnum, int node)
  659. {
  660. if (busnum >= 0 && busnum < BUS_NR)
  661. mp_bus_to_node[busnum] = (unsigned char) node;
  662. }
  663. int get_mp_bus_to_node(int busnum)
  664. {
  665. int node;
  666. if (busnum < 0 || busnum > (BUS_NR - 1))
  667. return 0;
  668. node = mp_bus_to_node[busnum];
  669. return node;
  670. }
  671. #endif /* CONFIG_X86_32 */
  672. #endif /* CONFIG_NUMA */