/** * genwqe_pci_fundamental_reset() - trigger a PCIe fundamental reset on the slot * * Note: pci_set_pcie_reset_state() is not implemented on all archs, so this * reset method will not work in all cases. * * Return: 0 on success or error code from pci_set_pcie_reset_state() */ static int genwqe_pci_fundamental_reset(struct pci_dev *pci_dev) { int rc; /* * lock pci config space access from userspace, * save state and issue PCIe fundamental reset */ pci_cfg_access_lock(pci_dev); pci_save_state(pci_dev); rc = pci_set_pcie_reset_state(pci_dev, pcie_warm_reset); if (!rc) { /* keep PCIe reset asserted for 250ms */ msleep(250); pci_set_pcie_reset_state(pci_dev, pcie_deassert_reset); /* Wait for 2s to reload flash and train the link */ msleep(2000); } pci_restore_state(pci_dev); pci_cfg_access_unlock(pci_dev); return rc; }
int cxl_reset(struct cxl *adapter) { struct pci_dev *dev = to_pci_dev(adapter->dev.parent); int rc; dev_info(&dev->dev, "CXL reset\n"); /* pcie_warm_reset requests a fundamental pci reset which includes a * PERST assert/deassert. PERST triggers a loading of the image * if "user" or "factory" is selected in sysfs */ if ((rc = pci_set_pcie_reset_state(dev, pcie_warm_reset))) { dev_err(&dev->dev, "cxl: pcie_warm_reset failed\n"); return rc; } return rc; }