mmconfig-shared.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * mmconfig-shared.c - Low-level direct PCI config space access via
  3. * MMCONFIG - common code between i386 and x86-64.
  4. *
  5. * This code does:
  6. * - known chipset handling
  7. * - ACPI decoding and validation
  8. *
  9. * Per-architecture code takes care of the mappings and accesses
  10. * themselves.
  11. */
  12. #include <linux/pci.h>
  13. #include <linux/init.h>
  14. #include <linux/acpi.h>
  15. #include <linux/sfi_acpi.h>
  16. #include <linux/bitmap.h>
  17. #include <linux/dmi.h>
  18. #include <linux/slab.h>
  19. #include <asm/e820.h>
  20. #include <asm/pci_x86.h>
  21. #include <asm/acpi.h>
  22. #define PREFIX "PCI: "
  23. /* Indicate if the mmcfg resources have been placed into the resource table. */
  24. static int __initdata pci_mmcfg_resources_inserted;
  25. LIST_HEAD(pci_mmcfg_list);
  26. static __init void pci_mmconfig_remove(struct pci_mmcfg_region *cfg)
  27. {
  28. if (cfg->res.parent)
  29. release_resource(&cfg->res);
  30. list_del(&cfg->list);
  31. kfree(cfg);
  32. }
  33. static __init void free_all_mmcfg(void)
  34. {
  35. struct pci_mmcfg_region *cfg, *tmp;
  36. pci_mmcfg_arch_free();
  37. list_for_each_entry_safe(cfg, tmp, &pci_mmcfg_list, list)
  38. pci_mmconfig_remove(cfg);
  39. }
  40. static __init void list_add_sorted(struct pci_mmcfg_region *new)
  41. {
  42. struct pci_mmcfg_region *cfg;
  43. /* keep list sorted by segment and starting bus number */
  44. list_for_each_entry(cfg, &pci_mmcfg_list, list) {
  45. if (cfg->segment > new->segment ||
  46. (cfg->segment == new->segment &&
  47. cfg->start_bus >= new->start_bus)) {
  48. list_add_tail(&new->list, &cfg->list);
  49. return;
  50. }
  51. }
  52. list_add_tail(&new->list, &pci_mmcfg_list);
  53. }
  54. static __devinit struct pci_mmcfg_region *pci_mmconfig_alloc(int segment,
  55. int start,
  56. int end, u64 addr)
  57. {
  58. struct pci_mmcfg_region *new;
  59. struct resource *res;
  60. if (addr == 0)
  61. return NULL;
  62. new = kzalloc(sizeof(*new), GFP_KERNEL);
  63. if (!new)
  64. return NULL;
  65. new->address = addr;
  66. new->segment = segment;
  67. new->start_bus = start;
  68. new->end_bus = end;
  69. res = &new->res;
  70. res->start = addr + PCI_MMCFG_BUS_OFFSET(start);
  71. res->end = addr + PCI_MMCFG_BUS_OFFSET(end + 1) - 1;
  72. res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  73. snprintf(new->name, PCI_MMCFG_RESOURCE_NAME_LEN,
  74. "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end);
  75. res->name = new->name;
  76. printk(KERN_INFO PREFIX "MMCONFIG for domain %04x [bus %02x-%02x] at "
  77. "%pR (base %#lx)\n", segment, start, end, &new->res,
  78. (unsigned long) addr);
  79. return new;
  80. }
  81. static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
  82. int end, u64 addr)
  83. {
  84. struct pci_mmcfg_region *new;
  85. new = pci_mmconfig_alloc(segment, start, end, addr);
  86. if (new)
  87. list_add_sorted(new);
  88. return new;
  89. }
  90. struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus)
  91. {
  92. struct pci_mmcfg_region *cfg;
  93. list_for_each_entry(cfg, &pci_mmcfg_list, list)
  94. if (cfg->segment == segment &&
  95. cfg->start_bus <= bus && bus <= cfg->end_bus)
  96. return cfg;
  97. return NULL;
  98. }
  99. static const char __init *pci_mmcfg_e7520(void)
  100. {
  101. u32 win;
  102. raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0xce, 2, &win);
  103. win = win & 0xf000;
  104. if (win == 0x0000 || win == 0xf000)
  105. return NULL;
  106. if (pci_mmconfig_add(0, 0, 255, win << 16) == NULL)
  107. return NULL;
  108. return "Intel Corporation E7520 Memory Controller Hub";
  109. }
  110. static const char __init *pci_mmcfg_intel_945(void)
  111. {
  112. u32 pciexbar, mask = 0, len = 0;
  113. raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0x48, 4, &pciexbar);
  114. /* Enable bit */
  115. if (!(pciexbar & 1))
  116. return NULL;
  117. /* Size bits */
  118. switch ((pciexbar >> 1) & 3) {
  119. case 0:
  120. mask = 0xf0000000U;
  121. len = 0x10000000U;
  122. break;
  123. case 1:
  124. mask = 0xf8000000U;
  125. len = 0x08000000U;
  126. break;
  127. case 2:
  128. mask = 0xfc000000U;
  129. len = 0x04000000U;
  130. break;
  131. default:
  132. return NULL;
  133. }
  134. /* Errata #2, things break when not aligned on a 256Mb boundary */
  135. /* Can only happen in 64M/128M mode */
  136. if ((pciexbar & mask) & 0x0fffffffU)
  137. return NULL;
  138. /* Don't hit the APIC registers and their friends */
  139. if ((pciexbar & mask) >= 0xf0000000U)
  140. return NULL;
  141. if (pci_mmconfig_add(0, 0, (len >> 20) - 1, pciexbar & mask) == NULL)
  142. return NULL;
  143. return "Intel Corporation 945G/GZ/P/PL Express Memory Controller Hub";
  144. }
  145. static const char __init *pci_mmcfg_amd_fam10h(void)
  146. {
  147. u32 low, high, address;
  148. u64 base, msr;
  149. int i;
  150. unsigned segnbits = 0, busnbits, end_bus;
  151. if (!(pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF))
  152. return NULL;
  153. address = MSR_FAM10H_MMIO_CONF_BASE;
  154. if (rdmsr_safe(address, &low, &high))
  155. return NULL;
  156. msr = high;
  157. msr <<= 32;
  158. msr |= low;
  159. /* mmconfig is not enable */
  160. if (!(msr & FAM10H_MMIO_CONF_ENABLE))
  161. return NULL;
  162. base = msr & (FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT);
  163. busnbits = (msr >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) &
  164. FAM10H_MMIO_CONF_BUSRANGE_MASK;
  165. /*
  166. * only handle bus 0 ?
  167. * need to skip it
  168. */
  169. if (!busnbits)
  170. return NULL;
  171. if (busnbits > 8) {
  172. segnbits = busnbits - 8;
  173. busnbits = 8;
  174. }
  175. end_bus = (1 << busnbits) - 1;
  176. for (i = 0; i < (1 << segnbits); i++)
  177. if (pci_mmconfig_add(i, 0, end_bus,
  178. base + (1<<28) * i) == NULL) {
  179. free_all_mmcfg();
  180. return NULL;
  181. }
  182. return "AMD Family 10h NB";
  183. }
  184. static bool __initdata mcp55_checked;
  185. static const char __init *pci_mmcfg_nvidia_mcp55(void)
  186. {
  187. int bus;
  188. int mcp55_mmconf_found = 0;
  189. static const u32 extcfg_regnum = 0x90;
  190. static const u32 extcfg_regsize = 4;
  191. static const u32 extcfg_enable_mask = 1<<31;
  192. static const u32 extcfg_start_mask = 0xff<<16;
  193. static const int extcfg_start_shift = 16;
  194. static const u32 extcfg_size_mask = 0x3<<28;
  195. static const int extcfg_size_shift = 28;
  196. static const int extcfg_sizebus[] = {0x100, 0x80, 0x40, 0x20};
  197. static const u32 extcfg_base_mask[] = {0x7ff8, 0x7ffc, 0x7ffe, 0x7fff};
  198. static const int extcfg_base_lshift = 25;
  199. /*
  200. * do check if amd fam10h already took over
  201. */
  202. if (!acpi_disabled || !list_empty(&pci_mmcfg_list) || mcp55_checked)
  203. return NULL;
  204. mcp55_checked = true;
  205. for (bus = 0; bus < 256; bus++) {
  206. u64 base;
  207. u32 l, extcfg;
  208. u16 vendor, device;
  209. int start, size_index, end;
  210. raw_pci_ops->read(0, bus, PCI_DEVFN(0, 0), 0, 4, &l);
  211. vendor = l & 0xffff;
  212. device = (l >> 16) & 0xffff;
  213. if (PCI_VENDOR_ID_NVIDIA != vendor || 0x0369 != device)
  214. continue;
  215. raw_pci_ops->read(0, bus, PCI_DEVFN(0, 0), extcfg_regnum,
  216. extcfg_regsize, &extcfg);
  217. if (!(extcfg & extcfg_enable_mask))
  218. continue;
  219. size_index = (extcfg & extcfg_size_mask) >> extcfg_size_shift;
  220. base = extcfg & extcfg_base_mask[size_index];
  221. /* base could > 4G */
  222. base <<= extcfg_base_lshift;
  223. start = (extcfg & extcfg_start_mask) >> extcfg_start_shift;
  224. end = start + extcfg_sizebus[size_index] - 1;
  225. if (pci_mmconfig_add(0, start, end, base) == NULL)
  226. continue;
  227. mcp55_mmconf_found++;
  228. }
  229. if (!mcp55_mmconf_found)
  230. return NULL;
  231. return "nVidia MCP55";
  232. }
  233. struct pci_mmcfg_hostbridge_probe {
  234. u32 bus;
  235. u32 devfn;
  236. u32 vendor;
  237. u32 device;
  238. const char *(*probe)(void);
  239. };
  240. static struct pci_mmcfg_hostbridge_probe pci_mmcfg_probes[] __initdata = {
  241. { 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID_INTEL,
  242. PCI_DEVICE_ID_INTEL_E7520_MCH, pci_mmcfg_e7520 },
  243. { 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID_INTEL,
  244. PCI_DEVICE_ID_INTEL_82945G_HB, pci_mmcfg_intel_945 },
  245. { 0, PCI_DEVFN(0x18, 0), PCI_VENDOR_ID_AMD,
  246. 0x1200, pci_mmcfg_amd_fam10h },
  247. { 0xff, PCI_DEVFN(0, 0), PCI_VENDOR_ID_AMD,
  248. 0x1200, pci_mmcfg_amd_fam10h },
  249. { 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID_NVIDIA,
  250. 0x0369, pci_mmcfg_nvidia_mcp55 },
  251. };
  252. static void __init pci_mmcfg_check_end_bus_number(void)
  253. {
  254. struct pci_mmcfg_region *cfg, *cfgx;
  255. /* Fixup overlaps */
  256. list_for_each_entry(cfg, &pci_mmcfg_list, list) {
  257. if (cfg->end_bus < cfg->start_bus)
  258. cfg->end_bus = 255;
  259. /* Don't access the list head ! */
  260. if (cfg->list.next == &pci_mmcfg_list)
  261. break;
  262. cfgx = list_entry(cfg->list.next, typeof(*cfg), list);
  263. if (cfg->end_bus >= cfgx->start_bus)
  264. cfg->end_bus = cfgx->start_bus - 1;
  265. }
  266. }
  267. static int __init pci_mmcfg_check_hostbridge(void)
  268. {
  269. u32 l;
  270. u32 bus, devfn;
  271. u16 vendor, device;
  272. int i;
  273. const char *name;
  274. if (!raw_pci_ops)
  275. return 0;
  276. free_all_mmcfg();
  277. for (i = 0; i < ARRAY_SIZE(pci_mmcfg_probes); i++) {
  278. bus = pci_mmcfg_probes[i].bus;
  279. devfn = pci_mmcfg_probes[i].devfn;
  280. raw_pci_ops->read(0, bus, devfn, 0, 4, &l);
  281. vendor = l & 0xffff;
  282. device = (l >> 16) & 0xffff;
  283. name = NULL;
  284. if (pci_mmcfg_probes[i].vendor == vendor &&
  285. pci_mmcfg_probes[i].device == device)
  286. name = pci_mmcfg_probes[i].probe();
  287. if (name)
  288. printk(KERN_INFO PREFIX "%s with MMCONFIG support\n",
  289. name);
  290. }
  291. /* some end_bus_number is crazy, fix it */
  292. pci_mmcfg_check_end_bus_number();
  293. return !list_empty(&pci_mmcfg_list);
  294. }
  295. static void __init pci_mmcfg_insert_resources(void)
  296. {
  297. struct pci_mmcfg_region *cfg;
  298. list_for_each_entry(cfg, &pci_mmcfg_list, list)
  299. insert_resource(&iomem_resource, &cfg->res);
  300. /* Mark that the resources have been inserted. */
  301. pci_mmcfg_resources_inserted = 1;
  302. }
  303. static acpi_status __init check_mcfg_resource(struct acpi_resource *res,
  304. void *data)
  305. {
  306. struct resource *mcfg_res = data;
  307. struct acpi_resource_address64 address;
  308. acpi_status status;
  309. if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
  310. struct acpi_resource_fixed_memory32 *fixmem32 =
  311. &res->data.fixed_memory32;
  312. if (!fixmem32)
  313. return AE_OK;
  314. if ((mcfg_res->start >= fixmem32->address) &&
  315. (mcfg_res->end < (fixmem32->address +
  316. fixmem32->address_length))) {
  317. mcfg_res->flags = 1;
  318. return AE_CTRL_TERMINATE;
  319. }
  320. }
  321. if ((res->type != ACPI_RESOURCE_TYPE_ADDRESS32) &&
  322. (res->type != ACPI_RESOURCE_TYPE_ADDRESS64))
  323. return AE_OK;
  324. status = acpi_resource_to_address64(res, &address);
  325. if (ACPI_FAILURE(status) ||
  326. (address.address_length <= 0) ||
  327. (address.resource_type != ACPI_MEMORY_RANGE))
  328. return AE_OK;
  329. if ((mcfg_res->start >= address.minimum) &&
  330. (mcfg_res->end < (address.minimum + address.address_length))) {
  331. mcfg_res->flags = 1;
  332. return AE_CTRL_TERMINATE;
  333. }
  334. return AE_OK;
  335. }
  336. static acpi_status __init find_mboard_resource(acpi_handle handle, u32 lvl,
  337. void *context, void **rv)
  338. {
  339. struct resource *mcfg_res = context;
  340. acpi_walk_resources(handle, METHOD_NAME__CRS,
  341. check_mcfg_resource, context);
  342. if (mcfg_res->flags)
  343. return AE_CTRL_TERMINATE;
  344. return AE_OK;
  345. }
  346. static int __init is_acpi_reserved(u64 start, u64 end, unsigned not_used)
  347. {
  348. struct resource mcfg_res;
  349. mcfg_res.start = start;
  350. mcfg_res.end = end - 1;
  351. mcfg_res.flags = 0;
  352. acpi_get_devices("PNP0C01", find_mboard_resource, &mcfg_res, NULL);
  353. if (!mcfg_res.flags)
  354. acpi_get_devices("PNP0C02", find_mboard_resource, &mcfg_res,
  355. NULL);
  356. return mcfg_res.flags;
  357. }
  358. typedef int (*check_reserved_t)(u64 start, u64 end, unsigned type);
  359. static int __init is_mmconf_reserved(check_reserved_t is_reserved,
  360. struct pci_mmcfg_region *cfg, int with_e820)
  361. {
  362. u64 addr = cfg->res.start;
  363. u64 size = resource_size(&cfg->res);
  364. u64 old_size = size;
  365. int valid = 0, num_buses;
  366. while (!is_reserved(addr, addr + size, E820_RESERVED)) {
  367. size >>= 1;
  368. if (size < (16UL<<20))
  369. break;
  370. }
  371. if (size >= (16UL<<20) || size == old_size) {
  372. printk(KERN_INFO PREFIX "MMCONFIG at %pR reserved in %s\n",
  373. &cfg->res,
  374. with_e820 ? "E820" : "ACPI motherboard resources");
  375. valid = 1;
  376. if (old_size != size) {
  377. /* update end_bus */
  378. cfg->end_bus = cfg->start_bus + ((size>>20) - 1);
  379. num_buses = cfg->end_bus - cfg->start_bus + 1;
  380. cfg->res.end = cfg->res.start +
  381. PCI_MMCFG_BUS_OFFSET(num_buses) - 1;
  382. snprintf(cfg->name, PCI_MMCFG_RESOURCE_NAME_LEN,
  383. "PCI MMCONFIG %04x [bus %02x-%02x]",
  384. cfg->segment, cfg->start_bus, cfg->end_bus);
  385. printk(KERN_INFO PREFIX
  386. "MMCONFIG for %04x [bus%02x-%02x] "
  387. "at %pR (base %#lx) (size reduced!)\n",
  388. cfg->segment, cfg->start_bus, cfg->end_bus,
  389. &cfg->res, (unsigned long) cfg->address);
  390. }
  391. }
  392. return valid;
  393. }
  394. static int __devinit pci_mmcfg_check_reserved(struct pci_mmcfg_region *cfg,
  395. int early)
  396. {
  397. if (!early && !acpi_disabled) {
  398. if (is_mmconf_reserved(is_acpi_reserved, cfg, 0))
  399. return 1;
  400. else
  401. printk(KERN_ERR FW_BUG PREFIX
  402. "MMCONFIG at %pR not reserved in "
  403. "ACPI motherboard resources\n",
  404. &cfg->res);
  405. }
  406. /* Don't try to do this check unless configuration
  407. type 1 is available. how about type 2 ?*/
  408. if (raw_pci_ops)
  409. return is_mmconf_reserved(e820_all_mapped, cfg, 1);
  410. return 0;
  411. }
  412. static void __init pci_mmcfg_reject_broken(int early)
  413. {
  414. struct pci_mmcfg_region *cfg;
  415. list_for_each_entry(cfg, &pci_mmcfg_list, list) {
  416. if (pci_mmcfg_check_reserved(cfg, early) == 0) {
  417. printk(KERN_INFO PREFIX "not using MMCONFIG\n");
  418. free_all_mmcfg();
  419. return;
  420. }
  421. }
  422. }
  423. static int __initdata known_bridge;
  424. static int __init acpi_mcfg_check_entry(struct acpi_table_mcfg *mcfg,
  425. struct acpi_mcfg_allocation *cfg)
  426. {
  427. int year;
  428. if (cfg->address < 0xFFFFFFFF)
  429. return 0;
  430. if (!strcmp(mcfg->header.oem_id, "SGI") ||
  431. !strcmp(mcfg->header.oem_id, "SGI2"))
  432. return 0;
  433. if (mcfg->header.revision >= 1) {
  434. if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) &&
  435. year >= 2010)
  436. return 0;
  437. }
  438. printk(KERN_ERR PREFIX "MCFG region for %04x [bus %02x-%02x] at %#llx "
  439. "is above 4GB, ignored\n", cfg->pci_segment,
  440. cfg->start_bus_number, cfg->end_bus_number, cfg->address);
  441. return -EINVAL;
  442. }
  443. static int __init pci_parse_mcfg(struct acpi_table_header *header)
  444. {
  445. struct acpi_table_mcfg *mcfg;
  446. struct acpi_mcfg_allocation *cfg_table, *cfg;
  447. unsigned long i;
  448. int entries;
  449. if (!header)
  450. return -EINVAL;
  451. mcfg = (struct acpi_table_mcfg *)header;
  452. /* how many config structures do we have */
  453. free_all_mmcfg();
  454. entries = 0;
  455. i = header->length - sizeof(struct acpi_table_mcfg);
  456. while (i >= sizeof(struct acpi_mcfg_allocation)) {
  457. entries++;
  458. i -= sizeof(struct acpi_mcfg_allocation);
  459. };
  460. if (entries == 0) {
  461. printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
  462. return -ENODEV;
  463. }
  464. cfg_table = (struct acpi_mcfg_allocation *) &mcfg[1];
  465. for (i = 0; i < entries; i++) {
  466. cfg = &cfg_table[i];
  467. if (acpi_mcfg_check_entry(mcfg, cfg)) {
  468. free_all_mmcfg();
  469. return -ENODEV;
  470. }
  471. if (pci_mmconfig_add(cfg->pci_segment, cfg->start_bus_number,
  472. cfg->end_bus_number, cfg->address) == NULL) {
  473. printk(KERN_WARNING PREFIX
  474. "no memory for MCFG entries\n");
  475. free_all_mmcfg();
  476. return -ENOMEM;
  477. }
  478. }
  479. return 0;
  480. }
  481. static void __init __pci_mmcfg_init(int early)
  482. {
  483. /* MMCONFIG disabled */
  484. if ((pci_probe & PCI_PROBE_MMCONF) == 0)
  485. return;
  486. /* MMCONFIG already enabled */
  487. if (!early && !(pci_probe & PCI_PROBE_MASK & ~PCI_PROBE_MMCONF))
  488. return;
  489. /* for late to exit */
  490. if (known_bridge)
  491. return;
  492. if (early) {
  493. if (pci_mmcfg_check_hostbridge())
  494. known_bridge = 1;
  495. }
  496. if (!known_bridge)
  497. acpi_sfi_table_parse(ACPI_SIG_MCFG, pci_parse_mcfg);
  498. pci_mmcfg_reject_broken(early);
  499. if (list_empty(&pci_mmcfg_list))
  500. return;
  501. if (pcibios_last_bus < 0) {
  502. const struct pci_mmcfg_region *cfg;
  503. list_for_each_entry(cfg, &pci_mmcfg_list, list) {
  504. if (cfg->segment)
  505. break;
  506. pcibios_last_bus = cfg->end_bus;
  507. }
  508. }
  509. if (pci_mmcfg_arch_init())
  510. pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
  511. else {
  512. /*
  513. * Signal not to attempt to insert mmcfg resources because
  514. * the architecture mmcfg setup could not initialize.
  515. */
  516. pci_mmcfg_resources_inserted = 1;
  517. }
  518. }
  519. void __init pci_mmcfg_early_init(void)
  520. {
  521. __pci_mmcfg_init(1);
  522. }
  523. void __init pci_mmcfg_late_init(void)
  524. {
  525. __pci_mmcfg_init(0);
  526. }
  527. static int __init pci_mmcfg_late_insert_resources(void)
  528. {
  529. /*
  530. * If resources are already inserted or we are not using MMCONFIG,
  531. * don't insert the resources.
  532. */
  533. if ((pci_mmcfg_resources_inserted == 1) ||
  534. (pci_probe & PCI_PROBE_MMCONF) == 0 ||
  535. list_empty(&pci_mmcfg_list))
  536. return 1;
  537. /*
  538. * Attempt to insert the mmcfg resources but not with the busy flag
  539. * marked so it won't cause request errors when __request_region is
  540. * called.
  541. */
  542. pci_mmcfg_insert_resources();
  543. return 0;
  544. }
  545. /*
  546. * Perform MMCONFIG resource insertion after PCI initialization to allow for
  547. * misprogrammed MCFG tables that state larger sizes but actually conflict
  548. * with other system resources.
  549. */
  550. late_initcall(pci_mmcfg_late_insert_resources);