pci_root.c 17 KB

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