realtek: rtl931x: Fix link status get not fetching correct status
authorHarshal Gohel <[email protected]>
Tue, 8 Apr 2025 10:46:15 +0000 (10:46 +0000)
committerHauke Mehrtens <[email protected]>
Thu, 7 Aug 2025 14:01:51 +0000 (16:01 +0200)
Just like rtl930x, rtl931x also requires two reads to fetch current link
status.

While at it, rename the function to a proper naming scheme.

Signed-off-by: Harshal Gohel <[email protected]>
Co-developed-by: Markus Stockhausen <[email protected]>
Signed-off-by: Markus Stockhausen <[email protected]>
Co-developed-by: Sven Eckelmann <[email protected]>
Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Sharadanand Karanjkar <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/19578
Signed-off-by: Hauke Mehrtens <[email protected]>
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c
target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h

index bcc8f392866a85423daf511bf1f6ba528af9d07f..66e06bbb31ef5cae0439ff999cbec6b36a8d142b 100644 (file)
@@ -610,7 +610,7 @@ static const struct rtl838x_eth_reg rtl931x_reg = {
        .dma_if_rx_ring_cntr = rtl931x_dma_if_rx_ring_cntr,
        .dma_if_rx_cur = RTL931X_DMA_IF_RX_CUR,
        .rst_glb_ctrl = RTL931X_RST_GLB_CTRL,
-       .get_mac_link_sts = rtl931x_get_mac_link_sts,
+       .get_mac_link_sts = rtldsa_931x_get_mac_link_sts,
        .get_mac_link_dup_sts = rtl931x_get_mac_link_dup_sts,
        .get_mac_link_spd_sts = rtl931x_get_mac_link_spd_sts,
        .get_mac_rx_pause_sts = rtl931x_get_mac_rx_pause_sts,
index c28a94ed9ff2daceb70572f31fc91dfa6195c47a..24c750b40327064d00b63bc1b1981d726916b7f9 100644 (file)
@@ -307,9 +307,16 @@ inline u32 rtl930x_get_mac_link_sts(int port)
        return link & BIT(port);
 }
 
-inline u32 rtl931x_get_mac_link_sts(int p)
+inline u32 rtldsa_931x_get_mac_link_sts(int port)
 {
-       return (sw_r32(RTL931X_MAC_LINK_STS + ((p >> 5) << 2)) & BIT(p % 32));
+       unsigned int reg = RTL931X_MAC_LINK_STS + (port / 32) * 4;
+       u32 mask = BIT(port % 32);
+       u32 link;
+
+       link = sw_r32(reg);
+       link = sw_r32(reg);
+
+       return (link & mask);
 }
 
 inline u32 rtl838x_get_mac_link_dup_sts(int port)