From: Florian Fainelli <florian.fainelli@broadcom.com>
To: netdev-bot+sashiko@kernel.org
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
Subject: Re: [PATCH net-next 1/3] net: phy: broadcom: Implement cable test initialization
Date: Fri, 4 Dec 2026 15:14:20 -0800 [thread overview]
Message-ID: <5258365b-144e-4e45-8b2f-430477375384@broadcom.com> (raw)
In-Reply-To: <179634776647.3146.2322254136336511605@kernel.org>
On 12/3/26 17:29, netdev-bot+sashiko@kernel.org wrote:
> 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?
I split the 0x47ae handling into a preliminary patch which was
originally Nicolai as a fixup sent separately. It documents the
saturated ECD failure value and reports the affected pair as unspecified
without a distance. The initialization patch now limits the vendor
sequence to BCM54210E, which was tested on a Raspberry Pi 4B. BCM54140
keeps its existing initialization path. I also clarified the enable mask
and its requirement for consecutive registers starting at 0xe0.
pw-bot: cr
--
Florian
next prev parent reply other threads:[~2026-12-04 23:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 0:47 [PATCH net-next 0/3] net: phy: Cable tests for BCM54210E Florian Fainelli
2026-12-03 0:48 ` [PATCH net-next 1/3] net: phy: broadcom: Implement cable test initialization Florian Fainelli
2026-12-04 1:29 ` netdev-bot+sashiko
2026-12-04 23:14 ` Florian Fainelli [this message]
2026-12-03 0:48 ` [PATCH net-next 2/3] net: phy: broadcom: Wire-up cable tests for BCM54210E Florian Fainelli
2026-12-03 12:59 ` Nicolai Buchwitz
2026-12-04 1:29 ` netdev-bot+sashiko
2026-12-04 23:06 ` Florian Fainelli
2026-12-03 0:48 ` [PATCH net-next 3/3] net: phy: broadcom: Time out a stuck cable test Florian Fainelli
2026-12-04 1:29 ` netdev-bot+sashiko
2026-12-04 23:18 ` Florian Fainelli
2026-12-03 21:20 ` [PATCH net-next 0/3] net: phy: Cable tests for BCM54210E Nicolai Buchwitz
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=5258365b-144e-4e45-8b2f-430477375384@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nb@tipi-net.de \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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