28 #include <linux/module.h>
29 #include <linux/pci.h>
33 #include <asm/pci-bridge.h>
44 static inline const char *eeh_pcid_name(
struct pci_dev *pdev)
46 if (pdev && pdev->
dev.driver)
47 return pdev->
dev.driver->name;
62 if (!pdev || !pdev->
driver)
65 if (!try_module_get(pdev->
driver->driver.owner))
78 static inline void eeh_pcid_put(
struct pci_dev *pdev)
80 if (!pdev || !pdev->
driver)
83 module_put(pdev->
driver->driver.owner);
87 static void print_device_node_tree(
struct pci_dn *pdn,
int dent)
94 for (i = 0; i < dent; i++)
96 printk(
"dn=%s mode=%x \tcfg_addr=%x pe_addr=%x \tfull=%s\n",
97 pdn->node->name, pdn->eeh_mode, pdn->eeh_config_addr,
98 pdn->eeh_pe_config_addr, pdn->node->full_name);
100 pc = pdn->node->
child;
102 print_device_node_tree(PCI_DN(pc), dent);
118 static void eeh_disable_irq(
struct pci_dev *
dev)
120 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
129 if (!irq_has_action(dev->
irq))
132 edev->mode |= EEH_DEV_IRQ_DISABLED;
143 static void eeh_enable_irq(
struct pci_dev *dev)
145 struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
147 if ((edev->mode) & EEH_DEV_IRQ_DISABLED) {
148 edev->mode &= ~EEH_DEV_IRQ_DISABLED;
162 static void *eeh_report_error(
void *
data,
void *userdata)
164 struct eeh_dev *edev = (
struct eeh_dev *)data;
165 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
172 if (!dev)
return NULL;
175 driver = eeh_pcid_get(dev);
176 if (!driver)
return NULL;
178 eeh_disable_irq(dev);
205 static void *eeh_report_mmio_enabled(
void *data,
void *userdata)
207 struct eeh_dev *edev = (
struct eeh_dev *)data;
208 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
212 driver = eeh_pcid_get(dev);
213 if (!driver)
return NULL;
241 static void *eeh_report_reset(
void *data,
void *userdata)
243 struct eeh_dev *edev = (
struct eeh_dev *)data;
244 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
248 if (!dev)
return NULL;
251 driver = eeh_pcid_get(dev);
252 if (!driver)
return NULL;
281 static void *eeh_report_resume(
void *data,
void *userdata)
283 struct eeh_dev *edev = (
struct eeh_dev *)data;
284 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
287 if (!dev)
return NULL;
290 driver = eeh_pcid_get(dev);
291 if (!driver)
return NULL;
315 static void *eeh_report_failure(
void *data,
void *userdata)
317 struct eeh_dev *edev = (
struct eeh_dev *)data;
318 struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
321 if (!dev)
return NULL;
324 driver = eeh_pcid_get(dev);
325 if (!driver)
return NULL;
327 eeh_disable_irq(dev);
350 static int eeh_reset_device(
struct eeh_pe *pe,
struct pci_bus *
bus)
355 cnt = pe->freeze_count;
388 pe->freeze_count =
cnt;
396 #define MAX_WAIT_FOR_RECOVERY 150
423 pr_err(
"%s: Cannot find PCI bus for PHB#%d-PE#%x\n",
424 __func__, pe->phb->global_number, pe->addr);
429 if (pe->freeze_count > EEH_MAX_ALLOWED_FREEZES)
430 goto excess_failures;
431 pr_warning(
"EEH: This PCI device has failed %d times in the last hour\n",
446 if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) {
462 rc = eeh_reset_device(pe, frozen_bus);
503 rc = eeh_reset_device(pe,
NULL);
530 pr_err(
"EEH: PHB#%d-PE#%x has failed %d times in the\n"
531 "last hour and has been permanently disabled.\n"
532 "Please try reseating or replacing it.\n",
533 pe->phb->global_number, pe->addr,
538 pr_err(
"EEH: Unable to recover from failure from PHB#%d-PE#%x.\n"
539 "Please try reseating or replacing it\n",
540 pe->phb->global_number, pe->addr);