🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24899

Re: [PATCH net 11/14] net: phy: as21xxx: Read 10/100/1000 link modes from C22 advertisement

#24899
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 01:50
149 lines
13635 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

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

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] The commit message promises something the code does not deliver:
  "The PHY is reset when the driver is unbound, so it reports the…
- [Low] as21xxx_get_features() falls back to the C45-derived modes when
  either register lacks the relevant bits: `!(adv & ADVERTISE_ALL) ||…

--

net: phy: as21xxx: Read 10/100/1000 link modes from C22 advertisement

This adds an as21xxx_get_features() callback. It reads the 2.5G, 5G and
10G abilities from the Clause 45 registers, then takes the 10/100/1000
link modes from the C22 ADVERTISE and CTRL1000 registers mapped in the AN
MMD. If those registers do not have the expected bits set, the Clause 45
derived modes are kept.

> diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
> index 1c4a808bf01e9..3423448a0cb1c 100644
> --- a/drivers/net/phy/as21xxx.c
> +++ b/drivers/net/phy/as21xxx.c
> @@ -644,6 +644,61 @@ static int as21xxx_probe(struct phy_device *phydev)
>  	return aeon_dpc_ra_enable(phydev);
>  }
>  
> +static int as21xxx_get_features(struct phy_device *phydev)
> +{
> +	int ret, adv, ctrl1000;
> +

[ ... ]

> +	adv = phy_read_mmd(phydev, MDIO_MMD_AN,
> +			   AS21XXX_MDIO_AN_C22 + MII_ADVERTISE);
> +	if (adv < 0)
> +		return adv;
> +
> +	ctrl1000 = phy_read_mmd(phydev, MDIO_MMD_AN,
> +				AS21XXX_MDIO_AN_C22 + MII_CTRL1000);
> +	if (ctrl1000 < 0)
> +		return ctrl1000;

[Severity: High]
Does this always sample the firmware defaults? The commit message says:

  The PHY is reset when the driver is unbound, so it reports the generic
  pre-firmware ID again and the firmware is reloaded from
  .match_phy_device() before the next probe.
  Hence .get_features() always samples the firmware defaults.

as21xxx has no .remove or .soft_reset callback. The only reset on unbind
is the one in phy_remove():

drivers/net/phy/phy_device.c:phy_remove() {
    ...
	/* Assert the reset signal */
	phy_device_reset(phydev, 1);
    ...
}

That call ends in mdio_device_reset(), which returns immediately when the
board describes no reset line:

drivers/net/phy/mdio_device.c:mdio_device_reset() {
    ...
	if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl)
		return;
    ...
}

On those boards the firmware keeps running across a sysfs unbind/bind or
a module reload. On rebind, as21xxx_match_phy_device() reads the
post-firmware ID and returns early without reloading the firmware:

	if (phy_id != PHY_ID_AS21XXX)
		return phy_id == phydrv->phy_id;

as21xxx_get_features() then reads ADVERTISE and CTRL1000 in whatever
state the previous session left them. The commit message itself says
these registers mirror the current advertisement.

The later patch in this series, "net: phy: as21xxx: Configure autoneg
advertisement via IPC", changes that advertisement through
aeon_set_top_speed(). Suppose the previous session limited it to 100M,
for example with "ethtool -s ethX advertise 100baseT/Full", which selects
IPC_CU_AN_TOP_SPD_100. CTRL1000 then reads back with no 1000 bits and the
fallback below is taken. That leaves 10baseT/Half and 100baseT/Half set
in phydev->supported again.

Doesn't that bring back the problem this patch is meant to fix? In the
final series, as21xxx_resolve_duplex() uses those Half bits to report
DUPLEX_HALF on parallel detection.

The same thing can happen if a bootloader loaded the firmware and changed
the advertisement before Linux probes.

Boards with a reset line have a separate problem at this commit: match
runs while the PHY is still held in reset, because phy_probe() deasserts
reset only after the bus match. The last patch in the series, "net: phy:
as21xxx: Release reset before reading ID in match", fixes that case. Its
own commit message says the deassert "does nothing when the PHY has no
reset described", though, so the case without a reset line is still open
at the end of the series.

Could the default top speed be restored before these registers are read?
Alternatively, the firmware could be reset or reloaded on unbind, or the
modes could come from a fixed capability source. Either way, the commit
message would need to be corrected.

> +
> +	/* If the firmware defaults are not available, keep the C45-derived
> +	 * modes rather than dropping all 10/100/1000 link modes.
> +	 */
> +	if (!(adv & ADVERTISE_ALL) ||
> +	    !(ctrl1000 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL))) {
> +		phydev_warn(phydev,
> +			    "Empty C22 advertisement, using C45 abilities\n");
> +		return 0;
> +	}

[Severity: Low]
This isn't a bug, but the check here ORs the two registers, while the
commit message says the fallback happens only "If the advertisement
reads back empty".

Take the case where ADVERTISE has valid 10/100 bits but CTRL1000 has no
1000 bits, which is the state an advertisement limited to 100M leaves
behind. The advertisement is not empty. Even so, the valid 10/100 data is
thrown away, the C45 modes with both duplexes are kept, and the warning
says "Empty C22 advertisement".

Could the two registers be handled separately, with ADVERTISE used for
10/100 and C45 or CTRL1000 used for 1G? If not, could the commit message
and the warning text describe the condition the code actually checks?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-as21xxx-fixes-v1-0-1bd2eae6ccbc%40collabora.com
Technical Details
Message-ID: <179608985834.3146.6893473863100169136@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-374619-linux-kernel-netdev=dewy.ru
References: <20261130-as21xxx-fixes-v1-11-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-374619-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 11/14] net: phy: as21xxx: Read 10/100/1000 link modes
 from C22 advertisement
Date: Tue, 01 Dec 2026 01:50:58 +0000
Organization: Usenet Network
Message-ID: <179608985834.3146.6893473863100169136@kernel.org>
References: <20261130-as21xxx-fixes-v1-11-1bd2eae6ccbc@collabora.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1587074"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:n6HYhYiEbWUETLKd/fm7tSWRvGo= sha256:CP4cr9zY4EZNXsj//DghIjEaWGSYv6+8PNxeGWf7ptk=
	sha1:8OFqMecgZ2ExwNQ6AAN6YCdhSQI= sha256:XPcnFZCz5xb+7oHrKvIyfeEv2D/85c0vEMR22kpCJEs=
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 D3F0F1171F2; Tue,  1 Dec 2026 04:51:23 +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 WSWPG-DQ_cFy;
	Tue,  1 Dec 2026 04:51:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374619-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 5C9011171F3; Tue,  1 Dec 2026 04:51:10 +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 EABFC26ED2; Tue,  1 Dec 2026 01:51:03 +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=1796089860;
	b=ode3WNPVhSQUqTvXIh7t9+9IKlNTKg60Qxatu+ap6PnFnI0D/W/J2aVnrxzaaPDLW7Rk
	 wjF345av6lG0vn+dwy80RJ9A8zJYsC3Z7ZQvrOiqMAw7uLOV1a4scmayV3Bv9NWQ1Jeq4
	 IIZtTvznA0lBCjXg9cn5vhxLEDbZ0Uel8N7wuZs5XBhFiDNdNbtdsXSiQZ1g6YHqd0lBI
	 BTrB1LkbQaQSUR6SDONwT2ZM5O7tJGX125aDfZgOTkCKEH2BfxYq8fSLSDqp7wq0mdo/V
	 B0OTTsSWiusbZskWzMhYyZeOSylARetlJih6qZzthFypCgxNWUwxZ8w3SmC5Ff/k1bQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796089860;
	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=kM+7QbZ2CeF6cG0IgYOKVyk3RyB4RHDnI4OP3SIIycc=;
	b=UfRyj1LJ13l8BInzjZTzhFLs3Tf2kUXpaOUsSEfN/RjuOOKSae4EHmPXrtCg5JLhyt0H
	 /6d+S1Dupe2zm1MGdgQdFrDeGIRB3VepFjXO75PyrxjWlCCCvoNKX3dfov7Nwr8cBxsiY
	 tinbLjE6Q6vYhhw+UT1FKZ6ZJBflWbYJ9AeqpT5c1yERKW/+eVe1ZESXvhCZbv1JaFD31
	 9XqusnF02JAQJUGytSrvRI4sEWOrA7/D5C7PLEJ6BQkZguoZDqNyTLHYXSvQKuRWFLMkT
	 rjxhqGIUhjC+qcFgiBvL67uFyjp1C9CjTKZU+a+EPT6nTsqm1yli5B/hWvyxnjkkWBg==
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=GVJNagRr;
	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 67932606A336;
	Tue,  1 Dec 2026 01:51:00 +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=GVJNagRr
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=1796089859;
	b=vqcrjAE0f4+Yj9FWeepoa46tBrGEHFMCdr1C3Rt8QSriuWWL8jdfzmNY5hxtm57cmOCl
	 7ZgLW1OrxyOCu/ngF59RirKrcAM5RbrZ+rPxpVhNhSw060qQV/uchEK/cxb9JUXzeQVRp
	 dGoBKJ58YyC5Sa7QGxhmGMjCC83DmokErHW4AT7wq6gkWwOgQQrGKFYQhINJZi31Sl4Zt
	 z+VBMWTd5ImV8CxALjr3sOmn95qulAinuvDdoZLQdFw6lJI8AMnzgWzFa2oc4G3XFdJS+
	 5iX08DOHyqL32QyBdmOGOjefVilk1KvHZjMbTLF5ptY0uqRtV/JL2j5oCg7Ud7dgSUQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796089859;
	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=kM+7QbZ2CeF6cG0IgYOKVyk3RyB4RHDnI4OP3SIIycc=;
	b=toMl0m84DELlnDAXW5TtmE32JOKWsEDVRsNevVMk7+/fHL3scJ3IHEWwsZx5gDAVHTBS
	 a14+IvklQHUc/xuwlnihu0tzYBxEBa9iErqJ90M8pMMSUZ+hahd1DIjWDTIvlasTpYtgG
	 6xljXM4uhFXH2HZOi964uRHygFwmKhuXxHyPM8xBBhrypkCALk5xWUXqYcwbZnpgmaX25
	 3aopcGnas4dAr0DYerQpIG5ZqjLv3HayCYh1DijDIex5TPg8PRXtYmgVuobRiwjEo8gUe
	 QdDNxlCjXHQZxSNPOQ8b793011iVx3B5aJHco56oSFiD7UK6tRkZW7b5mlm6EJ4xyYQ==
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=GVJNagRr;
	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 8A559606A33E
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 01:50:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C63F51F00898;
	Tue,  1 Dec 2026 01:50:58 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796089859;
	bh=kM+7QbZ2CeF6cG0IgYOKVyk3RyB4RHDnI4OP3SIIycc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=GVJNagRr8tldSKxG83F1kuTi5l/z1cgEaYW896xzvFZbnYSbCgg29V8btT2dsj71U
	 8UhoJRwQKRiY547RUjkESiY/t1ODR06MCdyJQswnXYj0QTdEmXqVPH67xtn/OEpb5z
	 Xj+29tXyml6E0g0ethhWnzP7LwgKAoO4kAULW09Og/PVwgSFynfU8rWQn4QlfuJzE4
	 Sh95YHh/gFYAE5Bzk9lLeIV4WetNTxQkFLmgjvT9MybFXWTijp7y+VoGTnMgQ1wWy3
	 L1oVTi/ffXEg82BzqHBAdh753GI91JrSK9PdXT+IGYC0JX2Mt4abVzBq1h2QpJHstA
	 gc7R3X3cuUVcw==
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-11-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