Commit 828bcbdc authored by Harish Chegondi's avatar Harish Chegondi Committed by Doug Ledford

IB/hfi1: Unsuccessful PCIe caps tuning should not fail driver load

Failure to tune PCIe capabilities should not fail driver load. This can
cause the driver load to fail on systems with any of the following:
1. HFI's parent is not root. Example: HFI card is behind a PCIe bridge.
2. HFI's parent is not PCI Express capable.
In these situations, failure to tune PCIe capabilities should be logged
in the system message logs but not cause the driver load to fail.

This patch also ensures pcie capability word DevCtl is written only
after a successful read and the capability tuning process continues
even if read/write of the pcie capability word DevCtl fails.

Fixes: c53df62c ("IB/hfi1: Check return values from PCI config API calls")
Fixes: bf70a775 ("staging/rdma/hfi1: Enable WFR PCIe extended tags from the driver")
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: default avatarJakub Byczkowski <jakub.byczkowski@intel.com>
Signed-off-by: default avatarHarish Chegondi <harish.chegondi@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent b8f42738
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
/* /*
* Code to adjust PCIe capabilities. * Code to adjust PCIe capabilities.
*/ */
static int tune_pcie_caps(struct hfi1_devdata *); static void tune_pcie_caps(struct hfi1_devdata *);
/* /*
* Do all the common PCIe setup and initialization. * Do all the common PCIe setup and initialization.
...@@ -351,7 +351,7 @@ int pcie_speeds(struct hfi1_devdata *dd) ...@@ -351,7 +351,7 @@ int pcie_speeds(struct hfi1_devdata *dd)
*/ */
int request_msix(struct hfi1_devdata *dd, u32 msireq) int request_msix(struct hfi1_devdata *dd, u32 msireq)
{ {
int nvec, ret; int nvec;
nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq, nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq,
PCI_IRQ_MSIX | PCI_IRQ_LEGACY); PCI_IRQ_MSIX | PCI_IRQ_LEGACY);
...@@ -360,12 +360,7 @@ int request_msix(struct hfi1_devdata *dd, u32 msireq) ...@@ -360,12 +360,7 @@ int request_msix(struct hfi1_devdata *dd, u32 msireq)
return nvec; return nvec;
} }
ret = tune_pcie_caps(dd); tune_pcie_caps(dd);
if (ret) {
dd_dev_err(dd, "tune_pcie_caps() failed: %d\n", ret);
pci_free_irq_vectors(dd->pcidev);
return ret;
}
/* check for legacy IRQ */ /* check for legacy IRQ */
if (nvec == 1 && !dd->pcidev->msix_enabled) if (nvec == 1 && !dd->pcidev->msix_enabled)
...@@ -502,7 +497,7 @@ uint aspm_mode = ASPM_MODE_DISABLED; ...@@ -502,7 +497,7 @@ uint aspm_mode = ASPM_MODE_DISABLED;
module_param_named(aspm, aspm_mode, uint, S_IRUGO); module_param_named(aspm, aspm_mode, uint, S_IRUGO);
MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic"); MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic");
static int tune_pcie_caps(struct hfi1_devdata *dd) static void tune_pcie_caps(struct hfi1_devdata *dd)
{ {
struct pci_dev *parent; struct pci_dev *parent;
u16 rc_mpss, rc_mps, ep_mpss, ep_mps; u16 rc_mpss, rc_mps, ep_mpss, ep_mps;
...@@ -513,22 +508,14 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) ...@@ -513,22 +508,14 @@ static int tune_pcie_caps(struct hfi1_devdata *dd)
* Turn on extended tags in DevCtl in case the BIOS has turned it off * Turn on extended tags in DevCtl in case the BIOS has turned it off
* to improve WFR SDMA bandwidth * to improve WFR SDMA bandwidth
*/ */
ret = pcie_capability_read_word(dd->pcidev, ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl);
PCI_EXP_DEVCTL, &ectl); if ((!ret) && !(ectl & PCI_EXP_DEVCTL_EXT_TAG)) {
if (ret) {
dd_dev_err(dd, "Unable to read from PCI config\n");
return ret;
}
if (!(ectl & PCI_EXP_DEVCTL_EXT_TAG)) {
dd_dev_info(dd, "Enabling PCIe extended tags\n"); dd_dev_info(dd, "Enabling PCIe extended tags\n");
ectl |= PCI_EXP_DEVCTL_EXT_TAG; ectl |= PCI_EXP_DEVCTL_EXT_TAG;
ret = pcie_capability_write_word(dd->pcidev, ret = pcie_capability_write_word(dd->pcidev,
PCI_EXP_DEVCTL, ectl); PCI_EXP_DEVCTL, ectl);
if (ret) { if (ret)
dd_dev_err(dd, "Unable to write to PCI config\n"); dd_dev_info(dd, "Unable to write to PCI config\n");
return ret;
}
} }
/* Find out supported and configured values for parent (root) */ /* Find out supported and configured values for parent (root) */
parent = dd->pcidev->bus->self; parent = dd->pcidev->bus->self;
...@@ -536,15 +523,22 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) ...@@ -536,15 +523,22 @@ static int tune_pcie_caps(struct hfi1_devdata *dd)
* The driver cannot perform the tuning if it does not have * The driver cannot perform the tuning if it does not have
* access to the upstream component. * access to the upstream component.
*/ */
if (!parent) if (!parent) {
return -EINVAL; dd_dev_info(dd, "Parent not found\n");
return;
}
if (!pci_is_root_bus(parent->bus)) { if (!pci_is_root_bus(parent->bus)) {
dd_dev_info(dd, "Parent not root\n"); dd_dev_info(dd, "Parent not root\n");
return -EINVAL; return;
}
if (!pci_is_pcie(parent)) {
dd_dev_info(dd, "Parent is not PCI Express capable\n");
return;
}
if (!pci_is_pcie(dd->pcidev)) {
dd_dev_info(dd, "PCI device is not PCI Express capable\n");
return;
} }
if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev))
return -EINVAL;
rc_mpss = parent->pcie_mpss; rc_mpss = parent->pcie_mpss;
rc_mps = ffs(pcie_get_mps(parent)) - 8; rc_mps = ffs(pcie_get_mps(parent)) - 8;
/* Find out supported and configured values for endpoint (us) */ /* Find out supported and configured values for endpoint (us) */
...@@ -590,8 +584,6 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) ...@@ -590,8 +584,6 @@ static int tune_pcie_caps(struct hfi1_devdata *dd)
ep_mrrs = max_mrrs; ep_mrrs = max_mrrs;
pcie_set_readrq(dd->pcidev, ep_mrrs); pcie_set_readrq(dd->pcidev, ep_mrrs);
} }
return 0;
} }
/* End of PCIe capability tuning */ /* End of PCIe capability tuning */
......
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