Skip to content

Commit a6195d9

Browse files
author
Mamatha Inamdar
committed
powerpc/pseries/eeh: Fix pseries_eeh_err_inject
JIRA: https://issues.redhat.com/browse/RHEL-61572 commit b0e2b82 Author: Narayana Murty N <nnmlinux@linux.ibm.com> Date: Mon Sep 9 09:02:20 2024 -0500 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 Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent d639f49 commit a6195d9

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
@@ -1533,10 +1533,6 @@ int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
15331533
if (!eeh_ops || !eeh_ops->err_inject)
15341534
return -ENOENT;
15351535

1536-
/* Check on PCI error type */
1537-
if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
1538-
return -EINVAL;
1539-
15401536
/* Check on PCI error function */
15411537
if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
15421538
return -EINVAL;
@@ -1847,6 +1843,11 @@ static const struct file_operations eeh_dev_break_fops = {
18471843
.read = eeh_debugfs_dev_usage,
18481844
};
18491845

1846+
int eeh_pe_inject_mmio_error(struct pci_dev *pdev)
1847+
{
1848+
return eeh_debugfs_break_device(pdev);
1849+
}
1850+
18501851
static ssize_t eeh_dev_can_recover(struct file *filp,
18511852
const char __user *user_buf,
18521853
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
@@ -782,6 +782,43 @@ static int pseries_notify_resume(struct eeh_dev *edev)
782782
}
783783
#endif
784784

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

0 commit comments

Comments
 (0)