Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 1 | /* |
| 2 | * PCI Error Recovery Driver for RPA-compliant PPC64 platform. |
Linas Vepstas | 3c8c90a | 2007-05-24 03:28:01 +1000 | [diff] [blame] | 3 | * Copyright IBM Corp. 2004 2005 |
| 4 | * Copyright Linas Vepstas <linas@linas.org> 2004, 2005 |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 5 | * |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or (at |
| 11 | * your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 16 | * NON INFRINGEMENT. See the GNU General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | * |
Linas Vepstas | 3c8c90a | 2007-05-24 03:28:01 +1000 | [diff] [blame] | 23 | * Send comments and feedback to Linas Vepstas <linas@austin.ibm.com> |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 24 | */ |
| 25 | #include <linux/delay.h> |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 26 | #include <linux/interrupt.h> |
Linas Vepstas | ac325ac | 2006-04-18 21:05:21 -0700 | [diff] [blame] | 27 | #include <linux/irq.h> |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 28 | #include <linux/module.h> |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 29 | #include <linux/pci.h> |
| 30 | #include <asm/eeh.h> |
| 31 | #include <asm/eeh_event.h> |
| 32 | #include <asm/ppc-pci.h> |
| 33 | #include <asm/pci-bridge.h> |
| 34 | #include <asm/prom.h> |
| 35 | #include <asm/rtas.h> |
| 36 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 37 | struct eeh_rmv_data { |
| 38 | struct list_head edev_list; |
| 39 | int removed; |
| 40 | }; |
| 41 | |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 42 | /** |
| 43 | * eeh_pcid_name - Retrieve name of PCI device driver |
| 44 | * @pdev: PCI device |
| 45 | * |
| 46 | * This routine is used to retrieve the name of PCI device driver |
| 47 | * if that's valid. |
| 48 | */ |
Gavin Shan | 40a7cd9 | 2012-02-27 20:04:08 +0000 | [diff] [blame] | 49 | static inline const char *eeh_pcid_name(struct pci_dev *pdev) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 50 | { |
Olaf Hering | 273d280 | 2006-02-27 15:52:59 +0100 | [diff] [blame] | 51 | if (pdev && pdev->dev.driver) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 52 | return pdev->dev.driver->name; |
| 53 | return ""; |
| 54 | } |
| 55 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 56 | /** |
| 57 | * eeh_pcid_get - Get the PCI device driver |
| 58 | * @pdev: PCI device |
| 59 | * |
| 60 | * The function is used to retrieve the PCI device driver for |
| 61 | * the indicated PCI device. Besides, we will increase the reference |
| 62 | * of the PCI device driver to prevent that being unloaded on |
| 63 | * the fly. Otherwise, kernel crash would be seen. |
| 64 | */ |
| 65 | static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev) |
| 66 | { |
| 67 | if (!pdev || !pdev->driver) |
| 68 | return NULL; |
| 69 | |
| 70 | if (!try_module_get(pdev->driver->driver.owner)) |
| 71 | return NULL; |
| 72 | |
| 73 | return pdev->driver; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * eeh_pcid_put - Dereference on the PCI device driver |
| 78 | * @pdev: PCI device |
| 79 | * |
| 80 | * The function is called to do dereference on the PCI device |
| 81 | * driver of the indicated PCI device. |
| 82 | */ |
| 83 | static inline void eeh_pcid_put(struct pci_dev *pdev) |
| 84 | { |
| 85 | if (!pdev || !pdev->driver) |
| 86 | return; |
| 87 | |
| 88 | module_put(pdev->driver->driver.owner); |
| 89 | } |
| 90 | |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 91 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 92 | * eeh_disable_irq - Disable interrupt for the recovering device |
| 93 | * @dev: PCI device |
| 94 | * |
| 95 | * This routine must be called when reporting temporary or permanent |
| 96 | * error to the particular PCI device to disable interrupt of that |
| 97 | * device. If the device has enabled MSI or MSI-X interrupt, we needn't |
| 98 | * do real work because EEH should freeze DMA transfers for those PCI |
| 99 | * devices encountering EEH errors, which includes MSI or MSI-X. |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 100 | */ |
| 101 | static void eeh_disable_irq(struct pci_dev *dev) |
| 102 | { |
Gavin Shan | 40a7cd9 | 2012-02-27 20:04:08 +0000 | [diff] [blame] | 103 | struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 104 | |
| 105 | /* Don't disable MSI and MSI-X interrupts. They are |
| 106 | * effectively disabled by the DMA Stopped state |
| 107 | * when an EEH error occurs. |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 108 | */ |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 109 | if (dev->msi_enabled || dev->msix_enabled) |
| 110 | return; |
| 111 | |
Michael Ellerman | 59e3f83 | 2009-10-13 19:44:47 +0000 | [diff] [blame] | 112 | if (!irq_has_action(dev->irq)) |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 113 | return; |
| 114 | |
Gavin Shan | dbbceee | 2012-09-07 22:44:20 +0000 | [diff] [blame] | 115 | edev->mode |= EEH_DEV_IRQ_DISABLED; |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 116 | disable_irq_nosync(dev->irq); |
| 117 | } |
| 118 | |
| 119 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 120 | * eeh_enable_irq - Enable interrupt for the recovering device |
| 121 | * @dev: PCI device |
| 122 | * |
| 123 | * This routine must be called to enable interrupt while failed |
| 124 | * device could be resumed. |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 125 | */ |
| 126 | static void eeh_enable_irq(struct pci_dev *dev) |
| 127 | { |
Gavin Shan | 40a7cd9 | 2012-02-27 20:04:08 +0000 | [diff] [blame] | 128 | struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 129 | |
Gavin Shan | dbbceee | 2012-09-07 22:44:20 +0000 | [diff] [blame] | 130 | if ((edev->mode) & EEH_DEV_IRQ_DISABLED) { |
| 131 | edev->mode &= ~EEH_DEV_IRQ_DISABLED; |
Thomas Gleixner | b8a9a11 | 2014-02-23 21:40:09 +0000 | [diff] [blame] | 132 | /* |
| 133 | * FIXME !!!!! |
| 134 | * |
| 135 | * This is just ass backwards. This maze has |
| 136 | * unbalanced irq_enable/disable calls. So instead of |
| 137 | * finding the root cause it works around the warning |
| 138 | * in the irq_enable code by conditionally calling |
| 139 | * into it. |
| 140 | * |
| 141 | * That's just wrong.The warning in the core code is |
Michael Ellerman | 027dfac | 2016-06-01 16:34:37 +1000 | [diff] [blame] | 142 | * there to tell people to fix their asymmetries in |
Thomas Gleixner | b8a9a11 | 2014-02-23 21:40:09 +0000 | [diff] [blame] | 143 | * their own code, not by abusing the core information |
| 144 | * to avoid it. |
| 145 | * |
| 146 | * I so wish that the assymetry would be the other way |
| 147 | * round and a few more irq_disable calls render that |
| 148 | * shit unusable forever. |
| 149 | * |
| 150 | * tglx |
| 151 | */ |
Thomas Gleixner | 57310c3 | 2014-03-05 00:06:11 +0100 | [diff] [blame] | 152 | if (irqd_irq_disabled(irq_get_irq_data(dev->irq))) |
Gavin Shan | 91150af | 2013-07-24 10:25:00 +0800 | [diff] [blame] | 153 | enable_irq(dev->irq); |
Thomas Gleixner | 57310c3 | 2014-03-05 00:06:11 +0100 | [diff] [blame] | 154 | } |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 157 | static bool eeh_dev_removed(struct eeh_dev *edev) |
| 158 | { |
| 159 | /* EEH device removed ? */ |
| 160 | if (!edev || (edev->mode & EEH_DEV_REMOVED)) |
| 161 | return true; |
| 162 | |
| 163 | return false; |
| 164 | } |
| 165 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 166 | static void *eeh_dev_save_state(void *data, void *userdata) |
| 167 | { |
| 168 | struct eeh_dev *edev = data; |
| 169 | struct pci_dev *pdev; |
| 170 | |
| 171 | if (!edev) |
| 172 | return NULL; |
| 173 | |
Gavin Shan | 5a0cdbf | 2016-04-27 11:14:51 +1000 | [diff] [blame] | 174 | /* |
| 175 | * We cannot access the config space on some adapters. |
| 176 | * Otherwise, it will cause fenced PHB. We don't save |
| 177 | * the content in their config space and will restore |
| 178 | * from the initial config space saved when the EEH |
| 179 | * device is created. |
| 180 | */ |
| 181 | if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) |
| 182 | return NULL; |
| 183 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 184 | pdev = eeh_dev_to_pci_dev(edev); |
| 185 | if (!pdev) |
| 186 | return NULL; |
| 187 | |
| 188 | pci_save_state(pdev); |
| 189 | return NULL; |
| 190 | } |
| 191 | |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 192 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 193 | * eeh_report_error - Report pci error to each device driver |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 194 | * @data: eeh device |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 195 | * @userdata: return value |
Gavin Shan | a84f273 | 2013-06-20 13:20:51 +0800 | [diff] [blame] | 196 | * |
| 197 | * Report an EEH error to each device driver, collect up and |
| 198 | * merge the device driver responses. Cumulative response |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 199 | * passed back in "userdata". |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 200 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 201 | static void *eeh_report_error(void *data, void *userdata) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 202 | { |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 203 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 204 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
Paul Mackerras | 18eb3b3 | 2005-11-29 17:17:02 +1100 | [diff] [blame] | 205 | enum pci_ers_result rc, *res = userdata; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 206 | struct pci_driver *driver; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 207 | |
Gavin Shan | 2311cca | 2016-03-04 10:53:12 +1100 | [diff] [blame] | 208 | if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 209 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 210 | dev->error_state = pci_channel_io_frozen; |
| 211 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 212 | driver = eeh_pcid_get(dev); |
| 213 | if (!driver) return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 214 | |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 215 | eeh_disable_irq(dev); |
| 216 | |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 217 | if (!driver->err_handler || |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 218 | !driver->err_handler->error_detected) { |
| 219 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 220 | return NULL; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 221 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 222 | |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 223 | rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen); |
Linas Vepstas | 2a50f14 | 2007-11-03 07:27:50 +1100 | [diff] [blame] | 224 | |
| 225 | /* A driver that needs a reset trumps all others */ |
| 226 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
Paul Mackerras | 18eb3b3 | 2005-11-29 17:17:02 +1100 | [diff] [blame] | 227 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; |
Zhang, Yanmin | 70298c6 | 2009-06-16 13:34:38 +0800 | [diff] [blame] | 228 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 229 | edev->in_error = true; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 230 | eeh_pcid_put(dev); |
Bryant G. Ly | 856e1eb | 2018-01-05 10:45:47 -0600 | [diff] [blame] | 231 | pci_uevent_ers(dev, PCI_ERS_RESULT_NONE); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 232 | return NULL; |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 236 | * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 237 | * @data: eeh device |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 238 | * @userdata: return value |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 239 | * |
Linas Vepstas | 638799b | 2007-11-03 07:25:55 +1100 | [diff] [blame] | 240 | * Tells each device driver that IO ports, MMIO and config space I/O |
| 241 | * are now enabled. Collects up and merges the device driver responses. |
| 242 | * Cumulative response passed back in "userdata". |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 243 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 244 | static void *eeh_report_mmio_enabled(void *data, void *userdata) |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 245 | { |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 246 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 247 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 248 | enum pci_ers_result rc, *res = userdata; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 249 | struct pci_driver *driver; |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 250 | |
Gavin Shan | 2311cca | 2016-03-04 10:53:12 +1100 | [diff] [blame] | 251 | if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 252 | return NULL; |
| 253 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 254 | driver = eeh_pcid_get(dev); |
| 255 | if (!driver) return NULL; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 256 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 257 | if (!driver->err_handler || |
Gavin Shan | f26c7a0 | 2014-01-12 14:13:45 +0800 | [diff] [blame] | 258 | !driver->err_handler->mmio_enabled || |
| 259 | (edev->mode & EEH_DEV_NO_HANDLER)) { |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 260 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 261 | return NULL; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 262 | } |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 263 | |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 264 | rc = driver->err_handler->mmio_enabled(dev); |
Linas Vepstas | 2a50f14 | 2007-11-03 07:27:50 +1100 | [diff] [blame] | 265 | |
| 266 | /* A driver that needs a reset trumps all others */ |
| 267 | if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 268 | if (*res == PCI_ERS_RESULT_NONE) *res = rc; |
Zhang, Yanmin | 70298c6 | 2009-06-16 13:34:38 +0800 | [diff] [blame] | 269 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 270 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 271 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 272 | } |
| 273 | |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 274 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 275 | * eeh_report_reset - Tell device that slot has been reset |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 276 | * @data: eeh device |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 277 | * @userdata: return value |
| 278 | * |
| 279 | * This routine must be called while EEH tries to reset particular |
| 280 | * PCI device so that the associated PCI device driver could take |
| 281 | * some actions, usually to save data the driver needs so that the |
| 282 | * driver can work again while the device is recovered. |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 283 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 284 | static void *eeh_report_reset(void *data, void *userdata) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 285 | { |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 286 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 287 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 288 | enum pci_ers_result rc, *res = userdata; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 289 | struct pci_driver *driver; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 290 | |
Gavin Shan | 2311cca | 2016-03-04 10:53:12 +1100 | [diff] [blame] | 291 | if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 292 | return NULL; |
Mike Mason | c58dc57 | 2009-04-10 08:57:03 +0000 | [diff] [blame] | 293 | dev->error_state = pci_channel_io_normal; |
| 294 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 295 | driver = eeh_pcid_get(dev); |
| 296 | if (!driver) return NULL; |
| 297 | |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 298 | eeh_enable_irq(dev); |
| 299 | |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 300 | if (!driver->err_handler || |
Gavin Shan | f26c7a0 | 2014-01-12 14:13:45 +0800 | [diff] [blame] | 301 | !driver->err_handler->slot_reset || |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 302 | (edev->mode & EEH_DEV_NO_HANDLER) || |
| 303 | (!edev->in_error)) { |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 304 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 305 | return NULL; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 306 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 307 | |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 308 | rc = driver->err_handler->slot_reset(dev); |
Linas Vepstas | 5794dbc | 2007-03-19 14:55:51 -0500 | [diff] [blame] | 309 | if ((*res == PCI_ERS_RESULT_NONE) || |
| 310 | (*res == PCI_ERS_RESULT_RECOVERED)) *res = rc; |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 311 | if (*res == PCI_ERS_RESULT_DISCONNECT && |
| 312 | rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; |
Zhang, Yanmin | 70298c6 | 2009-06-16 13:34:38 +0800 | [diff] [blame] | 313 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 314 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 315 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 316 | } |
| 317 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 318 | static void *eeh_dev_restore_state(void *data, void *userdata) |
| 319 | { |
| 320 | struct eeh_dev *edev = data; |
| 321 | struct pci_dev *pdev; |
| 322 | |
| 323 | if (!edev) |
| 324 | return NULL; |
| 325 | |
Gavin Shan | 5a0cdbf | 2016-04-27 11:14:51 +1000 | [diff] [blame] | 326 | /* |
| 327 | * The content in the config space isn't saved because |
| 328 | * the blocked config space on some adapters. We have |
| 329 | * to restore the initial saved config space when the |
| 330 | * EEH device is created. |
| 331 | */ |
| 332 | if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) { |
| 333 | if (list_is_last(&edev->list, &edev->pe->edevs)) |
| 334 | eeh_pe_restore_bars(edev->pe); |
| 335 | |
| 336 | return NULL; |
| 337 | } |
| 338 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 339 | pdev = eeh_dev_to_pci_dev(edev); |
| 340 | if (!pdev) |
| 341 | return NULL; |
| 342 | |
| 343 | pci_restore_state(pdev); |
| 344 | return NULL; |
| 345 | } |
| 346 | |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 347 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 348 | * eeh_report_resume - Tell device to resume normal operations |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 349 | * @data: eeh device |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 350 | * @userdata: return value |
| 351 | * |
| 352 | * This routine must be called to notify the device driver that it |
| 353 | * could resume so that the device driver can do some initialization |
| 354 | * to make the recovered device work again. |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 355 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 356 | static void *eeh_report_resume(void *data, void *userdata) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 357 | { |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 358 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 359 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 360 | bool was_in_error; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 361 | struct pci_driver *driver; |
| 362 | |
Gavin Shan | 2311cca | 2016-03-04 10:53:12 +1100 | [diff] [blame] | 363 | if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 364 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 365 | dev->error_state = pci_channel_io_normal; |
| 366 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 367 | driver = eeh_pcid_get(dev); |
| 368 | if (!driver) return NULL; |
Linas Vepstas | d0e7034 | 2006-12-06 12:32:20 -0600 | [diff] [blame] | 369 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 370 | was_in_error = edev->in_error; |
| 371 | edev->in_error = false; |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 372 | eeh_enable_irq(dev); |
| 373 | |
Linas Vepstas | d0e7034 | 2006-12-06 12:32:20 -0600 | [diff] [blame] | 374 | if (!driver->err_handler || |
Gavin Shan | f26c7a0 | 2014-01-12 14:13:45 +0800 | [diff] [blame] | 375 | !driver->err_handler->resume || |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 376 | (edev->mode & EEH_DEV_NO_HANDLER) || !was_in_error) { |
Gavin Shan | f26c7a0 | 2014-01-12 14:13:45 +0800 | [diff] [blame] | 377 | edev->mode &= ~EEH_DEV_NO_HANDLER; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 378 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 379 | return NULL; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 380 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 381 | |
| 382 | driver->err_handler->resume(dev); |
Zhang, Yanmin | 70298c6 | 2009-06-16 13:34:38 +0800 | [diff] [blame] | 383 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 384 | eeh_pcid_put(dev); |
Bryant G. Ly | 856e1eb | 2018-01-05 10:45:47 -0600 | [diff] [blame] | 385 | pci_uevent_ers(dev, PCI_ERS_RESULT_RECOVERED); |
| 386 | #ifdef CONFIG_PCI_IOV |
Juan J. Alvarez | 521ca5a | 2018-02-15 12:49:51 -0600 | [diff] [blame] | 387 | if (eeh_ops->notify_resume && eeh_dev_to_pdn(edev)) |
| 388 | eeh_ops->notify_resume(eeh_dev_to_pdn(edev)); |
Bryant G. Ly | 856e1eb | 2018-01-05 10:45:47 -0600 | [diff] [blame] | 389 | #endif |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 390 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 391 | } |
| 392 | |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 393 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 394 | * eeh_report_failure - Tell device driver that device is dead. |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 395 | * @data: eeh device |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 396 | * @userdata: return value |
Linas Vepstas | cb5b5624 | 2006-09-15 18:56:35 -0500 | [diff] [blame] | 397 | * |
| 398 | * This informs the device driver that the device is permanently |
| 399 | * dead, and that no further recovery attempts will be made on it. |
| 400 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 401 | static void *eeh_report_failure(void *data, void *userdata) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 402 | { |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 403 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 404 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
| 405 | struct pci_driver *driver; |
| 406 | |
Gavin Shan | 2311cca | 2016-03-04 10:53:12 +1100 | [diff] [blame] | 407 | if (!dev || eeh_dev_removed(edev) || eeh_pe_passed(edev->pe)) |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 408 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 409 | dev->error_state = pci_channel_io_perm_failure; |
| 410 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 411 | driver = eeh_pcid_get(dev); |
| 412 | if (!driver) return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 413 | |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 414 | eeh_disable_irq(dev); |
| 415 | |
| 416 | if (!driver->err_handler || |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 417 | !driver->err_handler->error_detected) { |
| 418 | eeh_pcid_put(dev); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 419 | return NULL; |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 420 | } |
Mike Mason | 8535ef0 | 2009-02-10 11:12:21 +0000 | [diff] [blame] | 421 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 422 | driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); |
Zhang, Yanmin | 70298c6 | 2009-06-16 13:34:38 +0800 | [diff] [blame] | 423 | |
Gavin Shan | feadf7c | 2012-09-17 04:34:27 +0000 | [diff] [blame] | 424 | eeh_pcid_put(dev); |
Bryant G. Ly | 856e1eb | 2018-01-05 10:45:47 -0600 | [diff] [blame] | 425 | pci_uevent_ers(dev, PCI_ERS_RESULT_DISCONNECT); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 426 | return NULL; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 427 | } |
| 428 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 429 | static void *eeh_add_virt_device(void *data, void *userdata) |
| 430 | { |
| 431 | struct pci_driver *driver; |
| 432 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 433 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
| 434 | struct pci_dn *pdn = eeh_dev_to_pdn(edev); |
| 435 | |
| 436 | if (!(edev->physfn)) { |
| 437 | pr_warn("%s: EEH dev %04x:%02x:%02x.%01x not for VF\n", |
Alexey Kardashevskiy | 69672bd | 2017-08-29 17:34:01 +1000 | [diff] [blame] | 438 | __func__, pdn->phb->global_number, pdn->busno, |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 439 | PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn)); |
| 440 | return NULL; |
| 441 | } |
| 442 | |
| 443 | driver = eeh_pcid_get(dev); |
| 444 | if (driver) { |
| 445 | eeh_pcid_put(dev); |
| 446 | if (driver->err_handler) |
| 447 | return NULL; |
| 448 | } |
| 449 | |
Bryant G. Ly | 988fc3b | 2017-11-09 08:00:33 -0600 | [diff] [blame] | 450 | #ifdef CONFIG_PCI_IOV |
Jan H. Schönherr | 753f612 | 2017-09-26 12:53:23 -0500 | [diff] [blame] | 451 | pci_iov_add_virtfn(edev->physfn, pdn->vf_index); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 452 | #endif |
| 453 | return NULL; |
| 454 | } |
| 455 | |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 456 | static void *eeh_rmv_device(void *data, void *userdata) |
| 457 | { |
| 458 | struct pci_driver *driver; |
| 459 | struct eeh_dev *edev = (struct eeh_dev *)data; |
| 460 | struct pci_dev *dev = eeh_dev_to_pci_dev(edev); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 461 | struct eeh_rmv_data *rmv_data = (struct eeh_rmv_data *)userdata; |
| 462 | int *removed = rmv_data ? &rmv_data->removed : NULL; |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 463 | |
| 464 | /* |
| 465 | * Actually, we should remove the PCI bridges as well. |
| 466 | * However, that's lots of complexity to do that, |
| 467 | * particularly some of devices under the bridge might |
| 468 | * support EEH. So we just care about PCI devices for |
| 469 | * simplicity here. |
| 470 | */ |
Bjorn Helgaas | 93de690 | 2015-12-03 13:18:18 -0600 | [diff] [blame] | 471 | if (!dev || (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)) |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 472 | return NULL; |
Thadeu Lima de Souza Cascardo | 8cc6b6c | 2014-02-05 16:20:45 -0200 | [diff] [blame] | 473 | |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 474 | /* |
| 475 | * We rely on count-based pcibios_release_device() to |
| 476 | * detach permanently offlined PEs. Unfortunately, that's |
| 477 | * not reliable enough. We might have the permanently |
| 478 | * offlined PEs attached, but we needn't take care of |
| 479 | * them and their child devices. |
| 480 | */ |
| 481 | if (eeh_dev_removed(edev)) |
| 482 | return NULL; |
| 483 | |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 484 | driver = eeh_pcid_get(dev); |
Thadeu Lima de Souza Cascardo | 8cc6b6c | 2014-02-05 16:20:45 -0200 | [diff] [blame] | 485 | if (driver) { |
| 486 | eeh_pcid_put(dev); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 487 | if (removed && |
Gavin Shan | 3fa7bf7 | 2016-03-04 10:53:13 +1100 | [diff] [blame] | 488 | eeh_pe_passed(edev->pe)) |
| 489 | return NULL; |
| 490 | if (removed && |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 491 | driver->err_handler && |
Gavin Shan | f2da4cc | 2015-10-08 14:58:53 +1100 | [diff] [blame] | 492 | driver->err_handler->error_detected && |
Gavin Shan | f6bf0fa | 2016-02-12 16:03:05 +1100 | [diff] [blame] | 493 | driver->err_handler->slot_reset) |
Thadeu Lima de Souza Cascardo | 8cc6b6c | 2014-02-05 16:20:45 -0200 | [diff] [blame] | 494 | return NULL; |
| 495 | } |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 496 | |
| 497 | /* Remove it from PCI subsystem */ |
| 498 | pr_debug("EEH: Removing %s without EEH sensitive driver\n", |
| 499 | pci_name(dev)); |
| 500 | edev->bus = dev->bus; |
| 501 | edev->mode |= EEH_DEV_DISCONNECTED; |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 502 | if (removed) |
| 503 | (*removed)++; |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 504 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 505 | if (edev->physfn) { |
Bryant G. Ly | 988fc3b | 2017-11-09 08:00:33 -0600 | [diff] [blame] | 506 | #ifdef CONFIG_PCI_IOV |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 507 | struct pci_dn *pdn = eeh_dev_to_pdn(edev); |
| 508 | |
Jan H. Schönherr | 753f612 | 2017-09-26 12:53:23 -0500 | [diff] [blame] | 509 | pci_iov_remove_virtfn(edev->physfn, pdn->vf_index); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 510 | edev->pdev = NULL; |
| 511 | |
| 512 | /* |
| 513 | * We have to set the VF PE number to invalid one, which is |
| 514 | * required to plug the VF successfully. |
| 515 | */ |
| 516 | pdn->pe_number = IODA_INVALID_PE; |
| 517 | #endif |
| 518 | if (rmv_data) |
| 519 | list_add(&edev->rmv_list, &rmv_data->edev_list); |
| 520 | } else { |
| 521 | pci_lock_rescan_remove(); |
| 522 | pci_stop_and_remove_bus_device(dev); |
| 523 | pci_unlock_rescan_remove(); |
| 524 | } |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 525 | |
| 526 | return NULL; |
| 527 | } |
| 528 | |
| 529 | static void *eeh_pe_detach_dev(void *data, void *userdata) |
| 530 | { |
| 531 | struct eeh_pe *pe = (struct eeh_pe *)data; |
| 532 | struct eeh_dev *edev, *tmp; |
| 533 | |
| 534 | eeh_pe_for_each_dev(pe, edev, tmp) { |
| 535 | if (!(edev->mode & EEH_DEV_DISCONNECTED)) |
| 536 | continue; |
| 537 | |
| 538 | edev->mode &= ~(EEH_DEV_DISCONNECTED | EEH_DEV_IRQ_DISABLED); |
| 539 | eeh_rmv_from_parent_pe(edev); |
| 540 | } |
| 541 | |
| 542 | return NULL; |
| 543 | } |
| 544 | |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 545 | /* |
| 546 | * Explicitly clear PE's frozen state for PowerNV where |
| 547 | * we have frozen PE until BAR restore is completed. It's |
| 548 | * harmless to clear it for pSeries. To be consistent with |
| 549 | * PE reset (for 3 times), we try to clear the frozen state |
| 550 | * for 3 times as well. |
| 551 | */ |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 552 | static void *__eeh_clear_pe_frozen_state(void *data, void *flag) |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 553 | { |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 554 | struct eeh_pe *pe = (struct eeh_pe *)data; |
Gavin Shan | f05fea5 | 2017-01-19 10:10:16 +1100 | [diff] [blame] | 555 | bool clear_sw_state = *(bool *)flag; |
Gavin Shan | c9dd014 | 2014-09-30 12:39:02 +1000 | [diff] [blame] | 556 | int i, rc = 1; |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 557 | |
Gavin Shan | c9dd014 | 2014-09-30 12:39:02 +1000 | [diff] [blame] | 558 | for (i = 0; rc && i < 3; i++) |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 559 | rc = eeh_unfreeze_pe(pe, clear_sw_state); |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 560 | |
Gavin Shan | c9dd014 | 2014-09-30 12:39:02 +1000 | [diff] [blame] | 561 | /* Stop immediately on any errors */ |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 562 | if (rc) { |
Gavin Shan | c9dd014 | 2014-09-30 12:39:02 +1000 | [diff] [blame] | 563 | pr_warn("%s: Failure %d unfreezing PHB#%x-PE#%x\n", |
| 564 | __func__, rc, pe->phb->global_number, pe->addr); |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 565 | return (void *)pe; |
| 566 | } |
| 567 | |
| 568 | return NULL; |
| 569 | } |
| 570 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 571 | static int eeh_clear_pe_frozen_state(struct eeh_pe *pe, |
| 572 | bool clear_sw_state) |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 573 | { |
| 574 | void *rc; |
| 575 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 576 | rc = eeh_pe_traverse(pe, __eeh_clear_pe_frozen_state, &clear_sw_state); |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 577 | if (!rc) |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 578 | eeh_pe_state_clear(pe, EEH_PE_ISOLATED); |
| 579 | |
Gavin Shan | 2c66599 | 2014-05-05 09:29:02 +1000 | [diff] [blame] | 580 | return rc ? -EIO : 0; |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 581 | } |
| 582 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 583 | int eeh_pe_reset_and_recover(struct eeh_pe *pe) |
| 584 | { |
Gavin Shan | 2efc771 | 2016-04-27 11:14:52 +1000 | [diff] [blame] | 585 | int ret; |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 586 | |
| 587 | /* Bail if the PE is being recovered */ |
| 588 | if (pe->state & EEH_PE_RECOVERING) |
| 589 | return 0; |
| 590 | |
| 591 | /* Put the PE into recovery mode */ |
| 592 | eeh_pe_state_mark(pe, EEH_PE_RECOVERING); |
| 593 | |
| 594 | /* Save states */ |
| 595 | eeh_pe_dev_traverse(pe, eeh_dev_save_state, NULL); |
| 596 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 597 | /* Issue reset */ |
Russell Currey | 6654c93 | 2016-11-17 16:07:47 +1100 | [diff] [blame] | 598 | ret = eeh_pe_reset_full(pe); |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 599 | if (ret) { |
Gavin Shan | 28bf36f | 2014-11-14 10:47:29 +1100 | [diff] [blame] | 600 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 601 | return ret; |
| 602 | } |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 603 | |
| 604 | /* Unfreeze the PE */ |
| 605 | ret = eeh_clear_pe_frozen_state(pe, true); |
| 606 | if (ret) { |
| 607 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); |
| 608 | return ret; |
| 609 | } |
| 610 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 611 | /* Restore device state */ |
| 612 | eeh_pe_dev_traverse(pe, eeh_dev_restore_state, NULL); |
| 613 | |
Gavin Shan | 5cfb20b | 2014-09-30 12:39:07 +1000 | [diff] [blame] | 614 | /* Clear recovery mode */ |
| 615 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); |
| 616 | |
| 617 | return 0; |
| 618 | } |
| 619 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 620 | /** |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 621 | * eeh_reset_device - Perform actual reset of a pci slot |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 622 | * @pe: EEH PE |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 623 | * @bus: PCI bus corresponding to the isolcated slot |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 624 | * |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 625 | * This routine must be called to do reset on the indicated PE. |
| 626 | * During the reset, udev might be invoked because those affected |
| 627 | * PCI devices will be removed and then added. |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 628 | */ |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 629 | static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus, |
| 630 | struct eeh_rmv_data *rmv_data) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 631 | { |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 632 | struct pci_bus *frozen_bus = eeh_pe_bus_get(pe); |
Arnd Bergmann | edfd17f | 2017-11-04 22:26:52 +0100 | [diff] [blame] | 633 | time64_t tstamp; |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 634 | int cnt, rc; |
| 635 | struct eeh_dev *edev; |
Linas Vepstas | 4240545 | 2006-04-28 17:39:38 -0500 | [diff] [blame] | 636 | |
| 637 | /* pcibios will clear the counter; save the value */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 638 | cnt = pe->freeze_count; |
Gavin Shan | 5a71978 | 2013-06-20 13:21:01 +0800 | [diff] [blame] | 639 | tstamp = pe->tstamp; |
Linas Vepstas | 4240545 | 2006-04-28 17:39:38 -0500 | [diff] [blame] | 640 | |
Gavin Shan | 20ee6a9 | 2012-09-11 19:16:17 +0000 | [diff] [blame] | 641 | /* |
| 642 | * We don't remove the corresponding PE instances because |
| 643 | * we need the information afterwords. The attached EEH |
| 644 | * devices are expected to be attached soon when calling |
Gavin Shan | bd251b8 | 2016-05-03 15:41:37 +1000 | [diff] [blame] | 645 | * into pci_hp_add_devices(). |
Gavin Shan | 20ee6a9 | 2012-09-11 19:16:17 +0000 | [diff] [blame] | 646 | */ |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 647 | eeh_pe_state_mark(pe, EEH_PE_KEEP); |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 648 | if (bus) { |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 649 | if (pe->type & EEH_PE_VF) { |
| 650 | eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL); |
| 651 | } else { |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 652 | pci_lock_rescan_remove(); |
Gavin Shan | bd251b8 | 2016-05-03 15:41:37 +1000 | [diff] [blame] | 653 | pci_hp_remove_devices(bus); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 654 | pci_unlock_rescan_remove(); |
| 655 | } |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 656 | } else if (frozen_bus) { |
Gavin Shan | cca0e542 | 2016-06-24 14:49:02 +1000 | [diff] [blame] | 657 | eeh_pe_dev_traverse(pe, eeh_rmv_device, rmv_data); |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 658 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 659 | |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 660 | /* |
| 661 | * Reset the pci controller. (Asserts RST#; resets config space). |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 662 | * Reconfigure bridges and devices. Don't try to bring the system |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 663 | * up if the reset failed for some reason. |
Gavin Shan | d0914f5 | 2014-04-24 18:00:12 +1000 | [diff] [blame] | 664 | * |
| 665 | * During the reset, it's very dangerous to have uncontrolled PCI |
| 666 | * config accesses. So we prefer to block them. However, controlled |
| 667 | * PCI config accesses initiated from EEH itself are allowed. |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 668 | */ |
Russell Currey | 6654c93 | 2016-11-17 16:07:47 +1100 | [diff] [blame] | 669 | rc = eeh_pe_reset_full(pe); |
Gavin Shan | 28bf36f | 2014-11-14 10:47:29 +1100 | [diff] [blame] | 670 | if (rc) |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 671 | return rc; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 672 | |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 673 | pci_lock_rescan_remove(); |
| 674 | |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 675 | /* Restore PE */ |
| 676 | eeh_ops->configure_bridge(pe); |
| 677 | eeh_pe_restore_bars(pe); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 678 | |
Andrew Donnellan | dc9c41b | 2015-12-08 16:59:25 +1100 | [diff] [blame] | 679 | /* Clear frozen state */ |
| 680 | rc = eeh_clear_pe_frozen_state(pe, false); |
Andrew Donnellan | 409bf7f | 2016-12-01 11:23:05 +1100 | [diff] [blame] | 681 | if (rc) { |
| 682 | pci_unlock_rescan_remove(); |
Andrew Donnellan | dc9c41b | 2015-12-08 16:59:25 +1100 | [diff] [blame] | 683 | return rc; |
Andrew Donnellan | 409bf7f | 2016-12-01 11:23:05 +1100 | [diff] [blame] | 684 | } |
Gavin Shan | 7895470 | 2014-04-24 18:00:14 +1000 | [diff] [blame] | 685 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 686 | /* Give the system 5 seconds to finish running the user-space |
Gavin Shan | a84f273 | 2013-06-20 13:20:51 +0800 | [diff] [blame] | 687 | * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, |
| 688 | * this is a hack, but if we don't do this, and try to bring |
| 689 | * the device up before the scripts have taken it down, |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 690 | * potentially weird things happen. |
| 691 | */ |
| 692 | if (bus) { |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 693 | pr_info("EEH: Sleep 5s ahead of complete hotplug\n"); |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 694 | ssleep(5); |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 695 | |
| 696 | /* |
| 697 | * The EEH device is still connected with its parent |
| 698 | * PE. We should disconnect it so the binding can be |
| 699 | * rebuilt when adding PCI devices. |
| 700 | */ |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 701 | edev = list_first_entry(&pe->edevs, struct eeh_dev, list); |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 702 | eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL); |
Gavin Shan | a3aa256 | 2016-06-17 13:05:11 +1000 | [diff] [blame] | 703 | if (pe->type & EEH_PE_VF) { |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 704 | eeh_add_virt_device(edev, NULL); |
Gavin Shan | a3aa256 | 2016-06-17 13:05:11 +1000 | [diff] [blame] | 705 | } else { |
| 706 | eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); |
Gavin Shan | bd251b8 | 2016-05-03 15:41:37 +1000 | [diff] [blame] | 707 | pci_hp_add_devices(bus); |
Gavin Shan | a3aa256 | 2016-06-17 13:05:11 +1000 | [diff] [blame] | 708 | } |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 709 | } else if (frozen_bus && rmv_data->removed) { |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 710 | pr_info("EEH: Sleep 5s ahead of partial hotplug\n"); |
| 711 | ssleep(5); |
| 712 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 713 | edev = list_first_entry(&pe->edevs, struct eeh_dev, list); |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 714 | eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 715 | if (pe->type & EEH_PE_VF) |
| 716 | eeh_add_virt_device(edev, NULL); |
| 717 | else |
Gavin Shan | bd251b8 | 2016-05-03 15:41:37 +1000 | [diff] [blame] | 718 | pci_hp_add_devices(frozen_bus); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 719 | } |
Gavin Shan | f5c5771 | 2013-07-24 10:24:58 +0800 | [diff] [blame] | 720 | eeh_pe_state_clear(pe, EEH_PE_KEEP); |
Gavin Shan | 5a71978 | 2013-06-20 13:21:01 +0800 | [diff] [blame] | 721 | |
| 722 | pe->tstamp = tstamp; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 723 | pe->freeze_count = cnt; |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 724 | |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 725 | pci_unlock_rescan_remove(); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 726 | return 0; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | /* The longest amount of time to wait for a pci device |
| 730 | * to come back on line, in seconds. |
| 731 | */ |
Brian King | fb48dc2 | 2013-11-25 16:27:54 -0600 | [diff] [blame] | 732 | #define MAX_WAIT_FOR_RECOVERY 300 |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 733 | |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 734 | /** |
| 735 | * eeh_handle_normal_event - Handle EEH events on a specific PE |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 736 | * @pe: EEH PE - which should not be used after we return, as it may |
| 737 | * have been invalidated. |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 738 | * |
| 739 | * Attempts to recover the given PE. If recovery fails or the PE has failed |
| 740 | * too many times, remove the PE. |
| 741 | * |
Sam Bobroff | 6870178 | 2018-03-19 13:46:20 +1100 | [diff] [blame] | 742 | * While PHB detects address or data parity errors on particular PCI |
| 743 | * slot, the associated PE will be frozen. Besides, DMA's occurring |
| 744 | * to wild addresses (which usually happen due to bugs in device |
| 745 | * drivers or in PCI adapter firmware) can cause EEH error. #SERR, |
| 746 | * #PERR or other misc PCI-related errors also can trigger EEH errors. |
| 747 | * |
| 748 | * Recovery process consists of unplugging the device driver (which |
| 749 | * generated hotplug events to userspace), then issuing a PCI #RST to |
| 750 | * the device, then reconfiguring the PCI config space for all bridges |
| 751 | * & devices under this slot, and then finally restarting the device |
| 752 | * drivers (which cause a second set of hotplug events to go out to |
| 753 | * userspace). |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 754 | */ |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 755 | void eeh_handle_normal_event(struct eeh_pe *pe) |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 756 | { |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 757 | struct pci_bus *frozen_bus; |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 758 | struct eeh_dev *edev, *tmp; |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 759 | int rc = 0; |
Paul Mackerras | 18eb3b3 | 2005-11-29 17:17:02 +1100 | [diff] [blame] | 760 | enum pci_ers_result result = PCI_ERS_RESULT_NONE; |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 761 | struct eeh_rmv_data rmv_data = {LIST_HEAD_INIT(rmv_data.edev_list), 0}; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 762 | |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 763 | frozen_bus = eeh_pe_bus_get(pe); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 764 | if (!frozen_bus) { |
Russell Currey | 1f52f17 | 2016-11-16 14:02:15 +1100 | [diff] [blame] | 765 | pr_err("%s: Cannot find PCI bus for PHB#%x-PE#%x\n", |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 766 | __func__, pe->phb->global_number, pe->addr); |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 767 | return; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 768 | } |
| 769 | |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 770 | eeh_pe_state_mark(pe, EEH_PE_RECOVERING); |
| 771 | |
Gavin Shan | 5a71978 | 2013-06-20 13:21:01 +0800 | [diff] [blame] | 772 | eeh_pe_update_time_stamp(pe); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 773 | pe->freeze_count++; |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 774 | if (pe->freeze_count > eeh_max_freezes) { |
| 775 | pr_err("EEH: PHB#%x-PE#%x has failed %d times in the\n" |
| 776 | "last hour and has been permanently disabled.\n", |
| 777 | pe->phb->global_number, pe->addr, |
| 778 | pe->freeze_count); |
| 779 | goto hard_fail; |
| 780 | } |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 781 | pr_warn("EEH: This PCI device has failed %d times in the last hour\n", |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 782 | pe->freeze_count); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 783 | |
| 784 | /* Walk the various device drivers attached to this slot through |
| 785 | * a reset sequence, giving each an opportunity to do what it needs |
| 786 | * to accomplish the reset. Each child gets a report of the |
| 787 | * status ... if any child can't handle the reset, then the entire |
| 788 | * slot is dlpar removed and added. |
Gavin Shan | 8234fce | 2015-10-08 14:58:54 +1100 | [diff] [blame] | 789 | * |
| 790 | * When the PHB is fenced, we have to issue a reset to recover from |
| 791 | * the error. Override the result if necessary to have partially |
| 792 | * hotplug for this case. |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 793 | */ |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 794 | pr_info("EEH: Notify device drivers to shutdown\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 795 | eeh_pe_dev_traverse(pe, eeh_report_error, &result); |
Gavin Shan | 8234fce | 2015-10-08 14:58:54 +1100 | [diff] [blame] | 796 | if ((pe->type & EEH_PE_PHB) && |
| 797 | result != PCI_ERS_RESULT_NONE && |
| 798 | result != PCI_ERS_RESULT_NEED_RESET) |
| 799 | result = PCI_ERS_RESULT_NEED_RESET; |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 800 | |
Linas Vepstas | 5f1a7c8 | 2007-11-16 05:58:36 +1100 | [diff] [blame] | 801 | /* Get the current PCI slot state. This can take a long time, |
Wei Yang | 2ac3990 | 2015-04-27 09:25:10 +0800 | [diff] [blame] | 802 | * sometimes over 300 seconds for certain systems. |
Gavin Shan | 29f8bf1 | 2012-02-27 20:04:02 +0000 | [diff] [blame] | 803 | */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 804 | rc = eeh_ops->wait_state(pe, MAX_WAIT_FOR_RECOVERY*1000); |
Gavin Shan | eb594a4 | 2012-02-27 20:03:57 +0000 | [diff] [blame] | 805 | if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) { |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 806 | pr_warn("EEH: Permanent failure\n"); |
Linas Vepstas | 5f1a7c8 | 2007-11-16 05:58:36 +1100 | [diff] [blame] | 807 | goto hard_fail; |
| 808 | } |
| 809 | |
Linas Vepstas | ede8ca2 | 2007-05-09 09:33:29 +1000 | [diff] [blame] | 810 | /* Since rtas may enable MMIO when posting the error log, |
| 811 | * don't post the error log until after all dev drivers |
Linas Vepstas | 17213c3 | 2007-05-10 02:38:11 +1000 | [diff] [blame] | 812 | * have been informed. |
| 813 | */ |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 814 | pr_info("EEH: Collect temporary log\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 815 | eeh_slot_error_detail(pe, EEH_LOG_TEMP); |
Linas Vepstas | ede8ca2 | 2007-05-09 09:33:29 +1000 | [diff] [blame] | 816 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 817 | /* If all device drivers were EEH-unaware, then shut |
| 818 | * down all of the device drivers, and hope they |
| 819 | * go down willingly, without panicing the system. |
| 820 | */ |
Paul Mackerras | 18eb3b3 | 2005-11-29 17:17:02 +1100 | [diff] [blame] | 821 | if (result == PCI_ERS_RESULT_NONE) { |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 822 | pr_info("EEH: Reset with hotplug activity\n"); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 823 | rc = eeh_reset_device(pe, frozen_bus, NULL); |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 824 | if (rc) { |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 825 | pr_warn("%s: Unable to reset, err=%d\n", |
| 826 | __func__, rc); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 827 | goto hard_fail; |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 828 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 829 | } |
| 830 | |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 831 | /* If all devices reported they can proceed, then re-enable MMIO */ |
| 832 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 833 | pr_info("EEH: Enable I/O for affected devices\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 834 | rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 835 | |
Linas Vepstas | fa1be47 | 2007-03-19 14:59:59 -0500 | [diff] [blame] | 836 | if (rc < 0) |
| 837 | goto hard_fail; |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 838 | if (rc) { |
| 839 | result = PCI_ERS_RESULT_NEED_RESET; |
| 840 | } else { |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 841 | pr_info("EEH: Notify device drivers to resume I/O\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 842 | eeh_pe_dev_traverse(pe, eeh_report_mmio_enabled, &result); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 843 | } |
| 844 | } |
| 845 | |
| 846 | /* If all devices reported they can proceed, then re-enable DMA */ |
| 847 | if (result == PCI_ERS_RESULT_CAN_RECOVER) { |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 848 | pr_info("EEH: Enabled DMA for affected devices\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 849 | rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 850 | |
Linas Vepstas | fa1be47 | 2007-03-19 14:59:59 -0500 | [diff] [blame] | 851 | if (rc < 0) |
| 852 | goto hard_fail; |
Gavin Shan | 35845a7 | 2014-04-24 18:00:26 +1000 | [diff] [blame] | 853 | if (rc) { |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 854 | result = PCI_ERS_RESULT_NEED_RESET; |
Gavin Shan | 35845a7 | 2014-04-24 18:00:26 +1000 | [diff] [blame] | 855 | } else { |
| 856 | /* |
| 857 | * We didn't do PE reset for the case. The PE |
| 858 | * is still in frozen state. Clear it before |
| 859 | * resuming the PE. |
| 860 | */ |
| 861 | eeh_pe_state_clear(pe, EEH_PE_ISOLATED); |
Linas Vepstas | d0e7034 | 2006-12-06 12:32:20 -0600 | [diff] [blame] | 862 | result = PCI_ERS_RESULT_RECOVERED; |
Gavin Shan | 35845a7 | 2014-04-24 18:00:26 +1000 | [diff] [blame] | 863 | } |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | /* If any device has a hard failure, then shut off everything. */ |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 867 | if (result == PCI_ERS_RESULT_DISCONNECT) { |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 868 | pr_warn("EEH: Device driver gave up\n"); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 869 | goto hard_fail; |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 870 | } |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 871 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 872 | /* If any device called out for a reset, then reset the slot */ |
Paul Mackerras | 18eb3b3 | 2005-11-29 17:17:02 +1100 | [diff] [blame] | 873 | if (result == PCI_ERS_RESULT_NEED_RESET) { |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 874 | pr_info("EEH: Reset without hotplug activity\n"); |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 875 | rc = eeh_reset_device(pe, NULL, &rmv_data); |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 876 | if (rc) { |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 877 | pr_warn("%s: Cannot reset, err=%d\n", |
| 878 | __func__, rc); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 879 | goto hard_fail; |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 880 | } |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 881 | |
| 882 | pr_info("EEH: Notify device drivers " |
| 883 | "the completion of reset\n"); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 884 | result = PCI_ERS_RESULT_NONE; |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 885 | eeh_pe_dev_traverse(pe, eeh_report_reset, &result); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 886 | } |
| 887 | |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 888 | /* All devices should claim they have recovered by now. */ |
Linas Vepstas | 90fdd61 | 2007-03-19 14:55:10 -0500 | [diff] [blame] | 889 | if ((result != PCI_ERS_RESULT_RECOVERED) && |
| 890 | (result != PCI_ERS_RESULT_NONE)) { |
Gavin Shan | 0dae274 | 2014-07-17 14:41:41 +1000 | [diff] [blame] | 891 | pr_warn("EEH: Not recovered\n"); |
Linas Vepstas | 6a1ca37 | 2006-09-15 18:58:59 -0500 | [diff] [blame] | 892 | goto hard_fail; |
Linas Vepstas | e0f90b6 | 2007-03-19 14:52:04 -0500 | [diff] [blame] | 893 | } |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 894 | |
Wei Yang | 67086e3 | 2016-03-04 10:53:11 +1100 | [diff] [blame] | 895 | /* |
| 896 | * For those hot removed VFs, we should add back them after PF get |
| 897 | * recovered properly. |
| 898 | */ |
| 899 | list_for_each_entry_safe(edev, tmp, &rmv_data.edev_list, rmv_list) { |
| 900 | eeh_add_virt_device(edev, NULL); |
| 901 | list_del(&edev->rmv_list); |
| 902 | } |
| 903 | |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 904 | /* Tell all device drivers that they can resume operations */ |
Gavin Shan | 56ca4fd | 2013-06-27 13:46:46 +0800 | [diff] [blame] | 905 | pr_info("EEH: Notify device driver to resume\n"); |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 906 | eeh_pe_dev_traverse(pe, eeh_report_resume, NULL); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 907 | |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 908 | goto final; |
Gavin Shan | a84f273 | 2013-06-20 13:20:51 +0800 | [diff] [blame] | 909 | |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 910 | hard_fail: |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 911 | /* |
| 912 | * About 90% of all real-life EEH failures in the field |
| 913 | * are due to poorly seated PCI cards. Only 10% or so are |
| 914 | * due to actual, failed cards. |
| 915 | */ |
Russell Currey | 1f52f17 | 2016-11-16 14:02:15 +1100 | [diff] [blame] | 916 | pr_err("EEH: Unable to recover from failure from PHB#%x-PE#%x.\n" |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 917 | "Please try reseating or replacing it\n", |
| 918 | pe->phb->global_number, pe->addr); |
Linas Vepstas | 8df8302 | 2006-03-29 15:31:04 -0600 | [diff] [blame] | 919 | |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 920 | eeh_slot_error_detail(pe, EEH_LOG_PERM); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 921 | |
| 922 | /* Notify all devices that they're about to go down. */ |
Gavin Shan | 9b3c76f | 2012-09-07 22:44:19 +0000 | [diff] [blame] | 923 | eeh_pe_dev_traverse(pe, eeh_report_failure, NULL); |
Linas Vepstas | b6495c0 | 2005-11-03 18:54:54 -0600 | [diff] [blame] | 924 | |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 925 | /* Mark the PE to be removed permanently */ |
Gavin Shan | 432227e | 2014-12-11 14:28:55 +1100 | [diff] [blame] | 926 | eeh_pe_state_mark(pe, EEH_PE_REMOVED); |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 927 | |
| 928 | /* |
| 929 | * Shut down the device drivers for good. We mark |
| 930 | * all removed devices correctly to avoid access |
| 931 | * the their PCI config any more. |
| 932 | */ |
Sam Bobroff | 5b86ac9 | 2018-03-19 13:46:51 +1100 | [diff] [blame^] | 933 | if (pe->type & EEH_PE_VF) { |
| 934 | eeh_pe_dev_traverse(pe, eeh_rmv_device, NULL); |
| 935 | eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED); |
| 936 | } else { |
| 937 | eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); |
| 938 | eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED); |
Gavin Shan | d2b0f6f | 2014-04-24 18:00:19 +1000 | [diff] [blame] | 939 | |
Sam Bobroff | 5b86ac9 | 2018-03-19 13:46:51 +1100 | [diff] [blame^] | 940 | pci_lock_rescan_remove(); |
| 941 | pci_hp_remove_devices(frozen_bus); |
| 942 | pci_unlock_rescan_remove(); |
| 943 | /* The passed PE should no longer be used */ |
| 944 | return; |
Rafael J. Wysocki | 1c2042c | 2014-01-15 14:33:20 +0100 | [diff] [blame] | 945 | } |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 946 | final: |
| 947 | eeh_pe_state_clear(pe, EEH_PE_RECOVERING); |
Linas Vepstas | 77bd741 | 2005-11-03 18:52:49 -0600 | [diff] [blame] | 948 | } |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 949 | |
Russell Currey | c0b6497 | 2017-04-19 17:39:27 +1000 | [diff] [blame] | 950 | /** |
| 951 | * eeh_handle_special_event - Handle EEH events without a specific failing PE |
| 952 | * |
| 953 | * Called when an EEH event is detected but can't be narrowed down to a |
| 954 | * specific PE. Iterates through possible failures and handles them as |
| 955 | * necessary. |
| 956 | */ |
Sam Bobroff | 6870178 | 2018-03-19 13:46:20 +1100 | [diff] [blame] | 957 | void eeh_handle_special_event(void) |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 958 | { |
| 959 | struct eeh_pe *pe, *phb_pe; |
| 960 | struct pci_bus *bus; |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 961 | struct pci_controller *hose; |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 962 | unsigned long flags; |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 963 | int rc; |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 964 | |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 965 | |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 966 | do { |
| 967 | rc = eeh_ops->next_error(&pe); |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 968 | |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 969 | switch (rc) { |
| 970 | case EEH_NEXT_ERR_DEAD_IOC: |
| 971 | /* Mark all PHBs in dead state */ |
| 972 | eeh_serialize_lock(&flags); |
| 973 | |
| 974 | /* Purge all events */ |
Gavin Shan | 5c7a35e | 2014-06-04 17:31:52 +1000 | [diff] [blame] | 975 | eeh_remove_event(NULL, true); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 976 | |
| 977 | list_for_each_entry(hose, &hose_list, list_node) { |
| 978 | phb_pe = eeh_phb_pe_get(hose); |
| 979 | if (!phb_pe) continue; |
| 980 | |
Gavin Shan | 9e04937 | 2014-04-24 18:00:07 +1000 | [diff] [blame] | 981 | eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | eeh_serialize_unlock(flags); |
| 985 | |
| 986 | break; |
| 987 | case EEH_NEXT_ERR_FROZEN_PE: |
| 988 | case EEH_NEXT_ERR_FENCED_PHB: |
| 989 | case EEH_NEXT_ERR_DEAD_PHB: |
| 990 | /* Mark the PE in fenced state */ |
| 991 | eeh_serialize_lock(&flags); |
| 992 | |
| 993 | /* Purge all events of the PHB */ |
Gavin Shan | 5c7a35e | 2014-06-04 17:31:52 +1000 | [diff] [blame] | 994 | eeh_remove_event(pe, true); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 995 | |
| 996 | if (rc == EEH_NEXT_ERR_DEAD_PHB) |
Gavin Shan | 9e04937 | 2014-04-24 18:00:07 +1000 | [diff] [blame] | 997 | eeh_pe_state_mark(pe, EEH_PE_ISOLATED); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 998 | else |
| 999 | eeh_pe_state_mark(pe, |
| 1000 | EEH_PE_ISOLATED | EEH_PE_RECOVERING); |
| 1001 | |
| 1002 | eeh_serialize_unlock(flags); |
| 1003 | |
| 1004 | break; |
| 1005 | case EEH_NEXT_ERR_NONE: |
| 1006 | return; |
| 1007 | default: |
| 1008 | pr_warn("%s: Invalid value %d from next_error()\n", |
| 1009 | __func__, rc); |
| 1010 | return; |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 1011 | } |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 1012 | |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1013 | /* |
| 1014 | * For fenced PHB and frozen PE, it's handled as normal |
| 1015 | * event. We have to remove the affected PHBs for dead |
| 1016 | * PHB and IOC |
| 1017 | */ |
| 1018 | if (rc == EEH_NEXT_ERR_FROZEN_PE || |
| 1019 | rc == EEH_NEXT_ERR_FENCED_PHB) { |
Sam Bobroff | 37fd812 | 2018-03-19 13:46:30 +1100 | [diff] [blame] | 1020 | eeh_handle_normal_event(pe); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1021 | } else { |
Linus Torvalds | 1b17366 | 2014-01-27 21:11:26 -0800 | [diff] [blame] | 1022 | pci_lock_rescan_remove(); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1023 | list_for_each_entry(hose, &hose_list, list_node) { |
| 1024 | phb_pe = eeh_phb_pe_get(hose); |
| 1025 | if (!phb_pe || |
Gavin Shan | 9e04937 | 2014-04-24 18:00:07 +1000 | [diff] [blame] | 1026 | !(phb_pe->state & EEH_PE_ISOLATED) || |
| 1027 | (phb_pe->state & EEH_PE_RECOVERING)) |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1028 | continue; |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 1029 | |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1030 | /* Notify all devices to be down */ |
Gavin Shan | 05ba75f | 2016-02-09 15:50:21 +1100 | [diff] [blame] | 1031 | eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); |
Russell Currey | af2e3a0 | 2016-09-12 14:17:24 +1000 | [diff] [blame] | 1032 | eeh_pe_dev_traverse(pe, |
| 1033 | eeh_report_failure, NULL); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1034 | bus = eeh_pe_bus_get(phb_pe); |
Russell Currey | 04fec21c | 2016-09-12 14:17:22 +1000 | [diff] [blame] | 1035 | if (!bus) { |
| 1036 | pr_err("%s: Cannot find PCI bus for " |
Russell Currey | 1f52f17 | 2016-11-16 14:02:15 +1100 | [diff] [blame] | 1037 | "PHB#%x-PE#%x\n", |
Russell Currey | 04fec21c | 2016-09-12 14:17:22 +1000 | [diff] [blame] | 1038 | __func__, |
| 1039 | pe->phb->global_number, |
| 1040 | pe->addr); |
| 1041 | break; |
| 1042 | } |
Gavin Shan | bd251b8 | 2016-05-03 15:41:37 +1000 | [diff] [blame] | 1043 | pci_hp_remove_devices(bus); |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1044 | } |
Linus Torvalds | 1b17366 | 2014-01-27 21:11:26 -0800 | [diff] [blame] | 1045 | pci_unlock_rescan_remove(); |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 1046 | } |
Gavin Shan | 7e4e786 | 2014-01-15 13:16:11 +0800 | [diff] [blame] | 1047 | |
| 1048 | /* |
| 1049 | * If we have detected dead IOC, we needn't proceed |
| 1050 | * any more since all PHBs would have been removed |
| 1051 | */ |
| 1052 | if (rc == EEH_NEXT_ERR_DEAD_IOC) |
| 1053 | break; |
| 1054 | } while (rc != EEH_NEXT_ERR_NONE); |
Gavin Shan | 8a6b1bc | 2013-06-20 13:21:04 +0800 | [diff] [blame] | 1055 | } |