Commit 02758755 authored by David S. Miller's avatar David S. Miller

Merge branch 'Two-phylink-pause-fixes'

Russell King says:

====================
Two phylink pause fixes

While testing, I discovered two issues with ethtool -A with phylink.
First, if there is a PHY bound to the network device, we hit a
deadlock when phylib tries to notify us of the link changing as a
result of triggering a renegotiation.

Second, when we are manually forcing the pause settings, and there
is no renegotiation triggered, we do not update the MAC via the new
mac_link_up approach.

These two patches solve both problems, and will need to be backported
to v5.7; they do not apply cleanly there due to the introduction of
PCS in the v5.8 merge window.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 41b14fb8 2e919bc4
...@@ -1463,6 +1463,8 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1463,6 +1463,8 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
struct ethtool_pauseparam *pause) struct ethtool_pauseparam *pause)
{ {
struct phylink_link_state *config = &pl->link_config; struct phylink_link_state *config = &pl->link_config;
bool manual_changed;
int pause_state;
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -1477,15 +1479,15 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1477,15 +1479,15 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
!pause->autoneg && pause->rx_pause != pause->tx_pause) !pause->autoneg && pause->rx_pause != pause->tx_pause)
return -EINVAL; return -EINVAL;
mutex_lock(&pl->state_mutex); pause_state = 0;
config->pause = 0;
if (pause->autoneg) if (pause->autoneg)
config->pause |= MLO_PAUSE_AN; pause_state |= MLO_PAUSE_AN;
if (pause->rx_pause) if (pause->rx_pause)
config->pause |= MLO_PAUSE_RX; pause_state |= MLO_PAUSE_RX;
if (pause->tx_pause) if (pause->tx_pause)
config->pause |= MLO_PAUSE_TX; pause_state |= MLO_PAUSE_TX;
mutex_lock(&pl->state_mutex);
/* /*
* See the comments for linkmode_set_pause(), wrt the deficiencies * See the comments for linkmode_set_pause(), wrt the deficiencies
* with the current implementation. A solution to this issue would * with the current implementation. A solution to this issue would
...@@ -1502,18 +1504,35 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1502,18 +1504,35 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
linkmode_set_pause(config->advertising, pause->tx_pause, linkmode_set_pause(config->advertising, pause->tx_pause,
pause->rx_pause); pause->rx_pause);
/* If we have a PHY, phylib will call our link state function if the manual_changed = (config->pause ^ pause_state) & MLO_PAUSE_AN ||
* mode has changed, which will trigger a resolve and update the MAC (!(pause_state & MLO_PAUSE_AN) &&
* configuration. (config->pause ^ pause_state) & MLO_PAUSE_TXRX_MASK);
config->pause = pause_state;
if (!pl->phydev && !test_bit(PHYLINK_DISABLE_STOPPED,
&pl->phylink_disable_state))
phylink_pcs_config(pl, true, &pl->link_config);
mutex_unlock(&pl->state_mutex);
/* If we have a PHY, a change of the pause frame advertisement will
* cause phylib to renegotiate (if AN is enabled) which will in turn
* call our phylink_phy_change() and trigger a resolve. Note that
* we can't hold our state mutex while calling phy_set_asym_pause().
*/ */
if (pl->phydev) { if (pl->phydev)
phy_set_asym_pause(pl->phydev, pause->rx_pause, phy_set_asym_pause(pl->phydev, pause->rx_pause,
pause->tx_pause); pause->tx_pause);
} else if (!test_bit(PHYLINK_DISABLE_STOPPED,
&pl->phylink_disable_state)) { /* If the manual pause settings changed, make sure we trigger a
phylink_pcs_config(pl, true, &pl->link_config); * resolve to update their state; we can not guarantee that the
* link will cycle.
*/
if (manual_changed) {
pl->mac_link_dropped = true;
phylink_run_resolve(pl);
} }
mutex_unlock(&pl->state_mutex);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment