mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: mii: Check speed and duplex only when autoneg is off
@ 2026-11-06 19:55 Anthony Pighin
  2026-11-07 19:58 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Anthony Pighin @ 2026-11-06 19:55 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Xiangqian Zhang, linux-kernel, stable

mii_ethtool_get_link_ksettings() reports SPEED_UNKNOWN while the link is
down. ethtool reads the current settings, changes the autoneg and
advertising fields, and writes the result back. When it does this to
enable autoneg on a port without link, mii_ethtool_set_link_ksettings()
rejects the unknown speed with -EINVAL. For example, on an ax88179_178a
USB adapter while the link is down:

  # ethtool -s eth0 autoneg on advertise 0x2f
  Cannot set new settings: Invalid argument
    not setting autoneg

pch_gbe_set_link_ksettings() already works around the same failure by
replacing an unknown speed with SPEED_1000 before it calls
mii_ethtool_set_link_ksettings().

The autoneg path uses only the advertising mask, so check speed and
duplex only when the link is forced.

Fixes: f6f2e946aa4d ("net: mii: Fix the Speed display when the network cable is not connected")
Cc: stable@vger.kernel.org
Signed-off-by: Anthony Pighin <anthony.pighin@nokia.com>
---
 drivers/net/mii.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 37bc3131d31a..439444637537 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -333,12 +333,6 @@ int mii_ethtool_set_link_ksettings(struct mii_if_info *mii,
 	struct net_device *dev = mii->dev;
 	u32 speed = cmd->base.speed;
 
-	if (speed != SPEED_10 &&
-	    speed != SPEED_100 &&
-	    speed != SPEED_1000)
-		return -EINVAL;
-	if (cmd->base.duplex != DUPLEX_HALF && cmd->base.duplex != DUPLEX_FULL)
-		return -EINVAL;
 	if (cmd->base.port != PORT_MII)
 		return -EINVAL;
 	if (cmd->base.phy_address != mii->phy_id)
@@ -346,8 +340,19 @@ int mii_ethtool_set_link_ksettings(struct mii_if_info *mii,
 	if (cmd->base.autoneg != AUTONEG_DISABLE &&
 	    cmd->base.autoneg != AUTONEG_ENABLE)
 		return -EINVAL;
-	if ((speed == SPEED_1000) && (!mii->supports_gmii))
-		return -EINVAL;
+
+	/* Speed is SPEED_UNKNOWN while the link is down; autoneg ignores it */
+	if (cmd->base.autoneg == AUTONEG_DISABLE) {
+		if (speed != SPEED_10 &&
+		    speed != SPEED_100 &&
+		    speed != SPEED_1000)
+			return -EINVAL;
+		if (cmd->base.duplex != DUPLEX_HALF &&
+		    cmd->base.duplex != DUPLEX_FULL)
+			return -EINVAL;
+		if ((speed == SPEED_1000) && (!mii->supports_gmii))
+			return -EINVAL;
+	}
 
 	/* ignore supported, maxtxpkt, maxrxpkt */
 

base-commit: 19a227903e65c7a9c179156485660a4e017575fe
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-07 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 19:55 [PATCH net] net: mii: Check speed and duplex only when autoneg is off Anthony Pighin
2026-11-07 19:58 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®