linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] net: phy: smsc: Disable auto-negotiation on startup
@ 2016-10-10 17:41 Kyle Roeschley
  2016-10-11 14:32 ` Jeremy Linton
  2016-10-12  9:13 ` Florian Fainelli
  0 siblings, 2 replies; 6+ messages in thread
From: Kyle Roeschley @ 2016-10-10 17:41 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, linux-kernel, Kyle Roeschley

Because the SMSC PHY completes auto-negotiation before the driver is
ready to handle interrupts, the PHY state machine never realizes that we
have a link. Clear the ANENABLE bit on initialization, which lets
genphy_config_aneg do its thing when that code is hit later.

While this patch does fix the problem we see (no link on boot without
re-plugging the cable), it seems like the generic PHY code should be
able to handle auto-negotiation completing before interrupts are
enabled. Submitted as an RFC in the hopes that someone has an idea as to
how that could be done.

This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
negotiation on startup").

Signed-off-by: Kyle Roeschley <kyle.roeschley@ni.com>
---
 drivers/net/phy/smsc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index b62c4aa..8de8011 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -62,6 +62,16 @@ static int smsc_phy_config_init(struct phy_device *phydev)
 			return rc;
 	}
 
+	if (phy_interrupt_is_valid(phydev)) {
+		rc = phy_read(phydev, MII_BMCR);
+		if (rc < 0)
+			return rc;
+
+		rc = phy_write(phydev, MII_BMCR, rc & ~BMCR_ANENABLE);
+		if (rc < 0)
+			return rc;
+	}
+
 	return smsc_phy_ack_interrupt(phydev);
 }
 
-- 
2.9.3

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

* Re: [RFC] net: phy: smsc: Disable auto-negotiation on startup
  2016-10-10 17:41 [RFC] net: phy: smsc: Disable auto-negotiation on startup Kyle Roeschley
@ 2016-10-11 14:32 ` Jeremy Linton
  2016-10-12 15:09   ` Kyle Roeschley
  2016-10-12  9:13 ` Florian Fainelli
  1 sibling, 1 reply; 6+ messages in thread
From: Jeremy Linton @ 2016-10-11 14:32 UTC (permalink / raw)
  To: Kyle Roeschley, f.fainelli; +Cc: netdev, linux-kernel

On 10/10/2016 12:41 PM, Kyle Roeschley wrote:
> Because the SMSC PHY completes auto-negotiation before the driver is
> ready to handle interrupts, the PHY state machine never realizes that we
> have a link. Clear the ANENABLE bit on initialization, which lets
> genphy_config_aneg do its thing when that code is hit later.
>
> While this patch does fix the problem we see (no link on boot without
> re-plugging the cable), it seems like the generic PHY code should be
> able to handle auto-negotiation completing before interrupts are
> enabled. Submitted as an RFC in the hopes that someone has an idea as to
> how that could be done.

Hi,

	Which smsc chip/driver? Maybe assuring the device interrupts are 
enabled before the phy is started is a solution?

	The whole problem sounds similar to what was recently happening in the 
smsc911x driver, but AFAIK that driver is basically only polling at this 
point so connecting the phy before the interrupts are enabled shouldn't 
be a problem.




>
> This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
> negotiation on startup").
>
> Signed-off-by: Kyle Roeschley <kyle.roeschley@ni.com>
> ---
>  drivers/net/phy/smsc.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index b62c4aa..8de8011 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -62,6 +62,16 @@ static int smsc_phy_config_init(struct phy_device *phydev)
>  			return rc;
>  	}
>
> +	if (phy_interrupt_is_valid(phydev)) {
> +		rc = phy_read(phydev, MII_BMCR);
> +		if (rc < 0)
> +			return rc;
> +
> +		rc = phy_write(phydev, MII_BMCR, rc & ~BMCR_ANENABLE);
> +		if (rc < 0)
> +			return rc;
> +	}
> +
>  	return smsc_phy_ack_interrupt(phydev);
>  }
>
>

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

* Re: [RFC] net: phy: smsc: Disable auto-negotiation on startup
  2016-10-10 17:41 [RFC] net: phy: smsc: Disable auto-negotiation on startup Kyle Roeschley
  2016-10-11 14:32 ` Jeremy Linton
@ 2016-10-12  9:13 ` Florian Fainelli
  2016-10-12 15:05   ` Kyle Roeschley
  1 sibling, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2016-10-12  9:13 UTC (permalink / raw)
  To: Kyle Roeschley; +Cc: netdev, linux-kernel, Andrew Lunn

On 10/10/2016 10:41 AM, Kyle Roeschley wrote:
> Because the SMSC PHY completes auto-negotiation before the driver is
> ready to handle interrupts, the PHY state machine never realizes that we
> have a link. Clear the ANENABLE bit on initialization, which lets
> genphy_config_aneg do its thing when that code is hit later.
> 
> While this patch does fix the problem we see (no link on boot without
> re-plugging the cable), it seems like the generic PHY code should be
> able to handle auto-negotiation completing before interrupts are
> enabled. Submitted as an RFC in the hopes that someone has an idea as to
> how that could be done.
> 
> This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
> negotiation on startup").

Do you mind trying:

https://www.spinics.net/lists/netdev/msg397857.html

and see if you do get link interrupts without your patch applied? Thanks!
-- 
Florian

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

* Re: [RFC] net: phy: smsc: Disable auto-negotiation on startup
  2016-10-12  9:13 ` Florian Fainelli
@ 2016-10-12 15:05   ` Kyle Roeschley
  2016-10-12 19:55     ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Roeschley @ 2016-10-12 15:05 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, linux-kernel, Andrew Lunn

On Wed, Oct 12, 2016 at 02:13:06AM -0700, Florian Fainelli wrote:
> On 10/10/2016 10:41 AM, Kyle Roeschley wrote:
> > Because the SMSC PHY completes auto-negotiation before the driver is
> > ready to handle interrupts, the PHY state machine never realizes that we
> > have a link. Clear the ANENABLE bit on initialization, which lets
> > genphy_config_aneg do its thing when that code is hit later.
> > 
> > While this patch does fix the problem we see (no link on boot without
> > re-plugging the cable), it seems like the generic PHY code should be
> > able to handle auto-negotiation completing before interrupts are
> > enabled. Submitted as an RFC in the hopes that someone has an idea as to
> > how that could be done.
> > 
> > This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
> > negotiation on startup").
> 
> Do you mind trying:
> 
> https://www.spinics.net/lists/netdev/msg397857.html
> 
> and see if you do get link interrupts without your patch applied? Thanks!

Yep, that fixes it. I figured there was some state machine issue I was missing.
Thanks very much!

> -- 
> Florian

-- 
Kyle Roeschley
Software Engineer
National Instruments

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

* Re: [RFC] net: phy: smsc: Disable auto-negotiation on startup
  2016-10-11 14:32 ` Jeremy Linton
@ 2016-10-12 15:09   ` Kyle Roeschley
  0 siblings, 0 replies; 6+ messages in thread
From: Kyle Roeschley @ 2016-10-12 15:09 UTC (permalink / raw)
  To: Jeremy Linton; +Cc: f.fainelli, netdev, linux-kernel

On Tue, Oct 11, 2016 at 09:32:30AM -0500, Jeremy Linton wrote:
> On 10/10/2016 12:41 PM, Kyle Roeschley wrote:
> > Because the SMSC PHY completes auto-negotiation before the driver is
> > ready to handle interrupts, the PHY state machine never realizes that we
> > have a link. Clear the ANENABLE bit on initialization, which lets
> > genphy_config_aneg do its thing when that code is hit later.
> > 
> > While this patch does fix the problem we see (no link on boot without
> > re-plugging the cable), it seems like the generic PHY code should be
> > able to handle auto-negotiation completing before interrupts are
> > enabled. Submitted as an RFC in the hopes that someone has an idea as to
> > how that could be done.
> 
> Hi,
> 
> 	Which smsc chip/driver? Maybe assuring the device interrupts are enabled
> before the phy is started is a solution?
> 
> 	The whole problem sounds similar to what was recently happening in the
> smsc911x driver, but AFAIK that driver is basically only polling at this
> point so connecting the phy before the interrupts are enabled shouldn't be a
> problem.
> 

We're using the SMSC LAN8720A with the Cadence MACB ethernet controller.
Interrupts are enabled before the phy is started, but it looks like the patch
Florian pointed me to (https://www.spinics.net/lists/netdev/msg397857.html)
fixes my interrupt problem.

> > 
> > This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
> > negotiation on startup").
> > 
> > Signed-off-by: Kyle Roeschley <kyle.roeschley@ni.com>
> > ---
> >  drivers/net/phy/smsc.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> > index b62c4aa..8de8011 100644
> > --- a/drivers/net/phy/smsc.c
> > +++ b/drivers/net/phy/smsc.c
> > @@ -62,6 +62,16 @@ static int smsc_phy_config_init(struct phy_device *phydev)
> >  			return rc;
> >  	}
> > 
> > +	if (phy_interrupt_is_valid(phydev)) {
> > +		rc = phy_read(phydev, MII_BMCR);
> > +		if (rc < 0)
> > +			return rc;
> > +
> > +		rc = phy_write(phydev, MII_BMCR, rc & ~BMCR_ANENABLE);
> > +		if (rc < 0)
> > +			return rc;
> > +	}
> > +
> >  	return smsc_phy_ack_interrupt(phydev);
> >  }
> > 
> > 
> 

-- 
Kyle Roeschley
Software Engineer
National Instruments

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

* Re: [RFC] net: phy: smsc: Disable auto-negotiation on startup
  2016-10-12 15:05   ` Kyle Roeschley
@ 2016-10-12 19:55     ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2016-10-12 19:55 UTC (permalink / raw)
  To: Kyle Roeschley; +Cc: Florian Fainelli, netdev, linux-kernel

On Wed, Oct 12, 2016 at 10:05:33AM -0500, Kyle Roeschley wrote:
> On Wed, Oct 12, 2016 at 02:13:06AM -0700, Florian Fainelli wrote:
> > On 10/10/2016 10:41 AM, Kyle Roeschley wrote:
> > > Because the SMSC PHY completes auto-negotiation before the driver is
> > > ready to handle interrupts, the PHY state machine never realizes that we
> > > have a link. Clear the ANENABLE bit on initialization, which lets
> > > genphy_config_aneg do its thing when that code is hit later.
> > > 
> > > While this patch does fix the problem we see (no link on boot without
> > > re-plugging the cable), it seems like the generic PHY code should be
> > > able to handle auto-negotiation completing before interrupts are
> > > enabled. Submitted as an RFC in the hopes that someone has an idea as to
> > > how that could be done.
> > > 
> > > This fix is copied from commit 99f81afc139c ("phy: micrel: Disable auto
> > > negotiation on startup").
> > 
> > Do you mind trying:
> > 
> > https://www.spinics.net/lists/netdev/msg397857.html
> > 
> > and see if you do get link interrupts without your patch applied? Thanks!
> 
> Yep, that fixes it. I figured there was some state machine issue I was missing.
> Thanks very much!

Humm, O.K, time to pull that patch out of the series and make it
standalone.

	Andrew

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

end of thread, other threads:[~2016-10-12 20:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-10 17:41 [RFC] net: phy: smsc: Disable auto-negotiation on startup Kyle Roeschley
2016-10-11 14:32 ` Jeremy Linton
2016-10-12 15:09   ` Kyle Roeschley
2016-10-12  9:13 ` Florian Fainelli
2016-10-12 15:05   ` Kyle Roeschley
2016-10-12 19:55     ` Andrew Lunn

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).