From: "Krzysztof Hałasa" <khalasa@piap.pl>
To: netdev <netdev@vger.kernel.org>
Cc: Oliver Neukum <oneukum@suse.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Jose Ignacio Tornos Martinez <jtornosm@redhat.com>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH] PHY: Fix no autoneg corner case
Date: Wed, 27 Nov 2024 09:56:42 +0100 [thread overview]
Message-ID: <m3plmhhx6d.fsf@t19.piap.pl> (raw)
phydev->autoneg appears to indicate if autonegotiation is enabled or
not. Unfortunately it's initially set based on the supported capability
rather than the actual hw setting. While in most cases there is no
difference (i.e., autoneg is supported and on by default), certain
adapters (e.g. fiber optics) use fixed settings, configured in hardware.
Now autoneg flag is set only when it's supported and actually used.
Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 366cf3b2cbb0..6858f512558b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3453,7 +3453,7 @@ static int phy_probe(struct device *dev)
struct phy_device *phydev = to_phy_device(dev);
struct device_driver *drv = phydev->mdio.dev.driver;
struct phy_driver *phydrv = to_phy_driver(drv);
- int err = 0;
+ int err = 0, bmcr;
phydev->drv = phydrv;
@@ -3495,8 +3495,12 @@ static int phy_probe(struct device *dev)
if (err)
goto out;
+ err = bmcr = phy_read(phydev, MII_BMCR);
+ if (err < 0)
+ goto out;
+
if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
- phydev->supported))
+ phydev->supported) || !(bmcr & BMCR_ANENABLE))
phydev->autoneg = 0;
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
--
Krzysztof "Chris" Hałasa
Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa
next reply other threads:[~2024-11-27 8:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 8:56 Krzysztof Hałasa [this message]
2024-11-27 17:37 ` [PATCH] PHY: Fix no autoneg corner case Andrew Lunn
2024-11-28 6:31 ` Krzysztof Hałasa
2024-11-28 14:54 ` Andrew Lunn
2024-11-28 19:35 ` Heiner Kallweit
2024-11-29 6:17 ` Krzysztof Hałasa
2024-11-29 6:49 ` Heiner Kallweit
2024-12-02 7:57 ` Krzysztof Hałasa
2025-03-19 21:00 ` Heiner Kallweit
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=m3plmhhx6d.fsf@t19.piap.pl \
--to=khalasa@piap.pl \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jtornosm@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=pabeni@redhat.com \
/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).