pci_root.c 17 KB

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