]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: rtl930x: Fetch link status for all ports in switch IRQ
authorHarshal Gohel <hg@simonwunderlich.de>
Thu, 6 Mar 2025 07:47:18 +0000 (07:47 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Thu, 7 Aug 2025 14:01:51 +0000 (16:01 +0200)
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@simonwunderlich.de>
Co-developed-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Signed-off-by: Sharadanand Karanjkar <sk@simonwunderlich.de>
Link: https://github.com/openwrt/openwrt/pull/19578
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl83xx.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c

index fea0551ccaad5df65e69db8aac29155e29dedb4b..7f96bdd82d1989ab4281fa94ffe02125f162b623 100644 (file)
@@ -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:
index 0d81c707afa8884dda5ad670618fff62dbbf4c35..07cd98572a53dd8a3a3278d72d64ff855dc5cc30 100644 (file)
@@ -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);
index fc63e07ecc8d6a19b612940de0291ad59c458b57..4116fe20088f162f73fd0df4a8fdd91fb47b2fdc 100644 (file)
@@ -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;
 }