aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Shan <gwshan@linux.vnet.ibm.com>2014-09-29 22:39:02 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2014-09-30 03:15:14 -0400
commitc9dd0143978e1c473c08dafe8156259b895db3e2 (patch)
treec22ed5343c6b7d6b542a1dbe3fa79a1a48665063
parent4eeeff0ebcdeabf3f76c4eece0593e98c6619be8 (diff)
powerpc/eeh: Use eeh_unfreeze_pe()
The patch uses eeh_unfreeze_pe() to replace the logic clearing frozen IO and DMA, in order to simplify the code. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/kernel/eeh.c19
-rw-r--r--arch/powerpc/kernel/eeh_driver.c18
-rw-r--r--arch/powerpc/kernel/eeh_sysfs.c21
3 files changed, 8 insertions, 50 deletions
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index b569ce2a8037..c79583fe1905 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1433,24 +1433,7 @@ static int eeh_pe_reenable_devices(struct eeh_pe *pe)
1433 } 1433 }
1434 1434
1435 /* The PE is still in frozen state */ 1435 /* The PE is still in frozen state */
1436 ret = eeh_ops->set_option(pe, EEH_OPT_THAW_MMIO); 1436 return eeh_unfreeze_pe(pe, true);
1437 if (ret) {
1438 pr_warn("%s: Failure %d enabling MMIO for PHB#%x-PE#%x\n",
1439 __func__, ret, pe->phb->global_number, pe->addr);
1440 return ret;
1441 }
1442
1443 ret = eeh_ops->set_option(pe, EEH_OPT_THAW_DMA);
1444 if (ret) {
1445 pr_warn("%s: Failure %d enabling DMA for PHB#%x-PE#%x\n",
1446 __func__, ret, pe->phb->global_number, pe->addr);
1447 return ret;
1448 }
1449
1450 /* Clear software isolated state */
1451 eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
1452
1453 return ret;
1454} 1437}
1455 1438
1456/** 1439/**
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 6a0dcee8e931..948e6f99089f 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -450,21 +450,15 @@ static void *eeh_pe_detach_dev(void *data, void *userdata)
450static void *__eeh_clear_pe_frozen_state(void *data, void *flag) 450static void *__eeh_clear_pe_frozen_state(void *data, void *flag)
451{ 451{
452 struct eeh_pe *pe = (struct eeh_pe *)data; 452 struct eeh_pe *pe = (struct eeh_pe *)data;
453 int i, rc; 453 int i, rc = 1;
454 454
455 for (i = 0; i < 3; i++) { 455 for (i = 0; rc && i < 3; i++)
456 rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); 456 rc = eeh_unfreeze_pe(pe, false);
457 if (rc)
458 continue;
459 rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA);
460 if (!rc)
461 break;
462 }
463 457
464 /* The PE has been isolated, clear it */ 458 /* Stop immediately on any errors */
465 if (rc) { 459 if (rc) {
466 pr_warn("%s: Can't clear frozen PHB#%x-PE#%x (%d)\n", 460 pr_warn("%s: Failure %d unfreezing PHB#%x-PE#%x\n",
467 __func__, pe->phb->global_number, pe->addr, rc); 461 __func__, rc, pe->phb->global_number, pe->addr);
468 return (void *)pe; 462 return (void *)pe;
469 } 463 }
470 464
diff --git a/arch/powerpc/kernel/eeh_sysfs.c b/arch/powerpc/kernel/eeh_sysfs.c
index eb15be4d8849..9a44010bd4b5 100644
--- a/arch/powerpc/kernel/eeh_sysfs.c
+++ b/arch/powerpc/kernel/eeh_sysfs.c
@@ -75,7 +75,6 @@ static ssize_t eeh_pe_state_store(struct device *dev,
75{ 75{
76 struct pci_dev *pdev = to_pci_dev(dev); 76 struct pci_dev *pdev = to_pci_dev(dev);
77 struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev); 77 struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
78 int ret;
79 78
80 if (!edev || !edev->pe) 79 if (!edev || !edev->pe)
81 return -ENODEV; 80 return -ENODEV;
@@ -84,26 +83,8 @@ static ssize_t eeh_pe_state_store(struct device *dev,
84 if (!(edev->pe->state & EEH_PE_ISOLATED)) 83 if (!(edev->pe->state & EEH_PE_ISOLATED))
85 return count; 84 return count;
86 85
87 /* Enable MMIO */ 86 if (eeh_unfreeze_pe(edev->pe, true))
88 ret = eeh_pci_enable(edev->pe, EEH_OPT_THAW_MMIO);
89 if (ret) {
90 pr_warn("%s: Failure %d enabling MMIO for PHB#%d-PE#%d\n",
91 __func__, ret, edev->pe->phb->global_number,
92 edev->pe->addr);
93 return -EIO; 87 return -EIO;
94 }
95
96 /* Enable DMA */
97 ret = eeh_pci_enable(edev->pe, EEH_OPT_THAW_DMA);
98 if (ret) {
99 pr_warn("%s: Failure %d enabling DMA for PHB#%d-PE#%d\n",
100 __func__, ret, edev->pe->phb->global_number,
101 edev->pe->addr);
102 return -EIO;
103 }
104
105 /* Clear software state */
106 eeh_pe_state_clear(edev->pe, EEH_PE_ISOLATED);
107 88
108 return count; 89 return count;
109} 90}