[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7dd12859-dd20-4ce1-a877-4c93b335b911@lunn.ch>
Date: Wed, 15 Jan 2025 03:50:33 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Daniel Golle <daniel@...rotopia.org>
Cc: Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net] net: phy: realtek: clear status if link is down
On Wed, Jan 15, 2025 at 12:46:11AM +0000, Daniel Golle wrote:
> Clear speed, duplex and master/slave status in case the link is down
> to avoid reporting bogus link(-partner) properties.
>
> Fixes: 5cb409b3960e ("net: phy: realtek: clear 1000Base-T link partner advertisement")
> Signed-off-by: Daniel Golle <daniel@...rotopia.org>
> ---
> drivers/net/phy/realtek.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index f65d7f1f348e..3f0e03e2abce 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -720,8 +720,12 @@ static int rtlgen_read_status(struct phy_device *phydev)
> if (ret < 0)
> return ret;
>
> - if (!phydev->link)
> + if (!phydev->link) {
> + phydev->duplex = DUPLEX_UNKNOWN;
> + phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
> + phydev->speed = SPEED_UNKNOWN;
> return 0;
> + }
>
I must be missing something here...
rtlgen_read_status() first calls genphy_read_status(phydev);
int genphy_read_status(struct phy_device *phydev)
{
int err, old_link = phydev->link;
/* Update the link, but return if there was an error */
err = genphy_update_link(phydev);
if (err)
return err;
/* why bother the PHY if nothing can have changed */
if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
return 0;
phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
phydev->speed = SPEED_UNKNOWN;
phydev->duplex = DUPLEX_UNKNOWN;
phydev->pause = 0;
phydev->asym_pause = 0;
Why is that not sufficient ?
> val = phy_read_paged(phydev, 0xa43, 0x12);
> if (val < 0)
> @@ -1028,11 +1032,11 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
> return ret;
>
> if (phydev->autoneg == AUTONEG_DISABLE ||
> - !genphy_c45_aneg_done(phydev))
> + !genphy_c45_aneg_done(phydev) ||
> + !phydev->link) {
> mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0);
> -
> - /* Vendor register as C45 has no standardized support for 1000BaseT */
> - if (phydev->autoneg == AUTONEG_ENABLE) {
> + } else {
> + /* Vendor register as C45 has no standardized support for 1000BaseT */
> val = phy_read_mmd(phydev, MDIO_MMD_VEND2,
> RTL822X_VND2_GANLPAR);
> if (val < 0)
> @@ -1041,8 +1045,12 @@ static int rtl822x_c45_read_status(struct phy_device *phydev)
> mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val);
> }
>
> - if (!phydev->link)
> + if (!phydev->link) {
> + phydev->duplex = DUPLEX_UNKNOWN;
> + phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
> + phydev->speed = SPEED_UNKNOWN;
> return 0;
> + }
rtl822x_c45_read_status() calls genphy_c45_read_link() which again
clears state from phydev.
Andrew
Powered by blists - more mailing lists