Commit c9dd0143 authored by Gavin Shan's avatar Gavin Shan Committed by Michael Ellerman

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: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 4eeeff0e
...@@ -1433,24 +1433,7 @@ static int eeh_pe_reenable_devices(struct eeh_pe *pe) ...@@ -1433,24 +1433,7 @@ static int eeh_pe_reenable_devices(struct eeh_pe *pe)
} }
/* The PE is still in frozen state */ /* The PE is still in frozen state */
ret = eeh_ops->set_option(pe, EEH_OPT_THAW_MMIO); return eeh_unfreeze_pe(pe, true);
if (ret) {
pr_warn("%s: Failure %d enabling MMIO for PHB#%x-PE#%x\n",
__func__, ret, pe->phb->global_number, pe->addr);
return ret;
}
ret = eeh_ops->set_option(pe, EEH_OPT_THAW_DMA);
if (ret) {
pr_warn("%s: Failure %d enabling DMA for PHB#%x-PE#%x\n",
__func__, ret, pe->phb->global_number, pe->addr);
return ret;
}
/* Clear software isolated state */
eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
return ret;
} }
/** /**
......
...@@ -450,21 +450,15 @@ static void *eeh_pe_detach_dev(void *data, void *userdata) ...@@ -450,21 +450,15 @@ static void *eeh_pe_detach_dev(void *data, void *userdata)
static void *__eeh_clear_pe_frozen_state(void *data, void *flag) static void *__eeh_clear_pe_frozen_state(void *data, void *flag)
{ {
struct eeh_pe *pe = (struct eeh_pe *)data; struct eeh_pe *pe = (struct eeh_pe *)data;
int i, rc; int i, rc = 1;
for (i = 0; i < 3; i++) { for (i = 0; rc && i < 3; i++)
rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); rc = eeh_unfreeze_pe(pe, false);
if (rc)
continue;
rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA);
if (!rc)
break;
}
/* The PE has been isolated, clear it */ /* Stop immediately on any errors */
if (rc) { if (rc) {
pr_warn("%s: Can't clear frozen PHB#%x-PE#%x (%d)\n", pr_warn("%s: Failure %d unfreezing PHB#%x-PE#%x\n",
__func__, pe->phb->global_number, pe->addr, rc); __func__, rc, pe->phb->global_number, pe->addr);
return (void *)pe; return (void *)pe;
} }
......
...@@ -75,7 +75,6 @@ static ssize_t eeh_pe_state_store(struct device *dev, ...@@ -75,7 +75,6 @@ static ssize_t eeh_pe_state_store(struct device *dev,
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev); struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
int ret;
if (!edev || !edev->pe) if (!edev || !edev->pe)
return -ENODEV; return -ENODEV;
...@@ -84,26 +83,8 @@ static ssize_t eeh_pe_state_store(struct device *dev, ...@@ -84,26 +83,8 @@ static ssize_t eeh_pe_state_store(struct device *dev,
if (!(edev->pe->state & EEH_PE_ISOLATED)) if (!(edev->pe->state & EEH_PE_ISOLATED))
return count; return count;
/* Enable MMIO */ if (eeh_unfreeze_pe(edev->pe, true))
ret = eeh_pci_enable(edev->pe, EEH_OPT_THAW_MMIO);
if (ret) {
pr_warn("%s: Failure %d enabling MMIO for PHB#%d-PE#%d\n",
__func__, ret, edev->pe->phb->global_number,
edev->pe->addr);
return -EIO; return -EIO;
}
/* Enable DMA */
ret = eeh_pci_enable(edev->pe, EEH_OPT_THAW_DMA);
if (ret) {
pr_warn("%s: Failure %d enabling DMA for PHB#%d-PE#%d\n",
__func__, ret, edev->pe->phb->global_number,
edev->pe->addr);
return -EIO;
}
/* Clear software state */
eeh_pe_state_clear(edev->pe, EEH_PE_ISOLATED);
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment