diff options
| -rw-r--r-- | drivers/infiniband/hw/hfi1/pcie.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 82447b7cdda1..09e50fd2a08f 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c | |||
| @@ -68,7 +68,7 @@ | |||
| 68 | /* | 68 | /* |
| 69 | * Code to adjust PCIe capabilities. | 69 | * Code to adjust PCIe capabilities. |
| 70 | */ | 70 | */ |
| 71 | static int tune_pcie_caps(struct hfi1_devdata *); | 71 | static void tune_pcie_caps(struct hfi1_devdata *); |
| 72 | 72 | ||
| 73 | /* | 73 | /* |
| 74 | * Do all the common PCIe setup and initialization. | 74 | * Do all the common PCIe setup and initialization. |
| @@ -351,7 +351,7 @@ int pcie_speeds(struct hfi1_devdata *dd) | |||
| 351 | */ | 351 | */ |
| 352 | int request_msix(struct hfi1_devdata *dd, u32 msireq) | 352 | int request_msix(struct hfi1_devdata *dd, u32 msireq) |
| 353 | { | 353 | { |
| 354 | int nvec, ret; | 354 | int nvec; |
| 355 | 355 | ||
| 356 | nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq, | 356 | nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq, |
| 357 | PCI_IRQ_MSIX | PCI_IRQ_LEGACY); | 357 | PCI_IRQ_MSIX | PCI_IRQ_LEGACY); |
| @@ -360,12 +360,7 @@ int request_msix(struct hfi1_devdata *dd, u32 msireq) | |||
| 360 | return nvec; | 360 | return nvec; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | ret = tune_pcie_caps(dd); | 363 | tune_pcie_caps(dd); |
| 364 | if (ret) { | ||
| 365 | dd_dev_err(dd, "tune_pcie_caps() failed: %d\n", ret); | ||
| 366 | pci_free_irq_vectors(dd->pcidev); | ||
| 367 | return ret; | ||
| 368 | } | ||
| 369 | 364 | ||
| 370 | /* check for legacy IRQ */ | 365 | /* check for legacy IRQ */ |
| 371 | if (nvec == 1 && !dd->pcidev->msix_enabled) | 366 | if (nvec == 1 && !dd->pcidev->msix_enabled) |
| @@ -502,7 +497,7 @@ uint aspm_mode = ASPM_MODE_DISABLED; | |||
| 502 | module_param_named(aspm, aspm_mode, uint, S_IRUGO); | 497 | module_param_named(aspm, aspm_mode, uint, S_IRUGO); |
| 503 | MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic"); | 498 | MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic"); |
| 504 | 499 | ||
| 505 | static int tune_pcie_caps(struct hfi1_devdata *dd) | 500 | static void tune_pcie_caps(struct hfi1_devdata *dd) |
| 506 | { | 501 | { |
| 507 | struct pci_dev *parent; | 502 | struct pci_dev *parent; |
| 508 | u16 rc_mpss, rc_mps, ep_mpss, ep_mps; | 503 | u16 rc_mpss, rc_mps, ep_mpss, ep_mps; |
| @@ -513,22 +508,14 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) | |||
| 513 | * Turn on extended tags in DevCtl in case the BIOS has turned it off | 508 | * Turn on extended tags in DevCtl in case the BIOS has turned it off |
| 514 | * to improve WFR SDMA bandwidth | 509 | * to improve WFR SDMA bandwidth |
| 515 | */ | 510 | */ |
| 516 | ret = pcie_capability_read_word(dd->pcidev, | 511 | ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl); |
| 517 | PCI_EXP_DEVCTL, &ectl); | 512 | if ((!ret) && !(ectl & PCI_EXP_DEVCTL_EXT_TAG)) { |
| 518 | if (ret) { | ||
| 519 | dd_dev_err(dd, "Unable to read from PCI config\n"); | ||
| 520 | return ret; | ||
| 521 | } | ||
| 522 | |||
| 523 | if (!(ectl & PCI_EXP_DEVCTL_EXT_TAG)) { | ||
| 524 | dd_dev_info(dd, "Enabling PCIe extended tags\n"); | 513 | dd_dev_info(dd, "Enabling PCIe extended tags\n"); |
| 525 | ectl |= PCI_EXP_DEVCTL_EXT_TAG; | 514 | ectl |= PCI_EXP_DEVCTL_EXT_TAG; |
| 526 | ret = pcie_capability_write_word(dd->pcidev, | 515 | ret = pcie_capability_write_word(dd->pcidev, |
| 527 | PCI_EXP_DEVCTL, ectl); | 516 | PCI_EXP_DEVCTL, ectl); |
| 528 | if (ret) { | 517 | if (ret) |
| 529 | dd_dev_err(dd, "Unable to write to PCI config\n"); | 518 | dd_dev_info(dd, "Unable to write to PCI config\n"); |
| 530 | return ret; | ||
| 531 | } | ||
| 532 | } | 519 | } |
| 533 | /* Find out supported and configured values for parent (root) */ | 520 | /* Find out supported and configured values for parent (root) */ |
| 534 | parent = dd->pcidev->bus->self; | 521 | parent = dd->pcidev->bus->self; |
| @@ -536,15 +523,22 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) | |||
| 536 | * The driver cannot perform the tuning if it does not have | 523 | * The driver cannot perform the tuning if it does not have |
| 537 | * access to the upstream component. | 524 | * access to the upstream component. |
| 538 | */ | 525 | */ |
| 539 | if (!parent) | 526 | if (!parent) { |
| 540 | return -EINVAL; | 527 | dd_dev_info(dd, "Parent not found\n"); |
| 528 | return; | ||
| 529 | } | ||
| 541 | if (!pci_is_root_bus(parent->bus)) { | 530 | if (!pci_is_root_bus(parent->bus)) { |
| 542 | dd_dev_info(dd, "Parent not root\n"); | 531 | dd_dev_info(dd, "Parent not root\n"); |
| 543 | return -EINVAL; | 532 | return; |
| 533 | } | ||
| 534 | if (!pci_is_pcie(parent)) { | ||
| 535 | dd_dev_info(dd, "Parent is not PCI Express capable\n"); | ||
| 536 | return; | ||
| 537 | } | ||
| 538 | if (!pci_is_pcie(dd->pcidev)) { | ||
| 539 | dd_dev_info(dd, "PCI device is not PCI Express capable\n"); | ||
| 540 | return; | ||
| 544 | } | 541 | } |
| 545 | |||
| 546 | if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev)) | ||
| 547 | return -EINVAL; | ||
| 548 | rc_mpss = parent->pcie_mpss; | 542 | rc_mpss = parent->pcie_mpss; |
| 549 | rc_mps = ffs(pcie_get_mps(parent)) - 8; | 543 | rc_mps = ffs(pcie_get_mps(parent)) - 8; |
| 550 | /* Find out supported and configured values for endpoint (us) */ | 544 | /* Find out supported and configured values for endpoint (us) */ |
| @@ -590,8 +584,6 @@ static int tune_pcie_caps(struct hfi1_devdata *dd) | |||
| 590 | ep_mrrs = max_mrrs; | 584 | ep_mrrs = max_mrrs; |
| 591 | pcie_set_readrq(dd->pcidev, ep_mrrs); | 585 | pcie_set_readrq(dd->pcidev, ep_mrrs); |
| 592 | } | 586 | } |
| 593 | |||
| 594 | return 0; | ||
| 595 | } | 587 | } |
| 596 | 588 | ||
| 597 | /* End of PCIe capability tuning */ | 589 | /* End of PCIe capability tuning */ |
