Commit 4d4f577e authored by Gavin Shan's avatar Gavin Shan Committed by Michael Ellerman

powerpc/eeh: Fix improper condition in eeh_pci_enable()

The function eeh_pci_enable() is called to apply various requests
to one particular PE: Enabling EEH, Disabling EEH, Enabling IO,
Enabling DMA, Freezing PE. When enabling IO or DMA on one specific
PE, we need check that IO or DMA isn't enabled previously. But
the condition used to do the check isn't completely correct because
one PE would be in DMA frozen state with workable IO path, or vice
versa.

The patch fixes the improper condition.
Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 22fca179
...@@ -579,25 +579,51 @@ EXPORT_SYMBOL(eeh_check_failure); ...@@ -579,25 +579,51 @@ EXPORT_SYMBOL(eeh_check_failure);
*/ */
int eeh_pci_enable(struct eeh_pe *pe, int function) int eeh_pci_enable(struct eeh_pe *pe, int function)
{ {
int rc, flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE); int active_flag, rc;
/* /*
* pHyp doesn't allow to enable IO or DMA on unfrozen PE. * pHyp doesn't allow to enable IO or DMA on unfrozen PE.
* Also, it's pointless to enable them on unfrozen PE. So * Also, it's pointless to enable them on unfrozen PE. So
* we have the check here. * we have to check before enabling IO or DMA.
*/ */
if (function == EEH_OPT_THAW_MMIO || switch (function) {
function == EEH_OPT_THAW_DMA) { case EEH_OPT_THAW_MMIO:
active_flag = EEH_STATE_MMIO_ACTIVE;
break;
case EEH_OPT_THAW_DMA:
active_flag = EEH_STATE_DMA_ACTIVE;
break;
case EEH_OPT_DISABLE:
case EEH_OPT_ENABLE:
case EEH_OPT_FREEZE_PE:
active_flag = 0;
break;
default:
pr_warn("%s: Invalid function %d\n",
__func__, function);
return -EINVAL;
}
/*
* Check if IO or DMA has been enabled before
* enabling them.
*/
if (active_flag) {
rc = eeh_ops->get_state(pe, NULL); rc = eeh_ops->get_state(pe, NULL);
if (rc < 0) if (rc < 0)
return rc; return rc;
/* Needn't to enable or already enabled */ /* Needn't enable it at all */
if ((rc == EEH_STATE_NOT_SUPPORT) || if (rc == EEH_STATE_NOT_SUPPORT)
((rc & flags) == flags)) return 0;
/* It's already enabled */
if (rc & active_flag)
return 0; return 0;
} }
/* Issue the request */
rc = eeh_ops->set_option(pe, function); rc = eeh_ops->set_option(pe, function);
if (rc) if (rc)
pr_warn("%s: Unexpected state change %d on " pr_warn("%s: Unexpected state change %d on "
...@@ -605,17 +631,17 @@ int eeh_pci_enable(struct eeh_pe *pe, int function) ...@@ -605,17 +631,17 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)
__func__, function, pe->phb->global_number, __func__, function, pe->phb->global_number,
pe->addr, rc); pe->addr, rc);
rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); /* Check if the request is finished successfully */
if (rc <= 0) if (active_flag) {
return rc; rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC);
if (rc <= 0)
return rc;
if ((function == EEH_OPT_THAW_MMIO) && if (rc & active_flag)
(rc & EEH_STATE_MMIO_ENABLED)) return 0;
return 0;
if ((function == EEH_OPT_THAW_DMA) && return -EIO;
(rc & EEH_STATE_DMA_ENABLED)) }
return 0;
return rc; return rc;
} }
......
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