netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>,
	Wei Fang <wei.fang@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, Shenwei Wang <shenwei.wang@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>,
	NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [PATCH net-next v5 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes
Date: Thu, 22 Feb 2024 20:51:31 -0800	[thread overview]
Message-ID: <693c8801-498d-42e0-bb4e-8a5bc07d9131@gmail.com> (raw)
In-Reply-To: <20240221062107.778661-6-o.rempel@pengutronix.de>



On 2/20/2024 10:21 PM, Oleksij Rempel wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> 
> The MAC driver changes its EEE hardware configuration in its
> adjust_link callback. This is called when auto-neg
> completes. Disabling EEE via eee_enabled false will trigger an
> autoneg, and as a result the adjust_link callback will be called with
> phydev->enable_tx_lpi set to false. Similarly, eee_enabled set to true
> and with a change of advertised link modes will result in a new
> autoneg, and a call the adjust_link call.
> 
> If set_eee is called with only a change to tx_lpi_enabled which does
> not trigger an auto-neg, it is necessary to call the adjust_link
> callback so that the MAC is reconfigured to take this change into
> account.
> 
> When setting phydev->enable_tx_lpi, take both eee_enabled and
> tx_lpi_enabled into account, so the MAC drivers just needs to act on
> phydev->enable_tx_lpi and not the whole EEE configuration.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>

Definitively an improvement! Minor nits below

> ---
>   drivers/net/phy/phy-c45.c | 11 ++++++++---
>   drivers/net/phy/phy.c     | 25 ++++++++++++++++++++++---
>   2 files changed, 30 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
> index c69568e7695e..217d4df59eb6 100644
> --- a/drivers/net/phy/phy-c45.c
> +++ b/drivers/net/phy/phy-c45.c
> @@ -1549,6 +1549,8 @@ EXPORT_SYMBOL(genphy_c45_ethtool_get_eee);
>    * advertised, but the previously advertised link modes are
>    * retained. This allows EEE to be enabled/disabled in a
>    * non-destructive way.
> + * Returns either error code, 0 if there was no change, or positive
> + * value if there was a change which triggered auto-neg.
>    */
>   int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
>   			       struct ethtool_keee *data)
> @@ -1580,9 +1582,12 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
>   	ret = genphy_c45_an_config_eee_aneg(phydev);
>   	if (ret < 0)
>   		return ret;
> -	if (ret > 0)
> -		return phy_restart_aneg(phydev);
> -
> +	if (ret > 0) {
> +		ret = phy_restart_aneg(phydev);
> +		if (ret < 0)
> +			return ret;
> +		return 1;
> +	}
>   	return 0;
>   }
>   EXPORT_SYMBOL(genphy_c45_ethtool_set_eee);
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 7f3629d56503..dad827717ad9 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -988,7 +988,8 @@ static int phy_check_link_status(struct phy_device *phydev)
>   		if (err < 0)
>   			phydev->enable_tx_lpi = false;
>   		else
> -			phydev->enable_tx_lpi = err;
> +			phydev->enable_tx_lpi = (err & phydev->eee_cfg.tx_lpi_enabled);
> +
>   		phy_link_up(phydev);
>   	} else if (!phydev->link && phydev->state != PHY_NOLINK) {
>   		phydev->state = PHY_NOLINK;
> @@ -1679,6 +1680,21 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data)
>   }
>   EXPORT_SYMBOL(phy_ethtool_get_eee);
>   
> +/* auto-neg not triggered, directly inform the MAC if something
> + * changed'

Stray ' character at the end here.

> + */
> +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) {
> +		eee_to_eeecfg(data, &phydev->eee_cfg);
> +		phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
> +		if (phydev->link)
> +			phy_link_up(phydev);
> +	}
> +}
> +
>   /**
>    * phy_ethtool_set_eee - set EEE supported and status
>    * @phydev: target phy_device struct
> @@ -1695,11 +1711,14 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data)
>   
>   	mutex_lock(&phydev->lock);
>   	ret = genphy_c45_ethtool_set_eee(phydev, data);
> -	if (!ret)
> +	if (ret >= 0) {
> +		if (ret == 0)
> +			phy_ethtool_set_eee_noneg(phydev, data);
>   		eee_to_eeecfg(data, &phydev->eee_cfg);
> +	}
>   	mutex_unlock(&phydev->lock);
>   
> -	return ret;
> +	return (ret < 0 ? ret : 0);

Don't think the parenthesis are needed but does not hurt.
-- 
Florian

  reply	other threads:[~2024-02-23  4:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21  6:20 [PATCH net-next v5 0/8] net: ethernet: Rework EEE Oleksij Rempel
2024-02-21  6:21 ` [PATCH net-next v5 1/8] net: add helpers for EEE configuration Oleksij Rempel
2024-02-23  4:53   ` Florian Fainelli
2024-02-21  6:21 ` [PATCH net-next v5 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Oleksij Rempel
2024-02-23  5:36   ` Wei Fang
2024-02-23  6:58     ` Heiner Kallweit
2024-02-21  6:21 ` [PATCH net-next v5 3/8] net: phy: Add helper to set EEE Clock stop enable bit Oleksij Rempel
2024-02-23  4:47   ` Florian Fainelli
2024-02-23  8:54     ` Oleksij Rempel
2024-02-21  6:21 ` [PATCH net-next v5 4/8] net: phy: Keep track of EEE configuration Oleksij Rempel
2024-02-23  3:25   ` Jakub Kicinski
2024-02-23  4:53   ` Florian Fainelli
2024-02-21  6:21 ` [PATCH net-next v5 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Oleksij Rempel
2024-02-23  4:51   ` Florian Fainelli [this message]
2024-02-21  6:21 ` [PATCH net-next v5 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Oleksij Rempel
2024-02-23  4:52   ` Florian Fainelli
2024-02-23  5:47     ` Oleksij Rempel
2024-02-23 11:21     ` Russell King (Oracle)
2024-02-21  6:21 ` [PATCH net-next v5 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Oleksij Rempel
2024-02-23  6:03   ` Wei Fang
2024-02-21  6:21 ` [PATCH net-next v5 8/8] net: fec: Fixup EEE Oleksij Rempel
2024-02-23  6:03   ` Wei Fang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=693c8801-498d-42e0-bb4e-8a5bc07d9131@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=shenwei.wang@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).