diff mbox series

[v2,net] amd-xgbe: fix the false linkup in xgbe_phy_status

Message ID 20230525101728.863971-1-Raju.Rangoju@amd.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v2,net] amd-xgbe: fix the false linkup in xgbe_phy_status | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 2 blamed authors not CCed: Thomas.Lendacky@amd.com davem@davemloft.net; 5 maintainers not CCed: kuba@kernel.org pabeni@redhat.com davem@davemloft.net Thomas.Lendacky@amd.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Raju Rangoju May 25, 2023, 10:17 a.m. UTC
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 <sudheesh.mavila@amd.com>
Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
---
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(-)

Comments

Tom Lendacky May 25, 2023, 2:41 p.m. UTC | #1
On 5/25/23 05:17, Raju Rangoju wrote:
> 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 <sudheesh.mavila@amd.com>
> Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
> ---
> 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(-)
> 
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
> index 33a9574e9e04..9822648747b7 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
> @@ -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;

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

>   }
>   
>   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 May 25, 2023, 6:07 p.m. UTC | #2
On 5/25/2023 8:11 PM, Tom Lendacky wrote:

>> @@ -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;
> 
> 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.

> 
>      if (!xgbe_set_mode(pdata, mode))
>          return false;
> 
>      if (pdata->an_again)
>          xgbe_phy_reconfig_aneg(pdata);
> 
>      return true;
> 
> Thanks,
> Tom
> 
>>   }
>>   static void xgbe_phy_status(struct xgbe_prv_data *pdata)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
index 33a9574e9e04..9822648747b7 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
@@ -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);