Commit 34a286a4 authored by Sam Bobroff's avatar Sam Bobroff Committed by Michael Ellerman

powerpc/eeh: Add eeh_state_active() helper

Checking for a "fully active" device state requires testing two flag
bits, which is open coded in several places, so add a function to do
it.
Signed-off-by: default avatarSam Bobroff <sam.bobroff@au1.ibm.com>
Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 54048cf8
...@@ -256,6 +256,12 @@ static inline void eeh_serialize_unlock(unsigned long flags) ...@@ -256,6 +256,12 @@ static inline void eeh_serialize_unlock(unsigned long flags)
raw_spin_unlock_irqrestore(&confirm_error_lock, flags); raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
} }
static inline bool eeh_state_active(int state)
{
return (state & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE))
== (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
}
typedef void *(*eeh_traverse_func)(void *data, void *flag); typedef void *(*eeh_traverse_func)(void *data, void *flag);
void eeh_set_pe_aux_size(int size); void eeh_set_pe_aux_size(int size);
int eeh_phb_pe_create(struct pci_controller *phb); int eeh_phb_pe_create(struct pci_controller *phb);
......
...@@ -394,9 +394,7 @@ static int eeh_phb_check_failure(struct eeh_pe *pe) ...@@ -394,9 +394,7 @@ static int eeh_phb_check_failure(struct eeh_pe *pe)
/* Check PHB state */ /* Check PHB state */
ret = eeh_ops->get_state(phb_pe, NULL); ret = eeh_ops->get_state(phb_pe, NULL);
if ((ret < 0) || if ((ret < 0) ||
(ret == EEH_STATE_NOT_SUPPORT) || (ret == EEH_STATE_NOT_SUPPORT) || eeh_state_active(ret)) {
(ret & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) ==
(EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) {
ret = 0; ret = 0;
goto out; goto out;
} }
...@@ -433,7 +431,6 @@ static int eeh_phb_check_failure(struct eeh_pe *pe) ...@@ -433,7 +431,6 @@ static int eeh_phb_check_failure(struct eeh_pe *pe)
int eeh_dev_check_failure(struct eeh_dev *edev) int eeh_dev_check_failure(struct eeh_dev *edev)
{ {
int ret; int ret;
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
unsigned long flags; unsigned long flags;
struct device_node *dn; struct device_node *dn;
struct pci_dev *dev; struct pci_dev *dev;
...@@ -525,8 +522,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) ...@@ -525,8 +522,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
* state, PE is in good state. * state, PE is in good state.
*/ */
if ((ret < 0) || if ((ret < 0) ||
(ret == EEH_STATE_NOT_SUPPORT) || (ret == EEH_STATE_NOT_SUPPORT) || eeh_state_active(ret)) {
((ret & active_flags) == active_flags)) {
eeh_stats.false_positives++; eeh_stats.false_positives++;
pe->false_positives++; pe->false_positives++;
rc = 0; rc = 0;
...@@ -546,8 +542,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) ...@@ -546,8 +542,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
/* Frozen parent PE ? */ /* Frozen parent PE ? */
ret = eeh_ops->get_state(parent_pe, NULL); ret = eeh_ops->get_state(parent_pe, NULL);
if (ret > 0 && if (ret > 0 && !eeh_state_active(ret))
(ret & active_flags) != active_flags)
pe = parent_pe; pe = parent_pe;
/* Next parent level */ /* Next parent level */
...@@ -888,7 +883,6 @@ static void *eeh_set_dev_freset(void *data, void *flag) ...@@ -888,7 +883,6 @@ static void *eeh_set_dev_freset(void *data, void *flag)
*/ */
int eeh_pe_reset_full(struct eeh_pe *pe) int eeh_pe_reset_full(struct eeh_pe *pe)
{ {
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
int reset_state = (EEH_PE_RESET | EEH_PE_CFG_BLOCKED); int reset_state = (EEH_PE_RESET | EEH_PE_CFG_BLOCKED);
int type = EEH_RESET_HOT; int type = EEH_RESET_HOT;
unsigned int freset = 0; unsigned int freset = 0;
...@@ -919,7 +913,7 @@ int eeh_pe_reset_full(struct eeh_pe *pe) ...@@ -919,7 +913,7 @@ int eeh_pe_reset_full(struct eeh_pe *pe)
/* Wait until the PE is in a functioning state */ /* Wait until the PE is in a functioning state */
state = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); state = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC);
if ((state & active_flags) == active_flags) if (eeh_state_active(state))
break; break;
if (state < 0) { if (state < 0) {
...@@ -1352,16 +1346,15 @@ static int eeh_pe_change_owner(struct eeh_pe *pe) ...@@ -1352,16 +1346,15 @@ static int eeh_pe_change_owner(struct eeh_pe *pe)
struct eeh_dev *edev, *tmp; struct eeh_dev *edev, *tmp;
struct pci_dev *pdev; struct pci_dev *pdev;
struct pci_device_id *id; struct pci_device_id *id;
int flags, ret; int ret;
/* Check PE state */ /* Check PE state */
flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
ret = eeh_ops->get_state(pe, NULL); ret = eeh_ops->get_state(pe, NULL);
if (ret < 0 || ret == EEH_STATE_NOT_SUPPORT) if (ret < 0 || ret == EEH_STATE_NOT_SUPPORT)
return 0; return 0;
/* Unfrozen PE, nothing to do */ /* Unfrozen PE, nothing to do */
if ((ret & flags) == flags) if (eeh_state_active(ret))
return 0; return 0;
/* Frozen PE, check if it needs PE level reset */ /* Frozen PE, check if it needs PE level reset */
......
...@@ -1425,11 +1425,8 @@ static int pnv_eeh_get_pe(struct pci_controller *hose, ...@@ -1425,11 +1425,8 @@ static int pnv_eeh_get_pe(struct pci_controller *hose,
dev_pe = dev_pe->parent; dev_pe = dev_pe->parent;
while (dev_pe && !(dev_pe->type & EEH_PE_PHB)) { while (dev_pe && !(dev_pe->type & EEH_PE_PHB)) {
int ret; int ret;
int active_flags = (EEH_STATE_MMIO_ACTIVE |
EEH_STATE_DMA_ACTIVE);
ret = eeh_ops->get_state(dev_pe, NULL); ret = eeh_ops->get_state(dev_pe, NULL);
if (ret <= 0 || (ret & active_flags) == active_flags) { if (ret <= 0 || eeh_state_active(ret)) {
dev_pe = dev_pe->parent; dev_pe = dev_pe->parent;
continue; continue;
} }
...@@ -1463,7 +1460,6 @@ static int pnv_eeh_next_error(struct eeh_pe **pe) ...@@ -1463,7 +1460,6 @@ static int pnv_eeh_next_error(struct eeh_pe **pe)
struct eeh_pe *phb_pe, *parent_pe; struct eeh_pe *phb_pe, *parent_pe;
__be64 frozen_pe_no; __be64 frozen_pe_no;
__be16 err_type, severity; __be16 err_type, severity;
int active_flags = (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE);
long rc; long rc;
int state, ret = EEH_NEXT_ERR_NONE; int state, ret = EEH_NEXT_ERR_NONE;
...@@ -1626,8 +1622,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe) ...@@ -1626,8 +1622,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe)
/* Frozen parent PE ? */ /* Frozen parent PE ? */
state = eeh_ops->get_state(parent_pe, NULL); state = eeh_ops->get_state(parent_pe, NULL);
if (state > 0 && if (state > 0 && !eeh_state_active(state))
(state & active_flags) != active_flags)
*pe = parent_pe; *pe = parent_pe;
/* Next parent level */ /* Next parent level */
......
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