openwrt/target/linux/generic/pending-6.6/720-08-net-phy-realtek-work-around-broken-serdes.patch
Daniel Golle 81db307748
Some checks failed
Build Kernel / Build all affected Kernels (push) Waiting to run
Build all core packages / Build all core packages for selected target (push) Has been cancelled
generic: net: phy: realtek: work-around hang on SerDes setup
On some but not all devices using the RTL8221B 2.5GBit/s PHY the SerDes
setup sequence may hang under some circumstances (eg. <2500M link
partner present during boot).

RTL8221B-VB-CG 2.5Gbps PHY (C45) mdio-bus:01: rtl822xb_config_init failed: -110

Work-around the issue by performing a hardware reset and subsequent
retry of the SerDes setup, which seems to always succeed.

Doing this requires moving ALDPS setup to config_init (which is anyway
the better place for that) as it otherwise doesn't survive the reset.

Also disable listening on MDIO address 0 which may be used by other PHYs
despite being spec'ed as "broadcast address", as bus activity on address
0 may otherwise confuse the RealTek PHY for good reasons.

Tested-by: Luis Mita <luis@luismita.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit c87a767801ef375feadb0a5c41d5a674ad3a7d2c)
Link: https://github.com/openwrt/openwrt/pull/17790
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-01-31 21:38:34 +01:00

59 lines
2.0 KiB
Diff

From: Daniel Golle <daniel@makrotopia.org>
Date: Thu, 30 Jan 2025 05:33:12 +0000
Subject: [PATCH] net: phy: realtek: work around broken SerDes
For still unknown reasons the SerDes init sequence may sometimes
time out because a self-clearing bit never clears, indicating the
PHY has entered an unrecoverable error state.
Work-around the issue by triggering a hardware reset and retry the
setup sequence while warning the user that this has happened.
This is really more of a work-around than a fix, and should be
replaced by a better actual fix in future (hopefully).
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -923,6 +923,22 @@ static int rtl822xb_config_init(struct p
return 0;
}
+static int rtl822xb_config_init_war(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = rtl822xb_config_init(phydev);
+
+ if (ret == -ETIMEDOUT) {
+ phydev_warn(phydev, "SerDes setup timed out, retrying\n");
+ phy_device_reset(phydev, 1);
+ phy_device_reset(phydev, 0);
+ ret = rtl822xb_config_init(phydev);
+ }
+
+ return ret;
+}
+
static int rtl822xb_get_rate_matching(struct phy_device *phydev,
phy_interface_t iface)
{
@@ -1605,7 +1621,7 @@ static struct phy_driver realtek_drvs[]
.handle_interrupt = rtl8221b_handle_interrupt,
.soft_reset = genphy_soft_reset,
.probe = rtl822x_probe,
- .config_init = rtl822xb_config_init,
+ .config_init = rtl822xb_config_init_war,
.get_rate_matching = rtl822xb_get_rate_matching,
.get_features = rtl822x_c45_get_features,
.config_aneg = rtl822x_c45_config_aneg,
@@ -1635,7 +1651,7 @@ static struct phy_driver realtek_drvs[]
.handle_interrupt = rtl8221b_handle_interrupt,
.soft_reset = genphy_soft_reset,
.probe = rtl822x_probe,
- .config_init = rtl822xb_config_init,
+ .config_init = rtl822xb_config_init_war,
.get_rate_matching = rtl822xb_get_rate_matching,
.get_features = rtl822x_c45_get_features,
.config_aneg = rtl822x_c45_config_aneg,