[openwrt/openwrt] realtek: pcs: avoid unneeded SerDes reconfiguration

LEDE Commits lede-commits at lists.infradead.org
Sun Feb 1 02:47:29 PST 2026


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/66880d12c36b7b8f3f3407bbd120d82bc3ec4ea0

commit 66880d12c36b7b8f3f3407bbd120d82bc3ec4ea0
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Sun Jan 25 23:28:14 2026 +0000

    realtek: pcs: avoid unneeded SerDes reconfiguration
    
    Avoid to reconfigure a SerDes when it has been configured for a mode
    before. This usually applies to switches which drive multiple ports on a
    single SerDes. For those, the phylink subsystem triggers PCS
    configuration everytime although it's a single SerDes. For example, on
    switches with XSGMII-connected RTL8218D the particular SerDes is
    configured eight times but only a single run is needed.
    
    Add a proper check to pcs_config which checks the mode stored in the
    SerDes instance against the requested mode. Other 'settings' should be
    executed though, e.g. setting autoneg. While at it, drop the check if
    there is a 'setup_serdes' implementation. It's just a driver-internal
    interface and all variants implement this now.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21763
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
index 0628a8d4a0..993cdf8cdc 100644
--- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
@@ -3701,15 +3701,18 @@ static int rtpcs_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		return -ENOTSUPP;
 	}
 
-	dev_info(ctrl->dev, "configure SerDes %u for mode %s\n", sds->id,
-		 phy_modes(interface));
-
 	mutex_lock(&ctrl->lock);
 
-	if (ctrl->cfg->setup_serdes) {
+	if (sds->hw_mode != hw_mode) {
+		dev_info(ctrl->dev, "configure SerDes %u for mode %s\n", sds->id,
+			 phy_modes(interface));
+
 		ret = ctrl->cfg->setup_serdes(sds, hw_mode);
 		if (ret < 0)
 			goto out;
+	} else {
+		dev_dbg(ctrl->dev, "SerDes %u already in mode %s, no change\n",
+			 sds->id, phy_modes(interface));
 	}
 
 	if (ctrl->cfg->set_autoneg) {
@@ -3721,7 +3724,6 @@ static int rtpcs_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 	ret = 0;
 out:
 	mutex_unlock(&ctrl->lock);
-
 	return ret;
 }
 




More information about the lede-commits mailing list