diff options
| -rw-r--r-- | drivers/infiniband/hw/qib/qib_pcie.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/infiniband/hw/qib/qib_pcie.c b/drivers/infiniband/hw/qib/qib_pcie.c index 062c301ebf53..900137173210 100644 --- a/drivers/infiniband/hw/qib/qib_pcie.c +++ b/drivers/infiniband/hw/qib/qib_pcie.c | |||
| @@ -273,10 +273,9 @@ int qib_pcie_params(struct qib_devdata *dd, u32 minw, u32 *nent, | |||
| 273 | struct qib_msix_entry *entry) | 273 | struct qib_msix_entry *entry) |
| 274 | { | 274 | { |
| 275 | u16 linkstat, speed; | 275 | u16 linkstat, speed; |
| 276 | int pos = 0, pose, ret = 1; | 276 | int pos = 0, ret = 1; |
| 277 | 277 | ||
| 278 | pose = pci_pcie_cap(dd->pcidev); | 278 | if (!pci_is_pcie(dd->pcidev)) { |
| 279 | if (!pose) { | ||
| 280 | qib_dev_err(dd, "Can't find PCI Express capability!\n"); | 279 | qib_dev_err(dd, "Can't find PCI Express capability!\n"); |
| 281 | /* set up something... */ | 280 | /* set up something... */ |
| 282 | dd->lbus_width = 1; | 281 | dd->lbus_width = 1; |
| @@ -298,7 +297,7 @@ int qib_pcie_params(struct qib_devdata *dd, u32 minw, u32 *nent, | |||
| 298 | if (!pos) | 297 | if (!pos) |
| 299 | qib_enable_intx(dd->pcidev); | 298 | qib_enable_intx(dd->pcidev); |
| 300 | 299 | ||
| 301 | pci_read_config_word(dd->pcidev, pose + PCI_EXP_LNKSTA, &linkstat); | 300 | pcie_capability_read_word(dd->pcidev, PCI_EXP_LNKSTA, &linkstat); |
| 302 | /* | 301 | /* |
| 303 | * speed is bits 0-3, linkwidth is bits 4-8 | 302 | * speed is bits 0-3, linkwidth is bits 4-8 |
| 304 | * no defines for them in headers | 303 | * no defines for them in headers |
| @@ -516,7 +515,6 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd) | |||
| 516 | { | 515 | { |
| 517 | int r; | 516 | int r; |
| 518 | struct pci_dev *parent; | 517 | struct pci_dev *parent; |
| 519 | int ppos; | ||
| 520 | u16 devid; | 518 | u16 devid; |
| 521 | u32 mask, bits, val; | 519 | u32 mask, bits, val; |
| 522 | 520 | ||
| @@ -529,8 +527,7 @@ static int qib_tune_pcie_coalesce(struct qib_devdata *dd) | |||
| 529 | qib_devinfo(dd->pcidev, "Parent not root\n"); | 527 | qib_devinfo(dd->pcidev, "Parent not root\n"); |
| 530 | return 1; | 528 | return 1; |
| 531 | } | 529 | } |
| 532 | ppos = pci_pcie_cap(parent); | 530 | if (!pci_is_pcie(parent)) |
| 533 | if (!ppos) | ||
| 534 | return 1; | 531 | return 1; |
| 535 | if (parent->vendor != 0x8086) | 532 | if (parent->vendor != 0x8086) |
| 536 | return 1; | 533 | return 1; |
| @@ -587,7 +584,6 @@ static int qib_tune_pcie_caps(struct qib_devdata *dd) | |||
| 587 | { | 584 | { |
| 588 | int ret = 1; /* Assume the worst */ | 585 | int ret = 1; /* Assume the worst */ |
| 589 | struct pci_dev *parent; | 586 | struct pci_dev *parent; |
| 590 | int ppos, epos; | ||
| 591 | u16 pcaps, pctl, ecaps, ectl; | 587 | u16 pcaps, pctl, ecaps, ectl; |
| 592 | int rc_sup, ep_sup; | 588 | int rc_sup, ep_sup; |
| 593 | int rc_cur, ep_cur; | 589 | int rc_cur, ep_cur; |
| @@ -598,19 +594,15 @@ static int qib_tune_pcie_caps(struct qib_devdata *dd) | |||
| 598 | qib_devinfo(dd->pcidev, "Parent not root\n"); | 594 | qib_devinfo(dd->pcidev, "Parent not root\n"); |
| 599 | goto bail; | 595 | goto bail; |
| 600 | } | 596 | } |
| 601 | ppos = pci_pcie_cap(parent); | 597 | |
| 602 | if (ppos) { | 598 | if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev)) |
| 603 | pci_read_config_word(parent, ppos + PCI_EXP_DEVCAP, &pcaps); | ||
| 604 | pci_read_config_word(parent, ppos + PCI_EXP_DEVCTL, &pctl); | ||
| 605 | } else | ||
| 606 | goto bail; | 599 | goto bail; |
| 600 | pcie_capability_read_word(parent, PCI_EXP_DEVCAP, &pcaps); | ||
| 601 | pcie_capability_read_word(parent, PCI_EXP_DEVCTL, &pctl); | ||
| 607 | /* Find out supported and configured values for endpoint (us) */ | 602 | /* Find out supported and configured values for endpoint (us) */ |
| 608 | epos = pci_pcie_cap(dd->pcidev); | 603 | pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCAP, &ecaps); |
| 609 | if (epos) { | 604 | pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl); |
| 610 | pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCAP, &ecaps); | 605 | |
| 611 | pci_read_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, &ectl); | ||
| 612 | } else | ||
| 613 | goto bail; | ||
| 614 | ret = 0; | 606 | ret = 0; |
| 615 | /* Find max payload supported by root, endpoint */ | 607 | /* Find max payload supported by root, endpoint */ |
| 616 | rc_sup = fld2val(pcaps, PCI_EXP_DEVCAP_PAYLOAD); | 608 | rc_sup = fld2val(pcaps, PCI_EXP_DEVCAP_PAYLOAD); |
| @@ -629,14 +621,14 @@ static int qib_tune_pcie_caps(struct qib_devdata *dd) | |||
| 629 | rc_cur = rc_sup; | 621 | rc_cur = rc_sup; |
| 630 | pctl = (pctl & ~PCI_EXP_DEVCTL_PAYLOAD) | | 622 | pctl = (pctl & ~PCI_EXP_DEVCTL_PAYLOAD) | |
| 631 | val2fld(rc_cur, PCI_EXP_DEVCTL_PAYLOAD); | 623 | val2fld(rc_cur, PCI_EXP_DEVCTL_PAYLOAD); |
| 632 | pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); | 624 | pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl); |
| 633 | } | 625 | } |
| 634 | /* If less than (allowed, supported), bump endpoint payload */ | 626 | /* If less than (allowed, supported), bump endpoint payload */ |
| 635 | if (rc_sup > ep_cur) { | 627 | if (rc_sup > ep_cur) { |
| 636 | ep_cur = rc_sup; | 628 | ep_cur = rc_sup; |
| 637 | ectl = (ectl & ~PCI_EXP_DEVCTL_PAYLOAD) | | 629 | ectl = (ectl & ~PCI_EXP_DEVCTL_PAYLOAD) | |
| 638 | val2fld(ep_cur, PCI_EXP_DEVCTL_PAYLOAD); | 630 | val2fld(ep_cur, PCI_EXP_DEVCTL_PAYLOAD); |
| 639 | pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); | 631 | pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl); |
| 640 | } | 632 | } |
| 641 | 633 | ||
| 642 | /* | 634 | /* |
| @@ -654,13 +646,13 @@ static int qib_tune_pcie_caps(struct qib_devdata *dd) | |||
| 654 | rc_cur = rc_sup; | 646 | rc_cur = rc_sup; |
| 655 | pctl = (pctl & ~PCI_EXP_DEVCTL_READRQ) | | 647 | pctl = (pctl & ~PCI_EXP_DEVCTL_READRQ) | |
| 656 | val2fld(rc_cur, PCI_EXP_DEVCTL_READRQ); | 648 | val2fld(rc_cur, PCI_EXP_DEVCTL_READRQ); |
| 657 | pci_write_config_word(parent, ppos + PCI_EXP_DEVCTL, pctl); | 649 | pcie_capability_write_word(parent, PCI_EXP_DEVCTL, pctl); |
| 658 | } | 650 | } |
| 659 | if (rc_sup > ep_cur) { | 651 | if (rc_sup > ep_cur) { |
| 660 | ep_cur = rc_sup; | 652 | ep_cur = rc_sup; |
| 661 | ectl = (ectl & ~PCI_EXP_DEVCTL_READRQ) | | 653 | ectl = (ectl & ~PCI_EXP_DEVCTL_READRQ) | |
| 662 | val2fld(ep_cur, PCI_EXP_DEVCTL_READRQ); | 654 | val2fld(ep_cur, PCI_EXP_DEVCTL_READRQ); |
| 663 | pci_write_config_word(dd->pcidev, epos + PCI_EXP_DEVCTL, ectl); | 655 | pcie_capability_write_word(dd->pcidev, PCI_EXP_DEVCTL, ectl); |
| 664 | } | 656 | } |
| 665 | bail: | 657 | bail: |
| 666 | return ret; | 658 | return ret; |
