Skip to content

Commit b0e2b82

Browse files
NarayanamurtyNmpe
authored andcommitted
powerpc/pseries/eeh: Fix pseries_eeh_err_inject
VFIO_EEH_PE_INJECT_ERR ioctl is currently failing on pseries due to missing implementation of err_inject eeh_ops for pseries. This patch implements pseries_eeh_err_inject in eeh_ops/pseries eeh_ops. Implements support for injecting MMIO load/store error for testing from user space. The check on PCI error type (bus type) code is moved to platform code, since the eeh_pe_inject_err can be allowed to more error types depending on platform requirement. Removal of the check for 'type' in eeh_pe_inject_err() doesn't impact PowerNV as pnv_eeh_err_inject() already has an equivalent check in place. Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com> Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240909140220.529333-1-nnmlinux@linux.ibm.com
1 parent 8c9c01c commit b0e2b82

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

arch/powerpc/include/asm/eeh.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);
308308
int eeh_pe_configure(struct eeh_pe *pe);
309309
int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
310310
unsigned long addr, unsigned long mask);
311+
int eeh_pe_inject_mmio_error(struct pci_dev *pdev);
311312

312313
/**
313314
* EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.

arch/powerpc/kernel/eeh.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,10 +1537,6 @@ int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
15371537
if (!eeh_ops || !eeh_ops->err_inject)
15381538
return -ENOENT;
15391539

1540-
/* Check on PCI error type */
1541-
if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
1542-
return -EINVAL;
1543-
15441540
/* Check on PCI error function */
15451541
if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
15461542
return -EINVAL;
@@ -1848,6 +1844,11 @@ static const struct file_operations eeh_dev_break_fops = {
18481844
.read = eeh_debugfs_dev_usage,
18491845
};
18501846

1847+
int eeh_pe_inject_mmio_error(struct pci_dev *pdev)
1848+
{
1849+
return eeh_debugfs_break_device(pdev);
1850+
}
1851+
18511852
static ssize_t eeh_dev_can_recover(struct file *filp,
18521853
const char __user *user_buf,
18531854
size_t count, loff_t *ppos)

arch/powerpc/platforms/pseries/eeh_pseries.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,43 @@ static int pseries_notify_resume(struct eeh_dev *edev)
784784
}
785785
#endif
786786

787+
/**
788+
* pseries_eeh_err_inject - Inject specified error to the indicated PE
789+
* @pe: the indicated PE
790+
* @type: error type
791+
* @func: specific error type
792+
* @addr: address
793+
* @mask: address mask
794+
* The routine is called to inject specified error, which is
795+
* determined by @type and @func, to the indicated PE
796+
*/
797+
static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,
798+
unsigned long addr, unsigned long mask)
799+
{
800+
struct eeh_dev *pdev;
801+
802+
/* Check on PCI error type */
803+
if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
804+
return -EINVAL;
805+
806+
switch (func) {
807+
case EEH_ERR_FUNC_LD_MEM_ADDR:
808+
case EEH_ERR_FUNC_LD_MEM_DATA:
809+
case EEH_ERR_FUNC_ST_MEM_ADDR:
810+
case EEH_ERR_FUNC_ST_MEM_DATA:
811+
/* injects a MMIO error for all pdev's belonging to PE */
812+
pci_lock_rescan_remove();
813+
list_for_each_entry(pdev, &pe->edevs, entry)
814+
eeh_pe_inject_mmio_error(pdev->pdev);
815+
pci_unlock_rescan_remove();
816+
break;
817+
default:
818+
return -ERANGE;
819+
}
820+
821+
return 0;
822+
}
823+
787824
static struct eeh_ops pseries_eeh_ops = {
788825
.name = "pseries",
789826
.probe = pseries_eeh_probe,
@@ -792,7 +829,7 @@ static struct eeh_ops pseries_eeh_ops = {
792829
.reset = pseries_eeh_reset,
793830
.get_log = pseries_eeh_get_log,
794831
.configure_bridge = pseries_eeh_configure_bridge,
795-
.err_inject = NULL,
832+
.err_inject = pseries_eeh_err_inject,
796833
.read_config = pseries_eeh_read_config,
797834
.write_config = pseries_eeh_write_config,
798835
.next_error = NULL,

0 commit comments

Comments
 (0)