diff options
author | Gavin Shan <shangw@linux.vnet.ibm.com> | 2012-09-07 18:44:19 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-09-09 19:35:43 -0400 |
commit | 9b3c76f08122f5efdbe4992a64b8478cc92dd983 (patch) | |
tree | c5e668d39e96971e404c16a155e6a40cd5f62400 | |
parent | 120dc496617eb7105d577c6041cbc052ffb1d8c7 (diff) |
powerpc/eeh: Handle EEH error based on PE
The patch reworks the current implementation so that the eeh errors
will be handled basing on PE instead of eeh device.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/eeh.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/eeh_event.h | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/eeh_driver.c | 229 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/eeh_event.c | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/eeh_pe.c | 28 |
5 files changed, 125 insertions, 137 deletions
diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h index 629fb27c093e..d25a693595f8 100644 --- a/arch/powerpc/include/asm/eeh.h +++ b/arch/powerpc/include/asm/eeh.h | |||
@@ -174,6 +174,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev); | |||
174 | void *eeh_pe_dev_traverse(struct eeh_pe *root, | 174 | void *eeh_pe_dev_traverse(struct eeh_pe *root, |
175 | eeh_traverse_func fn, void *flag); | 175 | eeh_traverse_func fn, void *flag); |
176 | void eeh_pe_restore_bars(struct eeh_pe *pe); | 176 | void eeh_pe_restore_bars(struct eeh_pe *pe); |
177 | struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe); | ||
177 | 178 | ||
178 | void * __devinit eeh_dev_init(struct device_node *dn, void *data); | 179 | void * __devinit eeh_dev_init(struct device_node *dn, void *data); |
179 | void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb); | 180 | void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb); |
diff --git a/arch/powerpc/include/asm/eeh_event.h b/arch/powerpc/include/asm/eeh_event.h index dc722b58216c..de67d830151b 100644 --- a/arch/powerpc/include/asm/eeh_event.h +++ b/arch/powerpc/include/asm/eeh_event.h | |||
@@ -32,7 +32,7 @@ struct eeh_event { | |||
32 | }; | 32 | }; |
33 | 33 | ||
34 | int eeh_send_failure_event(struct eeh_pe *pe); | 34 | int eeh_send_failure_event(struct eeh_pe *pe); |
35 | struct eeh_dev *handle_eeh_events(struct eeh_event *); | 35 | void eeh_handle_event(struct eeh_pe *pe); |
36 | 36 | ||
37 | #endif /* __KERNEL__ */ | 37 | #endif /* __KERNEL__ */ |
38 | #endif /* ASM_POWERPC_EEH_EVENT_H */ | 38 | #endif /* ASM_POWERPC_EEH_EVENT_H */ |
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c index baf92cd9dfab..343c807e608a 100644 --- a/arch/powerpc/platforms/pseries/eeh_driver.c +++ b/arch/powerpc/platforms/pseries/eeh_driver.c | |||
@@ -116,28 +116,35 @@ static void eeh_enable_irq(struct pci_dev *dev) | |||
116 | 116 | ||
117 | /** | 117 | /** |
118 | * eeh_report_error - Report pci error to each device driver | 118 | * eeh_report_error - Report pci error to each device driver |
119 | * @dev: PCI device | 119 | * @data: eeh device |
120 | * @userdata: return value | 120 | * @userdata: return value |
121 | * | 121 | * |
122 | * Report an EEH error to each device driver, collect up and | 122 | * Report an EEH error to each device driver, collect up and |
123 | * merge the device driver responses. Cumulative response | 123 | * merge the device driver responses. Cumulative response |
124 | * passed back in "userdata". | 124 | * passed back in "userdata". |
125 | */ | 125 | */ |
126 | static int eeh_report_error(struct pci_dev *dev, void *userdata) | 126 | static void *eeh_report_error(void *data, void *userdata) |
127 | { | 127 | { |
128 | struct eeh_dev *edev = (struct eeh_dev *)data; | ||
129 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); | ||
128 | enum pci_ers_result rc, *res = userdata; | 130 | enum pci_ers_result rc, *res = userdata; |
129 | struct pci_driver *driver = dev->driver; | 131 | struct pci_driver *driver = dev->driver; |
130 | 132 | ||
133 | /* We might not have the associated PCI device, | ||
134 | * then we should continue for next one. | ||
135 | */ | ||
136 | if (!dev) return NULL; | ||
137 | |||
131 | dev->error_state = pci_channel_io_frozen; | 138 | dev->error_state = pci_channel_io_frozen; |
132 | 139 | ||
133 | if (!driver) | 140 | if (!driver) |
134 | return 0; | 141 | return NULL; |
135 | 142 | ||
136 | eeh_disable_irq(dev); | 143 | eeh_disable_irq(dev); |
137 | 144 | ||
138 | if (!driver->err_handler || | 145 | if (!driver->err_handler || |
139 | !driver->err_handler->error_detected) | 146 | !driver->err_handler->error_detected) |
140 | return 0; | 147 | return NULL; |
141 | 148 | ||
142 | rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen); | 149 | rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen); |
143 | 150 | ||
@@ -145,27 +152,31 @@ static int eeh_report_error(struct pci_dev *dev, void *userdata) | |||
145 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; | 152 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
146 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; | 153 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; |
147 | 154 | ||
148 | return 0; | 155 | return NULL; |
149 | } | 156 | } |
150 | 157 | ||
151 | /** | 158 | /** |
152 | * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled | 159 | * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled |
153 | * @dev: PCI device | 160 | * @data: eeh device |
154 | * @userdata: return value | 161 | * @userdata: return value |
155 | * | 162 | * |
156 | * Tells each device driver that IO ports, MMIO and config space I/O | 163 | * Tells each device driver that IO ports, MMIO and config space I/O |
157 | * are now enabled. Collects up and merges the device driver responses. | 164 | * are now enabled. Collects up and merges the device driver responses. |
158 | * Cumulative response passed back in "userdata". | 165 | * Cumulative response passed back in "userdata". |
159 | */ | 166 | */ |
160 | static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) | 167 | static void *eeh_report_mmio_enabled(void *data, void *userdata) |
161 | { | 168 | { |
169 | struct eeh_dev *edev = (struct eeh_dev *)data; | ||
170 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); | ||
162 | enum pci_ers_result rc, *res = userdata; | 171 | enum pci_ers_result rc, *res = userdata; |
163 | struct pci_driver *driver = dev->driver; | 172 | struct pci_driver *driver; |
164 | 173 | ||
165 | if (!driver || | 174 | if (!dev) return NULL; |
175 | |||
176 | if (!(driver = dev->driver) || | ||
166 | !driver->err_handler || | 177 | !driver->err_handler || |
167 | !driver->err_handler->mmio_enabled) | 178 | !driver->err_handler->mmio_enabled) |
168 | return 0; | 179 | return NULL; |
169 | 180 | ||
170 | rc = driver->err_handler->mmio_enabled(dev); | 181 | rc = driver->err_handler->mmio_enabled(dev); |
171 | 182 | ||
@@ -173,12 +184,12 @@ static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) | |||
173 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; | 184 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
174 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; | 185 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; |
175 | 186 | ||
176 | return 0; | 187 | return NULL; |
177 | } | 188 | } |
178 | 189 | ||
179 | /** | 190 | /** |
180 | * eeh_report_reset - Tell device that slot has been reset | 191 | * eeh_report_reset - Tell device that slot has been reset |
181 | * @dev: PCI device | 192 | * @data: eeh device |
182 | * @userdata: return value | 193 | * @userdata: return value |
183 | * | 194 | * |
184 | * This routine must be called while EEH tries to reset particular | 195 | * This routine must be called while EEH tries to reset particular |
@@ -186,13 +197,15 @@ static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) | |||
186 | * some actions, usually to save data the driver needs so that the | 197 | * some actions, usually to save data the driver needs so that the |
187 | * driver can work again while the device is recovered. | 198 | * driver can work again while the device is recovered. |
188 | */ | 199 | */ |
189 | static int eeh_report_reset(struct pci_dev *dev, void *userdata) | 200 | static void *eeh_report_reset(void *data, void *userdata) |
190 | { | 201 | { |
202 | struct eeh_dev *edev = (struct eeh_dev *)data; | ||
203 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); | ||
191 | enum pci_ers_result rc, *res = userdata; | 204 | enum pci_ers_result rc, *res = userdata; |
192 | struct pci_driver *driver = dev->driver; | 205 | struct pci_driver *driver; |
193 | 206 | ||
194 | if (!driver) | 207 | if (!dev || !(driver = dev->driver)) |
195 | return 0; | 208 | return NULL; |
196 | 209 | ||
197 | dev->error_state = pci_channel_io_normal; | 210 | dev->error_state = pci_channel_io_normal; |
198 | 211 | ||
@@ -200,7 +213,7 @@ static int eeh_report_reset(struct pci_dev *dev, void *userdata) | |||
200 | 213 | ||
201 | if (!driver->err_handler || | 214 | if (!driver->err_handler || |
202 | !driver->err_handler->slot_reset) | 215 | !driver->err_handler->slot_reset) |
203 | return 0; | 216 | return NULL; |
204 | 217 | ||
205 | rc = driver->err_handler->slot_reset(dev); | 218 | rc = driver->err_handler->slot_reset(dev); |
206 | if ((*res == PCI_ERS_RESULT_NONE) || | 219 | if ((*res == PCI_ERS_RESULT_NONE) || |
@@ -208,82 +221,89 @@ static int eeh_report_reset(struct pci_dev *dev, void *userdata) | |||
208 | if (*res == PCI_ERS_RESULT_DISCONNECT && | 221 | if (*res == PCI_ERS_RESULT_DISCONNECT && |
209 | rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; | 222 | rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
210 | 223 | ||
211 | return 0; | 224 | return NULL; |
212 | } | 225 | } |
213 | 226 | ||
214 | /** | 227 | /** |
215 | * eeh_report_resume - Tell device to resume normal operations | 228 | * eeh_report_resume - Tell device to resume normal operations |
216 | * @dev: PCI device | 229 | * @data: eeh device |
217 | * @userdata: return value | 230 | * @userdata: return value |
218 | * | 231 | * |
219 | * This routine must be called to notify the device driver that it | 232 | * This routine must be called to notify the device driver that it |
220 | * could resume so that the device driver can do some initialization | 233 | * could resume so that the device driver can do some initialization |
221 | * to make the recovered device work again. | 234 | * to make the recovered device work again. |
222 | */ | 235 | */ |
223 | static int eeh_report_resume(struct pci_dev *dev, void *userdata) | 236 | static void *eeh_report_resume(void *data, void *userdata) |
224 | { | 237 | { |
225 | struct pci_driver *driver = dev->driver; | 238 | struct eeh_dev *edev = (struct eeh_dev *)data; |
239 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); | ||
240 | struct pci_driver *driver; | ||
241 | |||
242 | if (!dev) return NULL; | ||
226 | 243 | ||
227 | dev->error_state = pci_channel_io_normal; | 244 | dev->error_state = pci_channel_io_normal; |
228 | 245 | ||
229 | if (!driver) | 246 | if (!(driver = dev->driver)) |
230 | return 0; | 247 | return NULL; |
231 | 248 | ||
232 | eeh_enable_irq(dev); | 249 | eeh_enable_irq(dev); |
233 | 250 | ||
234 | if (!driver->err_handler || | 251 | if (!driver->err_handler || |
235 | !driver->err_handler->resume) | 252 | !driver->err_handler->resume) |
236 | return 0; | 253 | return NULL; |
237 | 254 | ||
238 | driver->err_handler->resume(dev); | 255 | driver->err_handler->resume(dev); |
239 | 256 | ||
240 | return 0; | 257 | return NULL; |
241 | } | 258 | } |
242 | 259 | ||
243 | /** | 260 | /** |
244 | * eeh_report_failure - Tell device driver that device is dead. | 261 | * eeh_report_failure - Tell device driver that device is dead. |
245 | * @dev: PCI device | 262 | * @data: eeh device |
246 | * @userdata: return value | 263 | * @userdata: return value |
247 | * | 264 | * |
248 | * This informs the device driver that the device is permanently | 265 | * This informs the device driver that the device is permanently |
249 | * dead, and that no further recovery attempts will be made on it. | 266 | * dead, and that no further recovery attempts will be made on it. |
250 | */ | 267 | */ |
251 | static int eeh_report_failure(struct pci_dev *dev, void *userdata) | 268 | static void *eeh_report_failure(void *data, void *userdata) |
252 | { | 269 | { |
253 | struct pci_driver *driver = dev->driver; | 270 | struct eeh_dev *edev = (struct eeh_dev *)data; |
271 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); | ||
272 | struct pci_driver *driver; | ||
273 | |||
274 | if (!dev) return NULL; | ||
254 | 275 | ||
255 | dev->error_state = pci_channel_io_perm_failure; | 276 | dev->error_state = pci_channel_io_perm_failure; |
256 | 277 | ||
257 | if (!driver) | 278 | if (!(driver = dev->driver)) |
258 | return 0; | 279 | return NULL; |
259 | 280 | ||
260 | eeh_disable_irq(dev); | 281 | eeh_disable_irq(dev); |
261 | 282 | ||
262 | if (!driver->err_handler || | 283 | if (!driver->err_handler || |
263 | !driver->err_handler->error_detected) | 284 | !driver->err_handler->error_detected) |
264 | return 0; | 285 | return NULL; |
265 | 286 | ||
266 | driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); | 287 | driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); |
267 | 288 | ||
268 | return 0; | 289 | return NULL; |
269 | } | 290 | } |
270 | 291 | ||
271 | /** | 292 | /** |
272 | * eeh_reset_device - Perform actual reset of a pci slot | 293 | * eeh_reset_device - Perform actual reset of a pci slot |
273 | * @edev: PE associated EEH device | 294 | * @pe: EEH PE |
274 | * @bus: PCI bus corresponding to the isolcated slot | 295 | * @bus: PCI bus corresponding to the isolcated slot |
275 | * | 296 | * |
276 | * This routine must be called to do reset on the indicated PE. | 297 | * This routine must be called to do reset on the indicated PE. |
277 | * During the reset, udev might be invoked because those affected | 298 | * During the reset, udev might be invoked because those affected |
278 | * PCI devices will be removed and then added. | 299 | * PCI devices will be removed and then added. |
279 | */ | 300 | */ |
280 | static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) | 301 | static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) |
281 | { | 302 | { |
282 | struct device_node *dn; | ||
283 | int cnt, rc; | 303 | int cnt, rc; |
284 | 304 | ||
285 | /* pcibios will clear the counter; save the value */ | 305 | /* pcibios will clear the counter; save the value */ |
286 | cnt = edev->freeze_count; | 306 | cnt = pe->freeze_count; |
287 | 307 | ||
288 | if (bus) | 308 | if (bus) |
289 | pcibios_remove_pci_devices(bus); | 309 | pcibios_remove_pci_devices(bus); |
@@ -292,25 +312,13 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) | |||
292 | * Reconfigure bridges and devices. Don't try to bring the system | 312 | * Reconfigure bridges and devices. Don't try to bring the system |
293 | * up if the reset failed for some reason. | 313 | * up if the reset failed for some reason. |
294 | */ | 314 | */ |
295 | rc = eeh_reset_pe(edev); | 315 | rc = eeh_reset_pe(pe); |
296 | if (rc) | 316 | if (rc) |
297 | return rc; | 317 | return rc; |
298 | 318 | ||
299 | /* Walk over all functions on this device. */ | 319 | /* Restore PE */ |
300 | dn = eeh_dev_to_of_node(edev); | 320 | eeh_ops->configure_bridge(pe); |
301 | if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) | 321 | eeh_pe_restore_bars(pe); |
302 | dn = dn->parent->child; | ||
303 | |||
304 | while (dn) { | ||
305 | struct eeh_dev *pedev = of_node_to_eeh_dev(dn); | ||
306 | |||
307 | /* On Power4, always true because eeh_pe_config_addr=0 */ | ||
308 | if (edev->pe_config_addr == pedev->pe_config_addr) { | ||
309 | eeh_ops->configure_bridge(dn); | ||
310 | eeh_restore_bars(pedev); | ||
311 | } | ||
312 | dn = dn->sibling; | ||
313 | } | ||
314 | 322 | ||
315 | /* Give the system 5 seconds to finish running the user-space | 323 | /* Give the system 5 seconds to finish running the user-space |
316 | * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, | 324 | * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, |
@@ -322,7 +330,7 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) | |||
322 | ssleep(5); | 330 | ssleep(5); |
323 | pcibios_add_pci_devices(bus); | 331 | pcibios_add_pci_devices(bus); |
324 | } | 332 | } |
325 | edev->freeze_count = cnt; | 333 | pe->freeze_count = cnt; |
326 | 334 | ||
327 | return 0; | 335 | return 0; |
328 | } | 336 | } |
@@ -334,7 +342,7 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) | |||
334 | 342 | ||
335 | /** | 343 | /** |
336 | * eeh_handle_event - Reset a PCI device after hard lockup. | 344 | * eeh_handle_event - Reset a PCI device after hard lockup. |
337 | * @event: EEH event | 345 | * @pe: EEH PE |
338 | * | 346 | * |
339 | * While PHB detects address or data parity errors on particular PCI | 347 | * While PHB detects address or data parity errors on particular PCI |
340 | * slot, the associated PE will be frozen. Besides, DMA's occurring | 348 | * slot, the associated PE will be frozen. Besides, DMA's occurring |
@@ -349,69 +357,24 @@ static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) | |||
349 | * drivers (which cause a second set of hotplug events to go out to | 357 | * drivers (which cause a second set of hotplug events to go out to |
350 | * userspace). | 358 | * userspace). |
351 | */ | 359 | */ |
352 | struct eeh_dev *handle_eeh_events(struct eeh_event *event) | 360 | void eeh_handle_event(struct eeh_pe *pe) |
353 | { | 361 | { |
354 | struct device_node *frozen_dn; | ||
355 | struct eeh_dev *frozen_edev; | ||
356 | struct pci_bus *frozen_bus; | 362 | struct pci_bus *frozen_bus; |
357 | int rc = 0; | 363 | int rc = 0; |
358 | enum pci_ers_result result = PCI_ERS_RESULT_NONE; | 364 | enum pci_ers_result result = PCI_ERS_RESULT_NONE; |
359 | const char *location, *pci_str, *drv_str, *bus_pci_str, *bus_drv_str; | ||
360 | |||
361 | frozen_dn = eeh_find_device_pe(eeh_dev_to_of_node(event->edev)); | ||
362 | if (!frozen_dn) { | ||
363 | location = of_get_property(eeh_dev_to_of_node(event->edev), "ibm,loc-code", NULL); | ||
364 | location = location ? location : "unknown"; | ||
365 | printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " | ||
366 | "for location=%s pci addr=%s\n", | ||
367 | location, eeh_pci_name(eeh_dev_to_pci_dev(event->edev))); | ||
368 | return NULL; | ||
369 | } | ||
370 | |||
371 | frozen_bus = pcibios_find_pci_bus(frozen_dn); | ||
372 | location = of_get_property(frozen_dn, "ibm,loc-code", NULL); | ||
373 | location = location ? location : "unknown"; | ||
374 | |||
375 | /* There are two different styles for coming up with the PE. | ||
376 | * In the old style, it was the highest EEH-capable device | ||
377 | * which was always an EADS pci bridge. In the new style, | ||
378 | * there might not be any EADS bridges, and even when there are, | ||
379 | * the firmware marks them as "EEH incapable". So another | ||
380 | * two-step is needed to find the pci bus.. | ||
381 | */ | ||
382 | if (!frozen_bus) | ||
383 | frozen_bus = pcibios_find_pci_bus(frozen_dn->parent); | ||
384 | 365 | ||
366 | frozen_bus = eeh_pe_bus_get(pe); | ||
385 | if (!frozen_bus) { | 367 | if (!frozen_bus) { |
386 | printk(KERN_ERR "EEH: Cannot find PCI bus " | 368 | pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n", |
387 | "for location=%s dn=%s\n", | 369 | __func__, pe->phb->global_number, pe->addr); |
388 | location, frozen_dn->full_name); | 370 | return; |
389 | return NULL; | ||
390 | } | 371 | } |
391 | 372 | ||
392 | frozen_edev = of_node_to_eeh_dev(frozen_dn); | 373 | pe->freeze_count++; |
393 | frozen_edev->freeze_count++; | 374 | if (pe->freeze_count > EEH_MAX_ALLOWED_FREEZES) |
394 | pci_str = eeh_pci_name(eeh_dev_to_pci_dev(event->edev)); | ||
395 | drv_str = eeh_pcid_name(eeh_dev_to_pci_dev(event->edev)); | ||
396 | |||
397 | if (frozen_edev->freeze_count > EEH_MAX_ALLOWED_FREEZES) | ||
398 | goto excess_failures; | 375 | goto excess_failures; |
399 | 376 | pr_warning("EEH: This PCI device has failed %d times in the last hour\n", | |
400 | printk(KERN_WARNING | 377 | pe->freeze_count); |
401 | "EEH: This PCI device has failed %d times in the last hour:\n", | ||
402 | frozen_edev->freeze_count); | ||
403 | |||
404 | if (frozen_edev->pdev) { | ||
405 | bus_pci_str = pci_name(frozen_edev->pdev); | ||
406 | bus_drv_str = eeh_pcid_name(frozen_edev->pdev); | ||
407 | printk(KERN_WARNING | ||
408 | "EEH: Bus location=%s driver=%s pci addr=%s\n", | ||
409 | location, bus_drv_str, bus_pci_str); | ||
410 | } | ||
411 | |||
412 | printk(KERN_WARNING | ||
413 | "EEH: Device location=%s driver=%s pci addr=%s\n", | ||
414 | location, drv_str, pci_str); | ||
415 | 378 | ||
416 | /* Walk the various device drivers attached to this slot through | 379 | /* Walk the various device drivers attached to this slot through |
417 | * a reset sequence, giving each an opportunity to do what it needs | 380 | * a reset sequence, giving each an opportunity to do what it needs |
@@ -419,12 +382,12 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
419 | * status ... if any child can't handle the reset, then the entire | 382 | * status ... if any child can't handle the reset, then the entire |
420 | * slot is dlpar removed and added. | 383 | * slot is dlpar removed and added. |
421 | */ | 384 | */ |
422 | pci_walk_bus(frozen_bus, eeh_report_error, &result); | 385 | eeh_pe_dev_traverse(pe, eeh_report_error, &result); |
423 | 386 | ||
424 | /* Get the current PCI slot state. This can take a long time, | 387 | /* Get the current PCI slot state. This can take a long time, |
425 | * sometimes over 3 seconds for certain systems. | 388 | * sometimes over 3 seconds for certain systems. |
426 | */ | 389 | */ |
427 | rc = eeh_ops->wait_state(eeh_dev_to_of_node(frozen_edev), MAX_WAIT_FOR_RECOVERY*1000); | 390 | rc = eeh_ops->wait_state(pe, MAX_WAIT_FOR_RECOVERY*1000); |
428 | if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) { | 391 | if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) { |
429 | printk(KERN_WARNING "EEH: Permanent failure\n"); | 392 | printk(KERN_WARNING "EEH: Permanent failure\n"); |
430 | goto hard_fail; | 393 | goto hard_fail; |
@@ -434,14 +397,14 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
434 | * don't post the error log until after all dev drivers | 397 | * don't post the error log until after all dev drivers |
435 | * have been informed. | 398 | * have been informed. |
436 | */ | 399 | */ |
437 | eeh_slot_error_detail(frozen_edev, EEH_LOG_TEMP); | 400 | eeh_slot_error_detail(pe, EEH_LOG_TEMP); |
438 | 401 | ||
439 | /* If all device drivers were EEH-unaware, then shut | 402 | /* If all device drivers were EEH-unaware, then shut |
440 | * down all of the device drivers, and hope they | 403 | * down all of the device drivers, and hope they |
441 | * go down willingly, without panicing the system. | 404 | * go down willingly, without panicing the system. |
442 | */ | 405 | */ |
443 | if (result == PCI_ERS_RESULT_NONE) { | 406 | if (result == PCI_ERS_RESULT_NONE) { |
444 | rc = eeh_reset_device(frozen_edev, frozen_bus); | 407 | rc = eeh_reset_device(pe, frozen_bus); |
445 | if (rc) { | 408 | if (rc) { |
446 | printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc); | 409 | printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc); |
447 | goto hard_fail; | 410 | goto hard_fail; |
@@ -450,7 +413,7 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
450 | 413 | ||
451 | /* If all devices reported they can proceed, then re-enable MMIO */ | 414 | /* If all devices reported they can proceed, then re-enable MMIO */ |
452 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { | 415 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { |
453 | rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_MMIO); | 416 | rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); |
454 | 417 | ||
455 | if (rc < 0) | 418 | if (rc < 0) |
456 | goto hard_fail; | 419 | goto hard_fail; |
@@ -458,13 +421,13 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
458 | result = PCI_ERS_RESULT_NEED_RESET; | 421 | result = PCI_ERS_RESULT_NEED_RESET; |
459 | } else { | 422 | } else { |
460 | result = PCI_ERS_RESULT_NONE; | 423 | result = PCI_ERS_RESULT_NONE; |
461 | pci_walk_bus(frozen_bus, eeh_report_mmio_enabled, &result); | 424 | eeh_pe_dev_traverse(pe, eeh_report_mmio_enabled, &result); |
462 | } | 425 | } |
463 | } | 426 | } |
464 | 427 | ||
465 | /* If all devices reported they can proceed, then re-enable DMA */ | 428 | /* If all devices reported they can proceed, then re-enable DMA */ |
466 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { | 429 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { |
467 | rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_DMA); | 430 | rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA); |
468 | 431 | ||
469 | if (rc < 0) | 432 | if (rc < 0) |
470 | goto hard_fail; | 433 | goto hard_fail; |
@@ -482,13 +445,13 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
482 | 445 | ||
483 | /* If any device called out for a reset, then reset the slot */ | 446 | /* If any device called out for a reset, then reset the slot */ |
484 | if (result == PCI_ERS_RESULT_NEED_RESET) { | 447 | if (result == PCI_ERS_RESULT_NEED_RESET) { |
485 | rc = eeh_reset_device(frozen_edev, NULL); | 448 | rc = eeh_reset_device(pe, NULL); |
486 | if (rc) { | 449 | if (rc) { |
487 | printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc); | 450 | printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc); |
488 | goto hard_fail; | 451 | goto hard_fail; |
489 | } | 452 | } |
490 | result = PCI_ERS_RESULT_NONE; | 453 | result = PCI_ERS_RESULT_NONE; |
491 | pci_walk_bus(frozen_bus, eeh_report_reset, &result); | 454 | eeh_pe_dev_traverse(pe, eeh_report_reset, &result); |
492 | } | 455 | } |
493 | 456 | ||
494 | /* All devices should claim they have recovered by now. */ | 457 | /* All devices should claim they have recovered by now. */ |
@@ -499,9 +462,9 @@ struct eeh_dev *handle_eeh_events(struct eeh_event *event) | |||
499 | } | 462 | } |
500 | 463 | ||
501 | /* Tell all device drivers that they can resume operations */ | 464 | /* Tell all device drivers that they can resume operations */ |
502 | pci_walk_bus(frozen_bus, eeh_report_resume, NULL); | 465 | eeh_pe_dev_traverse(pe, eeh_report_resume, NULL); |
503 | 466 | ||
504 | return frozen_edev; | 467 | return; |
505 | 468 | ||
506 | excess_failures: | 469 | excess_failures: |
507 | /* | 470 | /* |
@@ -509,30 +472,26 @@ excess_failures: | |||
509 | * are due to poorly seated PCI cards. Only 10% or so are | 472 | * are due to poorly seated PCI cards. Only 10% or so are |
510 | * due to actual, failed cards. | 473 | * due to actual, failed cards. |
511 | */ | 474 | */ |
512 | printk(KERN_ERR | 475 | pr_err("EEH: PHB#%d-PE#%x has failed %d times in the\n" |
513 | "EEH: PCI device at location=%s driver=%s pci addr=%s\n" | 476 | "last hour and has been permanently disabled.\n" |
514 | "has failed %d times in the last hour " | 477 | "Please try reseating or replacing it.\n", |
515 | "and has been permanently disabled.\n" | 478 | pe->phb->global_number, pe->addr, |
516 | "Please try reseating this device or replacing it.\n", | 479 | pe->freeze_count); |
517 | location, drv_str, pci_str, frozen_edev->freeze_count); | ||
518 | goto perm_error; | 480 | goto perm_error; |
519 | 481 | ||
520 | hard_fail: | 482 | hard_fail: |
521 | printk(KERN_ERR | 483 | pr_err("EEH: Unable to recover from failure from PHB#%d-PE#%x.\n" |
522 | "EEH: Unable to recover from failure of PCI device " | 484 | "Please try reseating or replacing it\n", |
523 | "at location=%s driver=%s pci addr=%s\n" | 485 | pe->phb->global_number, pe->addr); |
524 | "Please try reseating this device or replacing it.\n", | ||
525 | location, drv_str, pci_str); | ||
526 | 486 | ||
527 | perm_error: | 487 | perm_error: |
528 | eeh_slot_error_detail(frozen_edev, EEH_LOG_PERM); | 488 | eeh_slot_error_detail(pe, EEH_LOG_PERM); |
529 | 489 | ||
530 | /* Notify all devices that they're about to go down. */ | 490 | /* Notify all devices that they're about to go down. */ |
531 | pci_walk_bus(frozen_bus, eeh_report_failure, NULL); | 491 | eeh_pe_dev_traverse(pe, eeh_report_failure, NULL); |
532 | 492 | ||
533 | /* Shut down the device drivers for good. */ | 493 | /* Shut down the device drivers for good. */ |
534 | pcibios_remove_pci_devices(frozen_bus); | 494 | if (frozen_bus) |
535 | 495 | pcibios_remove_pci_devices(frozen_bus); | |
536 | return NULL; | ||
537 | } | 496 | } |
538 | 497 | ||
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c index ba7005a5e2fe..51faaac8abe6 100644 --- a/arch/powerpc/platforms/pseries/eeh_event.c +++ b/arch/powerpc/platforms/pseries/eeh_event.c | |||
@@ -82,7 +82,7 @@ static int eeh_event_handler(void * dummy) | |||
82 | pe->phb->global_number, pe->addr); | 82 | pe->phb->global_number, pe->addr); |
83 | 83 | ||
84 | set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */ | 84 | set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */ |
85 | handle_eeh_events(event); | 85 | eeh_handle_event(pe); |
86 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); | 86 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); |
87 | 87 | ||
88 | kfree(event); | 88 | kfree(event); |
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c index 2b7e85b804a4..904123c7657b 100644 --- a/arch/powerpc/platforms/pseries/eeh_pe.c +++ b/arch/powerpc/platforms/pseries/eeh_pe.c | |||
@@ -561,3 +561,31 @@ void eeh_pe_restore_bars(struct eeh_pe *pe) | |||
561 | { | 561 | { |
562 | eeh_pe_dev_traverse(pe, eeh_restore_one_device_bars, NULL); | 562 | eeh_pe_dev_traverse(pe, eeh_restore_one_device_bars, NULL); |
563 | } | 563 | } |
564 | |||
565 | /** | ||
566 | * eeh_pe_bus_get - Retrieve PCI bus according to the given PE | ||
567 | * @pe: EEH PE | ||
568 | * | ||
569 | * Retrieve the PCI bus according to the given PE. Basically, | ||
570 | * there're 3 types of PEs: PHB/Bus/Device. For PHB PE, the | ||
571 | * primary PCI bus will be retrieved. The parent bus will be | ||
572 | * returned for BUS PE. However, we don't have associated PCI | ||
573 | * bus for DEVICE PE. | ||
574 | */ | ||
575 | struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe) | ||
576 | { | ||
577 | struct pci_bus *bus = NULL; | ||
578 | struct eeh_dev *edev; | ||
579 | struct pci_dev *pdev; | ||
580 | |||
581 | if (pe->type == EEH_PE_PHB) { | ||
582 | bus = pe->phb->bus; | ||
583 | } else if (pe->type == EEH_PE_BUS) { | ||
584 | edev = list_first_entry(&pe->edevs, struct eeh_dev, list); | ||
585 | pdev = eeh_dev_to_pci_dev(edev); | ||
586 | if (pdev) | ||
587 | bus = pdev->bus; | ||
588 | } | ||
589 | |||
590 | return bus; | ||
591 | } | ||