From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Andrew Lunn <andrew@lunn.ch>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH net v2] net: phy: fix phy_ethtool_set_eee() incorrectly enabling LPI
Date: Fri, 22 Nov 2024 21:04:02 +0100 [thread overview]
Message-ID: <f430fb95-362d-4436-8b33-0eebc15333a8@gmail.com> (raw)
In-Reply-To: <E1tESfx-004evI-NH@rmk-PC.armlinux.org.uk>
On 22.11.2024 13:22, Russell King (Oracle) wrote:
> ---
> drivers/net/phy/phy-c45.c | 2 +-
> drivers/net/phy/phy.c | 32 ++++++++++++++++++--------------
> include/linux/phy.h | 1 +
> 3 files changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
> index 96d0b3a5a9d3..944ae98ad110 100644
> --- a/drivers/net/phy/phy-c45.c
> +++ b/drivers/net/phy/phy-c45.c
> @@ -1530,7 +1530,7 @@ int genphy_c45_ethtool_get_eee(struct phy_device *phydev,
> return ret;
>
> data->eee_enabled = is_enabled;
> - data->eee_active = ret;
> + data->eee_active = phydev->eee_active;
> linkmode_copy(data->supported, phydev->supported_eee);
>
> return 0;
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 4f3e742907cb..e174107b96e2 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -990,14 +990,14 @@ static int phy_check_link_status(struct phy_device *phydev)
> phydev->state = PHY_RUNNING;
> err = genphy_c45_eee_is_active(phydev,
> NULL, NULL, NULL);
> - if (err <= 0)
> - phydev->enable_tx_lpi = false;
> - else
> - phydev->enable_tx_lpi = phydev->eee_cfg.tx_lpi_enabled;
> + phydev->eee_active = err > 0;
> + phydev->enable_tx_lpi = phydev->eee_cfg.tx_lpi_enabled &&
> + phydev->eee_active;
>
> phy_link_up(phydev);
> } else if (!phydev->link && phydev->state != PHY_NOLINK) {
> phydev->state = PHY_NOLINK;
> + phydev->eee_active = false;
> phydev->enable_tx_lpi = false;
> phy_link_down(phydev);
> }
> @@ -1685,16 +1685,20 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
> 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(&phydev->eee_cfg, data);
> - phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
> - if (phydev->link) {
> - phydev->link = false;
> - phy_link_down(phydev);
> - phydev->link = true;
> - phy_link_up(phydev);
> - }
> + bool enable_tx_lpi = data->tx_lpi_enabled &&
> + phydev->eee_active;
> +
> + eee_to_eeecfg(&phydev->eee_cfg, data);
> +
> + if ((phydev->enable_tx_lpi != enable_tx_lpi ||
> + phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) &&
> + phydev->link) {
> + phydev->enable_tx_lpi = false;
> + phydev->link = false;
> + phy_link_down(phydev);
> + phydev->enable_tx_lpi = enable_tx_lpi;
> + phydev->link = true;
> + phy_link_up(phydev);
This part collides with a pending patch:
https://patchwork.kernel.org/project/netdevbpf/patch/a5efc274-ce58-49f3-ac8a-5384d9b41695@gmail.com/
I think you have to rebase and resubmit once the pending patch has been applied.
> }
> }
>
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 77c6d6451638..6a17cc05f876 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -723,6 +723,7 @@ struct phy_device {
> /* Energy efficient ethernet modes which should be prohibited */
> __ETHTOOL_DECLARE_LINK_MODE_MASK(eee_broken_modes);
> bool enable_tx_lpi;
> + bool eee_active;
> struct eee_config eee_cfg;
>
> /* Host supported PHY interface types. Should be ignored if empty. */
> -- 2.30.2
next prev parent reply other threads:[~2024-11-22 20:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 12:22 [PATCH net v2] net: phy: fix phy_ethtool_set_eee() incorrectly enabling LPI Russell King (Oracle)
2024-11-22 13:10 ` Andrew Lunn
2024-11-22 20:04 ` Heiner Kallweit [this message]
2024-11-22 20:28 ` Heiner Kallweit
2024-11-23 14:03 ` Russell King (Oracle)
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=f430fb95-362d-4436-8b33-0eebc15333a8@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
/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).