aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaike Wan <kaike.wan@intel.com>2016-02-26 16:33:18 -0500
committerDoug Ledford <dledford@redhat.com>2016-03-10 20:45:46 -0500
commitbf400235f392eabf60c865c95da823727cb00def (patch)
tree24faafd6e639139752adb78b367cb8bae039aadc
parentaa0ad411e51763f95afdae11d6ee684915faecef (diff)
staging/rdma/hfi1: Avoid using upstream component if it is not accessible
When the hfi1 device is assigned to a VM (eg KVM), the hfi1 driver has no access to the upstream component and therefore cannot use it to perform some operations, such as secondary bus reset. As a result, the hfi1 driver cannot perform the pcie Gen3 transition. Instead, those operation should be done in the host environment, preferrably done during the Option ROM initialization. Similarly, the hfi1 driver cannot support ASPM and tune the pcie capability under this circumstance. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Kaike Wan <kaike.wan@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/staging/rdma/hfi1/aspm.h19
-rw-r--r--drivers/staging/rdma/hfi1/pcie.c22
2 files changed, 36 insertions, 5 deletions
diff --git a/drivers/staging/rdma/hfi1/aspm.h b/drivers/staging/rdma/hfi1/aspm.h
index 3aac80296dcc..0d58fe3b49b5 100644
--- a/drivers/staging/rdma/hfi1/aspm.h
+++ b/drivers/staging/rdma/hfi1/aspm.h
@@ -72,6 +72,13 @@ static inline bool aspm_hw_l1_supported(struct hfi1_devdata *dd)
72 struct pci_dev *parent = dd->pcidev->bus->self; 72 struct pci_dev *parent = dd->pcidev->bus->self;
73 u32 up, dn; 73 u32 up, dn;
74 74
75 /*
76 * If the driver does not have access to the upstream component,
77 * it cannot support ASPM L1 at all.
78 */
79 if (!parent)
80 return false;
81
75 pcie_capability_read_dword(dd->pcidev, PCI_EXP_LNKCAP, &dn); 82 pcie_capability_read_dword(dd->pcidev, PCI_EXP_LNKCAP, &dn);
76 dn = ASPM_L1_SUPPORTED(dn); 83 dn = ASPM_L1_SUPPORTED(dn);
77 84
@@ -98,6 +105,13 @@ static inline void aspm_hw_enable_l1(struct hfi1_devdata *dd)
98{ 105{
99 struct pci_dev *parent = dd->pcidev->bus->self; 106 struct pci_dev *parent = dd->pcidev->bus->self;
100 107
108 /*
109 * If the driver does not have access to the upstream component,
110 * it cannot support ASPM L1 at all.
111 */
112 if (!parent)
113 return;
114
101 /* Enable ASPM L1 first in upstream component and then downstream */ 115 /* Enable ASPM L1 first in upstream component and then downstream */
102 pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL, 116 pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL,
103 PCI_EXP_LNKCTL_ASPMC, 117 PCI_EXP_LNKCTL_ASPMC,
@@ -114,8 +128,9 @@ static inline void aspm_hw_disable_l1(struct hfi1_devdata *dd)
114 /* Disable ASPM L1 first in downstream component and then upstream */ 128 /* Disable ASPM L1 first in downstream component and then upstream */
115 pcie_capability_clear_and_set_word(dd->pcidev, PCI_EXP_LNKCTL, 129 pcie_capability_clear_and_set_word(dd->pcidev, PCI_EXP_LNKCTL,
116 PCI_EXP_LNKCTL_ASPMC, 0x0); 130 PCI_EXP_LNKCTL_ASPMC, 0x0);
117 pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL, 131 if (parent)
118 PCI_EXP_LNKCTL_ASPMC, 0x0); 132 pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL,
133 PCI_EXP_LNKCTL_ASPMC, 0x0);
119} 134}
120 135
121static inline void aspm_enable(struct hfi1_devdata *dd) 136static inline void aspm_enable(struct hfi1_devdata *dd)
diff --git a/drivers/staging/rdma/hfi1/pcie.c b/drivers/staging/rdma/hfi1/pcie.c
index 7855962a8ba5..1adfa8bfaf2b 100644
--- a/drivers/staging/rdma/hfi1/pcie.c
+++ b/drivers/staging/rdma/hfi1/pcie.c
@@ -362,6 +362,7 @@ static void update_lbus_info(struct hfi1_devdata *dd)
362int pcie_speeds(struct hfi1_devdata *dd) 362int pcie_speeds(struct hfi1_devdata *dd)
363{ 363{
364 u32 linkcap; 364 u32 linkcap;
365 struct pci_dev *parent = dd->pcidev->bus->self;
365 366
366 if (!pci_is_pcie(dd->pcidev)) { 367 if (!pci_is_pcie(dd->pcidev)) {
367 dd_dev_err(dd, "Can't find PCI Express capability!\n"); 368 dd_dev_err(dd, "Can't find PCI Express capability!\n");
@@ -382,7 +383,7 @@ int pcie_speeds(struct hfi1_devdata *dd)
382 /* 383 /*
383 * bus->max_bus_speed is set from the bridge's linkcap Max Link Speed 384 * bus->max_bus_speed is set from the bridge's linkcap Max Link Speed
384 */ 385 */
385 if (dd->pcidev->bus->max_bus_speed != PCIE_SPEED_8_0GT) { 386 if (parent && dd->pcidev->bus->max_bus_speed != PCIE_SPEED_8_0GT) {
386 dd_dev_info(dd, "Parent PCIe bridge does not support Gen3\n"); 387 dd_dev_info(dd, "Parent PCIe bridge does not support Gen3\n");
387 dd->link_gen3_capable = 0; 388 dd->link_gen3_capable = 0;
388 } 389 }
@@ -471,6 +472,12 @@ static void tune_pcie_caps(struct hfi1_devdata *dd)
471 } 472 }
472 /* Find out supported and configured values for parent (root) */ 473 /* Find out supported and configured values for parent (root) */
473 parent = dd->pcidev->bus->self; 474 parent = dd->pcidev->bus->self;
475 /*
476 * The driver cannot perform the tuning if it does not have
477 * access to the upstream component.
478 */
479 if (!parent)
480 return;
474 if (!pci_is_root_bus(parent->bus)) { 481 if (!pci_is_root_bus(parent->bus)) {
475 dd_dev_info(dd, "Parent not root\n"); 482 dd_dev_info(dd, "Parent not root\n");
476 return; 483 return;
@@ -939,7 +946,7 @@ static void write_xmt_margin(struct hfi1_devdata *dd, const char *fname)
939 */ 946 */
940int do_pcie_gen3_transition(struct hfi1_devdata *dd) 947int do_pcie_gen3_transition(struct hfi1_devdata *dd)
941{ 948{
942 struct pci_dev *parent; 949 struct pci_dev *parent = dd->pcidev->bus->self;
943 u64 fw_ctrl; 950 u64 fw_ctrl;
944 u64 reg, therm; 951 u64 reg, therm;
945 u32 reg32, fs, lf; 952 u32 reg32, fs, lf;
@@ -982,6 +989,16 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd)
982 } 989 }
983 990
984 /* 991 /*
992 * The driver cannot do the transition if it has no access to the
993 * upstream component
994 */
995 if (!parent) {
996 dd_dev_info(dd, "%s: No upstream, Can't do gen3 transition\n",
997 __func__);
998 return 0;
999 }
1000
1001 /*
985 * Do the Gen3 transition. Steps are those of the PCIe Gen3 1002 * Do the Gen3 transition. Steps are those of the PCIe Gen3
986 * recipe. 1003 * recipe.
987 */ 1004 */
@@ -1157,7 +1174,6 @@ retry:
1157 * that it is Gen3 capable earlier. 1174 * that it is Gen3 capable earlier.
1158 */ 1175 */
1159 dd_dev_info(dd, "%s: setting parent target link speed\n", __func__); 1176 dd_dev_info(dd, "%s: setting parent target link speed\n", __func__);
1160 parent = dd->pcidev->bus->self;
1161 pcie_capability_read_word(parent, PCI_EXP_LNKCTL2, &lnkctl2); 1177 pcie_capability_read_word(parent, PCI_EXP_LNKCTL2, &lnkctl2);
1162 dd_dev_info(dd, "%s: ..old link control2: 0x%x\n", __func__, 1178 dd_dev_info(dd, "%s: ..old link control2: 0x%x\n", __func__,
1163 (u32)lnkctl2); 1179 (u32)lnkctl2);