]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.drivers/bnx2-check-running.patch
Fix oinkmaster patch.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.drivers / bnx2-check-running.patch
CommitLineData
2cb7cef9
BS
1From: Michael Chan <mchan@broadcom.com>
2Subject: Check netif_running in most ethtool operations
3Acked-by: Karsten Keil <kkeil@novell.com>
4Reference: bnc#440052
5
6We 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
9 any MMIO.
10
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>
15
16Backport to 2.6.27
17
18---
19 drivers/net/bnx2.c | 40 ++++++++++++++++++++++++++++++++--------
20 1 file changed, 32 insertions(+), 8 deletions(-)
21
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;
26 int i;
27
28+ if (!netif_running(dev))
29+ return;
30+
31 spin_lock_bh(&bp->phy_lock);
32
33 rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS |
34@@ -5525,6 +5528,9 @@ bnx2_test_link(struct bnx2 *bp)
35 {
36 u32 bmsr;
37
38+ if (!netif_running(bp->dev))
39+ return -ENODEV;
40+
41 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) {
42 if (bp->link_up)
43 return 0;
44@@ -6489,6 +6495,9 @@ bnx2_nway_reset(struct net_device *dev)
45 struct bnx2 *bp = netdev_priv(dev);
46 u32 bmcr;
47
48+ if (!netif_running(dev))
49+ return -EAGAIN;
50+
51 if (!(bp->autoneg & AUTONEG_SPEED)) {
52 return -EINVAL;
53 }
54@@ -6544,6 +6553,9 @@ bnx2_get_eeprom(struct net_device *dev,
55 struct bnx2 *bp = netdev_priv(dev);
56 int rc;
57
58+ if (!netif_running(dev))
59+ return -EAGAIN;
60+
61 /* parameters already validated in ethtool_get_eeprom */
62
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);
66 int rc;
67
68+ if (!netif_running(dev))
69+ return -EAGAIN;
70+
71 /* parameters already validated in ethtool_set_eeprom */
72
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;
76 }
77
78- spin_lock_bh(&bp->phy_lock);
79-
80- bnx2_setup_phy(bp, bp->phy_port);
81-
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);
87+ }
88
89 return 0;
90 }
91@@ -6917,6 +6932,8 @@ bnx2_self_test(struct net_device *dev, s
92 {
93 struct bnx2 *bp = netdev_priv(dev);
94
95+ bnx2_set_power_state(bp, PCI_D0);
96+
97 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
98 if (etest->flags & ETH_TEST_FL_OFFLINE) {
99 int i;
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;
103
104- if (!netif_running(bp->dev)) {
105- bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
106- }
107+ if (!netif_running(bp->dev))
108+ bnx2_shutdown_chip(bp);
109 else {
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;
114
115 }
116+ if (!netif_running(bp->dev))
117+ bnx2_set_power_state(bp, PCI_D3hot);
118 }
119
120 static void
121@@ -7031,6 +7049,8 @@ bnx2_phys_id(struct net_device *dev, u32
122 int i;
123 u32 save;
124
125+ bnx2_set_power_state(bp, PCI_D0);
126+
127 if (data == 0)
128 data = 2;
129
130@@ -7055,6 +7075,10 @@ bnx2_phys_id(struct net_device *dev, u32
131 }
132 REG_WR(bp, BNX2_EMAC_LED, 0);
133 REG_WR(bp, BNX2_MISC_CFG, save);
134+
135+ if (!netif_running(dev))
136+ bnx2_set_power_state(bp, PCI_D3hot);
137+
138 return 0;
139 }
140