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/2026…%40broadcom.com