🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24900

Re: [PATCH net 13/14] net: phy: as21xxx: Fix speed and duplex reporting

#24900
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 01:51
205 lines
15093 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] Forced mode: as21xxx_read_status() can still leave phydev->speed
  = SPEED_UNKNOWN, which is the failure this patch says it removes.
- [Low] The LPA_1000MSFAIL check in as21xxx_read_lpa() now only runs once
  the link is up: as21xxx_read_status() returns early at 'if…
- [Low] The commit message justifies the duplex resolution with 'Since
  aeon_config_aneg() makes phydev->advertising reflect what the firmware…

--

net: phy: as21xxx: Fix speed and duplex reporting

With autoneg enabled, this patch takes the speed from VEND1_SPEED_STATUS
instead of resolving the advertisements. Duplex and pause are then
resolved from the link partner abilities, which are read from the mapped
C22 registers and the 10GBASE-T status register. With autoneg disabled,
it reports the PMA-programmed settings via genphy_c45_read_pma(), and
overrides the speed from VEND1_SPEED_STATUS once the link is up.

> Use VEND1_SPEED_STATUS, the authoritative source, on the autoneg path
> too.  Since aeon_config_aneg() makes phydev->advertising reflect what
> the firmware puts on the wire, it is still reliable for picking the
> duplex mode at that speed: resolve duplex from the link partner

[Severity: Low]
There is no aeon_config_aneg() in drivers/net/phy/as21xxx.c. Should this
be as21xxx_config_aneg()?

That function and its advertising expansion ("Let the advertisement
reflect the slower speeds which go on the wire along with the highest
one") come from the preceding patch, "net: phy: as21xxx: Configure
autoneg advertisement via IPC". The baseline driver has no config_aneg
callback at all.

Both patches carry only the Fixes: 830877d89edc tag, with no dependency
note. If this patch is backported alone, as21xxx_resolve_duplex() would
run this line without the implicitly advertised slower modes in
phydev->advertising:

	linkmode_and(common, phydev->lp_advertising, phydev->advertising);

Could a partner that negotiated full duplex below the advertised maximum
speed then fall into the parallel detection fallback and be reported as
half duplex?

Would it be worth stating the dependency for stable?

> diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
> index 967ff3020814e..5eea6baa75bfc 100644
> --- a/drivers/net/phy/as21xxx.c
> +++ b/drivers/net/phy/as21xxx.c

[ ... ]

> @@ -781,15 +781,107 @@ static int as21xxx_read_c22_lpa(struct phy_device *phydev)

[ ... ]

> +static int as21xxx_read_speed(struct phy_device *phydev)
> +{
> +	int val;
> +
> +	val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_SPEED_STATUS);
> +	if (val < 0)
> +		return val;
> +
> +	switch (val & VEND1_SPEED_MASK) {

[ ... ]

> +	default:
> +		dev_warn_once(&phydev->mdio.dev,
> +			      "Unknown speed status 0x%04x\n", val);
> +		phydev->speed = SPEED_UNKNOWN;
> +		break;
> +	}
> +
> +	return 0;
> +}

[ ... ]

> @@ -797,64 +889,54 @@ static int as21xxx_read_status(struct phy_device *phydev)
>  	if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
>  		return 0;
>  
> -	phydev->speed = SPEED_UNKNOWN;
> -	phydev->duplex = DUPLEX_UNKNOWN;
>  	phydev->pause = 0;
>  	phydev->asym_pause = 0;
>  
> -	if (phydev->autoneg == AUTONEG_ENABLE) {
> -		ret = genphy_c45_read_lpa(phydev);
> +	if (phydev->autoneg == AUTONEG_DISABLE) {
> +		ret = genphy_c45_read_pma(phydev);
>  		if (ret)
>  			return ret;
>  
> -		ret = as21xxx_read_c22_lpa(phydev);
> -		if (ret)
> -			return ret;
> +		if (phydev->link) {
> +			ret = as21xxx_read_speed(phydev);
>  
> -		phy_resolve_aneg_linkmode(phydev);
> -	} else {
> -		int speed;
> +			/* Hold the link down until the speed status settles */
> +			if (!ret && phydev->speed == SPEED_UNKNOWN)
> +				phydev->link = 0;
> +		}

[Severity: High]
Can this branch still leave phydev->speed set to SPEED_UNKNOWN in forced
mode?

genphy_c45_read_pma() sets phydev->speed from PMA CTRL1, which holds the
forced speed the user configured. If the link bit is up while
VEND1_SPEED_STATUS reads an unrecognised code, the default case in
as21xxx_read_speed() overwrites phydev->speed with SPEED_UNKNOWN. Only the
link is held down, and the PMA speed is not restored.

In forced mode, phydev->speed is also the configuration. PHY_HALTED does
not reset speed when autoneg is disabled, so if phy_stop() lands in this
window, the next phy_start() goes through:

phy_start()
  _phy_start_aneg()
    phy_sanitize_settings()
      phy_caps_lookup(SPEED_UNKNOWN, DUPLEX_FULL, supported, false)
    as21xxx_config_aneg()
      genphy_c45_pma_setup_forced()

When speed is -1, phy_caps_lookup() finds no entry with
lcap->speed <= speed and returns the slowest supported capability.

If 10baseT_Half is in phydev->supported, the result is 10/HALF.
genphy_c45_pma_setup_forced() returns -EINVAL for anything other than full
duplex, so the PHY goes to PHY_ERROR, and every later restart retries the
same sanitized setting. If 10baseT_Half is not supported, the slowest full
duplex speed is written into PMA CTRL1 instead, and the forced speed is
lost.

Isn't this the same problem the commit message says is being fixed?

    "Otherwise phy_sanitize_settings() sees unknown values on the next
    autoneg restart with the link down and falls back to the slowest
    mode."

Could as21xxx_read_speed() return the speed in a local variable, or leave
phydev->speed untouched in its default case, so that the PMA-derived
speed is kept?

> -		linkmode_zero(phydev->lp_advertising);
> +		return ret;
> +	}

[ ... ]

> +	phydev->speed = SPEED_UNKNOWN;
> +	phydev->duplex = DUPLEX_UNKNOWN;
> +	linkmode_zero(phydev->lp_advertising);

[ ... ]

> +	/* as21xxx_read_link() reports link up only once autoneg completed */
> +	if (!phydev->link)
> +		return 0;

[Severity: Low]
Because of this early return, as21xxx_read_lpa() is only reached once the
link is up. Before this patch, as21xxx_read_c22_lpa() ran on every
autoneg read_status where the link was not already up, including while
the link was down.

A 1000BASE-T master/slave configuration fault keeps the link down. Does
that mean the LPA_1000MSFAIL check in as21xxx_read_lpa(), and its
"Master/Slave resolution failed" message, are no longer reached in the
case they exist for?

If the check is reached with the link up, for example through a latched
fault bit, it still returns -ENOLINK. That moves the PHY to PHY_ERROR
while the link is actually up.

Should this follow the hold-the-link-down approach used here for an
unrecognised speed status instead?

The commit message says partner abilities are now read only once the
link is up, but it does not mention the lost diagnostic.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-as21xxx-fixes-v1-0-1bd2eae6ccbc%40collabora.com
Technical Details
Message-ID: <179608986082.3146.5210575164778107241@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374621-linux-kernel-netdev=dewy.ru
References: <20261130-as21xxx-fixes-v1-13-1bd2eae6ccbc@collabora.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374621-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 13/14] net: phy: as21xxx: Fix speed and duplex reporting
Date: Tue, 01 Dec 2026 01:51:00 +0000
Organization: Usenet Network
Message-ID: <179608986082.3146.5210575164778107241@kernel.org>
References: <20261130-as21xxx-fixes-v1-13-1bd2eae6ccbc@collabora.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1587130"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gUHkfPDGDgLSM8KZSKRS6gKg/Cw= sha256:uCaS0tTDzPk2t8ArBYSsTD3VC/DlYIDH23rpfn4YZCg=
	sha1:6uFzaaZbsCOIOWud9taNGzMQYk0= sha256:vNE9IbDsYjaY9LMvy1b6ojEQ7Wj79drW5bKpFJ6xJG8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id BBB841171F7; Tue,  1 Dec 2026 04:51:26 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rqC5Q27_uQ4R;
	Tue,  1 Dec 2026 04:51:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374621-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id F2A581171F6; Tue,  1 Dec 2026 04:51:14 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 0779D26B30; Tue,  1 Dec 2026 01:51:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796089863;
	b=U4kd0qdkbFCAEQYlBFaL8D3ZU9qH9uPTzK/Li0xbn0JTSMlnPxki2yLa8by72A91wD06
	 2v8QtVhFTfnHuw90UrWy6po8YkkdtbsXHlWtyadfnQyyAsRtHwOZi11FCYBK88WjiYiTw
	 WimwCUtVao4xeOFlsMjzN2I3E9oC5T1pUxOjVDdaZUm9pTgqIdZ7PwSpNQK9uo+K4sLZ8
	 led64oUVvPbO3UM0XrcvmFIMTt/uLQaccY+Nd3jCzMk6VT7rRiZXyaxqLCWvVD97msuis
	 T823+m13roLonMnOioEIO5b8MrKBWLHukhPh702/umg0q5EdhkOA/JDeXWdmw/pB76A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796089863;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=bT9wq9QMZ+EqB0P1sTQppDKdy0KUpswyHCmR0GlJQyM=;
	b=ZXaM6ND8/eeddckoTyvvUNnp0UBDk/Z0YucLu0uIoCeDR7oeyscwG3jSVvyzvtPNC1Ag
	 Q8UskSEwis5roEAFqL50Ro6KRajnboQlKiOp5pCFZfOUfEbH1pbU+ND/5wOH9lw15yEhb
	 qoMjqw/vULsSeHV9cOGzv5rOZUpVeDm4ZNiPnAr7B4sy4rse7mz19NO0yyJkKXTZrZijJ
	 ZGa2Yx6nP99do3XylQowVvXKb+L+W4dfWnyT3C0EN65ch40L+klSP96swp0PLgt6TZsAx
	 1xKydfYzWF8yFFs2lBhMPCPF7GNfkJtl0ZrRBF91rOyjhuYBP9BI3VU4px+HUWrDeSQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iDB4uJ3u;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DFDC4606A32D;
	Tue,  1 Dec 2026 01:51:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iDB4uJ3u
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796089862;
	b=kZ1tQ2cbsz8LMjc59zu9yn/G4sTT1sz9GOzy96CX3v3hS7SPKsPDODttS/4/KR2B/SqD
	 Vtam2qO2tzMCsn6wYwpXAU17nqlelfMD7KoGzExKC+kp+6j+6NrhcJprpWHFNtg9ISIcm
	 dBF8VGdbj9bITjXEU8yAtVjkbmqvz3xSxxSQfO5ngXUFFgqi2Ic+Ei+1HMo/m6gtZJiSP
	 lCuOXgleoif6a9oPbKpl/071VTwfTLKz3ayqcKp/IdFT8o9aR9VeO3zQUNqk3q8/FhhPR
	 +4slCM2q2S3o1H2hZTMNTAQAV4DKPlFieaRNt0TryqHqAKIVZnLI6m5B5YYjvYo2elw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796089862;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=bT9wq9QMZ+EqB0P1sTQppDKdy0KUpswyHCmR0GlJQyM=;
	b=zOgphXznkxb5J9vifIxAcgiPozqZ25vF7RyDoCVT7dD4uUJzXFeAFVYHOC6fGUu5Tr76
	 nzvmB27NpKG7tWbzCMWPLoVC31TIO1a4IsA+HK3iP1KSG1Z1Q3hnJlcTWTV4nrcsTLteg
	 Qm0jj4qis8xPsrsg1s2eUvm8AuB37ZjrUGuOKrKEsfCKAkzZLb9eyosWiGxtY1E0UpFkZ
	 VemmIJZyWTvukaMUTiaHS/PjBLyKgOK8THJqTr0DBrnV07PZslms4ZwHNAhFa8xHJkW0G
	 9qpninxzqpEoN9iyTZNAsF+eBPpin9FTHR/SYim+jBJ7Uf9XEs6jQaYilW7vmLKon7Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iDB4uJ3u;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D843606A681
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 01:51:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48B291F000C1;
	Tue,  1 Dec 2026 01:51:01 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796089861;
	bh=bT9wq9QMZ+EqB0P1sTQppDKdy0KUpswyHCmR0GlJQyM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=iDB4uJ3ucXciNZ6E03Ss+GhHE6y8eLnYjGjhnhjsWQvUaoi4Z+wxjcF0uCiukiRA6
	 OuNK36IGZfAobZHo8aJiWXz+kgW3KdCbuV7QMCa5Z1TcVdfh27PkNpOtXV9SZ9HZda
	 4NgTWPxUhP1VoYRhqbsPySCrFeoLq77lbLAhJ1qvz3ZzcEq7fHMSmMXLsSLaoZCSxj
	 kw5akOsSbmtf8LtZbN/1T0wb4usBxyzXvs3dEKu3LEkUgwBBjw6Fbo1S9d/IWQ3wYx
	 rvmX5omcQlbeL9Yq/jtPlzyJc/EpNCtE0pDEboSWuf1QZypWXAqO6G4ONRIWT5eDZ8
	 DiGNm2PAnoDkQ==
X-Cc: ansuelsmth@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com,
 linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, kernel@collabora.com,
 netdev@vger.kernel.org
X-In-Reply-To: <20261130-as21xxx-fixes-v1-13-1bd2eae6ccbc@collabora.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list