提交 4c009af4 编写于 作者: M Michael J. Ruhl 提交者: Jason Gunthorpe

IB/hfi: Only read capability registers if the capability exists

During driver init, various registers are saved to allow restoration
after an FLR or gen3 bump.  Some of these registers are not available
in some circumstances (i.e. Virtual machines).

This bug makes the driver unusable when the PCI device is passed into
a VM, it fails during probe.

Delete unnecessary register read/write, and only access register if
the capability exists.

Cc: <stable@vger.kernel.org> # 4.14.x
Fixes: a618b7e4 ("IB/hfi1: Move saving PCI values to a separate function")
Reviewed-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: NMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
上级 1f80bd6a
...@@ -1131,7 +1131,6 @@ struct hfi1_devdata { ...@@ -1131,7 +1131,6 @@ struct hfi1_devdata {
u16 pcie_lnkctl; u16 pcie_lnkctl;
u16 pcie_devctl2; u16 pcie_devctl2;
u32 pci_msix0; u32 pci_msix0;
u32 pci_lnkctl3;
u32 pci_tph2; u32 pci_tph2;
/* /*
......
...@@ -411,15 +411,12 @@ int restore_pci_variables(struct hfi1_devdata *dd) ...@@ -411,15 +411,12 @@ int restore_pci_variables(struct hfi1_devdata *dd)
if (ret) if (ret)
goto error; goto error;
ret = pci_write_config_dword(dd->pcidev, PCIE_CFG_SPCIE1, if (pci_find_ext_capability(dd->pcidev, PCI_EXT_CAP_ID_TPH)) {
dd->pci_lnkctl3); ret = pci_write_config_dword(dd->pcidev, PCIE_CFG_TPH2,
dd->pci_tph2);
if (ret) if (ret)
goto error; goto error;
}
ret = pci_write_config_dword(dd->pcidev, PCIE_CFG_TPH2, dd->pci_tph2);
if (ret)
goto error;
return 0; return 0;
error: error:
...@@ -469,15 +466,12 @@ int save_pci_variables(struct hfi1_devdata *dd) ...@@ -469,15 +466,12 @@ int save_pci_variables(struct hfi1_devdata *dd)
if (ret) if (ret)
goto error; goto error;
ret = pci_read_config_dword(dd->pcidev, PCIE_CFG_SPCIE1, if (pci_find_ext_capability(dd->pcidev, PCI_EXT_CAP_ID_TPH)) {
&dd->pci_lnkctl3); ret = pci_read_config_dword(dd->pcidev, PCIE_CFG_TPH2,
&dd->pci_tph2);
if (ret) if (ret)
goto error; goto error;
}
ret = pci_read_config_dword(dd->pcidev, PCIE_CFG_TPH2, &dd->pci_tph2);
if (ret)
goto error;
return 0; return 0;
error: error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册