All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net/phy: micrel: Reenable interrupts during resume
@ 2015-07-30 15:15 Nathan Sullivan
  2015-07-30 16:40 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Nathan Sullivan @ 2015-07-30 15:15 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, linux-kernel, Nathan Sullivan

The ksz9031 has a behavior where it will clear the interrupt enable bits
when leaving power down.  To work around this, make sure the interrupt
bits are in the state they are expected to be when resuming.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
---

Changes for V2: Actually make sure it compiles this time.

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

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 499185e..9774582 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -447,6 +447,22 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
 	return genphy_restart_aneg(phydev);
 }
 
+static int ksz9031_resume(struct phy_device *phydev)
+{
+	int result;
+
+	result = genphy_resume(phydev);
+
+	if (result)
+		return result;
+
+	/* This phy will reset interrupt enables when leaving power down */
+	if (PHY_INTERRUPT_ENABLED & phydev->interrupts)
+		result = kszphy_config_intr(phydev);
+
+	return result;
+}
+
 static int ksz9031_config_init(struct phy_device *phydev)
 {
 	const struct device *dev = &phydev->dev;
@@ -776,7 +792,7 @@ static struct phy_driver ksphy_driver[] = {
 	.ack_interrupt	= kszphy_ack_interrupt,
 	.config_intr	= kszphy_config_intr,
 	.suspend	= genphy_suspend,
-	.resume		= genphy_resume,
+	.resume		= ksz9031_resume,
 	.driver		= { .owner = THIS_MODULE, },
 }, {
 	.phy_id		= PHY_ID_KSZ8873MLL,
-- 
1.7.10.4


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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-30 15:15 [PATCH v2] net/phy: micrel: Reenable interrupts during resume Nathan Sullivan
@ 2015-07-30 16:40 ` Florian Fainelli
  2015-07-30 17:00 ` David Miller
  2015-07-30 18:00 ` Sergei Shtylyov
  2 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2015-07-30 16:40 UTC (permalink / raw)
  To: Nathan Sullivan; +Cc: netdev, linux-kernel

On 30/07/15 08:15, Nathan Sullivan wrote:
> The ksz9031 has a behavior where it will clear the interrupt enable bits
> when leaving power down.  To work around this, make sure the interrupt
> bits are in the state they are expected to be when resuming.
> 
> Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> ---
> 
> Changes for V2: Actually make sure it compiles this time.
> 
> ---
>  drivers/net/phy/micrel.c |   18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 499185e..9774582 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -447,6 +447,22 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
>  	return genphy_restart_aneg(phydev);
>  }
>  
> +static int ksz9031_resume(struct phy_device *phydev)
> +{
> +	int result;
> +
> +	result = genphy_resume(phydev);
> +
> +	if (result)
> +		return result;
> +
> +	/* This phy will reset interrupt enables when leaving power down */
> +	if (PHY_INTERRUPT_ENABLED & phydev->interrupts)
> +		result = kszphy_config_intr(phydev);
> +
> +	return result;
> +}
> +
>  static int ksz9031_config_init(struct phy_device *phydev)
>  {
>  	const struct device *dev = &phydev->dev;
> @@ -776,7 +792,7 @@ static struct phy_driver ksphy_driver[] = {
>  	.ack_interrupt	= kszphy_ack_interrupt,
>  	.config_intr	= kszphy_config_intr,
>  	.suspend	= genphy_suspend,
> -	.resume		= genphy_resume,
> +	.resume		= ksz9031_resume,
>  	.driver		= { .owner = THIS_MODULE, },
>  }, {
>  	.phy_id		= PHY_ID_KSZ8873MLL,
> 


-- 
Florian

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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-30 15:15 [PATCH v2] net/phy: micrel: Reenable interrupts during resume Nathan Sullivan
  2015-07-30 16:40 ` Florian Fainelli
@ 2015-07-30 17:00 ` David Miller
  2015-07-30 23:09   ` Nathan Sullivan
  2015-07-30 18:00 ` Sergei Shtylyov
  2 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2015-07-30 17:00 UTC (permalink / raw)
  To: nathan.sullivan; +Cc: f.fainelli, netdev, linux-kernel

From: Nathan Sullivan <nathan.sullivan@ni.com>
Date: Thu, 30 Jul 2015 10:15:48 -0500

> Changes for V2: Actually make sure it compiles this time.

If V1 didn't compile, even for you, then I have a big problem.

And that problem is that you didn't test this change at all.

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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-30 15:15 [PATCH v2] net/phy: micrel: Reenable interrupts during resume Nathan Sullivan
  2015-07-30 16:40 ` Florian Fainelli
  2015-07-30 17:00 ` David Miller
@ 2015-07-30 18:00 ` Sergei Shtylyov
  2 siblings, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2015-07-30 18:00 UTC (permalink / raw)
  To: Nathan Sullivan, f.fainelli; +Cc: netdev, linux-kernel

Hello.

On 07/30/2015 06:15 PM, Nathan Sullivan wrote:

> The ksz9031 has a behavior where it will clear the interrupt enable bits
> when leaving power down.  To work around this, make sure the interrupt
> bits are in the state they are expected to be when resuming.

> Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> ---

> Changes for V2: Actually make sure it compiles this time.

> ---
>   drivers/net/phy/micrel.c |   18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 499185e..9774582 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -447,6 +447,22 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
>   	return genphy_restart_aneg(phydev);
>   }
>
> +static int ksz9031_resume(struct phy_device *phydev)
> +{
> +	int result;
> +
> +	result = genphy_resume(phydev);
> +

    I don't think empty line is needed here. Sorry for missing it in the first 
posting...

> +	if (result)
> +		return result;
> +
> +	/* This phy will reset interrupt enables when leaving power down */
> +	if (PHY_INTERRUPT_ENABLED & phydev->interrupts)
> +		result = kszphy_config_intr(phydev);
> +
> +	return result;
> +}
> +
[...]

WBR, Sergei


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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-30 17:00 ` David Miller
@ 2015-07-30 23:09   ` Nathan Sullivan
  2015-07-31  7:22     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Sullivan @ 2015-07-30 23:09 UTC (permalink / raw)
  To: David Miller; +Cc: f.fainelli, netdev, linux-kernel

On Thu, Jul 30, 2015 at 10:00:34AM -0700, David Miller wrote:
> From: Nathan Sullivan <nathan.sullivan@ni.com>
> Date: Thu, 30 Jul 2015 10:15:48 -0500
> 
> > Changes for V2: Actually make sure it compiles this time.
> 
> If V1 didn't compile, even for you, then I have a big problem.
> 
> And that problem is that you didn't test this change at all.

Sorry about that, I have tested it against 3.14, which is why I had
the older interrupt function in v1.  On HEAD, the phy no longer
suspends when ethernet goes down on our hardware - I'm still working
on figuring out why.  I'm also surprised no one noticed this behavior
before I did, but if the phy never goes into suspend you wouldn't.

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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-30 23:09   ` Nathan Sullivan
@ 2015-07-31  7:22     ` David Miller
  2015-07-31 14:27       ` Nathan Sullivan
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2015-07-31  7:22 UTC (permalink / raw)
  To: nathan.sullivan; +Cc: f.fainelli, netdev, linux-kernel

From: Nathan Sullivan <nathan.sullivan@ni.com>
Date: Thu, 30 Jul 2015 18:09:05 -0500

> On Thu, Jul 30, 2015 at 10:00:34AM -0700, David Miller wrote:
>> From: Nathan Sullivan <nathan.sullivan@ni.com>
>> Date: Thu, 30 Jul 2015 10:15:48 -0500
>> 
>> > Changes for V2: Actually make sure it compiles this time.
>> 
>> If V1 didn't compile, even for you, then I have a big problem.
>> 
>> And that problem is that you didn't test this change at all.
> 
> Sorry about that, I have tested it against 3.14, which is why I had
> the older interrupt function in v1.  On HEAD, the phy no longer
> suspends when ethernet goes down on our hardware - I'm still working
> on figuring out why.  I'm also surprised no one noticed this behavior
> before I did, but if the phy never goes into suspend you wouldn't.

I think you should sort out the PHY suspending issue before we move
forward with this patch.

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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-31  7:22     ` David Miller
@ 2015-07-31 14:27       ` Nathan Sullivan
  2015-07-31 20:21         ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Nathan Sullivan @ 2015-07-31 14:27 UTC (permalink / raw)
  To: David Miller; +Cc: f.fainelli, netdev, linux-kernel

On Fri, Jul 31, 2015 at 12:22:04AM -0700, David Miller wrote:
> From: Nathan Sullivan <nathan.sullivan@ni.com>
> Date: Thu, 30 Jul 2015 18:09:05 -0500
> 
> > On Thu, Jul 30, 2015 at 10:00:34AM -0700, David Miller wrote:
> >> From: Nathan Sullivan <nathan.sullivan@ni.com>
> >> Date: Thu, 30 Jul 2015 10:15:48 -0500
> >> 
> >> > Changes for V2: Actually make sure it compiles this time.
> >> 
> >> If V1 didn't compile, even for you, then I have a big problem.
> >> 
> >> And that problem is that you didn't test this change at all.
> > 
> > Sorry about that, I have tested it against 3.14, which is why I had
> > the older interrupt function in v1.  On HEAD, the phy no longer
> > suspends when ethernet goes down on our hardware - I'm still working
> > on figuring out why.  I'm also surprised no one noticed this behavior
> > before I did, but if the phy never goes into suspend you wouldn't.
> 
> I think you should sort out the PHY suspending issue before we move
> forward with this patch.

I believe I found the issue, we are using this PHY with cadence macb as
the MAC.  The driver currently turns off the management port in
macb_reset_hw, which we have stopped with a local change since our hardware
typically has multiple phys on one mdio bus.  That also prevents phy suspend
from working correctly, since the bus goes down before the phy state machine
can stop the phy.

In our local patch, we have macb_reset_hw keep the mdio bus on if it's on
already.  Does that sound like an acceptable fix to you?

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

* Re: [PATCH v2] net/phy: micrel: Reenable interrupts during resume
  2015-07-31 14:27       ` Nathan Sullivan
@ 2015-07-31 20:21         ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-07-31 20:21 UTC (permalink / raw)
  To: nathan.sullivan; +Cc: f.fainelli, netdev, linux-kernel

From: Nathan Sullivan <nathan.sullivan@ni.com>
Date: Fri, 31 Jul 2015 09:27:06 -0500

> I believe I found the issue, we are using this PHY with cadence macb as
> the MAC.  The driver currently turns off the management port in
> macb_reset_hw, which we have stopped with a local change since our hardware
> typically has multiple phys on one mdio bus.  That also prevents phy suspend
> from working correctly, since the bus goes down before the phy state machine
> can stop the phy.
> 
> In our local patch, we have macb_reset_hw keep the mdio bus on if it's on
> already.  Does that sound like an acceptable fix to you?

Then you don't need this patch at all if your hardware configuration
in question will not suspend the PHY device.

Can you see how rediculous this situation looks to me?

You can't even test this change on the hardware you are using.

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

end of thread, other threads:[~2015-07-31 20:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30 15:15 [PATCH v2] net/phy: micrel: Reenable interrupts during resume Nathan Sullivan
2015-07-30 16:40 ` Florian Fainelli
2015-07-30 17:00 ` David Miller
2015-07-30 23:09   ` Nathan Sullivan
2015-07-31  7:22     ` David Miller
2015-07-31 14:27       ` Nathan Sullivan
2015-07-31 20:21         ` David Miller
2015-07-30 18:00 ` Sergei Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.