[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3767760.kQq0lBPeGt@steina-w>
Date: Wed, 11 Oct 2023 15:29:49 +0200
From: Alexander Stein <alexander.stein@...tq-group.com>
To: Woojung Huh <woojung.huh@...rochip.com>, UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>, Florian Fainelli <f.fainelli@...il.com>, Vladimir Oltean <olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Heiner Kallweit <hkallweit1@...il.com>, Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>, kernel@...gutronix.de, linux-kernel@...r.kernel.org, Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v1 3/3] net: phy: micrel: Fix forced link mode for KSZ886X switches
Hi Oleksij,
Am Mittwoch, 11. Oktober 2023, 14:38:56 CEST schrieb Oleksij Rempel:
> Address a link speed detection issue in KSZ886X PHY driver when in
> forced link mode. Previously, link partners like "ASIX AX88772B"
> with KSZ8873 could fall back to 10Mbit instead of configured 100Mbit.
>
> The issue arises as KSZ886X PHY continues sending Fast Link Pulses (FLPs)
> even with autonegotiation off, misleading link partners in autoneg mode,
> leading to incorrect link speed detection.
>
> Now, when autonegotiation is disabled, the driver sets the link state
> forcefully using KSZ886X_CTRL_FORCE_LINK bit. This action, beyond just
> disabling autonegotiation, makes the PHY state more reliably detected by
> link partners using parallel detection, thus fixing the link speed
> misconfiguration.
>
> With autonegotiation enabled, link state is not forced, allowing proper
> autonegotiation process participation.
>
> Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> ---
> drivers/net/phy/micrel.c | 32 +++++++++++++++++++++++++++++---
> 1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 927d3d54658e..12f093aed4ff 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1729,9 +1729,35 @@ static int ksz886x_config_aneg(struct phy_device
> *phydev) {
> int ret;
>
> - ret = genphy_config_aneg(phydev);
> - if (ret)
> - return ret;
> + if (phydev->autoneg != AUTONEG_ENABLE) {
> + ret = genphy_setup_forced(phydev);
> + if (ret)
> + return ret;
> +
> + /* When autonegotation is disabled, we need to manually
force
> + * the link state. If we don't do this, the PHY will keep
> + * sending Fast Link Pulses (FLPs) which are part of the
> + * autonegotiation process. This is not desired when
> + * autonegotiation is off.
> + */
> + ret = phy_set_bits(phydev, MII_KSZPHY_CTRL,
> + KSZ886X_CTRL_FORCE_LINK);
> + if (ret)
> + return ret;
> + } else {
> + /* Make sure, the link state is not forced.
> + * Otherwise, the PHY we create a link by skipping the
PHY will create?
> + * autonegotiation process.
> + */
> + ret = phy_clear_bits(phydev, MII_KSZPHY_CTRL,
> + KSZ886X_CTRL_FORCE_LINK);
> + if (ret)
> + return ret;
Isn't this call to phy_clear_bits() a fix for autonegotiation mode? This
should be a separate patch then.
Best regards,
Alexander
> +
> + ret = genphy_config_aneg(phydev);
> + if (ret)
> + return ret;
> + }
>
> /* The MDI-X configuration is automatically changed by the PHY after
> * switching from autoneg off to on. So, take MDI-X configuration
under
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
Powered by blists - more mailing lists