From: Sudheesh Mavila <[email protected]>
Signed-off-by: Sudheesh Mavila <[email protected]>
Signed-off-by: Yongxin Liu <[email protected]>
---
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 40 +++++++++++++++------
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 4 +--
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
index ba515ea7a012..3cdc51755164 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
@@ -827,6 +827,7 @@ static void xgbe_an37_state_machine(struct xgbe_prv_data
*pdata)
static void xgbe_an73_state_machine(struct xgbe_prv_data *pdata)
{
enum xgbe_an cur_state = pdata->an_state;
+ int phy_reset = 0;
if (!pdata->an_int)
return;
@@ -892,6 +893,10 @@ static void xgbe_an73_state_machine(struct xgbe_prv_data
*pdata)
pdata->an_int = 0;
xgbe_an73_clear_interrupts(pdata);
}
+ /* Bug fix for AN failure in KR mode */
+ if ((pdata->an_state == XGBE_AN_NO_LINK) || (pdata->an_state ==
XGBE_AN_ERROR)) {
+ phy_reset = 1;
+ }
if (pdata->an_state >= XGBE_AN_COMPLETE) {
pdata->an_result = pdata->an_state;
@@ -905,6 +910,12 @@ static void xgbe_an73_state_machine(struct xgbe_prv_data
*pdata)
netif_dbg(pdata, link, pdata->netdev, "CL73 AN result: %s\n",
xgbe_state_as_string(pdata->an_result));
+ /* Bug fix for AN failure in KR mode */
+ if(phy_reset) {
+ xgbe_kr_mode(pdata);
+ pdata->phy_if.phy_reset(pdata);
+ netif_dbg(pdata, link, pdata->netdev, " PHY Reset\n");
+ }
}
if (cur_state != pdata->an_state)
@@ -1183,12 +1194,11 @@ static int xgbe_phy_config_fixed(struct xgbe_prv_data
*pdata)
return 0;
}
+/* caller should hold an_mutex */
static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata, bool set_mode)
{
int ret;
- mutex_lock(&pdata->an_mutex);
-
set_bit(XGBE_LINK_INIT, &pdata->dev_state);
pdata->link_check = jiffies;
@@ -1255,8 +1265,6 @@ static int __xgbe_phy_config_aneg(struct xgbe_prv_data
*pdata, bool set_mode)
else
clear_bit(XGBE_LINK_ERR, &pdata->dev_state);
- mutex_unlock(&pdata->an_mutex);
-
return ret;
}
@@ -1361,6 +1369,8 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
unsigned int link_aneg;
int an_restart;
+ mutex_lock(&pdata->an_mutex);
+
if (test_bit(XGBE_LINK_ERR, &pdata->dev_state)) {
netif_carrier_off(pdata->netdev);
@@ -1374,13 +1384,14 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
&an_restart);
if (an_restart) {
xgbe_phy_config_aneg(pdata);
- if(XGBE_MODE_KR != pdata->phy_if.phy_impl.cur_mode(pdata))
- goto adjust_link;
+ mutex_unlock(&pdata->an_mutex);
+ return;
}
if (pdata->phy.link) {
if (link_aneg && !xgbe_phy_aneg_done(pdata)) {
xgbe_check_link_timeout(pdata);
+ mutex_unlock(&pdata->an_mutex);
return;
}
@@ -1394,18 +1405,25 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
} else {
if (test_bit(XGBE_LINK_INIT, &pdata->dev_state)) {
xgbe_check_link_timeout(pdata);
-
- if ((link_aneg) && (XGBE_MODE_KR !=
pdata->phy_if.phy_impl.cur_mode(pdata)))
+ /* Bug fix for AN failure in KR mode */
+ if ((link_aneg) && ((XGBE_MODE_KR !=
pdata->phy_if.phy_impl.cur_mode(pdata)) && (XGBE_MODE_KX_1000 !=
pdata->phy_if.phy_impl.cur_mode(pdata)))) {
+ mutex_unlock(&pdata->an_mutex);
return;
+ }
}
xgbe_phy_status_result(pdata);
netif_carrier_off(pdata->netdev);
+ /* Bug fix for AN failure in KR mode */
+ if ((link_aneg) && ((XGBE_MODE_KR ==
pdata->phy_if.phy_impl.cur_mode(pdata)) || (XGBE_MODE_KX_1000==
pdata->phy_if.phy_impl.cur_mode(pdata)))) {
+ xgbe_phy_config_aneg(pdata);
+ }
}
adjust_link:
xgbe_phy_adjust_link(pdata);
+ mutex_unlock(&pdata->an_mutex);
}
static void xgbe_phy_stop(struct xgbe_prv_data *pdata)
@@ -1484,8 +1502,10 @@ static int xgbe_phy_start(struct xgbe_prv_data *pdata)
xgbe_an_init(pdata);
xgbe_an_enable_interrupts(pdata);
-
- return xgbe_phy_config_aneg(pdata);
+ mutex_lock(&pdata->an_mutex);
+ ret = xgbe_phy_config_aneg(pdata);
+ mutex_unlock(&pdata->an_mutex);
+ return ret;
err_irq:
if (pdata->dev_irq != pdata->an_irq)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 2b681a09e046..922ea03ea94a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -2629,14 +2629,12 @@ static int xgbe_phy_link_status(struct xgbe_prv_data
*pdata, int *an_restart)
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1);
- if(phy_data->sfp_speed == XGBE_SFP_SPEED_10000 ||(XGBE_MODE_KR ==
xgbe_phy_cur_mode(pdata))) {
+ if(phy_data->sfp_speed == XGBE_SFP_SPEED_10000) {
if ((reg & MDIO_STAT1_LSTATUS) && !(reg & MDIO_STAT1_FAULT)) {
return 1;
} else {
- mutex_lock(&pdata->an_mutex);
*an_restart = 1;
pdata->phy_if.phy_reset(pdata);
- mutex_unlock(&pdata->an_mutex);
return 0;
}
} else {
--
2.39.2
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13019):
https://lists.yoctoproject.org/g/linux-yocto/message/13019
Mute This Topic: https://lists.yoctoproject.org/mt/100956973/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-