netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: smsc: energy saving does not work without interrupts
@ 2012-03-21 12:08 Wolfram Sang
  2012-03-21 14:28 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2012-03-21 12:08 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Wolfram Sang, Giuseppe Cavallaro

We discovered link detection failures using this PHY with the Freescale FEC
which does not have interrupt support yet. Disabling the energy saving mode
makes all go well. It should be possible to make this mode work without
interrupts by adding some code dealing with the ENERGYON flag. Since adding
interrupt support to the FEC driver seems to be the better solution for us, I
want to at least make sure the PHY works reliably always. So, disable energy
saving if there is no interrupt support.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---

Giuseppe: Did you test with interrupts? Do you agree?

If Giuseppe is fine with the patch, this should probably be tagged for stable.

 drivers/net/phy/smsc.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index fc3e7e9..6dcf57a 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -43,16 +43,18 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 
 static int smsc_phy_config_init(struct phy_device *phydev)
 {
-	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
-	if (rc < 0)
-		return rc;
-
-	/* Enable energy detect mode for this SMSC Transceivers */
-	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-		       rc | MII_LAN83C185_EDPWRDOWN);
-	if (rc < 0)
-		return rc;
-
+	/* TODO: add code to make EDPWRDOWN work without interrupts */
+	if (PHY_INTERRUPT_ENABLED == phydev->interrupts) {
+		int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+		if (rc < 0)
+			return rc;
+
+		/* Enable energy detect mode for this SMSC Transceivers */
+		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+			       rc | MII_LAN83C185_EDPWRDOWN);
+		if (rc < 0)
+			return rc;
+	}
 	return smsc_phy_ack_interrupt (phydev);
 }
 
-- 
1.7.9.1

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

* Re: [PATCH] net: phy: smsc: energy saving does not work without interrupts
  2012-03-21 12:08 [PATCH] net: phy: smsc: energy saving does not work without interrupts Wolfram Sang
@ 2012-03-21 14:28 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2012-03-21 14:28 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Giuseppe Cavallaro

[-- Attachment #1: Type: text/plain, Size: 2434 bytes --]

On Wed, Mar 21, 2012 at 01:08:27PM +0100, Wolfram Sang wrote:
> We discovered link detection failures using this PHY with the Freescale FEC
> which does not have interrupt support yet. Disabling the energy saving mode
> makes all go well. It should be possible to make this mode work without
> interrupts by adding some code dealing with the ENERGYON flag. Since adding
> interrupt support to the FEC driver seems to be the better solution for us, I
> want to at least make sure the PHY works reliably always. So, disable energy
> saving if there is no interrupt support.
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> ---
> 
> Giuseppe: Did you test with interrupts? Do you agree?
> 
> If Giuseppe is fine with the patch, this should probably be tagged for stable.
> 
>  drivers/net/phy/smsc.c |   22 ++++++++++++----------
>  1 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index fc3e7e9..6dcf57a 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -43,16 +43,18 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
>  
>  static int smsc_phy_config_init(struct phy_device *phydev)
>  {
> -	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> -	if (rc < 0)
> -		return rc;
> -
> -	/* Enable energy detect mode for this SMSC Transceivers */
> -	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> -		       rc | MII_LAN83C185_EDPWRDOWN);
> -	if (rc < 0)
> -		return rc;
> -
> +	/* TODO: add code to make EDPWRDOWN work without interrupts */
> +	if (PHY_INTERRUPT_ENABLED == phydev->interrupts) {

Gnarg, that should probably be:

+	if (phydev->irq != PHY_POLL) ...

since interrupts maybe not enabled at this point? Will resend, but will
wait some more for comments.

> +		int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> +		if (rc < 0)
> +			return rc;
> +
> +		/* Enable energy detect mode for this SMSC Transceivers */
> +		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> +			       rc | MII_LAN83C185_EDPWRDOWN);
> +		if (rc < 0)
> +			return rc;
> +	}
>  	return smsc_phy_ack_interrupt (phydev);
>  }
>  
> -- 
> 1.7.9.1
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2012-03-21 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21 12:08 [PATCH] net: phy: smsc: energy saving does not work without interrupts Wolfram Sang
2012-03-21 14:28 ` Wolfram Sang

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