mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Anton Bondarenko <anton.bondarenko.sama@gmail.com>
To: s.hauer@pengutronix.de, barebox@lists.infradead.org
Subject: [PATCH] net: phy: wait for link OK after successfull autonegotiation
Date: Sat, 31 Oct 2015 14:07:52 +0100	[thread overview]
Message-ID: <1446296872-1592-2-git-send-email-anton.bondarenko.sama@gmail.com> (raw)
In-Reply-To: <1446296872-1592-1-git-send-email-anton.bondarenko.sama@gmail.com>

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 | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2b3c5e2..73569f3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -502,13 +502,17 @@ 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;
+		if (phy_aneg_done(phydev) > 0)
+			break;
+	}
+
+	genphy_update_link(phydev);
+	while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
+		if (phydev->link == 1)
 			return 0;
-		}
+		genphy_update_link(phydev);
 	}
 
-	phydev->link = 0;
 	return -ETIMEDOUT;
 }
 
-- 
2.6.2


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

  reply	other threads:[~2015-10-31 13:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-31 13:07 [PATCH] Improve PHY AutoNeg procedure Anton Bondarenko
2015-10-31 13:07 ` Anton Bondarenko [this message]
2015-11-02  8:00   ` [PATCH] net: phy: wait for link OK after successfull autonegotiation Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446296872-1592-2-git-send-email-anton.bondarenko.sama@gmail.com \
    --to=anton.bondarenko.sama@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox