Message ID | 20231019111459.1000218-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:2010:b0:403:3b70:6f57 with SMTP id fe16csp307082vqb; Thu, 19 Oct 2023 04:16:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/5kY+8XrsH+Zo1gGmJ0YPa4Ef0z/sv/XRL69A6al+Ffk/wayPrBHTFsE+KzniqRq0FJUW X-Received: by 2002:a05:6871:49c4:b0:1ea:29a:861e with SMTP id ty4-20020a05687149c400b001ea029a861emr1855956oab.12.1697714163096; Thu, 19 Oct 2023 04:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697714163; cv=none; d=google.com; s=arc-20160816; b=hy2n/1VD9ZID/6gIF7ROXMzjcwIBUE9uFPiSCivycshKKv8MRMU+2OgkMBDC/OH5A2 ek02yXpVKDw/SaJnqy7vWIhK9rK3I0RWBTMvCYnbno7yzCXcOCWlGIpJYbAEz9AdFPY7 6FCUDyucXPWHvcz5SPAvGUNskwDWJi4y+ZMdscPOfYf7gGZG1nVZIYIM9A4d0xqSZkFV eZMoaT1VnciPjSxrbPQ1p8dT+EAtYaB9UuTmdrHq0/B4fkAyDjag0SDWibrgiVtOsiwv HHx8SRoy8Z0u27nYGRXwP/JV6bblDX3qoMuMy8SkuNLjaV5BQfba9GqcF6JqfL2/Eahn 7w0w== 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=IXpcA6nihhZ5Uolwb7DlH4v7rYyK78rZ51t6iRuix2A=; fh=oLQ93Jj/lOpIDL9R7QhdcwQr3NPpWnMdqx90qGj8Dkw=; b=G7D+3IskyTDn5YI38bH6rbaquywojhXYbxuVn0wvcohKppDnFQIk0Dpxm3Lb/xfJQ2 O6kIXE5/YNOLKdYwbQr5Y1bsLEs4qXdp4r5U9O8VVEptRqy2kKUy/UFhy8NQWVZymc6m tGb97dpJLlUAsKH6ojInS61CAgrWEVKcRAhDpfaQw0si0iJIQYS000prlu/7L2CNMN1r 1oFCkVQkHsq911WxjpLk6pAwTlnfM/UTnfX/JwOWGZBff74NyH+FtF8kiGV0tEzx2gNA V4d46gLUO2ZLBqN0ciNHqfRKu5Gz9px3FT9tOnFh0kpLgUavK80dXPW+huYqlSM+A0Dp gVTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bq16-20020a056a02045000b00578acf1e8a3si5237167pgb.576.2023.10.19.04.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 04:16:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 65EDB8070DA1; Thu, 19 Oct 2023 04:15:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233147AbjJSLPQ (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Thu, 19 Oct 2023 07:15:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233139AbjJSLPP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Oct 2023 07:15:15 -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 73176FA for <linux-kernel@vger.kernel.org>; Thu, 19 Oct 2023 04:15:13 -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 1qtQzV-0000t1-RA; Thu, 19 Oct 2023 13:15:01 +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 1qtQzU-002mGF-WA; Thu, 19 Oct 2023 13:15:01 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from <ore@pengutronix.de>) id 1qtQzU-004CEM-2z; Thu, 19 Oct 2023 13:15:00 +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, Alexander Stein <alexander.stein@ew.tq-group.com> Subject: [PATCH net-next v3 2/2] net: phy: micrel: Fix forced link mode for KSZ886X switches Date: Thu, 19 Oct 2023 13:14:59 +0200 Message-Id: <20231019111459.1000218-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019111459.1000218-1-o.rempel@pengutronix.de> References: <20231019111459.1000218-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 04:15:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780182326331193196 X-GMAIL-MSGID: 1780182326331193196 |
Series |
fix forced link mode for KSZ886X switches
|
|
Commit Message
Oleksij Rempel
Oct. 19, 2023, 11:14 a.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 | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
Comments
On Thu, Oct 19, 2023 at 01:14:59PM +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> > --- Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> -----Original Message----- > From: Oleksij Rempel <o.rempel@pengutronix.de> > Sent: Thursday, October 19, 2023 4:45 PM > To: Woojung Huh - C21699 <Woojung.Huh@microchip.com>; > UNGLinuxDriver <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; Alexander Stein <alexander.stein@ew.tq-group.com> > Subject: [PATCH net-next v3 2/2] net: phy: micrel: Fix forced link mode for > KSZ886X switches > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the > content is safe > > 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 | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index > 927d3d54658e..08e3915001c3 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -1733,6 +1733,28 @@ static int ksz886x_config_aneg(struct phy_device > *phydev) > if (ret) > return ret; > > + if (phydev->autoneg != AUTONEG_ENABLE) { > + /* 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 { > + /* If we had previously forced the link state, we need to > + * clear KSZ886X_CTRL_FORCE_LINK bit now. Otherwise, the PHY > + * will not perform autonegotiation. > + */ > + ret = phy_clear_bits(phydev, MII_KSZPHY_CTRL, > + KSZ886X_CTRL_FORCE_LINK); > + 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 > * own control and set it after autoneg configuration was done. > -- > 2.39.2 Reviewed-by: Divya Koppera <divya.koppera@microchip.com>
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 927d3d54658e..08e3915001c3 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -1733,6 +1733,28 @@ static int ksz886x_config_aneg(struct phy_device *phydev) if (ret) return ret; + if (phydev->autoneg != AUTONEG_ENABLE) { + /* 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 { + /* If we had previously forced the link state, we need to + * clear KSZ886X_CTRL_FORCE_LINK bit now. Otherwise, the PHY + * will not perform autonegotiation. + */ + ret = phy_clear_bits(phydev, MII_KSZPHY_CTRL, + KSZ886X_CTRL_FORCE_LINK); + 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 * own control and set it after autoneg configuration was done.