]> www.infradead.org Git - users/willy/xarray.git/commitdiff
powerpc/pseries/eeh: Fix pseries_eeh_err_inject
authorNarayana Murty N <nnmlinux@linux.ibm.com>
Mon, 9 Sep 2024 14:02:20 +0000 (09:02 -0500)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 10 Sep 2024 01:01:08 +0000 (11:01 +1000)
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
arch/powerpc/include/asm/eeh.h
arch/powerpc/kernel/eeh.c
arch/powerpc/platforms/pseries/eeh_pseries.c

index 91a9fd53254fa979fe8fdbe0e8df9305e9c82d32..5e34611de9ef406c3eca0140342816ed925db72c 100644 (file)
@@ -308,6 +308,7 @@ int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);
 int eeh_pe_configure(struct eeh_pe *pe);
 int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
                      unsigned long addr, unsigned long mask);
+int eeh_pe_inject_mmio_error(struct pci_dev *pdev);
 
 /**
  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
index 2f7f0efd564a9c08c7aed5673cb345cc93f2cac4..0e59b8fd9bc69096eb340c8bc9a782ba5f8ad2a4 100644 (file)
@@ -1537,10 +1537,6 @@ int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
        if (!eeh_ops || !eeh_ops->err_inject)
                return -ENOENT;
 
-       /* Check on PCI error type */
-       if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
-               return -EINVAL;
-
        /* Check on PCI error function */
        if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
                return -EINVAL;
@@ -1848,6 +1844,11 @@ static const struct file_operations eeh_dev_break_fops = {
        .read   = eeh_debugfs_dev_usage,
 };
 
+int eeh_pe_inject_mmio_error(struct pci_dev *pdev)
+{
+       return eeh_debugfs_break_device(pdev);
+}
+
 static ssize_t eeh_dev_can_recover(struct file *filp,
                                   const char __user *user_buf,
                                   size_t count, loff_t *ppos)
index b1ae0c0d1187825cd490c95e5b4d1174fa056928..1893f66371fa43bda3f29fda8bf22df1622634b1 100644 (file)
@@ -784,6 +784,43 @@ static int pseries_notify_resume(struct eeh_dev *edev)
 }
 #endif
 
+/**
+ * pseries_eeh_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
+ */
+static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,
+                                 unsigned long addr, unsigned long mask)
+{
+       struct  eeh_dev *pdev;
+
+       /* Check on PCI error type */
+       if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
+               return -EINVAL;
+
+       switch (func) {
+       case EEH_ERR_FUNC_LD_MEM_ADDR:
+       case EEH_ERR_FUNC_LD_MEM_DATA:
+       case EEH_ERR_FUNC_ST_MEM_ADDR:
+       case EEH_ERR_FUNC_ST_MEM_DATA:
+               /* injects a MMIO error for all pdev's belonging to PE */
+               pci_lock_rescan_remove();
+               list_for_each_entry(pdev, &pe->edevs, entry)
+                       eeh_pe_inject_mmio_error(pdev->pdev);
+               pci_unlock_rescan_remove();
+               break;
+       default:
+               return -ERANGE;
+       }
+
+       return 0;
+}
+
 static struct eeh_ops pseries_eeh_ops = {
        .name                   = "pseries",
        .probe                  = pseries_eeh_probe,
@@ -792,7 +829,7 @@ static struct eeh_ops pseries_eeh_ops = {
        .reset                  = pseries_eeh_reset,
        .get_log                = pseries_eeh_get_log,
        .configure_bridge       = pseries_eeh_configure_bridge,
-       .err_inject             = NULL,
+       .err_inject             = pseries_eeh_err_inject,
        .read_config            = pseries_eeh_read_config,
        .write_config           = pseries_eeh_write_config,
        .next_error             = NULL,