diff options
author | Matt Domsch <Matt_Domsch@dell.com> | 2009-11-02 12:51:24 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-04 16:06:25 -0500 |
commit | 0584396157ad2d008e2cc76b4ed6254151183a25 (patch) | |
tree | 8860a033938b1a01cccf9a203208f741758724ac | |
parent | 8792e11f1c54bcba34412f03959e70ee217f2231 (diff) |
PCI: PCIe AER: honor ACPI HEST FIRMWARE FIRST mode
Feedback from Hidetoshi Seto and Kenji Kaneshige incorporated. This
correctly handles PCI-X bridges, PCIe root ports and endpoints, and
prints debug messages when invalid/reserved types are found in the
HEST. PCI devices not in domain/segment 0 are not represented in
HEST, thus will be ignored.
Today, the PCIe Advanced Error Reporting (AER) driver attaches itself
to every PCIe root port for which BIOS reports it should, via ACPI
_OSC.
However, _OSC alone is insufficient for newer BIOSes. Part of ACPI
4.0 is the new APEI (ACPI Platform Error Interfaces) which is a way
for OS and BIOS to handshake over which errors for which components
each will handle. One table in ACPI 4.0 is the Hardware Error Source
Table (HEST), where BIOS can define that errors for certain PCIe
devices (or all devices), should be handled by BIOS ("Firmware First
mode"), rather than be handled by the OS.
Dell PowerEdge 11G server BIOS defines Firmware First mode in HEST, so
that it may manage such errors, log them to the System Event Log, and
possibly take other actions. The aer driver should honor this, and
not attach itself to devices noted as such.
Furthermore, Kenji Kaneshige reminded us to disallow changing the AER
registers when respecting Firmware First mode. Platform firmware is
expected to manage these, and if changes to them are allowed, it could
break that firmware's behavior.
The HEST parsing code may be replaced in the future by a more
feature-rich implementation. This patch provides the minimum needed
to prevent breakage until that implementation is available.
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: Matt Domsch <Matt_Domsch@dell.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r-- | drivers/acpi/Makefile | 1 | ||||
-rw-r--r-- | drivers/acpi/hest.c | 135 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_core.c | 24 | ||||
-rw-r--r-- | drivers/pci/probe.c | 8 | ||||
-rw-r--r-- | include/acpi/acpi_hest.h | 12 | ||||
-rw-r--r-- | include/linux/pci.h | 1 |
6 files changed, 179 insertions, 2 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 7702118509a0..c7b10b4298e9 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -19,6 +19,7 @@ obj-y += acpi.o \ | |||
19 | 19 | ||
20 | # All the builtin files are in the "acpi." module_param namespace. | 20 | # All the builtin files are in the "acpi." module_param namespace. |
21 | acpi-y += osl.o utils.o reboot.o | 21 | acpi-y += osl.o utils.o reboot.o |
22 | acpi-y += hest.o | ||
22 | 23 | ||
23 | # sleep related files | 24 | # sleep related files |
24 | acpi-y += wakeup.o | 25 | acpi-y += wakeup.o |
diff --git a/drivers/acpi/hest.c b/drivers/acpi/hest.c new file mode 100644 index 000000000000..4bb18c980ac6 --- /dev/null +++ b/drivers/acpi/hest.c | |||
@@ -0,0 +1,135 @@ | |||
1 | #include <linux/acpi.h> | ||
2 | #include <linux/pci.h> | ||
3 | |||
4 | #define PREFIX "ACPI: " | ||
5 | |||
6 | static inline unsigned long parse_acpi_hest_ia_machine_check(struct acpi_hest_ia_machine_check *p) | ||
7 | { | ||
8 | return sizeof(*p) + | ||
9 | (sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks); | ||
10 | } | ||
11 | |||
12 | static inline unsigned long parse_acpi_hest_ia_corrected(struct acpi_hest_ia_corrected *p) | ||
13 | { | ||
14 | return sizeof(*p) + | ||
15 | (sizeof(struct acpi_hest_ia_error_bank) * p->num_hardware_banks); | ||
16 | } | ||
17 | |||
18 | static inline unsigned long parse_acpi_hest_ia_nmi(struct acpi_hest_ia_nmi *p) | ||
19 | { | ||
20 | return sizeof(*p); | ||
21 | } | ||
22 | |||
23 | static inline unsigned long parse_acpi_hest_generic(struct acpi_hest_generic *p) | ||
24 | { | ||
25 | return sizeof(*p); | ||
26 | } | ||
27 | |||
28 | static inline unsigned int hest_match_pci(struct acpi_hest_aer_common *p, struct pci_dev *pci) | ||
29 | { | ||
30 | return (0 == pci_domain_nr(pci->bus) && | ||
31 | p->bus == pci->bus->number && | ||
32 | p->device == PCI_SLOT(pci->devfn) && | ||
33 | p->function == PCI_FUNC(pci->devfn)); | ||
34 | } | ||
35 | |||
36 | static unsigned long parse_acpi_hest_aer(void *hdr, int type, struct pci_dev *pci, int *firmware_first) | ||
37 | { | ||
38 | struct acpi_hest_aer_common *p = hdr + sizeof(struct acpi_hest_header); | ||
39 | unsigned long rc=0; | ||
40 | u8 pcie_type = 0; | ||
41 | u8 bridge = 0; | ||
42 | switch (type) { | ||
43 | case ACPI_HEST_TYPE_AER_ROOT_PORT: | ||
44 | rc = sizeof(struct acpi_hest_aer_root); | ||
45 | pcie_type = PCI_EXP_TYPE_ROOT_PORT; | ||
46 | break; | ||
47 | case ACPI_HEST_TYPE_AER_ENDPOINT: | ||
48 | rc = sizeof(struct acpi_hest_aer); | ||
49 | pcie_type = PCI_EXP_TYPE_ENDPOINT; | ||
50 | break; | ||
51 | case ACPI_HEST_TYPE_AER_BRIDGE: | ||
52 | rc = sizeof(struct acpi_hest_aer_bridge); | ||
53 | if ((pci->class >> 16) == PCI_BASE_CLASS_BRIDGE) | ||
54 | bridge = 1; | ||
55 | break; | ||
56 | } | ||
57 | |||
58 | if (p->flags & ACPI_HEST_GLOBAL) { | ||
59 | if ((pci->is_pcie && (pci->pcie_type == pcie_type)) || bridge) | ||
60 | *firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); | ||
61 | } | ||
62 | else | ||
63 | if (hest_match_pci(p, pci)) | ||
64 | *firmware_first = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); | ||
65 | return rc; | ||
66 | } | ||
67 | |||
68 | static int acpi_hest_firmware_first(struct acpi_table_header *stdheader, struct pci_dev *pci) | ||
69 | { | ||
70 | struct acpi_table_hest *hest = (struct acpi_table_hest *)stdheader; | ||
71 | void *p = (void *)hest + sizeof(*hest); /* defined by the ACPI 4.0 spec */ | ||
72 | struct acpi_hest_header *hdr = p; | ||
73 | |||
74 | int i; | ||
75 | int firmware_first = 0; | ||
76 | static unsigned char printed_unused = 0; | ||
77 | static unsigned char printed_reserved = 0; | ||
78 | |||
79 | for (i=0, hdr=p; p < (((void *)hest) + hest->header.length) && i < hest->error_source_count; i++) { | ||
80 | switch (hdr->type) { | ||
81 | case ACPI_HEST_TYPE_IA32_CHECK: | ||
82 | p += parse_acpi_hest_ia_machine_check(p); | ||
83 | break; | ||
84 | case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: | ||
85 | p += parse_acpi_hest_ia_corrected(p); | ||
86 | break; | ||
87 | case ACPI_HEST_TYPE_IA32_NMI: | ||
88 | p += parse_acpi_hest_ia_nmi(p); | ||
89 | break; | ||
90 | /* These three should never appear */ | ||
91 | case ACPI_HEST_TYPE_NOT_USED3: | ||
92 | case ACPI_HEST_TYPE_NOT_USED4: | ||
93 | case ACPI_HEST_TYPE_NOT_USED5: | ||
94 | if (!printed_unused) { | ||
95 | printk(KERN_DEBUG PREFIX | ||
96 | "HEST Error Source list contains an obsolete type (%d).\n", hdr->type); | ||
97 | printed_unused = 1; | ||
98 | } | ||
99 | break; | ||
100 | case ACPI_HEST_TYPE_AER_ROOT_PORT: | ||
101 | case ACPI_HEST_TYPE_AER_ENDPOINT: | ||
102 | case ACPI_HEST_TYPE_AER_BRIDGE: | ||
103 | p += parse_acpi_hest_aer(p, hdr->type, pci, &firmware_first); | ||
104 | break; | ||
105 | case ACPI_HEST_TYPE_GENERIC_ERROR: | ||
106 | p += parse_acpi_hest_generic(p); | ||
107 | break; | ||
108 | /* These should never appear either */ | ||
109 | case ACPI_HEST_TYPE_RESERVED: | ||
110 | default: | ||
111 | if (!printed_reserved) { | ||
112 | printk(KERN_DEBUG PREFIX | ||
113 | "HEST Error Source list contains a reserved type (%d).\n", hdr->type); | ||
114 | printed_reserved = 1; | ||
115 | } | ||
116 | break; | ||
117 | } | ||
118 | } | ||
119 | return firmware_first; | ||
120 | } | ||
121 | |||
122 | int acpi_hest_firmware_first_pci(struct pci_dev *pci) | ||
123 | { | ||
124 | acpi_status status = AE_NOT_FOUND; | ||
125 | struct acpi_table_header *hest = NULL; | ||
126 | status = acpi_get_table(ACPI_SIG_HEST, 1, &hest); | ||
127 | |||
128 | if (ACPI_SUCCESS(status)) { | ||
129 | if (acpi_hest_firmware_first(hest, pci)) { | ||
130 | return 1; | ||
131 | } | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci); | ||
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 9f5ccbeb4fa5..f4512feac12b 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -35,6 +35,9 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev) | |||
35 | u16 reg16 = 0; | 35 | u16 reg16 = 0; |
36 | int pos; | 36 | int pos; |
37 | 37 | ||
38 | if (dev->aer_firmware_first) | ||
39 | return -EIO; | ||
40 | |||
38 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | 41 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
39 | if (!pos) | 42 | if (!pos) |
40 | return -EIO; | 43 | return -EIO; |
@@ -60,6 +63,9 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev) | |||
60 | u16 reg16 = 0; | 63 | u16 reg16 = 0; |
61 | int pos; | 64 | int pos; |
62 | 65 | ||
66 | if (dev->aer_firmware_first) | ||
67 | return -EIO; | ||
68 | |||
63 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | 69 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); |
64 | if (!pos) | 70 | if (!pos) |
65 | return -EIO; | 71 | return -EIO; |
@@ -874,8 +880,22 @@ void aer_delete_rootport(struct aer_rpc *rpc) | |||
874 | */ | 880 | */ |
875 | int aer_init(struct pcie_device *dev) | 881 | int aer_init(struct pcie_device *dev) |
876 | { | 882 | { |
877 | if (aer_osc_setup(dev) && !forceload) | 883 | if (dev->port->aer_firmware_first) { |
878 | return -ENXIO; | 884 | dev_printk(KERN_DEBUG, &dev->device, |
885 | "PCIe errors handled by platform firmware.\n"); | ||
886 | goto out; | ||
887 | } | ||
888 | |||
889 | if (aer_osc_setup(dev)) | ||
890 | goto out; | ||
879 | 891 | ||
880 | return 0; | 892 | return 0; |
893 | out: | ||
894 | if (forceload) { | ||
895 | dev_printk(KERN_DEBUG, &dev->device, | ||
896 | "aerdrv forceload requested.\n"); | ||
897 | dev->port->aer_firmware_first = 0; | ||
898 | return 0; | ||
899 | } | ||
900 | return -ENXIO; | ||
881 | } | 901 | } |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 9cefc54a0125..118463befef0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/cpumask.h> | 11 | #include <linux/cpumask.h> |
12 | #include <linux/pci-aspm.h> | 12 | #include <linux/pci-aspm.h> |
13 | #include <linux/iommu.h> | 13 | #include <linux/iommu.h> |
14 | #include <acpi/acpi_hest.h> | ||
14 | #include <xen/xen.h> | 15 | #include <xen/xen.h> |
15 | #include "pci.h" | 16 | #include "pci.h" |
16 | 17 | ||
@@ -706,6 +707,12 @@ static void set_pcie_hotplug_bridge(struct pci_dev *pdev) | |||
706 | pdev->is_hotplug_bridge = 1; | 707 | pdev->is_hotplug_bridge = 1; |
707 | } | 708 | } |
708 | 709 | ||
710 | static void set_pci_aer_firmware_first(struct pci_dev *pdev) | ||
711 | { | ||
712 | if (acpi_hest_firmware_first_pci(pdev)) | ||
713 | pdev->aer_firmware_first = 1; | ||
714 | } | ||
715 | |||
709 | #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) | 716 | #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) |
710 | 717 | ||
711 | /** | 718 | /** |
@@ -734,6 +741,7 @@ int pci_setup_device(struct pci_dev *dev) | |||
734 | dev->multifunction = !!(hdr_type & 0x80); | 741 | dev->multifunction = !!(hdr_type & 0x80); |
735 | dev->error_state = pci_channel_io_normal; | 742 | dev->error_state = pci_channel_io_normal; |
736 | set_pcie_port_type(dev); | 743 | set_pcie_port_type(dev); |
744 | set_pci_aer_firmware_first(dev); | ||
737 | 745 | ||
738 | list_for_each_entry(slot, &dev->bus->slots, list) | 746 | list_for_each_entry(slot, &dev->bus->slots, list) |
739 | if (PCI_SLOT(dev->devfn) == slot->number) | 747 | if (PCI_SLOT(dev->devfn) == slot->number) |
diff --git a/include/acpi/acpi_hest.h b/include/acpi/acpi_hest.h new file mode 100644 index 000000000000..63194d03cb2d --- /dev/null +++ b/include/acpi/acpi_hest.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __ACPI_HEST_H | ||
2 | #define __ACPI_HEST_H | ||
3 | |||
4 | #include <linux/pci.h> | ||
5 | |||
6 | #ifdef CONFIG_ACPI | ||
7 | extern int acpi_hest_firmware_first_pci(struct pci_dev *pci); | ||
8 | #else | ||
9 | static inline int acpi_hest_firmware_first_pci(struct pci_dev *pci) { return 0; } | ||
10 | #endif | ||
11 | |||
12 | #endif | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index da4128f6e916..9d646e60cae0 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -280,6 +280,7 @@ struct pci_dev { | |||
280 | unsigned int is_virtfn:1; | 280 | unsigned int is_virtfn:1; |
281 | unsigned int reset_fn:1; | 281 | unsigned int reset_fn:1; |
282 | unsigned int is_hotplug_bridge:1; | 282 | unsigned int is_hotplug_bridge:1; |
283 | unsigned int aer_firmware_first:1; | ||
283 | pci_dev_flags_t dev_flags; | 284 | pci_dev_flags_t dev_flags; |
284 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 285 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
285 | 286 | ||