aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_ethtool.c
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2006-08-16 16:38:46 -0400
committerAuke Kok <juke-jan.h.kok@intel.com>2006-08-16 16:38:46 -0400
commit1a821ca59593d307e564800c2f25ed1f9e1e2a6f (patch)
tree371bbd22f21c1b1883acfe44cbefe8991006a232 /drivers/net/e1000/e1000_ethtool.c
parentd658266ed6144f9dbc785c7d5bb6e8e5e2e7f3cf (diff)
e1000: explicit locking for two ethtool path functions
Explicitly lock two more ethtool entry points completely instead of the hardware reset only to prevent a race condition. Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Diffstat (limited to 'drivers/net/e1000/e1000_ethtool.c')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 8edbc6b0b9c7..2baccf864328 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -183,6 +183,9 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
183 return -EINVAL; 183 return -EINVAL;
184 } 184 }
185 185
186 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
187 msleep(1);
188
186 if (ecmd->autoneg == AUTONEG_ENABLE) { 189 if (ecmd->autoneg == AUTONEG_ENABLE) {
187 hw->autoneg = 1; 190 hw->autoneg = 1;
188 if (hw->media_type == e1000_media_type_fiber) 191 if (hw->media_type == e1000_media_type_fiber)
@@ -199,16 +202,20 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
199 ADVERTISED_TP; 202 ADVERTISED_TP;
200 ecmd->advertising = hw->autoneg_advertised; 203 ecmd->advertising = hw->autoneg_advertised;
201 } else 204 } else
202 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) 205 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
206 clear_bit(__E1000_RESETTING, &adapter->flags);
203 return -EINVAL; 207 return -EINVAL;
208 }
204 209
205 /* reset the link */ 210 /* reset the link */
206 211
207 if (netif_running(adapter->netdev)) 212 if (netif_running(adapter->netdev)) {
208 e1000_reinit_locked(adapter); 213 e1000_down(adapter);
209 else 214 e1000_up(adapter);
215 } else
210 e1000_reset(adapter); 216 e1000_reset(adapter);
211 217
218 clear_bit(__E1000_RESETTING, &adapter->flags);
212 return 0; 219 return 0;
213} 220}
214 221
@@ -238,9 +245,13 @@ e1000_set_pauseparam(struct net_device *netdev,
238{ 245{
239 struct e1000_adapter *adapter = netdev_priv(netdev); 246 struct e1000_adapter *adapter = netdev_priv(netdev);
240 struct e1000_hw *hw = &adapter->hw; 247 struct e1000_hw *hw = &adapter->hw;
248 int retval = 0;
241 249
242 adapter->fc_autoneg = pause->autoneg; 250 adapter->fc_autoneg = pause->autoneg;
243 251
252 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
253 msleep(1);
254
244 if (pause->rx_pause && pause->tx_pause) 255 if (pause->rx_pause && pause->tx_pause)
245 hw->fc = e1000_fc_full; 256 hw->fc = e1000_fc_full;
246 else if (pause->rx_pause && !pause->tx_pause) 257 else if (pause->rx_pause && !pause->tx_pause)
@@ -253,15 +264,17 @@ e1000_set_pauseparam(struct net_device *netdev,
253 hw->original_fc = hw->fc; 264 hw->original_fc = hw->fc;
254 265
255 if (adapter->fc_autoneg == AUTONEG_ENABLE) { 266 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
256 if (netif_running(adapter->netdev)) 267 if (netif_running(adapter->netdev)) {
257 e1000_reinit_locked(adapter); 268 e1000_down(adapter);
258 else 269 e1000_up(adapter);
270 } else
259 e1000_reset(adapter); 271 e1000_reset(adapter);
260 } else 272 } else
261 return ((hw->media_type == e1000_media_type_fiber) ? 273 retval = ((hw->media_type == e1000_media_type_fiber) ?
262 e1000_setup_link(hw) : e1000_force_mac_fc(hw)); 274 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
263 275
264 return 0; 276 clear_bit(__E1000_RESETTING, &adapter->flags);
277 return retval;
265} 278}
266 279
267static uint32_t 280static uint32_t