From: Anthony Pighin <anthony.pighin@nokia.com>
To: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Xiangqian Zhang <zhangxiangqian@kylinos.cn>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH net] net: mii: Check speed and duplex only when autoneg is off
Date: Fri, 6 Nov 2026 14:55:44 -0500 [thread overview]
Message-ID: <20261106195544.4146568-1-anthony.pighin@nokia.com> (raw)
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
next reply other threads:[~2026-11-06 19:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 19:55 Anthony Pighin [this message]
2026-11-07 19:58 ` netdev-bot+sashiko
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=20261106195544.4146568-1-anthony.pighin@nokia.com \
--to=anthony.pighin@nokia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=zhangxiangqian@kylinos.cn \
/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
all inboxes | Powered by JetHome®