Re: [PATCH net-next v7 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes

From: Russell King (Oracle)
Date: Thu Feb 29 2024 - 16:20:05 EST


On Thu, Feb 29, 2024 at 03:07:57PM +0100, Oleksij Rempel wrote:
> +static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
> + struct ethtool_keee *data)
> +{
> + if (phydev->eee_cfg.tx_lpi_enabled != data->tx_lpi_enabled ||
> + phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) {
> + eee_to_eeecfg(data, &phydev->eee_cfg);
> + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
> + if (phydev->link) {
> + phy_link_down(phydev);
> + phy_link_up(phydev);

Unfortunately, this isn't sufficient in all cases. Phylink will be fine
with this though.

If we take a look at fec_enet_adjust_link(), then we can see it tests
phydev->link directly (which it has to, because there's nothing else
to determine whether the link is up or down. FEC will cope with its
fec_enet_adjust_link() being called with no changes however.

In order to properly resolve this, I think we need:

if (phydev->link) {
phydev->link = false;
phy_link_down(phydev);
phydev->link = true;
phy_link_up(phydev);

to properly avoid the issue I've referred to.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!