[openwrt/openwrt] realtek: rtl930x: Fetch link status for all ports in switch IRQ

LEDE Commits lede-commits at lists.infradead.org
Thu Aug 7 07:09:20 PDT 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/445af8c038f46855a919e2feebcf473d8e2d32ec

commit 445af8c038f46855a919e2feebcf473d8e2d32ec
Author: Harshal Gohel <hg at simonwunderlich.de>
AuthorDate: Thu Mar 6 07:47:18 2025 +0000

    realtek: rtl930x: Fetch link status for all ports in switch IRQ
    
    Link status needs to be read twice, and a single register value is
    enough for determining link status for all the ports
    
    It is not necessary to go through each potential port separately and later
    actually identify for which ports the interrupt actually was. The helper
    for_each_set_bit() directly iterate through all set bits.
    
    While at it, rename the function to a proper naming scheme.
    
    Signed-off-by: Harshal Gohel <hg at simonwunderlich.de>
    Co-developed-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
    Signed-off-by: Sharadanand Karanjkar <sk at simonwunderlich.de>
    Link: https://github.com/openwrt/openwrt/pull/19578
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/dsa/rtl83xx/common.c    |  2 +-
 .../files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h   |  2 +-
 .../files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c   | 27 ++++++++++------------
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
index fea0551cca..7f96bdd82d 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
@@ -1614,7 +1614,7 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
 		                  IRQF_SHARED, "rtl839x-link-state", priv->ds);
 		break;
 	case RTL9300_FAMILY_ID:
-		err = request_irq(priv->link_state_irq, rtl930x_switch_irq,
+		err = request_irq(priv->link_state_irq, rtldsa_930x_switch_irq,
 				  IRQF_SHARED, "rtl930x-link-state", priv->ds);
 		break;
 	case RTL9310_FAMILY_ID:
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h
index 0d81c707af..07cd98572a 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h
@@ -175,7 +175,7 @@ void rtl839x_print_matrix(void);
 
 /* RTL930x-specific */
 u32 rtl930x_hash(struct rtl838x_switch_priv *priv, u64 seed);
-irqreturn_t rtl930x_switch_irq(int irq, void *dev_id);
+irqreturn_t rtldsa_930x_switch_irq(int irq, void *dev_id);
 irqreturn_t rtl839x_switch_irq(int irq, void *dev_id);
 void rtl930x_vlan_profile_dump(int index);
 int rtl9300_sds_power(int mac, int val);
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
index fc63e07ecc..4116fe2008 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
@@ -698,28 +698,25 @@ void rtl9300_dump_debug(void)
 	);
 }
 
-irqreturn_t rtl930x_switch_irq(int irq, void *dev_id)
+irqreturn_t rtldsa_930x_switch_irq(int irq, void *dev_id)
 {
 	struct dsa_switch *ds = dev_id;
-	u32 ports = sw_r32(RTL930X_ISR_PORT_LINK_STS_CHG);
+	struct rtl838x_switch_priv *priv = ds->priv;
+	unsigned long ports = sw_r32(RTL930X_ISR_PORT_LINK_STS_CHG);
+	unsigned int i;
 	u32 link;
 
 	/* Clear status */
 	sw_w32(ports, RTL930X_ISR_PORT_LINK_STS_CHG);
 
-	for (int i = 0; i < 28; i++) {
-		if (ports & BIT(i)) {
-			/* Read the register twice because of issues with latency at least
-			 * with the external RTL8226 PHY on the XGS1210
-			 */
-			link = sw_r32(RTL930X_MAC_LINK_STS);
-			link = sw_r32(RTL930X_MAC_LINK_STS);
-			if (link & BIT(i))
-				dsa_port_phylink_mac_change(ds, i, true);
-			else
-				dsa_port_phylink_mac_change(ds, i, false);
-		}
-	}
+	/* Read the register twice because of issues with latency at least
+	 * with the external RTL8226 PHY on the XGS1210
+	 */
+	link = sw_r32(RTL930X_MAC_LINK_STS);
+	link = sw_r32(RTL930X_MAC_LINK_STS);
+
+	for_each_set_bit(i, &ports, priv->cpu_port)
+		dsa_port_phylink_mac_change(ds, i, link & BIT(i));
 
 	return IRQ_HANDLED;
 }




More information about the lede-commits mailing list