diff options
Diffstat (limited to 'drivers/pci/pcie/aer/aerdrv_errprint.c')
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_errprint.c | 182 |
1 files changed, 107 insertions, 75 deletions
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c index 9d3e4c8d0184..b07a42e0b350 100644 --- a/drivers/pci/pcie/aer/aerdrv_errprint.c +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/pm.h> | 20 | #include <linux/pm.h> |
21 | #include <linux/suspend.h> | 21 | #include <linux/suspend.h> |
22 | #include <linux/cper.h> | ||
22 | 23 | ||
23 | #include "aerdrv.h" | 24 | #include "aerdrv.h" |
24 | 25 | ||
@@ -57,86 +58,44 @@ | |||
57 | (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \ | 58 | (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \ |
58 | AER_TRANSACTION_LAYER_ERROR) | 59 | AER_TRANSACTION_LAYER_ERROR) |
59 | 60 | ||
60 | #define AER_PR(info, pdev, fmt, args...) \ | ||
61 | printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \ | ||
62 | KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \ | ||
63 | dev_name(&pdev->dev), ## args) | ||
64 | |||
65 | /* | 61 | /* |
66 | * AER error strings | 62 | * AER error strings |
67 | */ | 63 | */ |
68 | static char *aer_error_severity_string[] = { | 64 | static const char *aer_error_severity_string[] = { |
69 | "Uncorrected (Non-Fatal)", | 65 | "Uncorrected (Non-Fatal)", |
70 | "Uncorrected (Fatal)", | 66 | "Uncorrected (Fatal)", |
71 | "Corrected" | 67 | "Corrected" |
72 | }; | 68 | }; |
73 | 69 | ||
74 | static char *aer_error_layer[] = { | 70 | static const char *aer_error_layer[] = { |
75 | "Physical Layer", | 71 | "Physical Layer", |
76 | "Data Link Layer", | 72 | "Data Link Layer", |
77 | "Transaction Layer" | 73 | "Transaction Layer" |
78 | }; | 74 | }; |
79 | static char *aer_correctable_error_string[] = { | 75 | |
80 | "Receiver Error ", /* Bit Position 0 */ | 76 | static const char *aer_correctable_error_string[] = { |
81 | NULL, | 77 | "Receiver Error", /* Bit Position 0 */ |
82 | NULL, | ||
83 | NULL, | ||
84 | NULL, | ||
85 | NULL, | ||
86 | "Bad TLP ", /* Bit Position 6 */ | ||
87 | "Bad DLLP ", /* Bit Position 7 */ | ||
88 | "RELAY_NUM Rollover ", /* Bit Position 8 */ | ||
89 | NULL, | ||
90 | NULL, | ||
91 | NULL, | ||
92 | "Replay Timer Timeout ", /* Bit Position 12 */ | ||
93 | "Advisory Non-Fatal ", /* Bit Position 13 */ | ||
94 | NULL, | ||
95 | NULL, | ||
96 | NULL, | ||
97 | NULL, | ||
98 | NULL, | ||
99 | NULL, | ||
100 | NULL, | ||
101 | NULL, | ||
102 | NULL, | ||
103 | NULL, | ||
104 | NULL, | 78 | NULL, |
105 | NULL, | 79 | NULL, |
106 | NULL, | 80 | NULL, |
107 | NULL, | 81 | NULL, |
108 | NULL, | 82 | NULL, |
83 | "Bad TLP", /* Bit Position 6 */ | ||
84 | "Bad DLLP", /* Bit Position 7 */ | ||
85 | "RELAY_NUM Rollover", /* Bit Position 8 */ | ||
109 | NULL, | 86 | NULL, |
110 | NULL, | 87 | NULL, |
111 | NULL, | 88 | NULL, |
89 | "Replay Timer Timeout", /* Bit Position 12 */ | ||
90 | "Advisory Non-Fatal", /* Bit Position 13 */ | ||
112 | }; | 91 | }; |
113 | 92 | ||
114 | static char *aer_uncorrectable_error_string[] = { | 93 | static const char *aer_uncorrectable_error_string[] = { |
115 | NULL, | ||
116 | NULL, | ||
117 | NULL, | ||
118 | NULL, | ||
119 | "Data Link Protocol ", /* Bit Position 4 */ | ||
120 | NULL, | ||
121 | NULL, | ||
122 | NULL, | ||
123 | NULL, | ||
124 | NULL, | ||
125 | NULL, | ||
126 | NULL, | ||
127 | "Poisoned TLP ", /* Bit Position 12 */ | ||
128 | "Flow Control Protocol ", /* Bit Position 13 */ | ||
129 | "Completion Timeout ", /* Bit Position 14 */ | ||
130 | "Completer Abort ", /* Bit Position 15 */ | ||
131 | "Unexpected Completion ", /* Bit Position 16 */ | ||
132 | "Receiver Overflow ", /* Bit Position 17 */ | ||
133 | "Malformed TLP ", /* Bit Position 18 */ | ||
134 | "ECRC ", /* Bit Position 19 */ | ||
135 | "Unsupported Request ", /* Bit Position 20 */ | ||
136 | NULL, | 94 | NULL, |
137 | NULL, | 95 | NULL, |
138 | NULL, | 96 | NULL, |
139 | NULL, | 97 | NULL, |
98 | "Data Link Protocol", /* Bit Position 4 */ | ||
140 | NULL, | 99 | NULL, |
141 | NULL, | 100 | NULL, |
142 | NULL, | 101 | NULL, |
@@ -144,19 +103,29 @@ static char *aer_uncorrectable_error_string[] = { | |||
144 | NULL, | 103 | NULL, |
145 | NULL, | 104 | NULL, |
146 | NULL, | 105 | NULL, |
106 | "Poisoned TLP", /* Bit Position 12 */ | ||
107 | "Flow Control Protocol", /* Bit Position 13 */ | ||
108 | "Completion Timeout", /* Bit Position 14 */ | ||
109 | "Completer Abort", /* Bit Position 15 */ | ||
110 | "Unexpected Completion", /* Bit Position 16 */ | ||
111 | "Receiver Overflow", /* Bit Position 17 */ | ||
112 | "Malformed TLP", /* Bit Position 18 */ | ||
113 | "ECRC", /* Bit Position 19 */ | ||
114 | "Unsupported Request", /* Bit Position 20 */ | ||
147 | }; | 115 | }; |
148 | 116 | ||
149 | static char *aer_agent_string[] = { | 117 | static const char *aer_agent_string[] = { |
150 | "Receiver ID", | 118 | "Receiver ID", |
151 | "Requester ID", | 119 | "Requester ID", |
152 | "Completer ID", | 120 | "Completer ID", |
153 | "Transmitter ID" | 121 | "Transmitter ID" |
154 | }; | 122 | }; |
155 | 123 | ||
156 | static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) | 124 | static void __aer_print_error(const char *prefix, |
125 | struct aer_err_info *info) | ||
157 | { | 126 | { |
158 | int i, status; | 127 | int i, status; |
159 | char *errmsg = NULL; | 128 | const char *errmsg = NULL; |
160 | 129 | ||
161 | status = (info->status & ~info->mask); | 130 | status = (info->status & ~info->mask); |
162 | 131 | ||
@@ -165,15 +134,17 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) | |||
165 | continue; | 134 | continue; |
166 | 135 | ||
167 | if (info->severity == AER_CORRECTABLE) | 136 | if (info->severity == AER_CORRECTABLE) |
168 | errmsg = aer_correctable_error_string[i]; | 137 | errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ? |
138 | aer_correctable_error_string[i] : NULL; | ||
169 | else | 139 | else |
170 | errmsg = aer_uncorrectable_error_string[i]; | 140 | errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ? |
141 | aer_uncorrectable_error_string[i] : NULL; | ||
171 | 142 | ||
172 | if (errmsg) | 143 | if (errmsg) |
173 | AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg, | 144 | printk("%s"" [%2d] %-22s%s\n", prefix, i, errmsg, |
174 | info->first_error == i ? " (First)" : ""); | 145 | info->first_error == i ? " (First)" : ""); |
175 | else | 146 | else |
176 | AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i, | 147 | printk("%s"" [%2d] Unknown Error Bit%s\n", prefix, i, |
177 | info->first_error == i ? " (First)" : ""); | 148 | info->first_error == i ? " (First)" : ""); |
178 | } | 149 | } |
179 | } | 150 | } |
@@ -181,11 +152,15 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) | |||
181 | void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | 152 | void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) |
182 | { | 153 | { |
183 | int id = ((dev->bus->number << 8) | dev->devfn); | 154 | int id = ((dev->bus->number << 8) | dev->devfn); |
155 | char prefix[44]; | ||
156 | |||
157 | snprintf(prefix, sizeof(prefix), "%s%s %s: ", | ||
158 | (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR, | ||
159 | dev_driver_string(&dev->dev), dev_name(&dev->dev)); | ||
184 | 160 | ||
185 | if (info->status == 0) { | 161 | if (info->status == 0) { |
186 | AER_PR(info, dev, | 162 | printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, " |
187 | "PCIe Bus Error: severity=%s, type=Unaccessible, " | 163 | "id=%04x(Unregistered Agent ID)\n", prefix, |
188 | "id=%04x(Unregistered Agent ID)\n", | ||
189 | aer_error_severity_string[info->severity], id); | 164 | aer_error_severity_string[info->severity], id); |
190 | } else { | 165 | } else { |
191 | int layer, agent; | 166 | int layer, agent; |
@@ -193,23 +168,22 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | |||
193 | layer = AER_GET_LAYER_ERROR(info->severity, info->status); | 168 | layer = AER_GET_LAYER_ERROR(info->severity, info->status); |
194 | agent = AER_GET_AGENT(info->severity, info->status); | 169 | agent = AER_GET_AGENT(info->severity, info->status); |
195 | 170 | ||
196 | AER_PR(info, dev, | 171 | printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", |
197 | "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", | 172 | prefix, aer_error_severity_string[info->severity], |
198 | aer_error_severity_string[info->severity], | ||
199 | aer_error_layer[layer], id, aer_agent_string[agent]); | 173 | aer_error_layer[layer], id, aer_agent_string[agent]); |
200 | 174 | ||
201 | AER_PR(info, dev, | 175 | printk("%s"" device [%04x:%04x] error status/mask=%08x/%08x\n", |
202 | " device [%04x:%04x] error status/mask=%08x/%08x\n", | 176 | prefix, dev->vendor, dev->device, |
203 | dev->vendor, dev->device, info->status, info->mask); | 177 | info->status, info->mask); |
204 | 178 | ||
205 | __aer_print_error(info, dev); | 179 | __aer_print_error(prefix, info); |
206 | 180 | ||
207 | if (info->tlp_header_valid) { | 181 | if (info->tlp_header_valid) { |
208 | unsigned char *tlp = (unsigned char *) &info->tlp; | 182 | unsigned char *tlp = (unsigned char *) &info->tlp; |
209 | AER_PR(info, dev, " TLP Header:" | 183 | printk("%s"" TLP Header:" |
210 | " %02x%02x%02x%02x %02x%02x%02x%02x" | 184 | " %02x%02x%02x%02x %02x%02x%02x%02x" |
211 | " %02x%02x%02x%02x %02x%02x%02x%02x\n", | 185 | " %02x%02x%02x%02x %02x%02x%02x%02x\n", |
212 | *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, | 186 | prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, |
213 | *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), | 187 | *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), |
214 | *(tlp + 11), *(tlp + 10), *(tlp + 9), | 188 | *(tlp + 11), *(tlp + 10), *(tlp + 9), |
215 | *(tlp + 8), *(tlp + 15), *(tlp + 14), | 189 | *(tlp + 8), *(tlp + 15), *(tlp + 14), |
@@ -218,8 +192,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) | |||
218 | } | 192 | } |
219 | 193 | ||
220 | if (info->id && info->error_dev_num > 1 && info->id == id) | 194 | if (info->id && info->error_dev_num > 1 && info->id == id) |
221 | AER_PR(info, dev, | 195 | printk("%s"" Error of this Agent(%04x) is reported first\n", |
222 | " Error of this Agent(%04x) is reported first\n", id); | 196 | prefix, id); |
223 | } | 197 | } |
224 | 198 | ||
225 | void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) | 199 | void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) |
@@ -228,3 +202,61 @@ void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) | |||
228 | info->multi_error_valid ? "Multiple " : "", | 202 | info->multi_error_valid ? "Multiple " : "", |
229 | aer_error_severity_string[info->severity], info->id); | 203 | aer_error_severity_string[info->severity], info->id); |
230 | } | 204 | } |
205 | |||
206 | #ifdef CONFIG_ACPI_APEI_PCIEAER | ||
207 | static int cper_severity_to_aer(int cper_severity) | ||
208 | { | ||
209 | switch (cper_severity) { | ||
210 | case CPER_SEV_RECOVERABLE: | ||
211 | return AER_NONFATAL; | ||
212 | case CPER_SEV_FATAL: | ||
213 | return AER_FATAL; | ||
214 | default: | ||
215 | return AER_CORRECTABLE; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | void cper_print_aer(const char *prefix, int cper_severity, | ||
220 | struct aer_capability_regs *aer) | ||
221 | { | ||
222 | int aer_severity, layer, agent, status_strs_size, tlp_header_valid = 0; | ||
223 | u32 status, mask; | ||
224 | const char **status_strs; | ||
225 | |||
226 | aer_severity = cper_severity_to_aer(cper_severity); | ||
227 | if (aer_severity == AER_CORRECTABLE) { | ||
228 | status = aer->cor_status; | ||
229 | mask = aer->cor_mask; | ||
230 | status_strs = aer_correctable_error_string; | ||
231 | status_strs_size = ARRAY_SIZE(aer_correctable_error_string); | ||
232 | } else { | ||
233 | status = aer->uncor_status; | ||
234 | mask = aer->uncor_mask; | ||
235 | status_strs = aer_uncorrectable_error_string; | ||
236 | status_strs_size = ARRAY_SIZE(aer_uncorrectable_error_string); | ||
237 | tlp_header_valid = status & AER_LOG_TLP_MASKS; | ||
238 | } | ||
239 | layer = AER_GET_LAYER_ERROR(aer_severity, status); | ||
240 | agent = AER_GET_AGENT(aer_severity, status); | ||
241 | printk("%s""aer_status: 0x%08x, aer_mask: 0x%08x\n", | ||
242 | prefix, status, mask); | ||
243 | cper_print_bits(prefix, status, status_strs, status_strs_size); | ||
244 | printk("%s""aer_layer=%s, aer_agent=%s\n", prefix, | ||
245 | aer_error_layer[layer], aer_agent_string[agent]); | ||
246 | if (aer_severity != AER_CORRECTABLE) | ||
247 | printk("%s""aer_uncor_severity: 0x%08x\n", | ||
248 | prefix, aer->uncor_severity); | ||
249 | if (tlp_header_valid) { | ||
250 | const unsigned char *tlp; | ||
251 | tlp = (const unsigned char *)&aer->header_log; | ||
252 | printk("%s""aer_tlp_header:" | ||
253 | " %02x%02x%02x%02x %02x%02x%02x%02x" | ||
254 | " %02x%02x%02x%02x %02x%02x%02x%02x\n", | ||
255 | prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, | ||
256 | *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), | ||
257 | *(tlp + 11), *(tlp + 10), *(tlp + 9), | ||
258 | *(tlp + 8), *(tlp + 15), *(tlp + 14), | ||
259 | *(tlp + 13), *(tlp + 12)); | ||
260 | } | ||
261 | } | ||
262 | #endif | ||