aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2008-11-21 20:17:04 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-21 20:17:04 -0500
commit52f4490c3b6dcb1e8dec7ff9f1c35f09bd7c136f (patch)
tree2629fc55c5cf9ca145a9e31b01840beec6635a9b /drivers
parentad8292681a629cdb16bb19ee7d721b457c32a23a (diff)
tg3: Qualify use of tp->pcix_cap
This patch makes sure the device is a PCIX device before attempting to use the pcix_cap device structure member. This is prep work for the following patch. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/tg3.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 0a82ea878aea..821e3812c085 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -5876,7 +5876,7 @@ static void tg3_restore_pci_state(struct tg3 *tp)
5876 } 5876 }
5877 5877
5878 /* Make sure PCI-X relaxed ordering bit is clear. */ 5878 /* Make sure PCI-X relaxed ordering bit is clear. */
5879 if (tp->pcix_cap) { 5879 if (tp->tg3_flags & TG3_FLAG_PCIX_MODE) {
5880 u16 pcix_cmd; 5880 u16 pcix_cmd;
5881 5881
5882 pci_read_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD, 5882 pci_read_config_word(tp->pdev, tp->pcix_cap + PCI_X_CMD,
@@ -12190,6 +12190,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12190 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) 12190 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS))
12191 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE; 12191 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
12192 12192
12193 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE,
12194 &pci_state_reg);
12195
12193 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP); 12196 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
12194 if (pcie_cap != 0) { 12197 if (pcie_cap != 0) {
12195 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 12198 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
@@ -12205,8 +12208,20 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12205 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) 12208 if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN)
12206 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2; 12209 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_2;
12207 } 12210 }
12208 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) 12211 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) {
12209 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 12212 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
12213 } else if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ||
12214 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) {
12215 tp->pcix_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_PCIX);
12216 if (!tp->pcix_cap) {
12217 printk(KERN_ERR PFX "Cannot find PCI-X "
12218 "capability, aborting.\n");
12219 return -EIO;
12220 }
12221
12222 if (!(pci_state_reg & PCISTATE_CONV_PCI_MODE))
12223 tp->tg3_flags |= TG3_FLAG_PCIX_MODE;
12224 }
12210 12225
12211 /* If we have an AMD 762 or VIA K8T800 chipset, write 12226 /* If we have an AMD 762 or VIA K8T800 chipset, write
12212 * reordering to the mailbox registers done by the host 12227 * reordering to the mailbox registers done by the host
@@ -12231,29 +12246,18 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12231 cacheline_sz_reg); 12246 cacheline_sz_reg);
12232 } 12247 }
12233 12248
12234 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) || 12249 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) {
12235 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { 12250 /* 5700 BX chips need to have their TX producer index
12236 tp->pcix_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_PCIX); 12251 * mailboxes written twice to workaround a bug.
12237 if (!tp->pcix_cap) { 12252 */
12238 printk(KERN_ERR PFX "Cannot find PCI-X " 12253 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG;
12239 "capability, aborting.\n");
12240 return -EIO;
12241 }
12242 }
12243
12244 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE,
12245 &pci_state_reg);
12246
12247 if (tp->pcix_cap && (pci_state_reg & PCISTATE_CONV_PCI_MODE) == 0) {
12248 tp->tg3_flags |= TG3_FLAG_PCIX_MODE;
12249 12254
12250 /* If this is a 5700 BX chipset, and we are in PCI-X 12255 /* If we are in PCI-X mode, enable register write workaround.
12251 * mode, enable register write workaround.
12252 * 12256 *
12253 * The workaround is to use indirect register accesses 12257 * The workaround is to use indirect register accesses
12254 * for all chip writes not to mailbox registers. 12258 * for all chip writes not to mailbox registers.
12255 */ 12259 */
12256 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) { 12260 if (tp->tg3_flags & TG3_FLAG_PCIX_MODE) {
12257 u32 pm_reg; 12261 u32 pm_reg;
12258 12262
12259 tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG; 12263 tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG;
@@ -12278,12 +12282,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12278 } 12282 }
12279 } 12283 }
12280 12284
12281 /* 5700 BX chips need to have their TX producer index mailboxes
12282 * written twice to workaround a bug.
12283 */
12284 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX)
12285 tp->tg3_flags |= TG3_FLAG_TXD_MBOX_HWBUG;
12286
12287 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0) 12285 if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0)
12288 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED; 12286 tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED;
12289 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0) 12287 if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0)