]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: hibmcge: fix the np_link_fail error reporting issue
authorJijie Shao <shaojijie@huawei.com>
Wed, 6 Aug 2025 10:27:58 +0000 (18:27 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 Aug 2025 18:48:49 +0000 (11:48 -0700)
Currently, after modifying device port mode, the np_link_ok state
is immediately checked. At this point, the device may not yet ready,
leading to the querying of an intermediate state.

This patch will poll to check if np_link is ok after
modifying device port mode, and only report np_link_fail upon timeout.

Fixes: e0306637e85d ("net: hibmcge: Add support for mac link exception handling feature")
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c

index 8cca8316ba4010819d87b6e4e3bec428f1761f5d..d0aa0661ecd4d83a5c001a78c119241fb3e8c0ec 100644 (file)
@@ -12,6 +12,8 @@
 
 #define HBG_HW_EVENT_WAIT_TIMEOUT_US   (2 * 1000 * 1000)
 #define HBG_HW_EVENT_WAIT_INTERVAL_US  (10 * 1000)
+#define HBG_MAC_LINK_WAIT_TIMEOUT_US   (500 * 1000)
+#define HBG_MAC_LINK_WAIT_INTERVAL_US  (5 * 1000)
 /* little endian or big endian.
  * ctrl means packet description, data means skb packet data
  */
@@ -228,6 +230,9 @@ void hbg_hw_fill_buffer(struct hbg_priv *priv, u32 buffer_dma_addr)
 
 void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
 {
+       u32 link_status;
+       int ret;
+
        hbg_hw_mac_enable(priv, HBG_STATUS_DISABLE);
 
        hbg_reg_write_field(priv, HBG_REG_PORT_MODE_ADDR,
@@ -239,8 +244,14 @@ void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
 
        hbg_hw_mac_enable(priv, HBG_STATUS_ENABLE);
 
-       if (!hbg_reg_read_field(priv, HBG_REG_AN_NEG_STATE_ADDR,
-                               HBG_REG_AN_NEG_STATE_NP_LINK_OK_B))
+       /* wait MAC link up */
+       ret = readl_poll_timeout(priv->io_base + HBG_REG_AN_NEG_STATE_ADDR,
+                                link_status,
+                                FIELD_GET(HBG_REG_AN_NEG_STATE_NP_LINK_OK_B,
+                                          link_status),
+                                HBG_MAC_LINK_WAIT_INTERVAL_US,
+                                HBG_MAC_LINK_WAIT_TIMEOUT_US);
+       if (ret)
                hbg_np_link_fail_task_schedule(priv);
 }