aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorJon Mason <jdmason@kudzu.us>2011-06-27 08:56:50 -0400
committerDavid S. Miller <davem@davemloft.net>2011-06-28 00:38:45 -0400
commit708ebb3a51489e70bc2b67b2772deea336eba849 (patch)
treec828b1e143ad95e0c5c8c83bedae9225db34dd01 /drivers/net/tg3.c
parentec0d75518cb06261f1823fa2713fe52b9b26455e (diff)
tg3: remove unnecessary read of PCI_CAP_ID_EXP
The PCIE capability offset is saved during PCI bus walking. Use the value from pci_dev instead of checking in the driver and saving it off the the driver specific structure. It will remove an unnecessary search in the PCI configuration space if this value is referenced instead of reacquiring it. v2 of the patch re-adds the PCI_EXPRESS flag and adds comments describing why it is necessary. [ pdev->pcie_cap --> pci_pcie_cap(pdev) -DaveM ] Signed-off-by: Jon Mason <jdmason@kudzu.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 97cd02d08021..8211b9a29d6d 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -2679,11 +2679,11 @@ static int tg3_power_down_prepare(struct tg3 *tp)
2679 u16 lnkctl; 2679 u16 lnkctl;
2680 2680
2681 pci_read_config_word(tp->pdev, 2681 pci_read_config_word(tp->pdev,
2682 tp->pcie_cap + PCI_EXP_LNKCTL, 2682 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
2683 &lnkctl); 2683 &lnkctl);
2684 lnkctl |= PCI_EXP_LNKCTL_CLKREQ_EN; 2684 lnkctl |= PCI_EXP_LNKCTL_CLKREQ_EN;
2685 pci_write_config_word(tp->pdev, 2685 pci_write_config_word(tp->pdev,
2686 tp->pcie_cap + PCI_EXP_LNKCTL, 2686 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
2687 lnkctl); 2687 lnkctl);
2688 } 2688 }
2689 2689
@@ -3485,7 +3485,7 @@ relink:
3485 u16 oldlnkctl, newlnkctl; 3485 u16 oldlnkctl, newlnkctl;
3486 3486
3487 pci_read_config_word(tp->pdev, 3487 pci_read_config_word(tp->pdev,
3488 tp->pcie_cap + PCI_EXP_LNKCTL, 3488 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
3489 &oldlnkctl); 3489 &oldlnkctl);
3490 if (tp->link_config.active_speed == SPEED_100 || 3490 if (tp->link_config.active_speed == SPEED_100 ||
3491 tp->link_config.active_speed == SPEED_10) 3491 tp->link_config.active_speed == SPEED_10)
@@ -3494,7 +3494,7 @@ relink:
3494 newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN; 3494 newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN;
3495 if (newlnkctl != oldlnkctl) 3495 if (newlnkctl != oldlnkctl)
3496 pci_write_config_word(tp->pdev, 3496 pci_write_config_word(tp->pdev,
3497 tp->pcie_cap + PCI_EXP_LNKCTL, 3497 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
3498 newlnkctl); 3498 newlnkctl);
3499 } 3499 }
3500 3500
@@ -7226,7 +7226,7 @@ static int tg3_chip_reset(struct tg3 *tp)
7226 7226
7227 udelay(120); 7227 udelay(120);
7228 7228
7229 if (tg3_flag(tp, PCI_EXPRESS) && tp->pcie_cap) { 7229 if (tg3_flag(tp, PCI_EXPRESS) && pci_pcie_cap(tp->pdev)) {
7230 u16 val16; 7230 u16 val16;
7231 7231
7232 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) { 7232 if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) {
@@ -7244,7 +7244,7 @@ static int tg3_chip_reset(struct tg3 *tp)
7244 7244
7245 /* Clear the "no snoop" and "relaxed ordering" bits. */ 7245 /* Clear the "no snoop" and "relaxed ordering" bits. */
7246 pci_read_config_word(tp->pdev, 7246 pci_read_config_word(tp->pdev,
7247 tp->pcie_cap + PCI_EXP_DEVCTL, 7247 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL,
7248 &val16); 7248 &val16);
7249 val16 &= ~(PCI_EXP_DEVCTL_RELAX_EN | 7249 val16 &= ~(PCI_EXP_DEVCTL_RELAX_EN |
7250 PCI_EXP_DEVCTL_NOSNOOP_EN); 7250 PCI_EXP_DEVCTL_NOSNOOP_EN);
@@ -7255,14 +7255,14 @@ static int tg3_chip_reset(struct tg3 *tp)
7255 if (!tg3_flag(tp, CPMU_PRESENT)) 7255 if (!tg3_flag(tp, CPMU_PRESENT))
7256 val16 &= ~PCI_EXP_DEVCTL_PAYLOAD; 7256 val16 &= ~PCI_EXP_DEVCTL_PAYLOAD;
7257 pci_write_config_word(tp->pdev, 7257 pci_write_config_word(tp->pdev,
7258 tp->pcie_cap + PCI_EXP_DEVCTL, 7258 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL,
7259 val16); 7259 val16);
7260 7260
7261 pcie_set_readrq(tp->pdev, tp->pcie_readrq); 7261 pcie_set_readrq(tp->pdev, tp->pcie_readrq);
7262 7262
7263 /* Clear error status */ 7263 /* Clear error status */
7264 pci_write_config_word(tp->pdev, 7264 pci_write_config_word(tp->pdev,
7265 tp->pcie_cap + PCI_EXP_DEVSTA, 7265 pci_pcie_cap(tp->pdev) + PCI_EXP_DEVSTA,
7266 PCI_EXP_DEVSTA_CED | 7266 PCI_EXP_DEVSTA_CED |
7267 PCI_EXP_DEVSTA_NFED | 7267 PCI_EXP_DEVSTA_NFED |
7268 PCI_EXP_DEVSTA_FED | 7268 PCI_EXP_DEVSTA_FED |
@@ -13777,8 +13777,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13777 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, 13777 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE,
13778 &pci_state_reg); 13778 &pci_state_reg);
13779 13779
13780 tp->pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP); 13780 if (pci_is_pcie(tp->pdev)) {
13781 if (tp->pcie_cap != 0) {
13782 u16 lnkctl; 13781 u16 lnkctl;
13783 13782
13784 tg3_flag_set(tp, PCI_EXPRESS); 13783 tg3_flag_set(tp, PCI_EXPRESS);
@@ -13791,7 +13790,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13791 pcie_set_readrq(tp->pdev, tp->pcie_readrq); 13790 pcie_set_readrq(tp->pdev, tp->pcie_readrq);
13792 13791
13793 pci_read_config_word(tp->pdev, 13792 pci_read_config_word(tp->pdev,
13794 tp->pcie_cap + PCI_EXP_LNKCTL, 13793 pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL,
13795 &lnkctl); 13794 &lnkctl);
13796 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) { 13795 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) {
13797 if (GET_ASIC_REV(tp->pci_chip_rev_id) == 13796 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
@@ -13808,6 +13807,10 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13808 tg3_flag_set(tp, L1PLLPD_EN); 13807 tg3_flag_set(tp, L1PLLPD_EN);
13809 } 13808 }
13810 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) { 13809 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) {
13810 /* BCM5785 devices are effectively PCIe devices, and should
13811 * follow PCIe codepaths, but do not have a PCIe capabilities
13812 * section.
13813 */
13811 tg3_flag_set(tp, PCI_EXPRESS); 13814 tg3_flag_set(tp, PCI_EXPRESS);
13812 } else if (!tg3_flag(tp, 5705_PLUS) || 13815 } else if (!tg3_flag(tp, 5705_PLUS) ||
13813 tg3_flag(tp, 5780_CLASS)) { 13816 tg3_flag(tp, 5780_CLASS)) {