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