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 3/3] net: phy: broadcom: Time out a stuck cable test
Date: Fri, 4 Dec 2026 15:18:36 -0800 [thread overview]
Message-ID: <6d971bf4-c728-4af6-8d67-30c9748bcf0a@broadcom.com> (raw)
In-Reply-To: <179634776897.3146.1850367010981287121@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: 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.
I moved the reset into the PHY reinitialization path shared by timeout,
status-read failure, and interface shutdown during a cable test. The
reset runs before APD is restored and preserves the programmed WoL
filters and interrupt routing. The driver now logs the timeout and any
reset failure. The commit message also describes the completion
notification without pair results.
pw-bot: cr
--
Florian
next prev parent reply other threads:[~2026-12-04 23:18 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
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 [this message]
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=6d971bf4-c728-4af6-8d67-30c9748bcf0a@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