🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7657

Re: [PATCH net v2 3/4] net: phy: as21xxx: force C45 OPs for AUTONEG

#7657
From: netdev-bot+sashiko
Date: Mon, 26 Oct 2026 23:07
144 lines
13092 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

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

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).

- [Medium] The new as21xxx_config_aneg() in drivers/net/phy/as21xxx.c
  never checks phydev->autoneg, so a forced speed/duplex request is…
- [Medium] Installing the custom as21xxx_config_aneg() also drops
  master/slave (timing role) programming.

--

net: phy: as21xxx: force C45 OPs for AUTONEG

This patch clears the C22 bit from devices_in_package in as21xxx_probe().
It adds a custom as21xxx_config_aneg() that uses the generic C45 AN helpers
and also writes the 1000BASE-T advertisement through the mapped C22
CTRL1000 register in MMD 7. The new callback is hooked into all of the
post-firmware driver entries.

> diff --git a/drivers/net/phy/as21xxx.c b/drivers/net/phy/as21xxx.c
> index 519b78d3579d3..e2988cb10c047 100644
> --- a/drivers/net/phy/as21xxx.c
> +++ b/drivers/net/phy/as21xxx.c

[ ... ]

> @@ -633,6 +640,32 @@ static int as21xxx_probe(struct phy_device *phydev)
>  	return aeon_dpc_ra_enable(phydev);
>  }
>  
> +static int as21xxx_config_aneg(struct phy_device *phydev)
> +{
> +	bool changed = false;
> +	int ret;
> +	u16 adv;
> +
> +	ret = genphy_c45_an_config_aneg(phydev);

[Severity: Medium]
What happens here when phydev->autoneg == AUTONEG_DISABLE? There is no
forced-mode branch, so a request like "ethtool -s ethX autoneg off speed 100
duplex full" goes through:

phy_ethtool_ksettings_set()
  _phy_start_aneg()
    phy_config_aneg()
      as21xxx_config_aneg()
        genphy_c45_an_config_aneg()
        genphy_c45_check_and_restart_aneg()
          genphy_c45_restart_aneg()

genphy_c45_restart_aneg() sets MDIO_AN_CTRL1_ENABLE | MDIO_AN_CTRL1_RESTART.
So autoneg stays enabled, or gets turned back on, and no forced speed or
duplex is programmed.

Before this patch there was no .config_aneg, so phy_config_aneg() used
genphy_config_aneg()->__genphy_config_aneg(). That path handled forced mode
with genphy_setup_forced() below 1000, and for 1000 it advertised only the
requested mode. genphy_c45_config_aneg(), which this code seems to be
based on, also starts with:

	if (phydev->autoneg == AUTONEG_DISABLE)
		return genphy_c45_pma_setup_forced(phydev);

The config_aneg kernel-doc in include/linux/phy.h says the callback "forces
the speed to the current settings in phydev if phydev->autoneg is off".
as21xxx_read_status() also still has an AUTONEG_DISABLE branch.

Is this a regression for forced link modes? Against a partner forced to
10/100 full duplex, this side would fall back to parallel detection and end
up at half duplex. A forced 1000 request would also no longer restrict the
advertisement, so the link could come up at 2.5G or higher.

Would it make sense to add an AUTONEG_DISABLE branch at the top of
as21xxx_config_aneg(), for example returning
genphy_c45_pma_setup_forced(phydev)?

> +	if (ret < 0)
> +		return ret;
> +	if (ret > 0)
> +		changed = true;
> +
> +	adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
> +
> +	ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN,
> +				     AS21XXX_MDIO_AN_C22 + MII_CTRL1000,
> +				     ADVERTISE_1000FULL |
> +				     ADVERTISE_1000HALF, adv);

[Severity: Medium]
Does this drop master/slave (timing role) programming? The mask only covers
ADVERTISE_1000FULL | ADVERTISE_1000HALF. genphy_c45_an_config_aneg() only
writes the advertisement registers, so nothing in this callback uses
phydev->master_slave_set.

Before this patch, __genphy_config_aneg() called genphy_setup_master_slave().
That function does:

	return phy_modify_changed(phydev, MII_CTRL1000,
				  (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER |
				   CTL1000_PREFER_MASTER), ctl);

Its result was also counted toward the AN restart decision.
genphy_c45_config_aneg() does the same through
genphy_c45_an_setup_master_slave().

The ethtool paths can't reach this for this PHY, because master_slave_get is
never set and stays MASTER_SLAVE_CFG_UNSUPPORTED. A DT "timing-role"
property still sets master_slave_set through
phy_probe()->of_set_phy_timing_role().

With this patch that role is no longer written to the PHY. A role change on
its own also no longer causes an AN restart. If the link partner is forced
to the same role, master/slave resolution would fail and the link would not
come up.

as21xxx_read_c22_lpa() still prints "Master/Slave resolution failed, maybe
conflicting manual settings?", which suggests manual roles are meant to work.

Should the CTL1000 role bits be programmed in the mapped register as well,
or genphy_c45_an_setup_master_slave() be called, with the result folded
into changed?

> +	if (ret < 0)
> +		return ret;
> +	if (ret > 0)
> +		changed = true;
> +
> +	return genphy_c45_check_and_restart_aneg(phydev, changed);
> +}
> +

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261022222955.698722-1-ansuelsmth%40gmail.com
Technical Details
Message-ID: <179305602633.3134.8105334301986052059@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352108-linux-kernel-netdev=dewy.ru
References: <20261022222955.698722-3-ansuelsmth@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352108-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 3/4] net: phy: as21xxx: force C45 OPs for AUTONEG
Date: Mon, 26 Oct 2026 23:07:06 +0000
Organization: Usenet Network
Message-ID: <179305602633.3134.8105334301986052059@kernel.org>
References: <20261022222955.698722-3-ansuelsmth@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1418192"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5qjmi9a4a2zHIDxgwP6DsL6jpXE= sha256:Oaly9rWSLkbTqYOa+JLKHQb8c8bji5PVZCFMD2kM5Ys=
	sha1:34YDOS0l1kMbNo8beCt4KXwbblo= sha256:14bppdR81o0/3NOEebBl9Mwo8Ia+p1DuAbdvTEAAKo8=
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 59499125BC4; Tue, 27 Oct 2026 02:07:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.738
X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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 wIOXnCqhqgGV;
	Tue, 27 Oct 2026 02:07:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-352108-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 A57B5125BD5; Tue, 27 Oct 2026 02:07:42 +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 EAF322C4A8; Mon, 26 Oct 2026 23:07:13 +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=1793056033;
	b=A61OPjnZkSRUflCTXtfBRTf7wSLNbwmEISR869fAZIVKgz+HQv4+OTcqSRnzRmBr82EQ
	 S+/7LwL95IKckaPcdfEVlKiUdW3MOxT5/xYr2DfFqwNz9eTa90lyO608LACTe6edtRum+
	 nEG68USPti8sQoihwhhgchzyDlLtMczI5FM8AbLbiGAcOmr5cF9RlMI3fdxYs2+h5ulM5
	 q9XpljkEv8s30RM0e+nbWrbFfQnQAx06Qn0eLGcVUtFaGn/1nUhKZNmC4AnGekOZTsfgb
	 xW6efzHFENEGYyFbeKZz4fNQ8eRs1Klh14T6xeLQPj4Jdaw4FgZy/oYyzM4HBfFxXLA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793056033;
	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=cHpKnaLvTFTPYsx/NVwHyh0ZcsClx45PWlCQo1pFj+w=;
	b=UIN8iVYNNbEcPWvGoqCHzsH7KXANl4MePP0ZKfGhZgD5MwMx2k9NPJwp3zHTQ5HVKP2d
	 g9jP2/81L6KbKYMEsGSHcwdwh8nYkpx52SPV0VPrSaRlwb8jZpRBzB88DpuL8jYFNtjCq
	 626omwUe+MxDJ34a8wTRdR6G2jD/3aJvN3LW+DGwGfauX+4zemvVrMAd/gv/IxI7Guqme
	 cgiOWlP6sDsCfwoetI/20sp7L6PHwBjukUZeKGh/i3TzLtjHcpddPR+MJJb2DWunBNHWd
	 7SLC/EKgnq/9R+ptuVK7s/0rGAcIPmSAKbpDzxt1r+4jtELcD5i+PTbik+HX5z5jQHw==
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="Z98xm/jV";
	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 AC194606A31F;
	Mon, 26 Oct 2026 23:07:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z98xm/jV
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=1793056027;
	b=gLc2iL4YAYD+Pn04YcxtfX2RqGKKeoNAjHtURFQ4wWvYEQzGYYBflRIylRQkLMdNV99m
	 bbXwaT7LK4sozU1JcYnLZlq3h14YVqIuubJwnYgaKLHgWXuim9sDWW1rZMQTKy8g/i6A6
	 jZMY+H0iwN5l5SHACQLYKbjVqosLIQ4VJ3GK0C1QpLOJ1Zb+5Oi/PDyc2x84mstB9DLQA
	 PlDGQKu4kyVDvkGaGfhO+PZVwaTYW0qOlWKFyPMToRHd0tqCThHcdLwFX5XN+ON3Wu1HF
	 /gRLaWHkFd1PBN08mLaPqPnzSgY6DxODFtGeO6Am7h/oWgF79atDU7c6LUb6Iv/5PrQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793056027;
	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=cHpKnaLvTFTPYsx/NVwHyh0ZcsClx45PWlCQo1pFj+w=;
	b=N324n3iLJWt0MnhI5wZqTiBv3Y35tlv5fHM/ZiZzODOka6l2lqcqNS4bFumIK3jv+xNp
	 mQYLhEhGyIWWj3TimM1jNK7qPP/1Fj+V12yq3LLjhH25uJjY+mEhtp3x6XTpZ+dDN0RIq
	 jvzPyuSWR+7t31g97J+b19LLb6nm+5jRdiEZ8PcYFQOgCUmoVW/M10/qeFL5Vjo3x5HQi
	 68yfvZT+1A9IgwA2bbLVKHQ2AFG7GTv6PNpd3Q+t+T5WzmaMNLNn7gcxB15a78X59pjUl
	 ZrOrx4sRzsuqhXIiEo5AbAmagUUYC9ufqLKVuO/GGb600QKpi6lq135NdkoHwkIeQWw==
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="Z98xm/jV";
	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 8914D606A325;
	Mon, 26 Oct 2026 23:07:07 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD871F031E6;
	Mon, 26 Oct 2026 23:07:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793056027;
	bh=cHpKnaLvTFTPYsx/NVwHyh0ZcsClx45PWlCQo1pFj+w=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Z98xm/jVPcJrFcR5BChPoLPJpmAObj6q7LUEbYg8O8yfQ7tY1Z4bSA9H4nl6mVUQM
	 eG/sJWl2DwLJKRamCYkbU9OstNDZ2wbi9mcfri2RBIy9mz3db21GqIrfct807FMWYN
	 xAUNrc1TshJGLZGPlM74umrBO3nzZWzTLcpsHrx9b6h3tgGRJJRrqt6lFO4Q20XgaU
	 IIUMgGVbPq2/mlBnr5ZuVoVk4gDM8S4D/0sEPHb36PuF5Dih1AWzJbHkaDbPqxk9nN
	 +xnfsZf/LfZXev5E8TnQh5g2gOXKwsyKuIdxBRBnHf7Q/RIKhZU0DtkxQrtOfumvFu
	 2hc8IbQyTwTcA==
X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261022222955.698722-3-ansuelsmth@gmail.com>
X-sashiko-severity: Medium
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