* [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E
@ 2026-12-04 23:36 Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified Florian Fainelli
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:36 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Broadcom internal kernel review list,
Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
This patch series adds support for Cable tests and wires it up to the
BCM54210E PHY entry which is used on the Raspberry Pi 4 Model B and CM4
boards.
Nicolas helped me with cleaning up the code and as a second person
testing on his own systems.
Changes in v2:
- introduced separate commit changing the failed ECD pairs
- limited the ECD init to the 54210E where this was tested, leaving
BCM54140 unchanged
- make sure that a failed/aborted cable test is properly restoring all
of the registers, including those that are not part of .config_init()
like WoL
- corrected the Signed-off-by/Co-developped-by chain
- clarified in the commit message which platforms this was tested on
Florian Fainelli (2):
net: phy: broadcom: Implement cable test initialization for BCM54210E
net: phy: broadcom: Wire-up cable tests for BCM54210E
Nicolai Buchwitz (2):
net: phy: broadcom: Report failed ECD pairs as unspecified
net: phy: broadcom: Recover BCM54210E from aborted cable tests
drivers/net/phy/bcm-phy-lib.c | 202 +++++++++++++++++++++++++++++-----
drivers/net/phy/broadcom.c | 117 +++++++++++++++++++-
include/linux/brcmphy.h | 1 +
3 files changed, 292 insertions(+), 28 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
@ 2026-12-04 23:36 ` Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E Florian Fainelli
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:36 UTC (permalink / raw)
To: netdev
Cc: Nicolai Buchwitz, Florian Fainelli,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
From: Nicolai Buchwitz <nb@tipi-net.de>
The ECD engine can return the saturated value 0x47ae in a pair's
length register when the measurement fails. The shared result
handler currently reports it as a fault distance of 18350 cm.
The fault type is also invalid in this case. Check the length
before reporting the pair, report an unspecified result on
failure, and omit the distance.
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Co-developed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/phy/bcm-phy-lib.c | 46 +++++++++++++++--------------------
include/linux/brcmphy.h | 1 +
2 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index b64beade8dd9..4911dc8210cd 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -722,21 +722,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);
}
static int _bcm_phy_cable_test_get_status(struct phy_device *phydev,
@@ -772,23 +777,10 @@ static int _bcm_phy_cable_test_get_status(struct phy_device *phydev,
pair_c = FIELD_GET(BCM54XX_ECD_FAULT_TYPE_PAIR_C_MASK, ret);
pair_d = FIELD_GET(BCM54XX_ECD_FAULT_TYPE_PAIR_D_MASK, ret);
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A,
- bcm_phy_cable_test_report_trans(pair_a));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B,
- bcm_phy_cable_test_report_trans(pair_b));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_C,
- bcm_phy_cable_test_report_trans(pair_c));
- ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_D,
- bcm_phy_cable_test_report_trans(pair_d));
-
- if (bcm_phy_distance_valid(pair_a))
- bcm_phy_report_length(phydev, 0);
- if (bcm_phy_distance_valid(pair_b))
- bcm_phy_report_length(phydev, 1);
- if (bcm_phy_distance_valid(pair_c))
- bcm_phy_report_length(phydev, 2);
- if (bcm_phy_distance_valid(pair_d))
- bcm_phy_report_length(phydev, 3);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_A, pair_a);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_B, pair_b);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_C, pair_c);
+ bcm_phy_cable_test_report_pair(phydev, ETHTOOL_A_CABLE_PAIR_D, pair_d);
ret = 0;
*finished = true;
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 174687c4c80a..e90b0f7fc7b8 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -527,5 +527,6 @@
#define BCM54XX_RDB_ECD_PAIR_D_LENGTH_RESULTS 0x2a5
#define BCM54XX_EXP_ECD_PAIR_D_LENGTH_RESULTS (MII_BCM54XX_EXP_SEL_ER + 0xc5)
#define BCM54XX_ECD_LENGTH_RESULTS_INVALID 0xffff
+#define BCM54XX_ECD_LENGTH_RESULTS_FAILED 0x47ae /* saturated, ECD failure */
#endif /* _LINUX_BRCMPHY_H */
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified Florian Fainelli
@ 2026-12-04 23:36 ` Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests " Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Florian Fainelli
3 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:36 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Nicolai Buchwitz,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Load the vendor ECD parameters before starting a cable test on the
BCM54210E. The sequence was verified on a Raspberry Pi 4B with this
PHY. Match the BCM54210E model in the shared start helper so the
BCM54140 continues to use its existing start sequence.
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Co-developed-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/phy/bcm-phy-lib.c | 156 ++++++++++++++++++++++++++++++++++
1 file changed, 156 insertions(+)
diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
index 4911dc8210cd..1a170faf05ae 100644
--- a/drivers/net/phy/bcm-phy-lib.c
+++ b/drivers/net/phy/bcm-phy-lib.c
@@ -657,6 +657,156 @@ 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 the ECD page and clear the staging registers afterwards.
+ * The enable mask requires regs[] to list consecutive offsets from 0xe0.
+ */
+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;
+ }
+
+ /* Set the page number and the E* register enable mask */
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xef,
+ page_num << 14 | GENMASK(num_regs - 1, 0));
+ if (ret < 0)
+ return ret;
+
+ /* Write strobe 1 */
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xcd,
+ 0x1000);
+ if (ret < 0)
+ return ret;
+
+ /* Write strobe 0 */
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xcd, 0);
+ if (ret < 0)
+ return ret;
+
+ /* Restore expansion E* register values */
+ for (i = 0; i < num_regs; i++) {
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER +
+ regs[i].reg, 0);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* And restore 0xEF register */
+ return __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xef, 0);
+}
+
+/* Must be called with the MDIO bus lock held and legacy expansion register
+ * access enabled.
+ */
+static int __bcm_phy_cable_test_init(struct phy_device *phydev)
+{
+ static const struct __bcm_phy_regs init_regs[] = {
+ { 0xc7, 0xA01A },
+ { 0xc8, 0x0300 },
+ { 0xc9, 0x00EF },
+ { 0xcb, 0x1304 },
+ { 0xcc, 0x0180 },
+ { 0xce, 0x4000 },
+ { 0xcf, 0x3000 },
+ };
+ static const struct __bcm_phy_regs page1_init_regs[] = {
+ /* Page 1 */
+ { 0xe0, 0x0119 },
+ { 0xe1, 0x0202 },
+ { 0xe2, 0x000F },
+ { 0xe3, 0x5000 },
+ { 0xe4, 0x738E },
+ { 0xe5, 0x1000 },
+ { 0xe6, 0x1000 },
+ { 0xe7, 0xAA00 },
+ };
+ static const struct __bcm_phy_regs page2_init_regs[] = {
+ /* page 2 */
+ { 0xe0, 0x0B00 },
+ { 0xe1, 0x313D },
+ { 0xe2, 0x007C },
+ };
+ static const struct __bcm_phy_regs page0_init_regs[] = {
+ /* page 0 */
+ { 0xe0, 0x0001 },
+ { 0xe1, 0x0540 },
+ { 0xe2, 0x0E40 },
+ { 0xe3, 0x0841 },
+ { 0xe4, 0x1344 },
+ { 0xe8, 0x8760 },
+ { 0xe9, 0x4B33 },
+ { 0xea, 0x0400 },
+ };
+ unsigned int i;
+ int ret;
+
+ /* 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.
+ */
+ ret = __bcm_phy_write_exp(phydev, BCM54XX_EXP_ECD_CTRL, 0);
+ if (ret < 0)
+ return ret;
+
+ /* Prepare for loading value */
+ for (i = 0; i < ARRAY_SIZE(init_regs); i++) {
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER +
+ init_regs[i].reg,
+ init_regs[i].val);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Load page 1 values */
+ ret = _bcm_phy_load_values(phydev, page1_init_regs,
+ ARRAY_SIZE(page1_init_regs), 1);
+ if (ret < 0)
+ return ret;
+
+ /* Load page 2 values */
+ ret = _bcm_phy_load_values(phydev, page2_init_regs,
+ ARRAY_SIZE(page2_init_regs), 2);
+ if (ret < 0)
+ return ret;
+
+ /* Load the page 0 values */
+ for (i = 0; i < ARRAY_SIZE(page0_init_regs); i++) {
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER +
+ page0_init_regs[i].reg,
+ page0_init_regs[i].val);
+ if (ret < 0)
+ return ret;
+ }
+
+ /* Finish loading */
+ ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xcd, 0xd0);
+ if (ret < 0)
+ return ret;
+
+ /* Dummy read to flush the ECD register */
+ ret = __bcm_phy_read_exp(phydev, BCM54XX_EXP_ECD_CTRL);
+ if (ret < 0)
+ return ret;
+
+ return __bcm_phy_write_exp(phydev, BCM54XX_EXP_ECD_CTRL, 0);
+}
+
static int _bcm_phy_cable_test_start(struct phy_device *phydev, bool is_rdb)
{
u16 mask, set;
@@ -676,6 +826,12 @@ static int _bcm_phy_cable_test_start(struct phy_device *phydev, bool is_rdb)
goto out;
}
+ if (phy_id_compare_model(phydev->phy_id, PHY_ID_BCM54210E)) {
+ ret = __bcm_phy_cable_test_init(phydev);
+ if (ret < 0)
+ goto out;
+ }
+
mask = BCM54XX_ECD_CTRL_CROSS_SHORT_DIS | BCM54XX_ECD_CTRL_UNIT_MASK;
set = BCM54XX_ECD_CTRL_RUN | BCM54XX_ECD_CTRL_BREAK_LINK |
FIELD_PREP(BCM54XX_ECD_CTRL_UNIT_MASK,
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests for BCM54210E
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E Florian Fainelli
@ 2026-12-04 23:36 ` Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Florian Fainelli
3 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:36 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, Nicolai Buchwitz,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Wire up the cable diagnostics now that we have implemented the cable
test feature, this was verified with a Raspberry Pi 4B using a BCM54210E
PHY, Raspberry Pi CM4 and CM5 boards using BCM54210PE.
With auto power-down enabled the ECD run never finishes on an open
cable. The PHY stays in PHY_CABLETEST and the link stays down until the
interface is bounced. Turn auto power-down off during the test and
restore it via bcm54xx_adjust_rxrefclk() to ensure all cases are
covered.
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Co-developed-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/phy/broadcom.c | 43 +++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 9085b72e322f..19b97beb8be8 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -1469,6 +1469,44 @@ static int bcm54xx_disable_autonomous_eee(struct phy_device *phydev)
BCM54XX_MII_BUF_CNTL0_AUTOGREEEN_EN, 0);
}
+static int bcm54xx_cable_test_start(struct phy_device *phydev)
+{
+ int val, ret;
+
+ /* The ECD run never finishes on a line without energy while auto
+ * power-down is enabled.
+ */
+ val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD);
+ if (val < 0)
+ return val;
+
+ ret = bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD,
+ val & ~BCM54XX_SHD_APD_EN);
+ if (ret < 0)
+ return ret;
+
+ ret = bcm_phy_cable_test_start(phydev);
+ if (ret < 0)
+ bcm54xx_adjust_rxrefclk(phydev);
+
+ return ret;
+}
+
+static int bcm54xx_cable_test_get_status(struct phy_device *phydev,
+ bool *finished)
+{
+ int ret;
+
+ ret = bcm_phy_cable_test_get_status(phydev, finished);
+ if (ret < 0 || !*finished)
+ return ret;
+
+ /* Put auto power-down back the way config_init() left it */
+ bcm54xx_adjust_rxrefclk(phydev);
+
+ return 0;
+}
+
static struct phy_driver broadcom_drivers[] = {
{
PHY_ID_MATCH_MODEL(PHY_ID_BCM5411),
@@ -1498,7 +1536,8 @@ static struct phy_driver broadcom_drivers[] = {
PHY_ID_MATCH_MODEL(PHY_ID_BCM54210E),
.name = "Broadcom BCM54210E",
/* PHY_GBIT_FEATURES */
- .flags = PHY_ALWAYS_CALL_SUSPEND,
+ .flags = PHY_ALWAYS_CALL_SUSPEND |
+ PHY_POLL_CABLE_TEST,
.get_sset_count = bcm_phy_get_sset_count,
.get_strings = bcm_phy_get_strings,
.get_stats = bcm54xx_get_stats,
@@ -1513,6 +1552,8 @@ static struct phy_driver broadcom_drivers[] = {
.set_wol = bcm54xx_phy_set_wol,
.led_brightness_set = bcm_phy_led_brightness_set,
.disable_autonomous_eee = bcm54xx_disable_autonomous_eee,
+ .cable_test_start = bcm54xx_cable_test_start,
+ .cable_test_get_status = bcm54xx_cable_test_get_status,
}, {
PHY_ID_MATCH_MODEL(PHY_ID_BCM5461),
.name = "Broadcom BCM5461",
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
` (2 preceding siblings ...)
2026-12-04 23:36 ` [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests " Florian Fainelli
@ 2026-12-04 23:36 ` Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
3 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:36 UTC (permalink / raw)
To: netdev
Cc: Nicolai Buchwitz, Florian Fainelli,
Broadcom internal kernel review list, Andrew Lunn,
Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
From: Nicolai Buchwitz <nb@tipi-net.de>
A stuck ECD run can leave the PHY in PHY_CABLETEST indefinitely.
Time out after five seconds. phylib reports completion without
pair results, so log the timeout to distinguish it from a
successful test.
Reset the PHY through phy_init_hw() while it is still in
PHY_CABLETEST. This covers timeout, status read errors and an
interface stop during the test. A reset stops the ECD engine
before config_init() can re-enable auto power-down. Propagate
reset errors to phylib.
A soft reset may clear register settings outside config_init().
Preserve the enabled wake filters, interrupt mask and LED routing
across the reset without changing the host IRQ wake state. The
normal initialization sequence reapplies the driver's defaults,
including its LED configuration.
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Co-developed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/phy/broadcom.c | 80 ++++++++++++++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index 19b97beb8be8..3b32c15e4dd6 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -30,12 +30,16 @@ MODULE_DESCRIPTION("Broadcom PHY driver");
MODULE_AUTHOR("Maciej W. Rozycki");
MODULE_LICENSE("GPL");
+/* An ECD run takes less than a second */
+#define BCM54XX_CABLE_TEST_TIMEOUT_MS 5000
+
struct bcm54xx_phy_priv {
u64 *stats;
struct bcm_ptp_private *ptp;
int wake_irq;
bool wake_irq_enabled;
bool brr_mode;
+ unsigned long cable_test_timeout;
};
/* Link modes for BCM58411 PHY */
@@ -1471,6 +1475,7 @@ static int bcm54xx_disable_autonomous_eee(struct phy_device *phydev)
static int bcm54xx_cable_test_start(struct phy_device *phydev)
{
+ struct bcm54xx_phy_priv *priv = phydev->priv;
int val, ret;
/* The ECD run never finishes on a line without energy while auto
@@ -1486,21 +1491,89 @@ static int bcm54xx_cable_test_start(struct phy_device *phydev)
return ret;
ret = bcm_phy_cable_test_start(phydev);
- if (ret < 0)
+ if (ret < 0) {
bcm54xx_adjust_rxrefclk(phydev);
+ return ret;
+ }
- return ret;
+ priv->cable_test_timeout = jiffies +
+ msecs_to_jiffies(BCM54XX_CABLE_TEST_TIMEOUT_MS);
+
+ return 0;
+}
+
+static int bcm54210e_soft_reset(struct phy_device *phydev)
+{
+ static const u16 wol_regs[] = {
+ BCM54XX_WOL_MPD_DATA1(0), BCM54XX_WOL_MPD_DATA1(1),
+ BCM54XX_WOL_MPD_DATA1(2), BCM54XX_WOL_MPD_DATA2(0),
+ BCM54XX_WOL_MPD_DATA2(1), BCM54XX_WOL_MPD_DATA2(2),
+ BCM54XX_WOL_MASK(0), BCM54XX_WOL_MASK(1), BCM54XX_WOL_MASK(2),
+ BCM54XX_WOL_INT_MASK, BCM54XX_TOP_MISC_LED_CTL,
+ };
+ u16 wol_values[ARRAY_SIZE(wol_regs)];
+ int wol_ctl, ret;
+ unsigned int i;
+
+ /* phylib reinitializes the PHY before leaving PHY_CABLETEST
+ * on an abort. Reset the ECD engine before config_init restores APD.
+ */
+ if (phydev->state != PHY_CABLETEST)
+ return 0;
+
+ wol_ctl = bcm_phy_read_exp(phydev, BCM54XX_WOL_MAIN_CTL);
+ if (wol_ctl < 0)
+ return wol_ctl;
+
+ /* Preserve the programmed wake filters and interrupt routing. */
+ if (wol_ctl & BCM54XX_WOL_EN) {
+ for (i = 0; i < ARRAY_SIZE(wol_regs); i++) {
+ ret = bcm_phy_read_exp(phydev, wol_regs[i]);
+ if (ret < 0)
+ return ret;
+
+ wol_values[i] = ret;
+ }
+ }
+
+ ret = genphy_soft_reset(phydev);
+ if (ret < 0) {
+ phydev_err(phydev, "Failed to reset PHY after cable test: %d\n",
+ ret);
+ return ret;
+ }
+
+ if (!(wol_ctl & BCM54XX_WOL_EN))
+ return 0;
+
+ for (i = 0; i < ARRAY_SIZE(wol_regs); i++) {
+ ret = bcm_phy_write_exp(phydev, wol_regs[i], wol_values[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return bcm_phy_write_exp(phydev, BCM54XX_WOL_MAIN_CTL,
+ wol_ctl & ~BCM54XX_WOL_RST);
}
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;
+
+ phydev_warn(phydev, "Cable test timed out\n");
+ return -ETIMEDOUT;
+ }
+
/* Put auto power-down back the way config_init() left it */
bcm54xx_adjust_rxrefclk(phydev);
@@ -1542,6 +1615,7 @@ static struct phy_driver broadcom_drivers[] = {
.get_strings = bcm_phy_get_strings,
.get_stats = bcm54xx_get_stats,
.probe = bcm54xx_phy_probe,
+ .soft_reset = bcm54210e_soft_reset,
.config_init = bcm54xx_config_init,
.config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
--
2.56.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified
2026-12-04 23:36 ` [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified Florian Fainelli
@ 2026-12-06 0:07 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-06 0:07 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, nb, bcm-kernel-feedback-list, andrew, hkallweit1, linux,
davem, edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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_report_pair() only checks for the engine-
failure marker BCM54XX_ECD_LENGTH_RESULTS_FAILED (0x47ae) on pairs…
- [Low] The patch fixes behaviour in the shared Broadcom ECD result
handler but has no Fixes: tag.
--
net: phy: broadcom: Report failed ECD pairs as unspecified
This adds a BCM54XX_ECD_LENGTH_RESULTS_FAILED (0x47ae) sentinel for the
ECD length registers. It also merges the per-pair result and length
reporting into a new helper, bcm_phy_cable_test_report_pair(). When a
pair's length register reads 0x47ae, the pair is reported as UNSPEC and no
fault length is emitted.
> The ECD engine can return the saturated value 0x47ae in a pair's
> length register when the measurement fails. The shared result
> handler currently reports it as a fault distance of 18350 cm.
[Severity: Low]
Should this patch have a Fixes: tag?
The code in bcm_phy_report_length() that passed 0x47ae straight to
ethnl_cable_test_fault_length() came from this commit:
Fixes: 11ecf8c55b91 ("net: phy: broadcom: add cable test support")
At this point in the tree, BCM54140 is the only user of the shared handler,
through bcm_phy_cable_test_get_status_rdb() in drivers/net/phy/bcm54140.c.
BCM54210E only starts using it later in the series.
If BCM54140 can return 0x47ae, this fixes hardware that is already
supported. If the failure only shows up on BCM54210E, could the commit
message say so?
> diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
> index b64beade8dd93..4911dc8210cdd 100644
> --- a/drivers/net/phy/bcm-phy-lib.c
> +++ b/drivers/net/phy/bcm-phy-lib.c
> @@ -722,21 +722,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;
[Severity: Medium]
Can a failed pair still be reported as OK here?
The comment says the fault type is not valid when the engine fails. The
length register is the only failure indicator used, and it is only read
when bcm_phy_distance_valid(fault) is true. That means the nibble has to
be OPEN, SAME_SHORT or CROSS_SHORT:
static bool bcm_phy_distance_valid(int result)
{
switch (result) {
case BCM54XX_ECD_FAULT_TYPE_OPEN:
case BCM54XX_ECD_FAULT_TYPE_SAME_SHORT:
case BCM54XX_ECD_FAULT_TYPE_CROSS_SHORT:
return true;
}
return false;
}
Suppose a failed run leaves a pair's nibble as BCM54XX_ECD_FAULT_TYPE_OK:
- len stays -ENODATA.
- The 0x47ae check never fires.
- bcm_phy_cable_test_report_trans() returns
ETHTOOL_A_CABLE_RESULT_CODE_OK.
User space then sees a healthy pair instead of UNSPEC. INVALID, BUSY and
unknown nibbles already map to UNSPEC, so OK appears to be the only case
affected.
The new header definition also describes 0x47ae as an ECD failure without
tying it to any fault type:
#define BCM54XX_ECD_LENGTH_RESULTS_FAILED 0x47ae /* saturated, ECD failure */
Would it make sense to read the length register for OK pairs as well, and
check for the sentinel before trusting the decoded nibble? If the hardware
only reports 0x47ae together with an OPEN or SHORT code, could the commit
message and the comment say that?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204233633.3790143-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E
2026-12-04 23:36 ` [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E Florian Fainelli
@ 2026-12-06 0:07 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-06 0:07 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, nb, bcm-kernel-feedback-list, andrew, hkallweit1, linux,
davem, edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In _bcm_phy_load_values() (drivers/net/phy/bcm-phy-lib.c), two
comments say values are being restored, but the code only writes zeros.
--
net: phy: broadcom: Implement cable test initialization for BCM54210E
This commit loads vendor ECD parameters on the BCM54210E before a cable
test starts. It adds _bcm_phy_load_values() and
__bcm_phy_cable_test_init() to write the staging and paged expansion
registers. Only the BCM54210E model in _bcm_phy_cable_test_start() runs
this sequence.
> diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c
> index 4911dc8210cdd..1a170faf05aef 100644
> --- a/drivers/net/phy/bcm-phy-lib.c
> +++ b/drivers/net/phy/bcm-phy-lib.c
> @@ -657,6 +657,156 @@ static int __bcm_phy_enable_legacy_access(struct phy_device *phydev)
[ ... ]
> +/* Load the ECD page and clear the staging registers afterwards.
> + * The enable mask requires regs[] to list consecutive offsets from 0xe0.
> + */
> +static int _bcm_phy_load_values(struct phy_device *phydev,
> + const struct __bcm_phy_regs *regs,
> + size_t num_regs,
> + u16 page_num)
> +{
[ ... ]
> + /* Write strobe 0 */
> + ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xcd, 0);
> + if (ret < 0)
> + return ret;
> +
> + /* Restore expansion E* register values */
> + for (i = 0; i < num_regs; i++) {
> + ret = __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER +
> + regs[i].reg, 0);
> + if (ret < 0)
> + return ret;
> + }
> +
> + /* And restore 0xEF register */
> + return __bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0xef, 0);
> +}
[Severity: Low]
This isn't a bug, but should these two comments say "clear" instead of
"restore"?
Nothing in _bcm_phy_load_values() reads or saves the earlier contents
of the E* staging registers or of MII_BCM54XX_EXP_SEL_ER + 0xef. Both
blocks just write 0 to them.
The header comment above the function says "clear the staging registers
afterwards", which matches what the code does. The two comments in the
body say the old values are restored, which contradicts the header.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204233633.3790143-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests for BCM54210E
2026-12-04 23:36 ` [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests " Florian Fainelli
@ 2026-12-06 0:07 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-06 0:07 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, nb, bcm-kernel-feedback-list, andrew, hkallweit1, linux,
davem, edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] On BCM53573 boards, one successful cable test on a BCM54210E
silently drops the forced-master setting.
--
net: phy: broadcom: Wire-up cable tests for BCM54210E
This commit wires up cable diagnostics for the BCM54210E PHY. It turns off
auto power-down while the ECD run is in progress. On completion or on a
start failure it restores auto power-down through
bcm54xx_adjust_rxrefclk().
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 9085b72e322f4..19b97beb8be8d 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
[ ... ]
> +static int bcm54xx_cable_test_get_status(struct phy_device *phydev,
> + bool *finished)
> +{
> + int ret;
> +
> + ret = bcm_phy_cable_test_get_status(phydev, finished);
> + if (ret < 0 || !*finished)
> + return ret;
> +
> + /* Put auto power-down back the way config_init() left it */
> + bcm54xx_adjust_rxrefclk(phydev);
[Severity: Medium]
Does a successful cable test on BCM53573 boards drop the forced master
mode that config_init() set up?
bgmac_probe() in drivers/net/ethernet/broadcom/bgmac-bcma.c sets
PHY_BRCM_EN_MASTER_MODE for a BCM54210E on BCM53573. bcm54210e_config_init()
then sets the master bits:
drivers/net/phy/broadcom.c:bcm54210e_config_init() {
...
if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) {
val = phy_read(phydev, MII_CTRL1000);
val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER;
phy_write(phydev, MII_CTRL1000, val);
}
...
}
With this patch, bcm54xx_cable_test_start()->bcm_phy_cable_test_start()->
_bcm_phy_cable_test_start() becomes reachable for this PHY. That path
clears the register unconditionally:
drivers/net/phy/bcm-phy-lib.c:_bcm_phy_cable_test_start() {
...
phy_write(phydev, MII_CTRL1000, 0);
...
}
When the test completes, bcm54xx_cable_test_get_status() only calls
bcm54xx_adjust_rxrefclk(). That restores the SCR3 and APD shadow
registers, not MII_CTRL1000.
The BCM54210E entry has no .config_aneg, so the renegotiation after the
test goes through genphy_config_aneg(). genphy_setup_master_slave()
returns early for MASTER_SLAVE_CFG_UNKNOWN or MASTER_SLAVE_CFG_UNSUPPORTED,
because the forced-master request comes from a driver-private dev_flag
rather than ethtool or DT. genphy_config_advert() only modifies
ADVERTISE_1000FULL and ADVERTISE_1000HALF.
So the PHY renegotiates with automatic master/slave resolution until the
next phy_init_hw(). Only the abort path re-runs config_init, through
phy_abort_cable_test()->phy_init_hw().
The later commit in this series, "net: phy: broadcom: Recover BCM54210E
from aborted cable tests", adds bcm54210e_soft_reset(). That only acts
when phydev->state == PHY_CABLETEST on the abort path. The successful
completion path is unchanged, so the problem is still there at the end of
the series.
Could the completion path re-apply the PHY_BRCM_EN_MASTER_MODE bits, or
save and restore MII_CTRL1000 around the test?
> +
> + return 0;
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204233633.3790143-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests
2026-12-04 23:36 ` [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Florian Fainelli
@ 2026-12-06 0:07 ` netdev-bot+sashiko
0 siblings, 0 replies; 9+ messages in thread
From: netdev-bot+sashiko @ 2026-12-06 0:07 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, nb, bcm-kernel-feedback-list, andrew, hkallweit1, linux,
davem, edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · 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] bcm54210e_soft_reset() (drivers/net/phy/broadcom.c) adds a
BMCR_RESET through genphy_soft_reset() to every cable-test abort on…
- [Medium] net: phy: broadcom: bcm54210e_soft_reset() falsely clears
phydev->suspended
- [Medium] net: phy: broadcom: bcm54210e_soft_reset() drops unpolled PHY
stats counters
- [Low] Any error inside bcm54210e_soft_reset()
(drivers/net/phy/broadcom.c) is returned to phy_init_hw().
--
net: phy: broadcom: Recover BCM54210E from aborted cable tests
This patch adds a five second timeout to the BCM54210E cable test. It also
adds a .soft_reset callback that resets the PHY through genphy_soft_reset()
when phy_init_hw() runs while the state is still PHY_CABLETEST. When WoL is
enabled, the WoL filter registers, WoL interrupt mask and TOP_MISC_LED_CTL
are saved before the reset and restored after it.
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 19b97beb8be8d..3b32c15e4dd60 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
[ ... ]
> +static int bcm54210e_soft_reset(struct phy_device *phydev)
> +{
> + static const u16 wol_regs[] = {
> + BCM54XX_WOL_MPD_DATA1(0), BCM54XX_WOL_MPD_DATA1(1),
> + BCM54XX_WOL_MPD_DATA1(2), BCM54XX_WOL_MPD_DATA2(0),
> + BCM54XX_WOL_MPD_DATA2(1), BCM54XX_WOL_MPD_DATA2(2),
> + BCM54XX_WOL_MASK(0), BCM54XX_WOL_MASK(1), BCM54XX_WOL_MASK(2),
> + BCM54XX_WOL_INT_MASK, BCM54XX_TOP_MISC_LED_CTL,
> + };
[Severity: Medium]
What happens to the PTP timestamping configuration across this reset?
The commit message says "A soft reset may clear register settings outside
config_init()", and this list covers the WoL and LED registers. It does
not cover the PTP expansion registers that bcm_ptp_hwtstamp_set() programs
at runtime:
drivers/net/phy/bcm-phy-ptp.c:bcm_ptp_hwtstamp_set() {
...
bcm_phy_write_exp(priv->phydev, TX_EVENT_MODE, mode);
...
bcm_phy_write_exp(priv->phydev, RX_EVENT_MODE, mode);
bcm_phy_write_exp(priv->phydev, SLICE_CTRL, ctrl);
if (ctrl & SLICE_TX_EN)
bcm_phy_write_exp(priv->phydev, TX_TS_CAPTURE, TX_TS_CAP_EN);
...
}
PTP is only attached to PHY_ID_BCM54210E, the same device that now gets
the reset. After the reset, config_init() runs
bcm54xx_config_init()->bcm54xx_ptp_config_init()->bcm_ptp_config_init().
That path only writes NSE_CTRL, TIME_SYNC, DPLL_SELECT, TIMECODE_CTRL,
SHADOW_CTRL and SYNC_IN_DIVIDER.
priv->hwts_rx and priv->tx_type in struct bcm_ptp_private survive the
reset. So bcm_ptp_rxtstamp() and bcm_ptp_txtstamp() keep treating
timestamping as enabled.
If BMCR_RESET clears these registers, would TX timestamp requests sit in
tx_queue until they expire? Would RX PTP frames arrive without inserted
timestamps, with no error reported?
Before this patch the BCM54210E entry had no .soft_reset, so phy_init_hw()
on the abort path never reset the chip.
The LED routing has a smaller version of the same gap. TOP_MISC_LED_CTL is
only preserved when BCM54XX_WOL_EN is set. bcm_phy_set_wol() with
wolopts == 0 clears WOL_EN but leaves BCM54XX_LED4_SEL_INTR set in
TOP_MISC_LED_CTL. Is that LED setting expected to be lost in that case?
> + u16 wol_values[ARRAY_SIZE(wol_regs)];
> + int wol_ctl, ret;
> + unsigned int i;
[ ... ]
> + wol_ctl = bcm_phy_read_exp(phydev, BCM54XX_WOL_MAIN_CTL);
> + if (wol_ctl < 0)
> + return wol_ctl;
> +
> + /* Preserve the programmed wake filters and interrupt routing. */
> + if (wol_ctl & BCM54XX_WOL_EN) {
> + for (i = 0; i < ARRAY_SIZE(wol_regs); i++) {
> + ret = bcm_phy_read_exp(phydev, wol_regs[i]);
> + if (ret < 0)
> + return ret;
> +
> + wol_values[i] = ret;
> + }
> + }
> +
> + ret = genphy_soft_reset(phydev);
> + if (ret < 0) {
> + phydev_err(phydev, "Failed to reset PHY after cable test: %d\n",
> + ret);
> + return ret;
> + }
[Severity: Medium]
Are the PHY error and LPI counters lost across this reset?
The counters behind bcm54xx_get_stats() are clear-on-read in the
PHY. They only reach priv->stats when bcm_phy_update_stats_shadow()
runs, which is why bcm54xx_suspend() flushes them before powering
down:
drivers/net/phy/broadcom.c:bcm54xx_suspend() {
...
mutex_lock(&phydev->lock);
bcm_phy_update_stats_shadow(phydev, priv->stats);
mutex_unlock(&phydev->lock);
...
}
bcm54210e_soft_reset() calls genphy_soft_reset() without a similar
flush. Anything counted since the last ethtool -S read is then
discarded. That happens on every aborted cable test:
- on the new -ETIMEDOUT path,
- on a status read error,
- on phy_stop() during the test.
In the phy_stop() case, phy_abort_cable_test() runs phy_init_hw()
before phy_suspend() reaches bcm54xx_suspend(). The flush there
runs only after the counters are already gone.
Should the reset path call bcm_phy_update_stats_shadow() on
priv->stats before genphy_soft_reset()? The abort path already runs
with phydev->lock held, so it could not take the lock the way
bcm54xx_suspend() does.
[Severity: Low]
What state is the PHY left in if one of these error returns is taken?
phy_init_hw() returns as soon as soft_reset() fails. That skips
config_init(), config_intr() and the autonomous EEE re-apply:
drivers/net/phy/phy_device.c:phy_init_hw() {
...
if (phydev->drv->soft_reset) {
ret = phydev->drv->soft_reset(phydev);
if (ret < 0)
return ret;
...
}
phy_abort_cable_test() only logs the error. _phy_state_machine() then
moves to PHY_UP and starts aneg anyway:
drivers/net/phy/phy.c:phy_abort_cable_test() {
...
err = phy_init_hw(phydev);
if (err)
phydev_err(phydev, "Error while aborting cable test");
}
Suppose the bcm_phy_read_exp() of BCM54XX_WOL_MAIN_CTL fails, or a read of
one of the saved WoL registers fails. The function then returns before
genphy_soft_reset() runs.
Would that leave the ECD engine running, with APD still cleared by
bcm54xx_cable_test_start()? The state has already left PHY_CABLETEST, so
the new timeout in bcm54xx_cable_test_get_status() can no longer catch it.
Before this patch the abort path always reached config_init().
Now suppose genphy_soft_reset() fails after BMCR_RESET was written, for
example on a phy_poll_reset() timeout. Or one of the WoL restore writes
fails after a successful reset. Either way the PHY is left at reset
defaults.
Would the RGMII delays, ECR/IMR interrupt masking, LED and PTP setup then
stay unapplied while phylib carries on into autonegotiation?
> +
> + if (!(wol_ctl & BCM54XX_WOL_EN))
> + return 0;
[Severity: Medium]
Does adding a .soft_reset that is a no-op outside PHY_CABLETEST
change what phy_init_hw() assumes about the power state?
Before this patch the BCM54210E entry had no .soft_reset, so
phy_init_hw() never touched phydev->suspended. Now every
phy_init_hw() call takes the soft_reset branch. Once the callback
returns >= 0, the flag is cleared unconditionally:
drivers/net/phy/phy_device.c:phy_init_hw() {
...
if (phydev->drv->soft_reset) {
ret = phydev->drv->soft_reset(phydev);
if (ret < 0)
return ret;
phydev->suspended = 0;
}
...
}
That relies on BMCR_RESET having cleared BMCR_PDOWN. Outside
PHY_CABLETEST, bcm54210e_soft_reset() returns 0 without writing
BMCR. A PHY that bcm54xx_suspend() powered down then stays in
BMCR_PDOWN (and IDDQ if configured) while phydev->suspended reads 0.
Several callers run phy_init_hw() on a suspended PHY without a
guaranteed phy_resume() afterwards:
- bcmgenet_resume() calls phy_init_hw() before bcmgenet_init_dma()
and only calls phy_resume() conditionally. GENET is the MAC paired
with this PHY on the Raspberry Pi 4 and CM4.
- ave_resume() skips phy_resume() when the interface is down.
- mdio_bus_phy_resume() and phy_attach_direct() can fail between
phy_init_hw() and phy_resume().
With the flag out of sync, phylink_prepare_resume() would skip
phy_resume() while RXC is still stopped by BMCR_PDOWN. phy_suspend()
would also run bcm54xx_suspend() again on a PHY that is already
down. That repeats the stats shadow update and the
BCM54XX_WOL_INT_STATUS read while the PHY is powered down.
Could the cable test reset be done somewhere that does not report
a reset to phylib when none happened? One option might be the start
of bcm54xx_config_init() when phydev->state is PHY_CABLETEST.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204233633.3790143-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-06 0:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 23:36 [PATCH net-next v2 0/4] net: phy: Cable tests for BCM54210E Florian Fainelli
2026-12-04 23:36 ` [PATCH net-next v2 1/4] net: phy: broadcom: Report failed ECD pairs as unspecified Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 2/4] net: phy: broadcom: Implement cable test initialization for BCM54210E Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 3/4] net: phy: broadcom: Wire-up cable tests " Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
2026-12-04 23:36 ` [PATCH net-next v2 4/4] net: phy: broadcom: Recover BCM54210E from aborted cable tests Florian Fainelli
2026-12-06 0:07 ` netdev-bot+sashiko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.