amd-xgbe: fix the false linkup in xgbe_phy_status
Subsystems (3)
Raju Rangoju
maintainerPATCH v2 1/1 amd-xgbe: fix the false linkup in xgbe_phy_status
In the event of a change in XGBE mode, the current auto-negotiation needs to be reset and the AN cycle needs to be re-triggerred. However, the current code ignores the return value of xgbe_set_mode(), leading to false information as the link is declared without checking the status register.
Fix this by propagating the mode switch status information to xgbe_phy_status().
---
Changes since v1:
- Fixed the warning "1 blamed authors not CCed"
- Fixed spelling mistake
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +10 -4
@@ -1329,7 +1329,7 @@ static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)return pdata->phy_if.phy_impl.an_outcome (pdata); } -static void xgbe_phy_status_result (struct xgbe_prv_data *pdata) +static bool xgbe_phy_status_result (struct xgbe_prv_data *pdata) {struct ethtool_link_ksettings *lks = &pdata->phy.lks;enum xgbe_mode mode;
@@ -1367,8 +1367,13 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) pdata->phy.duplex =DUPLEX_FULL ; -if (xgbe_set_mode (pdata, mode) && pdata->an_again) -xgbe_phy_reconfig_aneg (pdata); +if (xgbe_set_mode (pdata, mode)) { +if (pdata->an_again) +xgbe_phy_reconfig_aneg (pdata); +return true; + } + +return false; }static void xgbe_phy_status (struct xgbe_prv_data *pdata)
@@ -1398,7 +1403,8 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)return ; } -xgbe_phy_status_result (pdata); +if (xgbe_phy_status_result (pdata)) +return ;if (test_bit (XGBE_LINK_INIT , &pdata->dev_state))clear_bit (XGBE_LINK_INIT , &pdata->dev_state);
Signature · 1 line
2.25.1
Quoted 39 lines · Raju Rangoju
In the event of a change in XGBE mode, the current auto-negotiation needs to be reset and the AN cycle needs to be re-triggerred. However, the current code ignores the return value of
xgbe_set_mode(), leading to false information as the link is declared without checking the status register.Fix this by propagating the mode switch status information to
xgbe_phy_status().Fixes e57f7a3feaef ("amd-xgbe: Prepare for working with more than one type of phy")Co-developed-by Sudheesh Mavila <[email protected]>Signed-off-by Sudheesh Mavila <[email protected]>Reviewed-by Simon Horman <[email protected]>Acked-by Shyam Sundar S K <[email protected]>Signed-off-by Raju Rangoju <[email protected]>---
Changes since v1:
- Fixed the warning "1 blamed authors not CCed"
- Fixed spelling mistakedrivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +1
-1@@ -1329,7 +1329,7 @@ static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)return pdata->phy_if.phy_impl.an_outcome (pdata); } -static void xgbe_phy_status_result (struct xgbe_prv_data *pdata) +static bool xgbe_phy_status_result (struct xgbe_prv_data *pdata) {struct ethtool_link_ksettings *lks = &pdata->phy.lks;enum xgbe_mode mode;@@ -1367,8 +1367,13 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) pdata->phy.duplex =DUPLEX_FULL ;
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) · line 1376
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +7
-2-if (xgbe_set_mode (pdata, mode) && pdata->an_again) -xgbe_phy_reconfig_aneg (pdata); +if (xgbe_set_mode (pdata, mode)) { +if (pdata->an_again) +xgbe_phy_reconfig_aneg (pdata); +return true; + } + +return false;
Just a nit (and only my opinion) for better code readability, but you can save some indentation and make this a bit cleaner by doing:
if (!xgbe_set_mode(pdata, mode)) return false; if (pdata->an_again) xgbe_phy_reconfig_aneg(pdata); return true;
Thanks,
Tom
Quoted 13 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +2
-1}static void xgbe_phy_status (struct xgbe_prv_data *pdata)@@ -1398,7 +1403,8 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)return ; } -xgbe_phy_status_result (pdata); +if (xgbe_phy_status_result (pdata)) +return ;if (test_bit (XGBE_LINK_INIT , &pdata->dev_state))clear_bit (XGBE_LINK_INIT , &pdata->dev_state);
Raju Rangoju
maintainerQuoted 6 lines · Tom Lendacky
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +1
-2@@ -1367,8 +1367,13 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) pdata->phy.duplex = DUPLEX_FULL; - if (xgbe_set_mode(pdata, mode) && pdata->an_again) - xgbe_phy_reconfig_aneg(pdata); + if (xgbe_set_mode(pdata, mode)) {
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) · line 1376
Quoted 6 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +6
-0+ if (pdata->an_again) + xgbe_phy_reconfig_aneg(pdata); + return true; + } + + return false;Just a nit (and only my opinion) for better code readability, but you can save some indentation and make this a bit cleaner by doing:
Thanks Tom for the suggestion. I'll fix it in v3.
Quoted 14 lines
if (!xgbe_set_mode(pdata, mode))
return false;if (
pdata->an_again)
xgbe_phy_reconfig_aneg(pdata);return true;
Thanks,
TomQuoted 2 lines
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +0
-0} static void xgbe_phy_status(struct xgbe_prv_data *pdata)