linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards
@ 2016-02-26 18:18 Alexandre Belloni
  2016-02-26 18:18 ` [PATCH 1/2] phy: micrel: Ensure interrupts are reenabled on resume Alexandre Belloni
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Belloni @ 2016-02-26 18:18 UTC (permalink / raw)
  To: Florian Fainelli, Nicolas Ferre
  Cc: David S . Miller, Andrew Lunn, netdev, linux-kernel, Alexandre Belloni

Hi,

Since the phy is not polled anymore, there were issues getting a link on the
sama5d* xplained boards.

I'm not too sure about were those fixes should go and I'm wondering whether the
first one shoud be made generic.

For the second one, I found the PHY_HAS_MAGICANEG flag that is not used and I
wondering whether this is related to that kind of issue. I had a quick look at
the history and could'nt find its use.

Alexandre Belloni (2):
  phy: micrel: Ensure interrupts are reenabled on resume
  phy: micrel: Disable auto negotiation on startup

 drivers/net/phy/micrel.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

-- 
2.7.0

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

* [PATCH 1/2] phy: micrel: Ensure interrupts are reenabled on resume
  2016-02-26 18:18 [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards Alexandre Belloni
@ 2016-02-26 18:18 ` Alexandre Belloni
  2016-02-26 18:18 ` [PATCH 2/2] phy: micrel: Disable auto negotiation on startup Alexandre Belloni
  2016-03-01 21:53 ` [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2016-02-26 18:18 UTC (permalink / raw)
  To: Florian Fainelli, Nicolas Ferre
  Cc: David S . Miller, Andrew Lunn, netdev, linux-kernel, Alexandre Belloni

At least on ksz8081, when getting back from power down, interrupts are
disabled. ensure they are reenabled if they were previously enabled.

This fixes resuming which is failing on the xplained boards from atmel
since 321beec5047a (net: phy: Use interrupts when available in NOLINK
state)

Fixes: 321beec5047a (net: phy: Use interrupts when available in NOLINK state)
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/net/phy/micrel.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 03833dbfca67..a5e265b2bbfb 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -635,6 +635,21 @@ static void kszphy_get_stats(struct phy_device *phydev,
 		data[i] = kszphy_get_stat(phydev, i);
 }
 
+static int kszphy_resume(struct phy_device *phydev)
+{
+	int value;
+
+	mutex_lock(&phydev->lock);
+
+	value = phy_read(phydev, MII_BMCR);
+	phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN);
+
+	kszphy_config_intr(phydev);
+	mutex_unlock(&phydev->lock);
+
+	return 0;
+}
+
 static int kszphy_probe(struct phy_device *phydev)
 {
 	const struct kszphy_type *type = phydev->drv->driver_data;
@@ -844,7 +859,7 @@ static struct phy_driver ksphy_driver[] = {
 	.get_strings	= kszphy_get_strings,
 	.get_stats	= kszphy_get_stats,
 	.suspend	= genphy_suspend,
-	.resume		= genphy_resume,
+	.resume		= kszphy_resume,
 }, {
 	.phy_id		= PHY_ID_KSZ8061,
 	.name		= "Micrel KSZ8061",
-- 
2.7.0

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

* [PATCH 2/2] phy: micrel: Disable auto negotiation on startup
  2016-02-26 18:18 [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards Alexandre Belloni
  2016-02-26 18:18 ` [PATCH 1/2] phy: micrel: Ensure interrupts are reenabled on resume Alexandre Belloni
@ 2016-02-26 18:18 ` Alexandre Belloni
  2016-03-01 21:53 ` [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2016-02-26 18:18 UTC (permalink / raw)
  To: Florian Fainelli, Nicolas Ferre
  Cc: David S . Miller, Andrew Lunn, netdev, linux-kernel, Alexandre Belloni

Disable auto negotiation on init to properly detect an already plugged
cable at boot.

At boot, when the phy is started, it is in the PHY_UP state.
However, if a cable is plugged at boot, because auto negociation is already
enabled at the time we get the first interrupt, the phy is already running.
But the state machine then switches from PHY_UP to PHY_AN and calls
phy_start_aneg(). phy_start_aneg() will not do anything because aneg is
already enabled on the phy. It will then wait for a interrupt before going
further. This interrupt will never happen unless the cable is unplugged and
then replugged.

It was working properly before 321beec5047a (net: phy: Use interrupts when
available in NOLINK state) because switching to NOLINK meant starting
polling the phy, even if IRQ were enabled.

Fixes: 321beec5047a (net: phy: Use interrupts when available in NOLINK state)
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/net/phy/micrel.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index a5e265b2bbfb..dc85f7095e51 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -297,6 +297,17 @@ static int kszphy_config_init(struct phy_device *phydev)
 	if (priv->led_mode >= 0)
 		kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode);
 
+	if (phy_interrupt_is_valid(phydev)) {
+		int ctl = phy_read(phydev, MII_BMCR);
+
+		if (ctl < 0)
+			return ctl;
+
+		ret = phy_write(phydev, MII_BMCR, ctl & ~BMCR_ANENABLE);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.0

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

* Re: [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards
  2016-02-26 18:18 [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards Alexandre Belloni
  2016-02-26 18:18 ` [PATCH 1/2] phy: micrel: Ensure interrupts are reenabled on resume Alexandre Belloni
  2016-02-26 18:18 ` [PATCH 2/2] phy: micrel: Disable auto negotiation on startup Alexandre Belloni
@ 2016-03-01 21:53 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-03-01 21:53 UTC (permalink / raw)
  To: alexandre.belloni; +Cc: f.fainelli, nicolas.ferre, andrew, netdev, linux-kernel

From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Date: Fri, 26 Feb 2016 19:18:21 +0100

> Since the phy is not polled anymore, there were issues getting a link on the
> sama5d* xplained boards.
 ...

Series applied, thanks.

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

end of thread, other threads:[~2016-03-01 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 18:18 [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards Alexandre Belloni
2016-02-26 18:18 ` [PATCH 1/2] phy: micrel: Ensure interrupts are reenabled on resume Alexandre Belloni
2016-02-26 18:18 ` [PATCH 2/2] phy: micrel: Disable auto negotiation on startup Alexandre Belloni
2016-03-01 21:53 ` [PATCH 0/2] phy: micrel: fix issues with interrupt on atmel boards 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).