1 From: Michael Chan <mchan@broadcom.com>
2 Subject: Check netif_running in most ethtool operations
3 Acked-by: Karsten Keil <kkeil@novell.com>
6 We need to check netif_running() state in most ethtool operations
7 and properly handle the !netif_running() state where the chip is
8 in an uninitailzed state or low power state that may not accept
11 Signed-off-by: Michael Chan <mchan@broadcom.com>
12 Signed-off-by: Benjamin Li <benli@broadcom.com>
13 Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
19 drivers/net/bnx2.c | 40 ++++++++++++++++++++++++++++++++--------
20 1 file changed, 32 insertions(+), 8 deletions(-)
22 --- a/drivers/net/bnx2.c
23 +++ b/drivers/net/bnx2.c
24 @@ -3252,6 +3252,9 @@ bnx2_set_rx_mode(struct net_device *dev)
25 struct dev_addr_list *uc_ptr;
28 + if (!netif_running(dev))
31 spin_lock_bh(&bp->phy_lock);
33 rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
34 @@ -5525,6 +5528,9 @@ bnx2_test_link(struct bnx2 *bp)
38 + if (!netif_running(bp->dev))
41 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) {
44 @@ -6489,6 +6495,9 @@ bnx2_nway_reset(struct net_device *dev)
45 struct bnx2 *bp = netdev_priv(dev);
48 + if (!netif_running(dev))
51 if (!(bp->autoneg & AUTONEG_SPEED)) {
54 @@ -6544,6 +6553,9 @@ bnx2_get_eeprom(struct net_device *dev,
55 struct bnx2 *bp = netdev_priv(dev);
58 + if (!netif_running(dev))
61 /* parameters already validated in ethtool_get_eeprom */
63 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
64 @@ -6558,6 +6570,9 @@ bnx2_set_eeprom(struct net_device *dev,
65 struct bnx2 *bp = netdev_priv(dev);
68 + if (!netif_running(dev))
71 /* parameters already validated in ethtool_set_eeprom */
73 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
74 @@ -6722,11 +6737,11 @@ bnx2_set_pauseparam(struct net_device *d
75 bp->autoneg &= ~AUTONEG_FLOW_CTRL;
78 - spin_lock_bh(&bp->phy_lock);
80 - bnx2_setup_phy(bp, bp->phy_port);
82 - spin_unlock_bh(&bp->phy_lock);
83 + if (netif_running(dev)) {
84 + spin_lock_bh(&bp->phy_lock);
85 + bnx2_setup_phy(bp, bp->phy_port);
86 + spin_unlock_bh(&bp->phy_lock);
91 @@ -6917,6 +6932,8 @@ bnx2_self_test(struct net_device *dev, s
93 struct bnx2 *bp = netdev_priv(dev);
95 + bnx2_set_power_state(bp, PCI_D0);
97 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
98 if (etest->flags & ETH_TEST_FL_OFFLINE) {
100 @@ -6936,9 +6953,8 @@ bnx2_self_test(struct net_device *dev, s
101 if ((buf[2] = bnx2_test_loopback(bp)) != 0)
102 etest->flags |= ETH_TEST_FL_FAILED;
104 - if (!netif_running(bp->dev)) {
105 - bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
107 + if (!netif_running(bp->dev))
108 + bnx2_shutdown_chip(bp);
110 bnx2_init_nic(bp, 1);
111 bnx2_netif_start(bp);
112 @@ -6966,6 +6982,8 @@ bnx2_self_test(struct net_device *dev, s
113 etest->flags |= ETH_TEST_FL_FAILED;
116 + if (!netif_running(bp->dev))
117 + bnx2_set_power_state(bp, PCI_D3hot);
121 @@ -7031,6 +7049,8 @@ bnx2_phys_id(struct net_device *dev, u32
125 + bnx2_set_power_state(bp, PCI_D0);
130 @@ -7055,6 +7075,10 @@ bnx2_phys_id(struct net_device *dev, u32
132 REG_WR(bp, BNX2_EMAC_LED, 0);
133 REG_WR(bp, BNX2_MISC_CFG, save);
135 + if (!netif_running(dev))
136 + bnx2_set_power_state(bp, PCI_D3hot);