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>
This commit is contained in:
parent
d658266ed6
commit
1a821ca595
1 changed files with 23 additions and 10 deletions
|
@ -183,6 +183,9 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
|
||||||
|
msleep(1);
|
||||||
|
|
||||||
if (ecmd->autoneg == AUTONEG_ENABLE) {
|
if (ecmd->autoneg == AUTONEG_ENABLE) {
|
||||||
hw->autoneg = 1;
|
hw->autoneg = 1;
|
||||||
if (hw->media_type == e1000_media_type_fiber)
|
if (hw->media_type == e1000_media_type_fiber)
|
||||||
|
@ -199,16 +202,20 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
|
||||||
ADVERTISED_TP;
|
ADVERTISED_TP;
|
||||||
ecmd->advertising = hw->autoneg_advertised;
|
ecmd->advertising = hw->autoneg_advertised;
|
||||||
} else
|
} else
|
||||||
if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex))
|
if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
|
||||||
|
clear_bit(__E1000_RESETTING, &adapter->flags);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* reset the link */
|
/* reset the link */
|
||||||
|
|
||||||
if (netif_running(adapter->netdev))
|
if (netif_running(adapter->netdev)) {
|
||||||
e1000_reinit_locked(adapter);
|
e1000_down(adapter);
|
||||||
else
|
e1000_up(adapter);
|
||||||
|
} else
|
||||||
e1000_reset(adapter);
|
e1000_reset(adapter);
|
||||||
|
|
||||||
|
clear_bit(__E1000_RESETTING, &adapter->flags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,9 +245,13 @@ e1000_set_pauseparam(struct net_device *netdev,
|
||||||
{
|
{
|
||||||
struct e1000_adapter *adapter = netdev_priv(netdev);
|
struct e1000_adapter *adapter = netdev_priv(netdev);
|
||||||
struct e1000_hw *hw = &adapter->hw;
|
struct e1000_hw *hw = &adapter->hw;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
adapter->fc_autoneg = pause->autoneg;
|
adapter->fc_autoneg = pause->autoneg;
|
||||||
|
|
||||||
|
while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
|
||||||
|
msleep(1);
|
||||||
|
|
||||||
if (pause->rx_pause && pause->tx_pause)
|
if (pause->rx_pause && pause->tx_pause)
|
||||||
hw->fc = e1000_fc_full;
|
hw->fc = e1000_fc_full;
|
||||||
else if (pause->rx_pause && !pause->tx_pause)
|
else if (pause->rx_pause && !pause->tx_pause)
|
||||||
|
@ -253,15 +264,17 @@ e1000_set_pauseparam(struct net_device *netdev,
|
||||||
hw->original_fc = hw->fc;
|
hw->original_fc = hw->fc;
|
||||||
|
|
||||||
if (adapter->fc_autoneg == AUTONEG_ENABLE) {
|
if (adapter->fc_autoneg == AUTONEG_ENABLE) {
|
||||||
if (netif_running(adapter->netdev))
|
if (netif_running(adapter->netdev)) {
|
||||||
e1000_reinit_locked(adapter);
|
e1000_down(adapter);
|
||||||
else
|
e1000_up(adapter);
|
||||||
|
} else
|
||||||
e1000_reset(adapter);
|
e1000_reset(adapter);
|
||||||
} else
|
} else
|
||||||
return ((hw->media_type == e1000_media_type_fiber) ?
|
retval = ((hw->media_type == e1000_media_type_fiber) ?
|
||||||
e1000_setup_link(hw) : e1000_force_mac_fc(hw));
|
e1000_setup_link(hw) : e1000_force_mac_fc(hw));
|
||||||
|
|
||||||
return 0;
|
clear_bit(__E1000_RESETTING, &adapter->flags);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
|
|
Reference in a new issue