mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] net: phy: wait for link OK after successfull autonegotiation
@ 2015-11-04 21:23 Anton Bondarenko
  2015-11-05  8:04 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Bondarenko @ 2015-11-04 21:23 UTC (permalink / raw)
  To: barebox, s.hauer

It may take some time for PHY to indicate link OK status after
autonegotiation completed. This change addresses this case
and prevent network commands fails due to the delay.

Signed-off-by: Anton Bondarenko <anton.bondarenko.sama@gmail.com>
---
 drivers/net/phy/phy.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2b3c5e2..25c999c 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -502,13 +502,16 @@ int phy_wait_aneg_done(struct phy_device *phydev)
 		return 0;
 
 	while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
-		if (phy_aneg_done(phydev) > 0) {
-			phydev->link = 1;
-			return 0;
-		}
+		if (phy_aneg_done(phydev) > 0)
+			break;
 	}
 
-	phydev->link = 0;
+	do {
+		genphy_update_link(phydev);
+		if (phydev->link == 1)
+			return 0;
+	} while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
+
 	return -ETIMEDOUT;
 }
 
-- 
2.6.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH v2] net: phy: wait for link OK after successfull autonegotiation
  2015-11-04 21:23 [PATCH v2] net: phy: wait for link OK after successfull autonegotiation Anton Bondarenko
@ 2015-11-05  8:04 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-11-05  8:04 UTC (permalink / raw)
  To: Anton Bondarenko; +Cc: barebox

On Wed, Nov 04, 2015 at 10:23:04PM +0100, Anton Bondarenko wrote:
> It may take some time for PHY to indicate link OK status after
> autonegotiation completed. This change addresses this case
> and prevent network commands fails due to the delay.
> 
> Signed-off-by: Anton Bondarenko <anton.bondarenko.sama@gmail.com>
> ---

Applied, thanks

Sascha

>  drivers/net/phy/phy.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 2b3c5e2..25c999c 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -502,13 +502,16 @@ int phy_wait_aneg_done(struct phy_device *phydev)
>  		return 0;
>  
>  	while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
> -		if (phy_aneg_done(phydev) > 0) {
> -			phydev->link = 1;
> -			return 0;
> -		}
> +		if (phy_aneg_done(phydev) > 0)
> +			break;
>  	}
>  
> -	phydev->link = 0;
> +	do {
> +		genphy_update_link(phydev);
> +		if (phydev->link == 1)
> +			return 0;
> +	} while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
> +
>  	return -ETIMEDOUT;
>  }
>  
> -- 
> 2.6.2
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-11-05  8:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 21:23 [PATCH v2] net: phy: wait for link OK after successfull autonegotiation Anton Bondarenko
2015-11-05  8:04 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox