netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] amd-xgbe-phy: Fix initial mode when autoneg is disabled
@ 2015-05-26 14:51 Tom Lendacky
  2015-05-26 14:57 ` Tom Lendacky
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2015-05-26 14:51 UTC (permalink / raw)
  To: netdev; +Cc: David Miller

When the ethtool command is used to set the speed of the device while
the device is down, the check to set the initial mode may fail when
the device is brought up, causing failure to bring the device up.

Update the code to set the initial mode based on the desired speed if
auto-negotiation is disabled.

This patch fixes a bug introduced by:
d9663c8c2149 ("amd-xgbe-phy: Use phydev advertising field vs supported")

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/net/phy/amd-xgbe-phy.c |   45 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/amd-xgbe-phy.c b/drivers/net/phy/amd-xgbe-phy.c
index fb276f6..34a75cb 100644
--- a/drivers/net/phy/amd-xgbe-phy.c
+++ b/drivers/net/phy/amd-xgbe-phy.c
@@ -755,6 +755,45 @@ static int amd_xgbe_phy_set_mode(struct phy_device *phydev,
 	return ret;
 }
 
+static bool amd_xgbe_phy_use_xgmii_mode(struct phy_device *phydev)
+{
+	if (phydev->autoneg == AUTONEG_ENABLE) {
+		if (phydev->advertising & ADVERTISED_10000baseKR_Full)
+			return true;
+	} else {
+		if (phydev->speed == SPEED_10000)
+			return true;
+	}
+
+	return false;
+}
+
+static bool amd_xgbe_phy_use_gmii_2500_mode(struct phy_device *phydev)
+{
+	if (phydev->autoneg == AUTONEG_ENABLE) {
+		if (phydev->advertising & ADVERTISED_2500baseX_Full)
+			return true;
+	} else {
+		if (phydev->speed == SPEED_2500)
+			return true;
+	}
+
+	return false;
+}
+
+static bool amd_xgbe_phy_use_gmii_mode(struct phy_device *phydev)
+{
+	if (phydev->autoneg == AUTONEG_ENABLE) {
+		if (phydev->advertising & ADVERTISED_1000baseKX_Full)
+			return true;
+	} else {
+		if (phydev->speed == SPEED_1000)
+			return true;
+	}
+
+	return false;
+}
+
 static int amd_xgbe_phy_set_an(struct phy_device *phydev, bool enable,
 			       bool restart)
 {
@@ -1235,11 +1274,11 @@ static int amd_xgbe_phy_config_init(struct phy_device *phydev)
 	/* Set initial mode - call the mode setting routines
 	 * directly to insure we are properly configured
 	 */
-	if (phydev->advertising & SUPPORTED_10000baseKR_Full)
+	if (amd_xgbe_phy_use_xgmii_mode(phydev))
 		ret = amd_xgbe_phy_xgmii_mode(phydev);
-	else if (phydev->advertising & SUPPORTED_1000baseKX_Full)
+	else if (amd_xgbe_phy_use_gmii_mode(phydev))
 		ret = amd_xgbe_phy_gmii_mode(phydev);
-	else if (phydev->advertising & SUPPORTED_2500baseX_Full)
+	else if (amd_xgbe_phy_use_gmii_2500_mode(phydev))
 		ret = amd_xgbe_phy_gmii_2500_mode(phydev);
 	else
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] amd-xgbe-phy: Fix initial mode when autoneg is disabled
  2015-05-26 14:51 [PATCH net] amd-xgbe-phy: Fix initial mode when autoneg is disabled Tom Lendacky
@ 2015-05-26 14:57 ` Tom Lendacky
  2015-05-26 23:48   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2015-05-26 14:57 UTC (permalink / raw)
  To: netdev; +Cc: David Miller

On 05/26/2015 09:51 AM, Tom Lendacky wrote:
> When the ethtool command is used to set the speed of the device while
> the device is down, the check to set the initial mode may fail when
> the device is brought up, causing failure to bring the device up.
>
> Update the code to set the initial mode based on the desired speed if
> auto-negotiation is disabled.
>
> This patch fixes a bug introduced by:
> d9663c8c2149 ("amd-xgbe-phy: Use phydev advertising field vs supported")
>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>   drivers/net/phy/amd-xgbe-phy.c |   45 +++++++++++++++++++++++++++++++++++++---
>   1 file changed, 42 insertions(+), 3 deletions(-)
>

Hi David,

Just a heads up on this patch. With the removal of this file in net-next
you'll have a conflict when merging into net-next. My updates from the
other day to net-next fix this bug in the new file/location.

Thanks,
Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] amd-xgbe-phy: Fix initial mode when autoneg is disabled
  2015-05-26 14:57 ` Tom Lendacky
@ 2015-05-26 23:48   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-05-26 23:48 UTC (permalink / raw)
  To: thomas.lendacky; +Cc: netdev

From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Tue, 26 May 2015 09:57:33 -0500

> On 05/26/2015 09:51 AM, Tom Lendacky wrote:
>> When the ethtool command is used to set the speed of the device while
>> the device is down, the check to set the initial mode may fail when
>> the device is brought up, causing failure to bring the device up.
>>
>> Update the code to set the initial mode based on the desired speed if
>> auto-negotiation is disabled.
>>
>> This patch fixes a bug introduced by:
>> d9663c8c2149 ("amd-xgbe-phy: Use phydev advertising field vs
>> supported")
>>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>>   drivers/net/phy/amd-xgbe-phy.c | 45
>>   +++++++++++++++++++++++++++++++++++++---
>>   1 file changed, 42 insertions(+), 3 deletions(-)
>>
> 
> Hi David,
> 
> Just a heads up on this patch. With the removal of this file in
> net-next
> you'll have a conflict when merging into net-next. My updates from the
> other day to net-next fix this bug in the new file/location.

Ok, applied, and thanks for the heads up about the conflict.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-26 23:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 14:51 [PATCH net] amd-xgbe-phy: Fix initial mode when autoneg is disabled Tom Lendacky
2015-05-26 14:57 ` Tom Lendacky
2015-05-26 23:48   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).