netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <shh.xie@gmail.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Subject: [PATCH] net: phy: fix PHY_RUNNING in phy_state_machine
Date: Fri, 14 Aug 2015 12:23:40 +0800	[thread overview]
Message-ID: <1439526220-31458-1-git-send-email-shh.xie@gmail.com> (raw)

From: Shaohui Xie <Shaohui.Xie@freescale.com>

Currently, if phy state is PHY_RUNNING, we always register a CHANGE
when phy works in polling or interrupt ignored, this will make the
adjust_link being called even the phy link did Not changed.

checking the phy link to make sure the link did changed before we
register a CHANGE, if link did not changed, we do nothing.

Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
---
 drivers/net/phy/phy.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 84b1fba..d972851 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -814,6 +814,7 @@ void phy_state_machine(struct work_struct *work)
 	bool needs_aneg = false, do_suspend = false;
 	enum phy_state old_state;
 	int err = 0;
+	int old_link;
 
 	mutex_lock(&phydev->lock);
 
@@ -899,11 +900,18 @@ void phy_state_machine(struct work_struct *work)
 		phydev->adjust_link(phydev->attached_dev);
 		break;
 	case PHY_RUNNING:
-		/* Only register a CHANGE if we are
-		 * polling or ignoring interrupts
+		/* Only register a CHANGE if we are polling or ignoring
+		 * interrupts and link changed since latest checking.
 		 */
-		if (!phy_interrupt_is_valid(phydev))
-			phydev->state = PHY_CHANGELINK;
+		if (!phy_interrupt_is_valid(phydev)) {
+			old_link = phydev->link;
+			err = phy_read_status(phydev);
+			if (err)
+				break;
+
+			if (old_link != phydev->link)
+				phydev->state = PHY_CHANGELINK;
+		}
 		break;
 	case PHY_CHANGELINK:
 		err = phy_read_status(phydev);
-- 
2.1.0.27.g96db324

             reply	other threads:[~2015-08-14  4:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14  4:23 shh.xie [this message]
2015-08-14 17:01 ` [PATCH] net: phy: fix PHY_RUNNING in phy_state_machine Florian Fainelli
2015-08-17  7:29   ` Shaohui Xie
2015-08-17  7:48   ` Shaohui Xie
2015-08-17 19:18 ` David Miller
2015-08-24  5:35   ` Andy Fleming
2016-03-16 15:59 ` Yegor Yefremov
2016-03-16 16:18   ` Andrew Lunn
2016-03-16 22:23     ` Yegor Yefremov
2016-03-16 23:05       ` Andrew Lunn
2016-03-17  8:14         ` Yegor Yefremov
2016-03-17 13:41           ` Andrew Lunn
2016-03-17 14:50             ` Yegor Yefremov
2016-03-17 15:12               ` Andrew Lunn
2016-03-17 15:21                 ` Yegor Yefremov
2016-03-17 15:28                   ` Andrew Lunn
2016-03-17 15:33                     ` Yegor Yefremov

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=1439526220-31458-1-git-send-email-shh.xie@gmail.com \
    --to=shh.xie@gmail.com \
    --cc=Shaohui.Xie@freescale.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).