common.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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/pci-acpi.h>
  9. #include <linux/ioport.h>
  10. #include <linux/init.h>
  11. #include <linux/dmi.h>
  12. #include <linux/slab.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. #include <asm/setup.h>
  19. unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
  20. PCI_PROBE_MMCONF;
  21. unsigned int pci_early_dump_regs;
  22. static int pci_bf_sort;
  23. static int smbios_type_b1_flag;
  24. int pci_routeirq;
  25. int noioapicquirk;
  26. #ifdef CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS
  27. int noioapicreroute = 0;
  28. #else
  29. int noioapicreroute = 1;
  30. #endif
  31. int pcibios_last_bus = -1;
  32. unsigned long pirq_table_addr;
  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 __init 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[] __initconst = {
  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 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 attempt 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 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. void pcibios_add_bus(struct pci_bus *bus)
  154. {
  155. acpi_pci_add_bus(bus);
  156. }
  157. void pcibios_remove_bus(struct pci_bus *bus)
  158. {
  159. acpi_pci_remove_bus(bus);
  160. }
  161. /*
  162. * Only use DMI information to set this if nothing was passed
  163. * on the kernel command line (which was parsed earlier).
  164. */
  165. static int __init set_bf_sort(const struct dmi_system_id *d)
  166. {
  167. if (pci_bf_sort == pci_bf_sort_default) {
  168. pci_bf_sort = pci_dmi_bf;
  169. printk(KERN_INFO "PCI: %s detected, enabling pci=bfsort.\n", d->ident);
  170. }
  171. return 0;
  172. }
  173. static void __init read_dmi_type_b1(const struct dmi_header *dm,
  174. void *private_data)
  175. {
  176. u8 *d = (u8 *)dm + 4;
  177. if (dm->type != 0xB1)
  178. return;
  179. switch (((*(u32 *)d) >> 9) & 0x03) {
  180. case 0x00:
  181. printk(KERN_INFO "dmi type 0xB1 record - unknown flag\n");
  182. break;
  183. case 0x01: /* set pci=bfsort */
  184. smbios_type_b1_flag = 1;
  185. break;
  186. case 0x02: /* do not set pci=bfsort */
  187. smbios_type_b1_flag = 2;
  188. break;
  189. default:
  190. break;
  191. }
  192. }
  193. static int __init find_sort_method(const struct dmi_system_id *d)
  194. {
  195. dmi_walk(read_dmi_type_b1, NULL);
  196. if (smbios_type_b1_flag == 1) {
  197. set_bf_sort(d);
  198. return 0;
  199. }
  200. return -1;
  201. }
  202. /*
  203. * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
  204. */
  205. #ifdef __i386__
  206. static int __init assign_all_busses(const struct dmi_system_id *d)
  207. {
  208. pci_probe |= PCI_ASSIGN_ALL_BUSSES;
  209. printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
  210. " (pci=assign-busses)\n", d->ident);
  211. return 0;
  212. }
  213. #endif
  214. static int __init set_scan_all(const struct dmi_system_id *d)
  215. {
  216. printk(KERN_INFO "PCI: %s detected, enabling pci=pcie_scan_all\n",
  217. d->ident);
  218. pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
  219. return 0;
  220. }
  221. static const struct dmi_system_id pciprobe_dmi_table[] __initconst = {
  222. #ifdef __i386__
  223. /*
  224. * Laptops which need pci=assign-busses to see Cardbus cards
  225. */
  226. {
  227. .callback = assign_all_busses,
  228. .ident = "Samsung X20 Laptop",
  229. .matches = {
  230. DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
  231. DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
  232. },
  233. },
  234. #endif /* __i386__ */
  235. {
  236. .callback = set_bf_sort,
  237. .ident = "Dell PowerEdge 1950",
  238. .matches = {
  239. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  240. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
  241. },
  242. },
  243. {
  244. .callback = set_bf_sort,
  245. .ident = "Dell PowerEdge 1955",
  246. .matches = {
  247. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  248. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1955"),
  249. },
  250. },
  251. {
  252. .callback = set_bf_sort,
  253. .ident = "Dell PowerEdge 2900",
  254. .matches = {
  255. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  256. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2900"),
  257. },
  258. },
  259. {
  260. .callback = set_bf_sort,
  261. .ident = "Dell PowerEdge 2950",
  262. .matches = {
  263. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  264. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2950"),
  265. },
  266. },
  267. {
  268. .callback = set_bf_sort,
  269. .ident = "Dell PowerEdge R900",
  270. .matches = {
  271. DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
  272. DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R900"),
  273. },
  274. },
  275. {
  276. .callback = find_sort_method,
  277. .ident = "Dell System",
  278. .matches = {
  279. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  280. },
  281. },
  282. {
  283. .callback = set_bf_sort,
  284. .ident = "HP ProLiant BL20p G3",
  285. .matches = {
  286. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  287. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G3"),
  288. },
  289. },
  290. {
  291. .callback = set_bf_sort,
  292. .ident = "HP ProLiant BL20p G4",
  293. .matches = {
  294. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  295. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL20p G4"),
  296. },
  297. },
  298. {
  299. .callback = set_bf_sort,
  300. .ident = "HP ProLiant BL30p G1",
  301. .matches = {
  302. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  303. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL30p G1"),
  304. },
  305. },
  306. {
  307. .callback = set_bf_sort,
  308. .ident = "HP ProLiant BL25p G1",
  309. .matches = {
  310. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  311. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL25p G1"),
  312. },
  313. },
  314. {
  315. .callback = set_bf_sort,
  316. .ident = "HP ProLiant BL35p G1",
  317. .matches = {
  318. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  319. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL35p G1"),
  320. },
  321. },
  322. {
  323. .callback = set_bf_sort,
  324. .ident = "HP ProLiant BL45p G1",
  325. .matches = {
  326. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  327. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G1"),
  328. },
  329. },
  330. {
  331. .callback = set_bf_sort,
  332. .ident = "HP ProLiant BL45p G2",
  333. .matches = {
  334. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  335. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL45p G2"),
  336. },
  337. },
  338. {
  339. .callback = set_bf_sort,
  340. .ident = "HP ProLiant BL460c G1",
  341. .matches = {
  342. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  343. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL460c G1"),
  344. },
  345. },
  346. {
  347. .callback = set_bf_sort,
  348. .ident = "HP ProLiant BL465c G1",
  349. .matches = {
  350. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  351. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL465c G1"),
  352. },
  353. },
  354. {
  355. .callback = set_bf_sort,
  356. .ident = "HP ProLiant BL480c G1",
  357. .matches = {
  358. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  359. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL480c G1"),
  360. },
  361. },
  362. {
  363. .callback = set_bf_sort,
  364. .ident = "HP ProLiant BL685c G1",
  365. .matches = {
  366. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  367. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant BL685c G1"),
  368. },
  369. },
  370. {
  371. .callback = set_bf_sort,
  372. .ident = "HP ProLiant DL360",
  373. .matches = {
  374. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  375. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL360"),
  376. },
  377. },
  378. {
  379. .callback = set_bf_sort,
  380. .ident = "HP ProLiant DL380",
  381. .matches = {
  382. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  383. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL380"),
  384. },
  385. },
  386. #ifdef __i386__
  387. {
  388. .callback = assign_all_busses,
  389. .ident = "Compaq EVO N800c",
  390. .matches = {
  391. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  392. DMI_MATCH(DMI_PRODUCT_NAME, "EVO N800c"),
  393. },
  394. },
  395. #endif
  396. {
  397. .callback = set_bf_sort,
  398. .ident = "HP ProLiant DL385 G2",
  399. .matches = {
  400. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  401. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL385 G2"),
  402. },
  403. },
  404. {
  405. .callback = set_bf_sort,
  406. .ident = "HP ProLiant DL585 G2",
  407. .matches = {
  408. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  409. DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant DL585 G2"),
  410. },
  411. },
  412. {
  413. .callback = set_scan_all,
  414. .ident = "Stratus/NEC ftServer",
  415. .matches = {
  416. DMI_MATCH(DMI_SYS_VENDOR, "Stratus"),
  417. DMI_MATCH(DMI_PRODUCT_NAME, "ftServer"),
  418. },
  419. },
  420. {
  421. .callback = set_scan_all,
  422. .ident = "Stratus/NEC ftServer",
  423. .matches = {
  424. DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
  425. DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R32"),
  426. },
  427. },
  428. {
  429. .callback = set_scan_all,
  430. .ident = "Stratus/NEC ftServer",
  431. .matches = {
  432. DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
  433. DMI_MATCH(DMI_PRODUCT_NAME, "Express5800/R31"),
  434. },
  435. },
  436. {}
  437. };
  438. void __init dmi_check_pciprobe(void)
  439. {
  440. dmi_check_system(pciprobe_dmi_table);
  441. }
  442. void pcibios_scan_root(int busnum)
  443. {
  444. struct pci_bus *bus;
  445. struct pci_sysdata *sd;
  446. LIST_HEAD(resources);
  447. sd = kzalloc(sizeof(*sd), GFP_KERNEL);
  448. if (!sd) {
  449. printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum);
  450. return;
  451. }
  452. sd->node = x86_pci_root_bus_node(busnum);
  453. x86_pci_root_bus_resources(busnum, &resources);
  454. printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
  455. bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources);
  456. if (!bus) {
  457. pci_free_resource_list(&resources);
  458. kfree(sd);
  459. return;
  460. }
  461. pci_bus_add_devices(bus);
  462. }
  463. void __init pcibios_set_cache_line_size(void)
  464. {
  465. struct cpuinfo_x86 *c = &boot_cpu_data;
  466. /*
  467. * Set PCI cacheline size to that of the CPU if the CPU has reported it.
  468. * (For older CPUs that don't support cpuid, we se it to 32 bytes
  469. * It's also good for 386/486s (which actually have 16)
  470. * as quite a few PCI devices do not support smaller values.
  471. */
  472. if (c->x86_clflush_size > 0) {
  473. pci_dfl_cache_line_size = c->x86_clflush_size >> 2;
  474. printk(KERN_DEBUG "PCI: pci_cache_line_size set to %d bytes\n",
  475. pci_dfl_cache_line_size << 2);
  476. } else {
  477. pci_dfl_cache_line_size = 32 >> 2;
  478. printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
  479. }
  480. }
  481. int __init pcibios_init(void)
  482. {
  483. if (!raw_pci_ops && !raw_pci_ext_ops) {
  484. printk(KERN_WARNING "PCI: System does not support PCI\n");
  485. return 0;
  486. }
  487. pcibios_set_cache_line_size();
  488. pcibios_resource_survey();
  489. if (pci_bf_sort >= pci_force_bf)
  490. pci_sort_breadthfirst();
  491. return 0;
  492. }
  493. char *__init pcibios_setup(char *str)
  494. {
  495. if (!strcmp(str, "off")) {
  496. pci_probe = 0;
  497. return NULL;
  498. } else if (!strcmp(str, "bfsort")) {
  499. pci_bf_sort = pci_force_bf;
  500. return NULL;
  501. } else if (!strcmp(str, "nobfsort")) {
  502. pci_bf_sort = pci_force_nobf;
  503. return NULL;
  504. }
  505. #ifdef CONFIG_PCI_BIOS
  506. else if (!strcmp(str, "bios")) {
  507. pci_probe = PCI_PROBE_BIOS;
  508. return NULL;
  509. } else if (!strcmp(str, "nobios")) {
  510. pci_probe &= ~PCI_PROBE_BIOS;
  511. return NULL;
  512. } else if (!strcmp(str, "biosirq")) {
  513. pci_probe |= PCI_BIOS_IRQ_SCAN;
  514. return NULL;
  515. } else if (!strncmp(str, "pirqaddr=", 9)) {
  516. pirq_table_addr = simple_strtoul(str+9, NULL, 0);
  517. return NULL;
  518. }
  519. #endif
  520. #ifdef CONFIG_PCI_DIRECT
  521. else if (!strcmp(str, "conf1")) {
  522. pci_probe = PCI_PROBE_CONF1 | PCI_NO_CHECKS;
  523. return NULL;
  524. }
  525. else if (!strcmp(str, "conf2")) {
  526. pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
  527. return NULL;
  528. }
  529. #endif
  530. #ifdef CONFIG_PCI_MMCONFIG
  531. else if (!strcmp(str, "nommconf")) {
  532. pci_probe &= ~PCI_PROBE_MMCONF;
  533. return NULL;
  534. }
  535. else if (!strcmp(str, "check_enable_amd_mmconf")) {
  536. pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
  537. return NULL;
  538. }
  539. #endif
  540. else if (!strcmp(str, "noacpi")) {
  541. acpi_noirq_set();
  542. return NULL;
  543. }
  544. else if (!strcmp(str, "noearly")) {
  545. pci_probe |= PCI_PROBE_NOEARLY;
  546. return NULL;
  547. }
  548. else if (!strcmp(str, "usepirqmask")) {
  549. pci_probe |= PCI_USE_PIRQ_MASK;
  550. return NULL;
  551. } else if (!strncmp(str, "irqmask=", 8)) {
  552. pcibios_irq_mask = simple_strtol(str+8, NULL, 0);
  553. return NULL;
  554. } else if (!strncmp(str, "lastbus=", 8)) {
  555. pcibios_last_bus = simple_strtol(str+8, NULL, 0);
  556. return NULL;
  557. } else if (!strcmp(str, "rom")) {
  558. pci_probe |= PCI_ASSIGN_ROMS;
  559. return NULL;
  560. } else if (!strcmp(str, "norom")) {
  561. pci_probe |= PCI_NOASSIGN_ROMS;
  562. return NULL;
  563. } else if (!strcmp(str, "nobar")) {
  564. pci_probe |= PCI_NOASSIGN_BARS;
  565. return NULL;
  566. } else if (!strcmp(str, "assign-busses")) {
  567. pci_probe |= PCI_ASSIGN_ALL_BUSSES;
  568. return NULL;
  569. } else if (!strcmp(str, "use_crs")) {
  570. pci_probe |= PCI_USE__CRS;
  571. return NULL;
  572. } else if (!strcmp(str, "nocrs")) {
  573. pci_probe |= PCI_ROOT_NO_CRS;
  574. return NULL;
  575. } else if (!strcmp(str, "earlydump")) {
  576. pci_early_dump_regs = 1;
  577. return NULL;
  578. } else if (!strcmp(str, "routeirq")) {
  579. pci_routeirq = 1;
  580. return NULL;
  581. } else if (!strcmp(str, "skip_isa_align")) {
  582. pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
  583. return NULL;
  584. } else if (!strcmp(str, "noioapicquirk")) {
  585. noioapicquirk = 1;
  586. return NULL;
  587. } else if (!strcmp(str, "ioapicreroute")) {
  588. if (noioapicreroute != -1)
  589. noioapicreroute = 0;
  590. return NULL;
  591. } else if (!strcmp(str, "noioapicreroute")) {
  592. if (noioapicreroute != -1)
  593. noioapicreroute = 1;
  594. return NULL;
  595. }
  596. return str;
  597. }
  598. unsigned int pcibios_assign_all_busses(void)
  599. {
  600. return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
  601. }
  602. #if defined(CONFIG_X86_DEV_DMA_OPS) && defined(CONFIG_PCI_DOMAINS)
  603. static LIST_HEAD(dma_domain_list);
  604. static DEFINE_SPINLOCK(dma_domain_list_lock);
  605. void add_dma_domain(struct dma_domain *domain)
  606. {
  607. spin_lock(&dma_domain_list_lock);
  608. list_add(&domain->node, &dma_domain_list);
  609. spin_unlock(&dma_domain_list_lock);
  610. }
  611. EXPORT_SYMBOL_GPL(add_dma_domain);
  612. void del_dma_domain(struct dma_domain *domain)
  613. {
  614. spin_lock(&dma_domain_list_lock);
  615. list_del(&domain->node);
  616. spin_unlock(&dma_domain_list_lock);
  617. }
  618. EXPORT_SYMBOL_GPL(del_dma_domain);
  619. static void set_dma_domain_ops(struct pci_dev *pdev)
  620. {
  621. struct dma_domain *domain;
  622. spin_lock(&dma_domain_list_lock);
  623. list_for_each_entry(domain, &dma_domain_list, node) {
  624. if (pci_domain_nr(pdev->bus) == domain->domain_nr) {
  625. pdev->dev.archdata.dma_ops = domain->dma_ops;
  626. break;
  627. }
  628. }
  629. spin_unlock(&dma_domain_list_lock);
  630. }
  631. #else
  632. static void set_dma_domain_ops(struct pci_dev *pdev) {}
  633. #endif
  634. static void set_dev_domain_options(struct pci_dev *pdev)
  635. {
  636. if (is_vmd(pdev->bus))
  637. pdev->hotplug_user_indicators = 1;
  638. }
  639. int pcibios_add_device(struct pci_dev *dev)
  640. {
  641. struct setup_data *data;
  642. struct pci_setup_rom *rom;
  643. u64 pa_data;
  644. pa_data = boot_params.hdr.setup_data;
  645. while (pa_data) {
  646. data = ioremap(pa_data, sizeof(*rom));
  647. if (!data)
  648. return -ENOMEM;
  649. if (data->type == SETUP_PCI) {
  650. rom = (struct pci_setup_rom *)data;
  651. if ((pci_domain_nr(dev->bus) == rom->segment) &&
  652. (dev->bus->number == rom->bus) &&
  653. (PCI_SLOT(dev->devfn) == rom->device) &&
  654. (PCI_FUNC(dev->devfn) == rom->function) &&
  655. (dev->vendor == rom->vendor) &&
  656. (dev->device == rom->devid)) {
  657. dev->rom = pa_data +
  658. offsetof(struct pci_setup_rom, romdata);
  659. dev->romlen = rom->pcilen;
  660. }
  661. }
  662. pa_data = data->next;
  663. iounmap(data);
  664. }
  665. set_dma_domain_ops(dev);
  666. set_dev_domain_options(dev);
  667. return 0;
  668. }
  669. int pcibios_enable_device(struct pci_dev *dev, int mask)
  670. {
  671. int err;
  672. if ((err = pci_enable_resources(dev, mask)) < 0)
  673. return err;
  674. if (!pci_dev_msi_enabled(dev))
  675. return pcibios_enable_irq(dev);
  676. return 0;
  677. }
  678. void pcibios_disable_device (struct pci_dev *dev)
  679. {
  680. if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq)
  681. pcibios_disable_irq(dev);
  682. }
  683. int pci_ext_cfg_avail(void)
  684. {
  685. if (raw_pci_ext_ops)
  686. return 1;
  687. else
  688. return 0;
  689. }