Commit 62c50180 authored by Jijie Shao's avatar Jijie Shao Committed by Jakub Kicinski
Browse files

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: e0306637 ("net: hibmcge: Add support for mac link exception handling feature")
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7004b26f
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -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);
}