Commit 131c123a authored by Gavin Shan's avatar Gavin Shan Committed by Michael Ellerman

powerpc/eeh: Introduce eeh_ops::err_inject

The patch introduces eeh_ops::err_inject(), which allows to inject
specified errors to indicated PE for testing purpose. The functionality
isn't support on pSeries platform. On PowerNV, the functionality
relies on OPAL API opal_pci_err_inject().
Signed-off-by: default avatarMike Qiu <qiudayu@linux.vnet.ibm.com>
Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 5b642340
...@@ -204,6 +204,8 @@ struct eeh_ops { ...@@ -204,6 +204,8 @@ struct eeh_ops {
int (*wait_state)(struct eeh_pe *pe, int max_wait); int (*wait_state)(struct eeh_pe *pe, int max_wait);
int (*get_log)(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len); int (*get_log)(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len);
int (*configure_bridge)(struct eeh_pe *pe); int (*configure_bridge)(struct eeh_pe *pe);
int (*err_inject)(struct eeh_pe *pe, int type, int func,
unsigned long addr, unsigned long mask);
int (*read_config)(struct device_node *dn, int where, int size, u32 *val); int (*read_config)(struct device_node *dn, int where, int size, u32 *val);
int (*write_config)(struct device_node *dn, int where, int size, u32 val); int (*write_config)(struct device_node *dn, int where, int size, u32 val);
int (*next_error)(struct eeh_pe **pe); int (*next_error)(struct eeh_pe **pe);
......
...@@ -673,6 +673,49 @@ static int ioda_eeh_configure_bridge(struct eeh_pe *pe) ...@@ -673,6 +673,49 @@ static int ioda_eeh_configure_bridge(struct eeh_pe *pe)
return 0; return 0;
} }
static int ioda_eeh_err_inject(struct eeh_pe *pe, int type, int func,
unsigned long addr, unsigned long mask)
{
struct pci_controller *hose = pe->phb;
struct pnv_phb *phb = hose->private_data;
s64 ret;
/* Sanity check on error type */
if (type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR &&
type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {
pr_warn("%s: Invalid error type %d\n",
__func__, type);
return -ERANGE;
}
if (func < OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR ||
func > OPAL_ERR_INJECT_FUNC_IOA_DMA_WR_TARGET) {
pr_warn("%s: Invalid error function %d\n",
__func__, func);
return -ERANGE;
}
/* Firmware supports error injection ? */
if (!opal_check_token(OPAL_PCI_ERR_INJECT)) {
pr_warn("%s: Firmware doesn't support error injection\n",
__func__);
return -ENXIO;
}
/* Do error injection */
ret = opal_pci_err_inject(phb->opal_id, pe->addr,
type, func, addr, mask);
if (ret != OPAL_SUCCESS) {
pr_warn("%s: Failure %lld injecting error "
"%d-%d to PHB#%x-PE#%x\n",
__func__, ret, type, func,
hose->global_number, pe->addr);
return -EIO;
}
return 0;
}
static void ioda_eeh_hub_diag_common(struct OpalIoP7IOCErrorData *data) static void ioda_eeh_hub_diag_common(struct OpalIoP7IOCErrorData *data)
{ {
/* GEM */ /* GEM */
...@@ -994,5 +1037,6 @@ struct pnv_eeh_ops ioda_eeh_ops = { ...@@ -994,5 +1037,6 @@ struct pnv_eeh_ops ioda_eeh_ops = {
.reset = ioda_eeh_reset, .reset = ioda_eeh_reset,
.get_log = ioda_eeh_get_log, .get_log = ioda_eeh_get_log,
.configure_bridge = ioda_eeh_configure_bridge, .configure_bridge = ioda_eeh_configure_bridge,
.err_inject = ioda_eeh_err_inject,
.next_error = ioda_eeh_next_error .next_error = ioda_eeh_next_error
}; };
...@@ -358,6 +358,31 @@ static int powernv_eeh_configure_bridge(struct eeh_pe *pe) ...@@ -358,6 +358,31 @@ static int powernv_eeh_configure_bridge(struct eeh_pe *pe)
return ret; return ret;
} }
/**
* powernv_pe_err_inject - Inject specified error to the indicated PE
* @pe: the indicated PE
* @type: error type
* @func: specific error type
* @addr: address
* @mask: address mask
*
* The routine is called to inject specified error, which is
* determined by @type and @func, to the indicated PE for
* testing purpose.
*/
static int powernv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
unsigned long addr, unsigned long mask)
{
struct pci_controller *hose = pe->phb;
struct pnv_phb *phb = hose->private_data;
int ret = -EEXIST;
if (phb->eeh_ops && phb->eeh_ops->err_inject)
ret = phb->eeh_ops->err_inject(pe, type, func, addr, mask);
return ret;
}
/** /**
* powernv_eeh_next_error - Retrieve next EEH error to handle * powernv_eeh_next_error - Retrieve next EEH error to handle
* @pe: Affected PE * @pe: Affected PE
...@@ -414,6 +439,7 @@ static struct eeh_ops powernv_eeh_ops = { ...@@ -414,6 +439,7 @@ static struct eeh_ops powernv_eeh_ops = {
.wait_state = powernv_eeh_wait_state, .wait_state = powernv_eeh_wait_state,
.get_log = powernv_eeh_get_log, .get_log = powernv_eeh_get_log,
.configure_bridge = powernv_eeh_configure_bridge, .configure_bridge = powernv_eeh_configure_bridge,
.err_inject = powernv_eeh_err_inject,
.read_config = pnv_pci_cfg_read, .read_config = pnv_pci_cfg_read,
.write_config = pnv_pci_cfg_write, .write_config = pnv_pci_cfg_write,
.next_error = powernv_eeh_next_error, .next_error = powernv_eeh_next_error,
......
...@@ -85,6 +85,8 @@ struct pnv_eeh_ops { ...@@ -85,6 +85,8 @@ struct pnv_eeh_ops {
int (*get_log)(struct eeh_pe *pe, int severity, int (*get_log)(struct eeh_pe *pe, int severity,
char *drv_log, unsigned long len); char *drv_log, unsigned long len);
int (*configure_bridge)(struct eeh_pe *pe); int (*configure_bridge)(struct eeh_pe *pe);
int (*err_inject)(struct eeh_pe *pe, int type, int func,
unsigned long addr, unsigned long mask);
int (*next_error)(struct eeh_pe **pe); int (*next_error)(struct eeh_pe **pe);
}; };
#endif /* CONFIG_EEH */ #endif /* CONFIG_EEH */
......
...@@ -731,6 +731,7 @@ static struct eeh_ops pseries_eeh_ops = { ...@@ -731,6 +731,7 @@ static struct eeh_ops pseries_eeh_ops = {
.wait_state = pseries_eeh_wait_state, .wait_state = pseries_eeh_wait_state,
.get_log = pseries_eeh_get_log, .get_log = pseries_eeh_get_log,
.configure_bridge = pseries_eeh_configure_bridge, .configure_bridge = pseries_eeh_configure_bridge,
.err_inject = NULL,
.read_config = pseries_eeh_read_config, .read_config = pseries_eeh_read_config,
.write_config = pseries_eeh_write_config, .write_config = pseries_eeh_write_config,
.next_error = NULL, .next_error = NULL,
......
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