netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev <netdev@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH RFC 5/6] net: phy: Trigger state machine on state change and not polling.
Date: Wed, 28 Sep 2016 10:32:23 +0200	[thread overview]
Message-ID: <1475051544-18561-6-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1475051544-18561-1-git-send-email-andrew@lunn.ch>

The phy_start() is used to indicate the PHY is now ready to do its
work. The state is changed, normally to PHY_UP which means that both
the MAC and the PHY are ready.

If the phy driver is using polling, when the next poll happens, the
state machine notices the PHY is now in PHY_UP, and kicks off
auto-negotiation, if needed.

If however, the PHY is using interrupts, there is no polling. The phy
is stuck in PHY_UP until the next interrupt comes along. And there is
no reason for the PHY to interrupt.

Have phy_start() schedule the state machine to run, which both speeds
up the polling use case, and makes the interrupt use case actually
work.

This problems exists whenever there is a state change which will not
cause an interrupt. Trigger the state machine in these cases,
e.g. phy_error().

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 940450c6cd2c..f446ce04caf3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -608,6 +608,21 @@ void phy_start_machine(struct phy_device *phydev)
 }
 
 /**
+ * phy_trigger_machine - trigger the state machine to run
+ *
+ * @phydev: the phy_device struct
+ *
+ * Description: There has been a change in state which requires that the
+ *   state machine runs.
+ */
+
+static void phy_trigger_machine(struct phy_device *phydev)
+{
+	cancel_delayed_work_sync(&phydev->state_queue);
+	queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0);
+}
+
+/**
  * phy_stop_machine - stop the PHY state machine tracking
  * @phydev: target phy_device struct
  *
@@ -639,6 +654,8 @@ static void phy_error(struct phy_device *phydev)
 	mutex_lock(&phydev->lock);
 	phydev->state = PHY_HALTED;
 	mutex_unlock(&phydev->lock);
+
+	phy_trigger_machine(phydev);
 }
 
 /**
@@ -785,8 +802,7 @@ void phy_change(struct phy_device *phydev)
 	}
 
 	/* reschedule state queue work to run as soon as possible */
-	cancel_delayed_work_sync(&phydev->state_queue);
-	queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, 0);
+	phy_trigger_machine(phydev);
 	return;
 
 ignore:
@@ -875,6 +891,8 @@ void phy_start(struct phy_device *phydev)
 	/* if phy was suspended, bring the physical link up again */
 	if (do_resume)
 		phy_resume(phydev);
+
+	phy_trigger_machine(phydev);
 }
 EXPORT_SYMBOL(phy_start);
 
-- 
2.9.3

  parent reply	other threads:[~2016-09-28  8:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1475051544-18561-1-git-send-email-andrew@lunn.ch>
2016-09-28  8:32 ` [PATCH RFC 1/6] net: dsa: mv88e6xxx: Implement interrupt support Andrew Lunn
2016-09-28 10:22   ` Andrew Lunn
2016-09-28  8:32 ` [PATCH RFC 2/6] net: phy: Use threaded IRQ, to allow IRQ from sleeping devices Andrew Lunn
2016-09-28 11:38   ` Sergei Shtylyov
2016-09-28 12:24     ` Andrew Lunn
2016-09-28 21:16     ` Andrew Lunn
2016-09-28  8:32 ` [PATCH RFC 3/6] net: phy: Threaded interrupts allow some simplification Andrew Lunn
2016-09-28 11:46   ` Sergei Shtylyov
2016-09-28 12:13     ` Sergei Shtylyov
2016-09-28 12:28       ` Andrew Lunn
2016-09-28 13:38         ` Sergei Shtylyov
2016-09-28 17:14           ` Florian Fainelli
2016-10-18 10:37             ` Sergei Shtylyov
2016-10-18 10:46               ` Andrew Lunn
2016-09-28  8:32 ` [PATCH RFC 4/6] net: phy: Use phy name when requesting the interrupt Andrew Lunn
2016-09-28 17:18   ` Florian Fainelli
2016-09-28  8:32 ` Andrew Lunn [this message]
2016-09-28 21:31   ` [PATCH RFC 5/6] net: phy: Trigger state machine on state change and not polling Florian Fainelli
2016-09-29  7:08     ` Andrew Lunn
2016-09-28  8:32 ` [PATCH RFC 6/6] arm: vf610: zii devel b: Add support for switch interrupts Andrew Lunn

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=1475051544-18561-6-git-send-email-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    /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).