Skip to content

Commit 62c5018

Browse files
Jijie Shaokuba-moo
authored andcommitted
net: hibmcge: fix the np_link_fail error reporting issue
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: e030663 ("net: hibmcge: Add support for mac link exception handling feature") Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7004b26 commit 62c5018

File tree

1 file changed

+13
-2
lines changed
  • drivers/net/ethernet/hisilicon/hibmcge

1 file changed

+13
-2
lines changed

drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#define HBG_HW_EVENT_WAIT_TIMEOUT_US (2 * 1000 * 1000)
1414
#define HBG_HW_EVENT_WAIT_INTERVAL_US (10 * 1000)
15+
#define HBG_MAC_LINK_WAIT_TIMEOUT_US (500 * 1000)
16+
#define HBG_MAC_LINK_WAIT_INTERVAL_US (5 * 1000)
1517
/* little endian or big endian.
1618
* ctrl means packet description, data means skb packet data
1719
*/
@@ -228,6 +230,9 @@ void hbg_hw_fill_buffer(struct hbg_priv *priv, u32 buffer_dma_addr)
228230

229231
void hbg_hw_adjust_link(struct hbg_priv *priv, u32 speed, u32 duplex)
230232
{
233+
u32 link_status;
234+
int ret;
235+
231236
hbg_hw_mac_enable(priv, HBG_STATUS_DISABLE);
232237

233238
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)
239244

240245
hbg_hw_mac_enable(priv, HBG_STATUS_ENABLE);
241246

242-
if (!hbg_reg_read_field(priv, HBG_REG_AN_NEG_STATE_ADDR,
243-
HBG_REG_AN_NEG_STATE_NP_LINK_OK_B))
247+
/* wait MAC link up */
248+
ret = readl_poll_timeout(priv->io_base + HBG_REG_AN_NEG_STATE_ADDR,
249+
link_status,
250+
FIELD_GET(HBG_REG_AN_NEG_STATE_NP_LINK_OK_B,
251+
link_status),
252+
HBG_MAC_LINK_WAIT_INTERVAL_US,
253+
HBG_MAC_LINK_WAIT_TIMEOUT_US);
254+
if (ret)
244255
hbg_np_link_fail_task_schedule(priv);
245256
}
246257

0 commit comments

Comments
 (0)