🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26644

Re: [PATCH net-next 1/3] net: phy: broadcom: Implement cable test initialization

#26644
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 01:29
176 lines
14366 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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).

- [Medium] _bcm_phy_cable_test_start() in drivers/net/phy/bcm-phy-lib.c
  (lines 827-829) now calls __bcm_phy_cable_test_init() every time, for…
- [Medium] The commit message only describes adding an ECD initialization
  sequence.
- [Low] In _bcm_phy_load_values() (drivers/net/phy/bcm-phy-
  lib.c:665-709), the 0xEF write is commented "Specify the number of E*…

--

net: phy: broadcom: Implement cable test initialization

This patch adds an ECD initialization sequence to bcm-phy-lib. Before
every cable test starts, the sequence loads a fixed set of vendor values
into the expansion registers. It also moves per-pair result reporting into
bcm_phy_cable_test_report_pair() and adds a new
BCM54XX_ECD_LENGTH_RESULTS_FAILED sentinel.

> diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
> index b64beade8dd93..9571928db0291 100644
> --- a/drivers/net/phy/bcm-phy-lib.c
> +++ b/drivers/net/phy/bcm-phy-lib.c
> @@ -657,6 +657,154 @@ static int __bcm_phy_enable_legacy_access(struct phy_device *phydev)
>  				   BCM54XX_ACCESS_MODE_LEGACY_EN);
>  }
>  
> +struct __bcm_phy_regs {
> +	u16 reg;
> +	u16 val;
> +};
> +
> +/* Load values from an array of registers and then restores those registers back to 0 */
> +static int _bcm_phy_load_values(struct phy_device *phydev,
> +				const struct __bcm_phy_regs *regs,
> +				size_t num_regs,
> +				u16 page_num)
> +{
> +	unsigned int i;
> +	int ret;
> +
> +	/* Load the registers into the expansion E* registers */
> +	for (i = 0; i < num_regs; i++) {
> +		ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER +
> +					  regs[i].reg, regs[i].val);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
> +	/* Specify the number of E* registers to write and the page number */
> +	ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xef,
> +				  page_num << 14 | GENMASK(num_regs - 1, 0));

[Severity: Low]
This isn't a bug, but the comment says this writes the number of E*
registers. The value written is actually a bitmask built only from
num_regs:

    page_num << 14 | GENMASK(num_regs - 1, 0)

The regs[i].reg offsets are not used here. That means this is only correct
when regs[] covers 0xe0, 0xe1, ... in order with no gaps.

Both current callers meet that requirement: page 1 is 0xe0-0xe7 and page 2
is 0xe0-0xe2. The page0_init_regs table in __bcm_phy_cable_test_init()
does not (0xe0-0xe4, 0xe8-0xea). If that table were passed to this helper,
it would enable E5-E7 instead of E8-EA.

Could this comment, and the one above _bcm_phy_load_values(), call the
value an enable mask and state the contiguity requirement?

[ ... ]

> @@ -676,6 +824,10 @@ static int _bcm_phy_cable_test_start(struct phy_device *phydev, bool is_rdb)
>  			goto out;
>  	}
>  
> +	ret = __bcm_phy_cable_test_init(phydev);
> +	if (ret < 0)
> +		goto out;

[Severity: Medium]
This now runs the vendor init sequence every time, for every PHY that uses
the shared ECD helpers. There is no PHY ID, revision or flag check.

At this point in the series, the only in-tree user is the BCM54140
(bcm54140_drivers in bcm54140.c, via bcm_phy_cable_test_start_rdb()). Its
cable test already worked without this sequence:

ethtool --cable-test
  phy_start_cable_test()
    bcm_phy_cable_test_start_rdb()
      _bcm_phy_cable_test_start(phydev, true)
        __bcm_phy_cable_test_init()

The commit message only says "a number of PHYs" and does not name them.

Were the register tables in __bcm_phy_cable_test_init(), and the new
0x47ae failed value, validated on the BCM54140? The later patch that wires
up the BCM54210E says it was tested on that PHY (RPi 4B). Nothing seems to
cover the BCM54140, and no later patch in the series gates this init.

Should this be limited to the PHYs it is known to apply to? If not, could
the commit message say which PHYs it was verified on?

[ ... ]

> @@ -722,21 +874,26 @@ static bool bcm_phy_distance_valid(int result)
>  	return false;
>  }
>  
> -static int bcm_phy_report_length(struct phy_device *phydev, int pair)
> +static void bcm_phy_cable_test_report_pair(struct phy_device *phydev, u8 pair,
> +					   int fault)
>  {
> -	int val;
> +	int code = bcm_phy_cable_test_report_trans(fault);
> +	int len = -ENODATA;
>  
> -	val = __bcm_phy_read_exp(phydev,
> -				 BCM54XX_EXP_ECD_PAIR_A_LENGTH_RESULTS + pair);
> -	if (val < 0)
> -		return val;
> +	if (bcm_phy_distance_valid(fault))
> +		len = __bcm_phy_read_exp(phydev,
> +					 BCM54XX_EXP_ECD_PAIR_A_LENGTH_RESULTS +
> +					 pair);
>  
> -	if (val == BCM54XX_ECD_LENGTH_RESULTS_INVALID)
> -		return 0;
> +	/* The fault type is not valid either when the engine failed */
> +	if (len == BCM54XX_ECD_LENGTH_RESULTS_FAILED)
> +		code = ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
>  
> -	ethnl_cable_test_fault_length(phydev, pair, val);
> +	ethnl_cable_test_result(phydev, pair, code);
>  
> -	return 0;
> +	if (len >= 0 && len != BCM54XX_ECD_LENGTH_RESULTS_INVALID &&
> +	    len != BCM54XX_ECD_LENGTH_RESULTS_FAILED)
> +		ethnl_cable_test_fault_length(phydev, pair, len);
>  }

[Severity: Medium]
The commit message only describes the new ECD initialization sequence.
This hunk also changes what gets reported to user space.

When a pair's length register reads 0x47ae, the fault code from the
hardware (OPEN, SAME_SHORT or CROSS_SHORT) is now replaced with
ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC, and no length is reported.

Before this patch, the translated fault code was always reported. The
length was skipped only for 0xffff, so 0x47ae reached user space as a
fault length of 18350 cm.

This changes ethtool --cable-test output on hardware that is already
supported, such as the BCM54140.

Could the commit message describe this change and say where the 0x47ae
value comes from? Would it make sense to split it into its own patch,
possibly with a Fixes: tag?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203004802.85707-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID: <179634776647.3146.2322254136336511605@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376951-linux-kernel-netdev=dewy.ru
References: <20261203004802.85707-2-florian.fainelli@broadcom.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376951-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/3] net: phy: broadcom: Implement cable test
 initialization
Date: Fri, 04 Dec 2026 01:29:26 +0000
Organization: Usenet Network
Message-ID: <179634776647.3146.2322254136336511605@kernel.org>
References: <20261203004802.85707-2-florian.fainelli@broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2647442"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:57SMa1zOUAg7Sw1sVC0jUP1v3Z4= sha256:xbLgcvty3aF2jSu5i/+5/yVXDvrla77sAv0x3GOmiDI=
	sha1:pQuFavRqQ39asZPE9jpmSvfMA5Y= sha256:T0PTL0qJQVZqecH0wgkbHu/k+N/p57EwKR7dOMu7yKQ=
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 5889F117AA1; Fri,  4 Dec 2026 04:29:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 pbFLZw0BhMUE;
	Fri,  4 Dec 2026 04:29:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376951-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 E2BF0117A9E; Fri,  4 Dec 2026 04:29:32 +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 C25DF23DB4; Fri,  4 Dec 2026 01:29:30 +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=1796347768;
	b=pklKTgAaqKGYj6BbiMtB8IuBqwvFoh9Pz82et1mBmYDQyU9sJQTcn+pjjakgvoXvEHX1
	 HrqGEMBjkPbyJxYnvcVtZBiJXkgUrnHt97ar8Kc7DdgY/JxT9hxlgEpWDnmR5DYUB2LMG
	 A0UVt1fST+1eaO/Q6sR1Tiozc0Q/dZuLKHNpzxo/Vnx4TlcBooMzwXv/NsiVFMpiAAvvu
	 nw7nHO8oGgsPQtluByv+P4mXM9fd01ZwC/4XnypqzSg9/rm1oLy8lbWR3WcMUoj/RQ1XL
	 AUxaX4DCf6oAEN9F1JpBlptdQs4r3KSViQCvuSjOr8CG07ADPI9ZdneNhjpIa7P9DTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796347768;
	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=3XomBYpum9Dd2y7JcXWNG8EYT37ITuNlMVTFaQ8IieE=;
	b=nD6xOwP0G0UudnVBQbyyahxVPWklAR3lRERsbwDEFjd7EZy00762vLgmbMsJb/f0+DXr
	 uhg8HLZZci2TP7OuhsbqNEPtI8n8dOG1TbC8xwvYQjOOgwv9YRQAOdi11ni8KC+G3VB35
	 CRgXoJKifH/HmEnwDuReWkvwqN98dd6camphn2DWtBLcXr+Ypv7OMOYwjfHG7VLo6xtBD
	 C4AByDXKCR86uGWSpjjJINPlZOiUEavX8rjhzyg1ChLWla1nXdqMsMlltlPeXAfjyXGg4
	 +IbQ9b2mY1erAcXah6nSqZo9Y+c7/fbdJEaGYVHm++jngiEiLIp5IOhxOy5kBlr+Ubw==
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=WTq5QMgz;
	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 A063D606A335;
	Fri,  4 Dec 2026 01:29:28 +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=WTq5QMgz
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=1796347767;
	b=4HhvB3J/xsyQbwfJL06v5XperiXeM34rzQrzugE9Zmm70Ys7nE3ivS3Brg4O6oKS3yz6
	 9CR3cy4uGxyXQp281Tyd3hwIPnJyGa3eYPn6hL+cFeR05DLp5akPCsE7ChyBjX8IIjveR
	 b9IqETAxhccJylYQCIJyLJ6qw1LAqoF7KS6CkDyo2iy3ZNYA3ml9h2B9Vc0gzB9gqp6pr
	 AQNZ7Xonjr7Q0E3OKhqt6FrzMahqkRL9GBhqju4iAqoP9njhmb+9rfxBqeIBz5C/G5Ysu
	 xrmTGsUmZAq3NYkaJsLlS7UmwApfx9Sqo5pygDbY6Yts6L6VR/BrQ6mRyH1bRYW0F4g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796347767;
	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=3XomBYpum9Dd2y7JcXWNG8EYT37ITuNlMVTFaQ8IieE=;
	b=ov4iln+6fT50DjMjR8TFom4pcTjLl3BH57WJU2AK3SYV8lUppf2CghH9+Jma+dSoInxS
	 POWJ+1RnpzcYmsPEcgKO8bioUetq8/Oe0s2hM73prWTW2LzruFb8HmitnTN1tFBj4SaLo
	 qvs8sKRyHY+5Azejfwq9gwufb5MtN6uq3mNR2B5ElVFqQCkVy4E6aGS0rEswVC7rxIq/1
	 jwzn3oyc09RiZV5BbvpSfJIfIu+AOTbfXcJ+mO4P/R8wCo7c35Ml42DrYTHujPLLmhCyP
	 QZnfwlOWPt34YVDNHVLvR5uyqVERmMQqXmuQGsLV8qGayvZmJBnVQV0uuGvl2uq93FA==
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=WTq5QMgz;
	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 BBEE9606A322
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 01:29:27 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED8D51F00897;
	Fri,  4 Dec 2026 01:29:26 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796347767;
	bh=3XomBYpum9Dd2y7JcXWNG8EYT37ITuNlMVTFaQ8IieE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=WTq5QMgzqQ1A/LgxNyeVaHSfhB1C7baArrxcJRqAnDvea1gV1vYk9wpX6Hi6XtfO+
	 Z/Dq/UKhMKSyMYi6JvkPAbStMmld5dYJpg4ZJF22+EEzgqvg4NrD1bUPx/8efa7FVL
	 k1ifpVR0wuxox8f6QpHzNHLbBTSdLFrh1pkTxmC2H+HWozxCqFjaj6j5WqEhFEByyI
	 xFDaP9Fy/E81Dgg9k/Vv6R4tYB+z3gTyQ+lusjz3hjO6AfjfX30CvQv63M6xefSltW
	 +jqFpa3yyJYtzWyXpDhZkMWGtBkrtXRZy2zUL/MdwrMz+bangHztrcnJiOJV9sE6G9
	 9kRA8szmVW0Mg==
X-Cc: netdev@vger.kernel.org, nb@tipi-net.de, f.fainelli@gmail.com,
 bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch, hkallweit1@gmail.com,
 linux@armlinux.org.uk, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com
X-In-Reply-To: <20261203004802.85707-2-florian.fainelli@broadcom.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