Message ID | 20231011123856.1443308-3-o.rempel@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp507829vqb; Wed, 11 Oct 2023 05:39:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGoXOpeiEBfzdmeYeomizKQHzyYiEonr9glSyx3yniV8c4/yZ4Zv2smGQRFxxDFSOgMfKyT X-Received: by 2002:a17:902:d2c1:b0:1c1:fbec:bc32 with SMTP id n1-20020a170902d2c100b001c1fbecbc32mr23546598plc.6.1697027968626; Wed, 11 Oct 2023 05:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697027968; cv=none; d=google.com; s=arc-20160816; b=BhXsXqOWF0GitdAPSIq7g7daZf2a0eWvbWwe7boqRJjLvRGoPuQvO5cEa/YcXxEbri ZVs2GRS0Dt2l3eBcyO62CI8b152oKNpinHQxVm+vy5NsOZidAFgf4gwC18nfuictAU8h mQSl1zHoosUjL3/Zyyz2ct/lFbaNUSuuUOkzabnRWky8Un9QbyEgg51sFzzeYJLZl08D Di7JLtQzzq4/tafTJPPEWV1fEgWYx1SllSCqVX/d1nJvu1+GKMXnfN7VdawMoAfxViIx E41BN0xX5Fq12UioPHUMd+QXVFwT9ZzDesGqq+yGy8jLvNlmkF8rJGsyG20n0Zx5cjgO Yf8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YH+C0R/4uk7mf/L8Qu3igoomq/cRFXzgiwxRZ+spcEM=; fh=j9s5hIO3Bp22eL5GiD7sdOL2eTdxGeOXyUDoEydDNo0=; b=k73xIa9C1+2hRNZBVLxKiSF9CdvE9qPuH1utxcoL3oGYs8pu6hKUj5/jwERzMt9xGc kOg/GMkOp+pnGv2wYklPBbM7bsQiZYL+mDe4eTGjX8JVZemN1RS3CiChFa6sdfgzKzpZ IYL48sOImclxi6ejvCBXbjGN1Z13HI5KdsyXlorMqQDlzojNsR6QBXl6ljuwZFKBC+pH fsAt/+qiY614UdrqAq7P5k7sTGd23ofFDsmtKS5aJ7jaoC8wcu87vXweVsak2ywvzX2Z 64SxFGt7gg661mF3+RA7ILNt6XYvSdp0DS2K0DTnIqSRlUi4WIF5MkiBy8ACiUitfpXW L0iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l4-20020a170902f68400b001c9d4d2460fsi581080plg.30.2023.10.11.05.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D32DD81CE10A; Wed, 11 Oct 2023 05:39:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346827AbjJKMjT (ORCPT <rfc822;kartikey406@gmail.com> + 18 others); Wed, 11 Oct 2023 08:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345956AbjJKMjR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Oct 2023 08:39:17 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125DE8F for <linux-kernel@vger.kernel.org>; Wed, 11 Oct 2023 05:39:16 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ore@pengutronix.de>) id 1qqYUN-0006sc-DJ; Wed, 11 Oct 2023 14:38:59 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1qqYUM-000uOC-8G; Wed, 11 Oct 2023 14:38:58 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from <ore@pengutronix.de>) id 1qqYUM-0063Tr-0c; Wed, 11 Oct 2023 14:38:58 +0200 From: Oleksij Rempel <o.rempel@pengutronix.de> To: Woojung Huh <woojung.huh@microchip.com>, UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Heiner Kallweit <hkallweit1@gmail.com> Cc: Oleksij Rempel <o.rempel@pengutronix.de>, kernel@pengutronix.de, linux-kernel@vger.kernel.org, Russell King <linux@armlinux.org.uk>, netdev@vger.kernel.org Subject: [PATCH net-next v1 3/3] net: phy: micrel: Fix forced link mode for KSZ886X switches Date: Wed, 11 Oct 2023 14:38:56 +0200 Message-Id: <20231011123856.1443308-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231011123856.1443308-1-o.rempel@pengutronix.de> References: <20231011123856.1443308-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 05:39:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779462799296614472 X-GMAIL-MSGID: 1779462799296614472 |
Series |
[net-next,v1,1/3] net: phy: micrel: Extend KSZ886X PHY Special Ctrl/Status Reg definitions
|
|
Commit Message
Oleksij Rempel
Oct. 11, 2023, 12:38 p.m. UTC
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@pengutronix.de>
---
drivers/net/phy/micrel.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
Comments
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@pengutronix.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
Hi Alexander, thank you for review! On Wed, Oct 11, 2023 at 03:29:49PM +0200, Alexander Stein wrote: > 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@pengutronix.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. First time this bit is set by this patch, I assume this problem would not exist without fixed link fix. Regards, Oleksij
On Wed, Oct 11, 2023 at 02:38:56PM +0200, Oleksij Rempel wrote: > 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@pengutronix.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 nit: autonegotiation > + * 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. > + */ ...
On Wed, Oct 11, 2023 at 03:29:49PM +0200, Alexander Stein wrote: > Hi Oleksij, > > Am Mittwoch, 11. Oktober 2023, 14:38:56 CEST schrieb Oleksij Rempel: > > + if (phydev->autoneg != AUTONEG_ENABLE) { > > + ret = genphy_setup_forced(phydev); > > + if (ret) > > + return ret; > > + ... > > + ret = phy_set_bits(phydev, MII_KSZPHY_CTRL, > > + KSZ886X_CTRL_FORCE_LINK); > > + if (ret) > > + return ret; > > + } else { ... > > + 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. No, I don't think that is the case. Compare the two paths above, noting that patch 1 introduces the definition for KSZ886X_CTRL_FORCE_LINK. If autoneg is disabled, then this bit is then set, which forces the link. Clearly, if autoneg is then re-enabled, this bit has to be cleared to allow the effects of the autoneg-disabled path to be undone. So both of these, the phy_set_bits() and the phy_clear_bits() belong in the same patch. Splitting them up, so we introduce phy_set_bits() first will create a regression - which we don't want. These two belong logically together. What does concern me, however, is that the autoneg-disabled path avoids calling genphy_setup_master_slave(), and since establishing which end of the link is part of the fundamentals of a 1000base-T link, I wonder whether both paths should still call genphy_config_aneg(). Apart from that, I think the patch is otherwise fine.
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 + * autonegotiation process. + */ + ret = phy_clear_bits(phydev, MII_KSZPHY_CTRL, + KSZ886X_CTRL_FORCE_LINK); + if (ret) + return ret; + + 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