diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-01-06 18:55:09 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-01-14 11:55:41 -0500 |
commit | 415e12b2379239973feab91850b0dce985c6058a (patch) | |
tree | aa79c7a87fd30ac13ae3fd146aad5a44e854c4bc | |
parent | 6e8af08dfa40b747002207d3ce8e8b43a050d99f (diff) |
PCI/ACPI: Request _OSC control once for each root bridge (v3)
Move the evaluation of acpi_pci_osc_control_set() (to request control of
PCI Express native features) into acpi_pci_root_add() to avoid calling
it many times for the same root complex with the same arguments.
Additionally, check if all of the requisite _OSC support bits are set
before calling acpi_pci_osc_control_set() for a given root complex.
References: https://bugzilla.kernel.org/show_bug.cgi?id=20232
Reported-by: Ozan Caglayan <ozan@pardus.org.tr>
Tested-by: Ozan Caglayan <ozan@pardus.org.tr>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r-- | drivers/acpi/apei/hest.c | 22 | ||||
-rw-r--r-- | drivers/acpi/pci_root.c | 35 | ||||
-rw-r--r-- | drivers/pci/pci.h | 8 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv.c | 1 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv.h | 3 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv.h | 3 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_acpi.c | 23 | ||||
-rw-r--r-- | include/acpi/apei.h | 6 | ||||
-rw-r--r-- | include/linux/pci-acpi.h | 6 | ||||
-rw-r--r-- | include/linux/pci.h | 11 |
10 files changed, 72 insertions, 46 deletions
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index daa7bc63f1d4..4ee58e72b730 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c | |||
@@ -195,24 +195,24 @@ static int __init setup_hest_disable(char *str) | |||
195 | 195 | ||
196 | __setup("hest_disable", setup_hest_disable); | 196 | __setup("hest_disable", setup_hest_disable); |
197 | 197 | ||
198 | static int __init hest_init(void) | 198 | void __init acpi_hest_init(void) |
199 | { | 199 | { |
200 | acpi_status status; | 200 | acpi_status status; |
201 | int rc = -ENODEV; | 201 | int rc = -ENODEV; |
202 | unsigned int ghes_count = 0; | 202 | unsigned int ghes_count = 0; |
203 | 203 | ||
204 | if (acpi_disabled) | 204 | if (acpi_disabled) |
205 | goto err; | 205 | return; |
206 | 206 | ||
207 | if (hest_disable) { | 207 | if (hest_disable) { |
208 | pr_info(HEST_PFX "HEST tabling parsing is disabled.\n"); | 208 | pr_info(HEST_PFX "Table parsing disabled.\n"); |
209 | goto err; | 209 | return; |
210 | } | 210 | } |
211 | 211 | ||
212 | status = acpi_get_table(ACPI_SIG_HEST, 0, | 212 | status = acpi_get_table(ACPI_SIG_HEST, 0, |
213 | (struct acpi_table_header **)&hest_tab); | 213 | (struct acpi_table_header **)&hest_tab); |
214 | if (status == AE_NOT_FOUND) { | 214 | if (status == AE_NOT_FOUND) { |
215 | pr_info(HEST_PFX "Table is not found!\n"); | 215 | pr_info(HEST_PFX "Table not found.\n"); |
216 | goto err; | 216 | goto err; |
217 | } else if (ACPI_FAILURE(status)) { | 217 | } else if (ACPI_FAILURE(status)) { |
218 | const char *msg = acpi_format_exception(status); | 218 | const char *msg = acpi_format_exception(status); |
@@ -226,15 +226,11 @@ static int __init hest_init(void) | |||
226 | goto err; | 226 | goto err; |
227 | 227 | ||
228 | rc = hest_ghes_dev_register(ghes_count); | 228 | rc = hest_ghes_dev_register(ghes_count); |
229 | if (rc) | 229 | if (!rc) { |
230 | goto err; | 230 | pr_info(HEST_PFX "Table parsing has been initialized.\n"); |
231 | 231 | return; | |
232 | pr_info(HEST_PFX "HEST table parsing is initialized.\n"); | 232 | } |
233 | 233 | ||
234 | return 0; | ||
235 | err: | 234 | err: |
236 | hest_disable = 1; | 235 | hest_disable = 1; |
237 | return rc; | ||
238 | } | 236 | } |
239 | |||
240 | subsys_initcall(hest_init); | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 96668ad09622..d9766797cd98 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <acpi/acpi_bus.h> | 37 | #include <acpi/acpi_bus.h> |
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | #include <acpi/apei.h> | ||
39 | 40 | ||
40 | #define PREFIX "ACPI: " | 41 | #define PREFIX "ACPI: " |
41 | 42 | ||
@@ -47,6 +48,11 @@ static int acpi_pci_root_add(struct acpi_device *device); | |||
47 | static int acpi_pci_root_remove(struct acpi_device *device, int type); | 48 | static int acpi_pci_root_remove(struct acpi_device *device, int type); |
48 | static int acpi_pci_root_start(struct acpi_device *device); | 49 | static int acpi_pci_root_start(struct acpi_device *device); |
49 | 50 | ||
51 | #define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ | ||
52 | | OSC_ACTIVE_STATE_PWR_SUPPORT \ | ||
53 | | OSC_CLOCK_PWR_CAPABILITY_SUPPORT \ | ||
54 | | OSC_MSI_SUPPORT) | ||
55 | |||
50 | static const struct acpi_device_id root_device_ids[] = { | 56 | static const struct acpi_device_id root_device_ids[] = { |
51 | {"PNP0A03", 0}, | 57 | {"PNP0A03", 0}, |
52 | {"", 0}, | 58 | {"", 0}, |
@@ -566,6 +572,33 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device) | |||
566 | if (flags != base_flags) | 572 | if (flags != base_flags) |
567 | acpi_pci_osc_support(root, flags); | 573 | acpi_pci_osc_support(root, flags); |
568 | 574 | ||
575 | if (!pcie_ports_disabled | ||
576 | && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { | ||
577 | flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL | ||
578 | | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | ||
579 | | OSC_PCI_EXPRESS_PME_CONTROL; | ||
580 | |||
581 | if (pci_aer_available()) { | ||
582 | if (aer_acpi_firmware_first()) | ||
583 | dev_dbg(root->bus->bridge, | ||
584 | "PCIe errors handled by BIOS.\n"); | ||
585 | else | ||
586 | flags |= OSC_PCI_EXPRESS_AER_CONTROL; | ||
587 | } | ||
588 | |||
589 | dev_info(root->bus->bridge, | ||
590 | "Requesting ACPI _OSC control (0x%02x)\n", flags); | ||
591 | |||
592 | status = acpi_pci_osc_control_set(device->handle, &flags, | ||
593 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); | ||
594 | if (ACPI_SUCCESS(status)) | ||
595 | dev_info(root->bus->bridge, | ||
596 | "ACPI _OSC control (0x%02x) granted\n", flags); | ||
597 | else | ||
598 | dev_dbg(root->bus->bridge, | ||
599 | "ACPI _OSC request failed (code %d)\n", status); | ||
600 | } | ||
601 | |||
569 | pci_acpi_add_bus_pm_notifier(device, root->bus); | 602 | pci_acpi_add_bus_pm_notifier(device, root->bus); |
570 | if (device->wakeup.flags.run_wake) | 603 | if (device->wakeup.flags.run_wake) |
571 | device_set_run_wake(root->bus->bridge, true); | 604 | device_set_run_wake(root->bus->bridge, true); |
@@ -603,6 +636,8 @@ static int __init acpi_pci_root_init(void) | |||
603 | if (acpi_pci_disabled) | 636 | if (acpi_pci_disabled) |
604 | return 0; | 637 | return 0; |
605 | 638 | ||
639 | acpi_hest_init(); | ||
640 | |||
606 | pci_acpi_crs_quirks(); | 641 | pci_acpi_crs_quirks(); |
607 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) | 642 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) |
608 | return -ENODEV; | 643 | return -ENODEV; |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 7d33f6673868..16ae9659346b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -140,14 +140,6 @@ static inline void pci_no_msi(void) { } | |||
140 | static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } | 140 | static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } |
141 | #endif | 141 | #endif |
142 | 142 | ||
143 | #ifdef CONFIG_PCIEAER | ||
144 | void pci_no_aer(void); | ||
145 | bool pci_aer_available(void); | ||
146 | #else | ||
147 | static inline void pci_no_aer(void) { } | ||
148 | static inline bool pci_aer_available(void) { return false; } | ||
149 | #endif | ||
150 | |||
151 | static inline int pci_no_d1d2(struct pci_dev *dev) | 143 | static inline int pci_no_d1d2(struct pci_dev *dev) |
152 | { | 144 | { |
153 | unsigned int parent_dstates = 0; | 145 | unsigned int parent_dstates = 0; |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 2b2b6508efde..58ad7917553c 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
20 | #include <linux/pci-acpi.h> | ||
20 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
21 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
22 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h index 9656e3060412..80c11d131499 100644 --- a/drivers/pci/pcie/aer/aerdrv.h +++ b/drivers/pci/pcie/aer/aerdrv.h | |||
@@ -132,7 +132,6 @@ static inline int aer_osc_setup(struct pcie_device *pciedev) | |||
132 | 132 | ||
133 | #ifdef CONFIG_ACPI_APEI | 133 | #ifdef CONFIG_ACPI_APEI |
134 | extern int pcie_aer_get_firmware_first(struct pci_dev *pci_dev); | 134 | extern int pcie_aer_get_firmware_first(struct pci_dev *pci_dev); |
135 | extern bool aer_acpi_firmware_first(void); | ||
136 | #else | 135 | #else |
137 | static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev) | 136 | static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev) |
138 | { | 137 | { |
@@ -140,8 +139,6 @@ static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev) | |||
140 | return pci_dev->__aer_firmware_first; | 139 | return pci_dev->__aer_firmware_first; |
141 | return 0; | 140 | return 0; |
142 | } | 141 | } |
143 | |||
144 | static inline bool aer_acpi_firmware_first(void) { return false; } | ||
145 | #endif | 142 | #endif |
146 | 143 | ||
147 | static inline void pcie_aer_force_firmware_first(struct pci_dev *pci_dev, | 144 | static inline void pcie_aer_force_firmware_first(struct pci_dev *pci_dev, |
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index 8fcc03598b29..bd00a01aef14 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h | |||
@@ -20,9 +20,6 @@ | |||
20 | 20 | ||
21 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) | 21 | #define get_descriptor_id(type, service) (((type - 4) << 4) | service) |
22 | 22 | ||
23 | extern bool pcie_ports_disabled; | ||
24 | extern bool pcie_ports_auto; | ||
25 | |||
26 | extern struct bus_type pcie_port_bus_type; | 23 | extern struct bus_type pcie_port_bus_type; |
27 | extern int pcie_port_device_register(struct pci_dev *dev); | 24 | extern int pcie_port_device_register(struct pci_dev *dev); |
28 | #ifdef CONFIG_PM | 25 | #ifdef CONFIG_PM |
diff --git a/drivers/pci/pcie/portdrv_acpi.c b/drivers/pci/pcie/portdrv_acpi.c index 5982b6a63b89..a86b56e5f2f2 100644 --- a/drivers/pci/pcie/portdrv_acpi.c +++ b/drivers/pci/pcie/portdrv_acpi.c | |||
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | int pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask) | 34 | int pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask) |
35 | { | 35 | { |
36 | acpi_status status; | 36 | struct acpi_pci_root *root; |
37 | acpi_handle handle; | 37 | acpi_handle handle; |
38 | u32 flags; | 38 | u32 flags; |
39 | 39 | ||
@@ -44,26 +44,11 @@ int pcie_port_acpi_setup(struct pci_dev *port, int *srv_mask) | |||
44 | if (!handle) | 44 | if (!handle) |
45 | return -EINVAL; | 45 | return -EINVAL; |
46 | 46 | ||
47 | flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL | 47 | root = acpi_pci_find_root(handle); |
48 | | OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | 48 | if (!root) |
49 | | OSC_PCI_EXPRESS_PME_CONTROL; | ||
50 | |||
51 | if (pci_aer_available()) { | ||
52 | if (aer_acpi_firmware_first()) | ||
53 | dev_dbg(&port->dev, "PCIe errors handled by BIOS.\n"); | ||
54 | else | ||
55 | flags |= OSC_PCI_EXPRESS_AER_CONTROL; | ||
56 | } | ||
57 | |||
58 | status = acpi_pci_osc_control_set(handle, &flags, | ||
59 | OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); | ||
60 | if (ACPI_FAILURE(status)) { | ||
61 | dev_dbg(&port->dev, "ACPI _OSC request failed (code %d)\n", | ||
62 | status); | ||
63 | return -ENODEV; | 49 | return -ENODEV; |
64 | } | ||
65 | 50 | ||
66 | dev_info(&port->dev, "ACPI _OSC control granted for 0x%02x\n", flags); | 51 | flags = root->osc_control_set; |
67 | 52 | ||
68 | *srv_mask = PCIE_PORT_SERVICE_VC; | 53 | *srv_mask = PCIE_PORT_SERVICE_VC; |
69 | if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL) | 54 | if (flags & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL) |
diff --git a/include/acpi/apei.h b/include/acpi/apei.h index b3365025ff8d..c4dbb132d902 100644 --- a/include/acpi/apei.h +++ b/include/acpi/apei.h | |||
@@ -19,6 +19,12 @@ | |||
19 | extern int hest_disable; | 19 | extern int hest_disable; |
20 | extern int erst_disable; | 20 | extern int erst_disable; |
21 | 21 | ||
22 | #ifdef CONFIG_ACPI_APEI | ||
23 | void __init acpi_hest_init(void); | ||
24 | #else | ||
25 | static inline void acpi_hest_init(void) { return; } | ||
26 | #endif | ||
27 | |||
22 | typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data); | 28 | typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data); |
23 | int apei_hest_parse(apei_hest_func_t func, void *data); | 29 | int apei_hest_parse(apei_hest_func_t func, void *data); |
24 | 30 | ||
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index c8b6473c5f42..479d9bb88e11 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h | |||
@@ -40,4 +40,10 @@ static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) | |||
40 | { return NULL; } | 40 | { return NULL; } |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifdef CONFIG_ACPI_APEI | ||
44 | extern bool aer_acpi_firmware_first(void); | ||
45 | #else | ||
46 | static inline bool aer_acpi_firmware_first(void) { return false; } | ||
47 | #endif | ||
48 | |||
43 | #endif /* _PCI_ACPI_H_ */ | 49 | #endif /* _PCI_ACPI_H_ */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 63cbadce337e..12dd86a82a15 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -994,6 +994,9 @@ extern void pci_restore_msi_state(struct pci_dev *dev); | |||
994 | extern int pci_msi_enabled(void); | 994 | extern int pci_msi_enabled(void); |
995 | #endif | 995 | #endif |
996 | 996 | ||
997 | extern bool pcie_ports_disabled; | ||
998 | extern bool pcie_ports_auto; | ||
999 | |||
997 | #ifndef CONFIG_PCIEASPM | 1000 | #ifndef CONFIG_PCIEASPM |
998 | static inline int pcie_aspm_enabled(void) | 1001 | static inline int pcie_aspm_enabled(void) |
999 | { | 1002 | { |
@@ -1003,6 +1006,14 @@ static inline int pcie_aspm_enabled(void) | |||
1003 | extern int pcie_aspm_enabled(void); | 1006 | extern int pcie_aspm_enabled(void); |
1004 | #endif | 1007 | #endif |
1005 | 1008 | ||
1009 | #ifdef CONFIG_PCIEAER | ||
1010 | void pci_no_aer(void); | ||
1011 | bool pci_aer_available(void); | ||
1012 | #else | ||
1013 | static inline void pci_no_aer(void) { } | ||
1014 | static inline bool pci_aer_available(void) { return false; } | ||
1015 | #endif | ||
1016 | |||
1006 | #ifndef CONFIG_PCIE_ECRC | 1017 | #ifndef CONFIG_PCIE_ECRC |
1007 | static inline void pcie_set_ecrc_checking(struct pci_dev *dev) | 1018 | static inline void pcie_set_ecrc_checking(struct pci_dev *dev) |
1008 | { | 1019 | { |