Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 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 patch resets the PHY only in the timeout branch of bcm54xx_cable_test_get_status() (drivers/net/phy/broadcom.c:1523),… - [Low] The timeout branch in bcm54xx_cable_test_get_status() (drivers/net/phy/broadcom.c:1523) adds a runtime BMCR_RESET for… - [Low] When a cable test times out, bcm54xx_cable_test_get_status() (drivers/net/phy/broadcom.c:1515-1526) resets the PHY with… -- net: phy: broadcom: Time out a stuck cable test This commit adds a 5 second timeout to bcm54xx_cable_test_get_status(). If the ECD run has not finished by then, the PHY is soft-reset and -ETIMEDOUT is returned, so phylib aborts the test and reruns config_init().
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c > index 19b97beb8be8d..776a88caae9ba 100644 > --- a/drivers/net/phy/broadcom.c > +++ b/drivers/net/phy/broadcom.c
[ ... ]
> @@ -1486,21 +1491,40 @@ static int bcm54xx_cable_test_start(struct phy_device *phydev)
[ ... ]
> static int bcm54xx_cable_test_get_status(struct phy_device *phydev, > bool *finished) > { > + struct bcm54xx_phy_priv *priv = phydev->priv; > int ret; > > ret = bcm_phy_cable_test_get_status(phydev, finished); > - if (ret < 0 || !*finished) > + if (ret < 0) > return ret; > > + if (!*finished) { > + if (time_before(jiffies, priv->cable_test_timeout)) > + return 0; > + > + /* A stuck ECD run cannot be stopped through ECD_CTRL, only a > + * reset gets the PHY back. phylib reruns config_init() when > + * it aborts the test. > + */ > + genphy_soft_reset(phydev);
[Severity: Medium] Is this the only place that resets the PHY after an ECD run has started? Only the polling state machine reaches it, and only after the 5 second timeout expires. Two other paths in drivers/net/phy/phy.c leave PHY_CABLETEST. The first is phy_stop(), for example "ip link set dev X down" while a test is running: if (phydev->state == PHY_CABLETEST) { phy_abort_cable_test(phydev); netif_testing_off(dev); } The second is _phy_state_machine(), when cable_test_get_status() takes the ret < 0 path above: err = phydev->drv->cable_test_get_status(phydev, &finished); if (err) { phy_abort_cable_test(phydev); netif_testing_off(dev); state_work = PHY_STATE_WORK_ANEG; phydev->state = PHY_UP; break; } phy_abort_cable_test() only calls ethnl_cable_test_finished() and phy_init_hw(). The BCM54210E entry in broadcom_drivers[] has no .soft_reset callback, so phy_init_hw() skips the reset and goes straight to bcm54xx_config_init(). bcm54xx_config_init() then calls bcm54xx_adjust_rxrefclk(). That sets BCM54XX_SHD_APD_EN again when clk125 is disabled or PHY_BRCM_AUTO_PWRDWN_ENABLE is set. At that point ECD_CTRL still has RUN and BREAK_LINK set from _bcm_phy_cable_test_start(). The comment in bcm54xx_cable_test_start() says an ECD run never finishes on a line without energy while auto power-down is enabled. The new comment here says only a reset clears a stuck run. Could aborting a test partway through therefore create the same stuck state this patch tries to recover from? After the abort the state is PHY_UP or PHY_HALTED. Nothing polls cable_test_get_status() again, so this timeout never fires. On the phy_stop() path with WoL enabled, bcm54xx_suspend() returns before it writes BMCR_PDOWN: if (phydev->wol_enabled) return bcm54xx_set_wakeup_irq(phydev, true); bcm54xx_resume() soft-resets only when PHY_BRCM_IDDQ_SUSPEND is set. A down/up cycle would therefore not clear the stuck run either. The error path goes straight to PHY_UP without any suspend. This depends on two hardware behaviours I could not verify. One is that the ECD run stays stuck through config_init() with APD re-enabled. The other is that the later BMCR writes from config_aneg do not clear it. Could the reset go somewhere that every abort passes through? One option is ".soft_reset = genphy_soft_reset" in the BCM54210E entry. Another is a reset in bcm54xx_config_init() when ECD_CTRL still reads in progress. [Severity: Low] Can this reset wipe state that config_init() does not restore? The comment says phylib reruns config_init() when it aborts the test. That is true, through phy_abort_cable_test()->phy_init_hw()-> bcm54xx_config_init(). But config_init() only restores the settings it makes itself. An earlier commit in this series, "net: phy: broadcom: Implement cable test initialization", left the soft reset out of the reference ECD sequence for exactly this reason: drivers/net/phy/bcm-phy-lib.c:__bcm_phy_cable_test_init() { ... /* Disable ECD to load parameters. Note that the reference sequence * soft-resets the PHY first, but that is only needed for the Broadcom * DVT process and would discard the configuration done at * config_init() time. */ ... } Wake-on-LAN, for example, is written directly to hardware by bcm54xx_phy_set_wol()->bcm_phy_set_wol(), and no copy is kept. bcm54xx_config_init() only reads and acknowledges BCM54XX_WOL_INT_STATUS. Suppose BMCR_RESET clears the WoL registers on BCM54210E. Would WoL set with "ethtool -s ethX wol g" then stop working after a timed-out cable test, with no message, while the kernel still reports it as enabled? I could not confirm this on the hardware. bcm54xx_resume() already soft-resets on PHY_BRCM_IDDQ_SUSPEND platforms without reprogramming WoL, which may mean the registers survive a reset. The commit message also doesn't mention this side effect of the reset. Could it be added?
> + > + return -ETIMEDOUT; > + }
[Severity: Low] Should this timeout branch log something? The return value of genphy_soft_reset() is ignored, and nothing is printed. _phy_state_machine() handles -ETIMEDOUT by calling phy_abort_cable_test(). That sends the notification created by ethnl_cable_test_alloc() with ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED and no pair results, and phylib then drops the error code. As a result, "ethtool --cable-test" reports a completed test with no results. Nothing in dmesg says the ECD run hung or that the PHY was reset. Would a phydev_warn() here help? The commit message also doesn't say what the user sees in this case.
> + > /* Put auto power-down back the way config_init() left it */ > bcm54xx_adjust_rxrefclk(phydev);
[ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40broadcom.com