pci_root.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * pci_root.c - ACPI PCI Root Bridge Driver ($Revision: 40 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/types.h>
  29. #include <linux/mutex.h>
  30. #include <linux/pm.h>
  31. #include <linux/pm_runtime.h>
  32. #include <linux/pci.h>
  33. #include <linux/pci-acpi.h>
  34. #include <linux/pci-aspm.h>
  35. #include <linux/acpi.h>
  36. #include <linux/slab.h>
  37. #include <acpi/apei.h> /* for acpi_hest_init() */
  38. #include "internal.h"
  39. #define PREFIX "ACPI: "
  40. #define _COMPONENT ACPI_PCI_COMPONENT
  41. ACPI_MODULE_NAME("pci_root");
  42. #define ACPI_PCI_ROOT_CLASS "pci_bridge"
  43. #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
  44. static int acpi_pci_root_add(struct acpi_device *device,
  45. const struct acpi_device_id *not_used);
  46. static void acpi_pci_root_remove(struct acpi_device *device);
  47. static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
  48. {
  49. acpiphp_check_host_bridge(adev->handle);
  50. return 0;
  51. }
  52. #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \
  53. | OSC_PCI_ASPM_SUPPORT \
  54. | OSC_PCI_CLOCK_PM_SUPPORT \
  55. | OSC_PCI_MSI_SUPPORT)
  56. static const struct acpi_device_id root_device_ids[] = {
  57. {"PNP0A03", 0},
  58. {"", 0},
  59. };
  60. static struct acpi_scan_handler pci_root_handler = {
  61. .ids = root_device_ids,
  62. .attach = acpi_pci_root_add,
  63. .detach = acpi_pci_root_remove,
  64. .hotplug = {
  65. .enabled = true,
  66. .scan_dependent = acpi_pci_root_scan_dependent,
  67. },
  68. };
  69. static DEFINE_MUTEX(osc_lock);
  70. /**
  71. * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge
  72. * @handle - the ACPI CA node in question.
  73. *
  74. * Note: we could make this API take a struct acpi_device * instead, but
  75. * for now, it's more convenient to operate on an acpi_handle.
  76. */
  77. int acpi_is_root_bridge(acpi_handle handle)
  78. {
  79. int ret;
  80. struct acpi_device *device;
  81. ret = acpi_bus_get_device(handle, &device);
  82. if (ret)
  83. return 0;
  84. ret = acpi_match_device_ids(device, root_device_ids);
  85. if (ret)
  86. return 0;
  87. else
  88. return 1;
  89. }
  90. EXPORT_SYMBOL_GPL(acpi_is_root_bridge);
  91. static acpi_status
  92. get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
  93. {
  94. struct resource *res = data;
  95. struct acpi_resource_address64 address;
  96. acpi_status status;
  97. status = acpi_resource_to_address64(resource, &address);
  98. if (ACPI_FAILURE(status))
  99. return AE_OK;
  100. if ((address.address_length > 0) &&
  101. (address.resource_type == ACPI_BUS_NUMBER_RANGE)) {
  102. res->start = address.minimum;
  103. res->end = address.minimum + address.address_length - 1;
  104. }
  105. return AE_OK;
  106. }
  107. static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
  108. struct resource *res)
  109. {
  110. acpi_status status;
  111. res->start = -1;
  112. status =
  113. acpi_walk_resources(handle, METHOD_NAME__CRS,
  114. get_root_bridge_busnr_callback, res);
  115. if (ACPI_FAILURE(status))
  116. return status;
  117. if (res->start == -1)
  118. return AE_ERROR;
  119. return AE_OK;
  120. }
  121. struct pci_osc_bit_struct {
  122. u32 bit;
  123. char *desc;
  124. };
  125. static struct pci_osc_bit_struct pci_osc_support_bit[] = {
  126. { OSC_PCI_EXT_CONFIG_SUPPORT, "ExtendedConfig" },
  127. { OSC_PCI_ASPM_SUPPORT, "ASPM" },
  128. { OSC_PCI_CLOCK_PM_SUPPORT, "ClockPM" },
  129. { OSC_PCI_SEGMENT_GROUPS_SUPPORT, "Segments" },
  130. { OSC_PCI_MSI_SUPPORT, "MSI" },
  131. };
  132. static struct pci_osc_bit_struct pci_osc_control_bit[] = {
  133. { OSC_PCI_EXPRESS_NATIVE_HP_CONTROL, "PCIeHotplug" },
  134. { OSC_PCI_SHPC_NATIVE_HP_CONTROL, "SHPCHotplug" },
  135. { OSC_PCI_EXPRESS_PME_CONTROL, "PME" },
  136. { OSC_PCI_EXPRESS_AER_CONTROL, "AER" },
  137. { OSC_PCI_EXPRESS_CAPABILITY_CONTROL, "PCIeCapability" },
  138. };
  139. static void decode_osc_bits(struct acpi_pci_root *root, char *msg, u32 word,
  140. struct pci_osc_bit_struct *table, int size)
  141. {
  142. char buf[80];
  143. int i, len = 0;
  144. struct pci_osc_bit_struct *entry;
  145. buf[0] = '\0';
  146. for (i = 0, entry = table; i < size; i++, entry++)
  147. if (word & entry->bit)
  148. len += snprintf(buf + len, sizeof(buf) - len, "%s%s",
  149. len ? " " : "", entry->desc);
  150. dev_info(&root->device->dev, "_OSC: %s [%s]\n", msg, buf);
  151. }
  152. static void decode_osc_support(struct acpi_pci_root *root, char *msg, u32 word)
  153. {
  154. decode_osc_bits(root, msg, word, pci_osc_support_bit,
  155. ARRAY_SIZE(pci_osc_support_bit));
  156. }
  157. static void decode_osc_control(struct acpi_pci_root *root, char *msg, u32 word)
  158. {
  159. decode_osc_bits(root, msg, word, pci_osc_control_bit,
  160. ARRAY_SIZE(pci_osc_control_bit));
  161. }
  162. static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
  163. static acpi_status acpi_pci_run_osc(acpi_handle handle,
  164. const u32 *capbuf, u32 *retval)
  165. {
  166. struct acpi_osc_context context = {
  167. .uuid_str = pci_osc_uuid_str,
  168. .rev = 1,
  169. .cap.length = 12,
  170. .cap.pointer = (void *)capbuf,
  171. };
  172. acpi_status status;
  173. status = acpi_run_osc(handle, &context);
  174. if (ACPI_SUCCESS(status)) {
  175. *retval = *((u32 *)(context.ret.pointer + 8));
  176. kfree(context.ret.pointer);
  177. }
  178. return status;
  179. }
  180. static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
  181. u32 support,
  182. u32 *control)
  183. {
  184. acpi_status status;
  185. u32 result, capbuf[3];
  186. support &= OSC_PCI_SUPPORT_MASKS;
  187. support |= root->osc_support_set;
  188. capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
  189. capbuf[OSC_SUPPORT_DWORD] = support;
  190. if (control) {
  191. *control &= OSC_PCI_CONTROL_MASKS;
  192. capbuf[OSC_CONTROL_DWORD] = *control | root->osc_control_set;
  193. } else {
  194. /* Run _OSC query only with existing controls. */
  195. capbuf[OSC_CONTROL_DWORD] = root->osc_control_set;
  196. }
  197. status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
  198. if (ACPI_SUCCESS(status)) {
  199. root->osc_support_set = support;
  200. if (control)
  201. *control = result;
  202. }
  203. return status;
  204. }
  205. static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
  206. {
  207. acpi_status status;
  208. mutex_lock(&osc_lock);
  209. status = acpi_pci_query_osc(root, flags, NULL);
  210. mutex_unlock(&osc_lock);
  211. return status;
  212. }
  213. struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
  214. {
  215. struct acpi_pci_root *root;
  216. struct acpi_device *device;
  217. if (acpi_bus_get_device(handle, &device) ||
  218. acpi_match_device_ids(device, root_device_ids))
  219. return NULL;
  220. root = acpi_driver_data(device);
  221. return root;
  222. }
  223. EXPORT_SYMBOL_GPL(acpi_pci_find_root);
  224. struct acpi_handle_node {
  225. struct list_head node;
  226. acpi_handle handle;
  227. };
  228. /**
  229. * acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
  230. * @handle: the handle in question
  231. *
  232. * Given an ACPI CA handle, the desired PCI device is located in the
  233. * list of PCI devices.
  234. *
  235. * If the device is found, its reference count is increased and this
  236. * function returns a pointer to its data structure. The caller must
  237. * decrement the reference count by calling pci_dev_put().
  238. * If no device is found, %NULL is returned.
  239. */
  240. struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
  241. {
  242. int dev, fn;
  243. unsigned long long adr;
  244. acpi_status status;
  245. acpi_handle phandle;
  246. struct pci_bus *pbus;
  247. struct pci_dev *pdev = NULL;
  248. struct acpi_handle_node *node, *tmp;
  249. struct acpi_pci_root *root;
  250. LIST_HEAD(device_list);
  251. /*
  252. * Walk up the ACPI CA namespace until we reach a PCI root bridge.
  253. */
  254. phandle = handle;
  255. while (!acpi_is_root_bridge(phandle)) {
  256. node = kzalloc(sizeof(struct acpi_handle_node), GFP_KERNEL);
  257. if (!node)
  258. goto out;
  259. INIT_LIST_HEAD(&node->node);
  260. node->handle = phandle;
  261. list_add(&node->node, &device_list);
  262. status = acpi_get_parent(phandle, &phandle);
  263. if (ACPI_FAILURE(status))
  264. goto out;
  265. }
  266. root = acpi_pci_find_root(phandle);
  267. if (!root)
  268. goto out;
  269. pbus = root->bus;
  270. /*
  271. * Now, walk back down the PCI device tree until we return to our
  272. * original handle. Assumes that everything between the PCI root
  273. * bridge and the device we're looking for must be a P2P bridge.
  274. */
  275. list_for_each_entry(node, &device_list, node) {
  276. acpi_handle hnd = node->handle;
  277. status = acpi_evaluate_integer(hnd, "_ADR", NULL, &adr);
  278. if (ACPI_FAILURE(status))
  279. goto out;
  280. dev = (adr >> 16) & 0xffff;
  281. fn = adr & 0xffff;
  282. pdev = pci_get_slot(pbus, PCI_DEVFN(dev, fn));
  283. if (!pdev || hnd == handle)
  284. break;
  285. pbus = pdev->subordinate;
  286. pci_dev_put(pdev);
  287. /*
  288. * This function may be called for a non-PCI device that has a
  289. * PCI parent (eg. a disk under a PCI SATA controller). In that
  290. * case pdev->subordinate will be NULL for the parent.
  291. */
  292. if (!pbus) {
  293. dev_dbg(&pdev->dev, "Not a PCI-to-PCI bridge\n");
  294. pdev = NULL;
  295. break;
  296. }
  297. }
  298. out:
  299. list_for_each_entry_safe(node, tmp, &device_list, node)
  300. kfree(node);
  301. return pdev;
  302. }
  303. EXPORT_SYMBOL_GPL(acpi_get_pci_dev);
  304. /**
  305. * acpi_pci_osc_control_set - Request control of PCI root _OSC features.
  306. * @handle: ACPI handle of a PCI root bridge (or PCIe Root Complex).
  307. * @mask: Mask of _OSC bits to request control of, place to store control mask.
  308. * @req: Mask of _OSC bits the control of is essential to the caller.
  309. *
  310. * Run _OSC query for @mask and if that is successful, compare the returned
  311. * mask of control bits with @req. If all of the @req bits are set in the
  312. * returned mask, run _OSC request for it.
  313. *
  314. * The variable at the @mask address may be modified regardless of whether or
  315. * not the function returns success. On success it will contain the mask of
  316. * _OSC bits the BIOS has granted control of, but its contents are meaningless
  317. * on failure.
  318. **/
  319. acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 req)
  320. {
  321. struct acpi_pci_root *root;
  322. acpi_status status = AE_OK;
  323. u32 ctrl, capbuf[3];
  324. if (!mask)
  325. return AE_BAD_PARAMETER;
  326. ctrl = *mask & OSC_PCI_CONTROL_MASKS;
  327. if ((ctrl & req) != req)
  328. return AE_TYPE;
  329. root = acpi_pci_find_root(handle);
  330. if (!root)
  331. return AE_NOT_EXIST;
  332. mutex_lock(&osc_lock);
  333. *mask = ctrl | root->osc_control_set;
  334. /* No need to evaluate _OSC if the control was already granted. */
  335. if ((root->osc_control_set & ctrl) == ctrl)
  336. goto out;
  337. /* Need to check the available controls bits before requesting them. */
  338. while (*mask) {
  339. status = acpi_pci_query_osc(root, root->osc_support_set, mask);
  340. if (ACPI_FAILURE(status))
  341. goto out;
  342. if (ctrl == *mask)
  343. break;
  344. decode_osc_control(root, "platform does not support",
  345. ctrl & ~(*mask));
  346. ctrl = *mask;
  347. }
  348. if ((ctrl & req) != req) {
  349. decode_osc_control(root, "not requesting control; platform does not support",
  350. req & ~(ctrl));
  351. status = AE_SUPPORT;
  352. goto out;
  353. }
  354. capbuf[OSC_QUERY_DWORD] = 0;
  355. capbuf[OSC_SUPPORT_DWORD] = root->osc_support_set;
  356. capbuf[OSC_CONTROL_DWORD] = ctrl;
  357. status = acpi_pci_run_osc(handle, capbuf, mask);
  358. if (ACPI_SUCCESS(status))
  359. root->osc_control_set = *mask;
  360. out:
  361. mutex_unlock(&osc_lock);
  362. return status;
  363. }
  364. EXPORT_SYMBOL(acpi_pci_osc_control_set);
  365. static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
  366. int *clear_aspm)
  367. {
  368. u32 support, control, requested;
  369. acpi_status status;
  370. struct acpi_device *device = root->device;
  371. acpi_handle handle = device->handle;
  372. /*
  373. * All supported architectures that use ACPI have support for
  374. * PCI domains, so we indicate this in _OSC support capabilities.
  375. */
  376. support = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
  377. if (pci_ext_cfg_avail())
  378. support |= OSC_PCI_EXT_CONFIG_SUPPORT;
  379. if (pcie_aspm_support_enabled())
  380. support |= OSC_PCI_ASPM_SUPPORT | OSC_PCI_CLOCK_PM_SUPPORT;
  381. if (pci_msi_enabled())
  382. support |= OSC_PCI_MSI_SUPPORT;
  383. decode_osc_support(root, "OS supports", support);
  384. status = acpi_pci_osc_support(root, support);
  385. if (ACPI_FAILURE(status)) {
  386. dev_info(&device->dev, "_OSC failed (%s); disabling ASPM\n",
  387. acpi_format_exception(status));
  388. *no_aspm = 1;
  389. return;
  390. }
  391. if (pcie_ports_disabled) {
  392. dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
  393. return;
  394. }
  395. if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
  396. decode_osc_support(root, "not requesting OS control; OS requires",
  397. ACPI_PCIE_REQ_SUPPORT);
  398. return;
  399. }
  400. control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
  401. | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL
  402. | OSC_PCI_EXPRESS_PME_CONTROL;
  403. if (pci_aer_available()) {
  404. if (aer_acpi_firmware_first())
  405. dev_info(&device->dev,
  406. "PCIe AER handled by firmware\n");
  407. else
  408. control |= OSC_PCI_EXPRESS_AER_CONTROL;
  409. }
  410. requested = control;
  411. status = acpi_pci_osc_control_set(handle, &control,
  412. OSC_PCI_EXPRESS_CAPABILITY_CONTROL);
  413. if (ACPI_SUCCESS(status)) {
  414. decode_osc_control(root, "OS now controls", control);
  415. if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
  416. /*
  417. * We have ASPM control, but the FADT indicates
  418. * that it's unsupported. Clear it.
  419. */
  420. *clear_aspm = 1;
  421. }
  422. } else {
  423. decode_osc_control(root, "OS requested", requested);
  424. decode_osc_control(root, "platform willing to grant", control);
  425. dev_info(&device->dev, "_OSC failed (%s); disabling ASPM\n",
  426. acpi_format_exception(status));
  427. /*
  428. * We want to disable ASPM here, but aspm_disabled
  429. * needs to remain in its state from boot so that we
  430. * properly handle PCIe 1.1 devices. So we set this
  431. * flag here, to defer the action until after the ACPI
  432. * root scan.
  433. */
  434. *no_aspm = 1;
  435. }
  436. }
  437. static int acpi_pci_root_add(struct acpi_device *device,
  438. const struct acpi_device_id *not_used)
  439. {
  440. unsigned long long segment, bus;
  441. acpi_status status;
  442. int result;
  443. struct acpi_pci_root *root;
  444. acpi_handle handle = device->handle;
  445. int no_aspm = 0, clear_aspm = 0;
  446. root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
  447. if (!root)
  448. return -ENOMEM;
  449. segment = 0;
  450. status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL,
  451. &segment);
  452. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  453. dev_err(&device->dev, "can't evaluate _SEG\n");
  454. result = -ENODEV;
  455. goto end;
  456. }
  457. /* Check _CRS first, then _BBN. If no _BBN, default to zero. */
  458. root->secondary.flags = IORESOURCE_BUS;
  459. status = try_get_root_bridge_busnr(handle, &root->secondary);
  460. if (ACPI_FAILURE(status)) {
  461. /*
  462. * We need both the start and end of the downstream bus range
  463. * to interpret _CBA (MMCONFIG base address), so it really is
  464. * supposed to be in _CRS. If we don't find it there, all we
  465. * can do is assume [_BBN-0xFF] or [0-0xFF].
  466. */
  467. root->secondary.end = 0xFF;
  468. dev_warn(&device->dev,
  469. FW_BUG "no secondary bus range in _CRS\n");
  470. status = acpi_evaluate_integer(handle, METHOD_NAME__BBN,
  471. NULL, &bus);
  472. if (ACPI_SUCCESS(status))
  473. root->secondary.start = bus;
  474. else if (status == AE_NOT_FOUND)
  475. root->secondary.start = 0;
  476. else {
  477. dev_err(&device->dev, "can't evaluate _BBN\n");
  478. result = -ENODEV;
  479. goto end;
  480. }
  481. }
  482. root->device = device;
  483. root->segment = segment & 0xFFFF;
  484. strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
  485. strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
  486. device->driver_data = root;
  487. pr_info(PREFIX "%s [%s] (domain %04x %pR)\n",
  488. acpi_device_name(device), acpi_device_bid(device),
  489. root->segment, &root->secondary);
  490. root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
  491. negotiate_os_control(root, &no_aspm, &clear_aspm);
  492. /*
  493. * TBD: Need PCI interface for enumeration/configuration of roots.
  494. */
  495. /*
  496. * Scan the Root Bridge
  497. * --------------------
  498. * Must do this prior to any attempt to bind the root device, as the
  499. * PCI namespace does not get created until this call is made (and
  500. * thus the root bridge's pci_dev does not exist).
  501. */
  502. root->bus = pci_acpi_scan_root(root);
  503. if (!root->bus) {
  504. dev_err(&device->dev,
  505. "Bus %04x:%02x not present in PCI namespace\n",
  506. root->segment, (unsigned int)root->secondary.start);
  507. device->driver_data = NULL;
  508. result = -ENODEV;
  509. goto end;
  510. }
  511. if (clear_aspm) {
  512. dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n");
  513. pcie_clear_aspm(root->bus);
  514. }
  515. if (no_aspm)
  516. pcie_no_aspm();
  517. pci_acpi_add_bus_pm_notifier(device, root->bus);
  518. if (device->wakeup.flags.run_wake)
  519. device_set_run_wake(root->bus->bridge, true);
  520. if (system_state != SYSTEM_BOOTING) {
  521. pcibios_resource_survey_bus(root->bus);
  522. pci_assign_unassigned_root_bus_resources(root->bus);
  523. }
  524. pci_lock_rescan_remove();
  525. pci_bus_add_devices(root->bus);
  526. pci_unlock_rescan_remove();
  527. return 1;
  528. end:
  529. kfree(root);
  530. return result;
  531. }
  532. static void acpi_pci_root_remove(struct acpi_device *device)
  533. {
  534. struct acpi_pci_root *root = acpi_driver_data(device);
  535. pci_lock_rescan_remove();
  536. pci_stop_root_bus(root->bus);
  537. device_set_run_wake(root->bus->bridge, false);
  538. pci_acpi_remove_bus_pm_notifier(device);
  539. pci_remove_root_bus(root->bus);
  540. pci_unlock_rescan_remove();
  541. kfree(root);
  542. }
  543. void __init acpi_pci_root_init(void)
  544. {
  545. acpi_hest_init();
  546. if (acpi_pci_disabled)
  547. return;
  548. pci_acpi_crs_quirks();
  549. acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root");
  550. }