netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] net: phy: resume phydev when going to RESUMING
@ 2014-05-14  1:31 Zhangfei Gao
  2014-05-14  1:40 ` Zhangfei Gao
  0 siblings, 1 reply; 4+ messages in thread
From: Zhangfei Gao @ 2014-05-14  1:31 UTC (permalink / raw)
  To: sebastian.hesselbarth, f.fainelli, davem, sergei.shtylyov
  Cc: netdev, Zhangfei Gao, Jiancheng Xue

"With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
to HALTED"), an unused PHY device will be put in a low-power mode
using BMCR_PDOWN. Some Ethernet drivers might be calling phy_start()
and phy_stop() from ndo_open and ndo_close() respectively, while
calling phy_connect() and phy_disconnect() from probe and remove.
In such a case, the PHY will be powered down during the phy_stop()
call, but will fail to be powered up in phy_start().
This patch fixes the following scenario."

Signed-off-by: Jiancheng Xue <xuejiancheng@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/net/phy/phy.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1b6d09a..be5d52e 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work)
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct phy_device *phydev =
 			container_of(dwork, struct phy_device, state_queue);
-	int needs_aneg = 0, do_suspend = 0;
+	int needs_aneg = 0, do_suspend = 0, do_resume = 0;
 	int err = 0;
 
 	mutex_lock(&phydev->lock);
@@ -865,6 +865,8 @@ void phy_state_machine(struct work_struct *work)
 			}
 			phydev->adjust_link(phydev->attached_dev);
 		}
+
+		do_resume = 1;
 		break;
 	}
 
@@ -876,6 +878,9 @@ void phy_state_machine(struct work_struct *work)
 	if (do_suspend)
 		phy_suspend(phydev);
 
+	if (do_resume)
+		phy_resume(phydev);
+
 	if (err < 0)
 		phy_error(phydev);
 
-- 
1.7.9.5

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

* [PATCH v1] net: phy: resume phydev when going to RESUMING
  2014-05-14  1:31 [PATCH v1] net: phy: resume phydev when going to RESUMING Zhangfei Gao
@ 2014-05-14  1:40 ` Zhangfei Gao
  2014-05-14  1:57   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Zhangfei Gao @ 2014-05-14  1:40 UTC (permalink / raw)
  To: sebastian.hesselbarth, f.fainelli, davem, sergei.shtylyov
  Cc: netdev, Zhangfei Gao, Jiancheng Xue

With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
to HALTED"), an unused PHY device will be put in a low-power mode
using BMCR_PDOWN. Some Ethernet drivers might be calling phy_start()
and phy_stop() from ndo_open and ndo_close() respectively, while
calling phy_connect() and phy_disconnect() from probe and remove.
In such a case, the PHY will be powered down during the phy_stop()
call, but will fail to be powered up in phy_start().
This patch fixes this scenario.

Signed-off-by: Jiancheng Xue <xuejiancheng@huawei.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/net/phy/phy.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1b6d09a..be5d52e 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work)
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct phy_device *phydev =
 			container_of(dwork, struct phy_device, state_queue);
-	int needs_aneg = 0, do_suspend = 0;
+	int needs_aneg = 0, do_suspend = 0, do_resume = 0;
 	int err = 0;
 
 	mutex_lock(&phydev->lock);
@@ -865,6 +865,8 @@ void phy_state_machine(struct work_struct *work)
 			}
 			phydev->adjust_link(phydev->attached_dev);
 		}
+
+		do_resume = 1;
 		break;
 	}
 
@@ -876,6 +878,9 @@ void phy_state_machine(struct work_struct *work)
 	if (do_suspend)
 		phy_suspend(phydev);
 
+	if (do_resume)
+		phy_resume(phydev);
+
 	if (err < 0)
 		phy_error(phydev);
 
-- 
1.7.9.5

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

* Re: [PATCH v1] net: phy: resume phydev when going to RESUMING
  2014-05-14  1:40 ` Zhangfei Gao
@ 2014-05-14  1:57   ` Joe Perches
  2014-05-15  1:57     ` zhangfei
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-05-14  1:57 UTC (permalink / raw)
  To: Zhangfei Gao
  Cc: sebastian.hesselbarth, f.fainelli, davem, sergei.shtylyov, netdev,
	Jiancheng Xue

On Wed, 2014-05-14 at 09:40 +0800, Zhangfei Gao wrote:
> With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
> to HALTED"), an unused PHY device will be put in a low-power mode
> using BMCR_PDOWN. Some Ethernet drivers might be calling phy_start()
> and phy_stop() from ndo_open and ndo_close() respectively, while
> calling phy_connect() and phy_disconnect() from probe and remove.
> In such a case, the PHY will be powered down during the phy_stop()
> call, but will fail to be powered up in phy_start().
> This patch fixes this scenario.

trivial notes:

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
[]
> @@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work)
>  	struct delayed_work *dwork = to_delayed_work(work);
>  	struct phy_device *phydev =
>  			container_of(dwork, struct phy_device, state_queue);
> -	int needs_aneg = 0, do_suspend = 0;
> +	int needs_aneg = 0, do_suspend = 0, do_resume = 0;

Perhaps these 3 vars should bool

> @@ -876,6 +878,9 @@ void phy_state_machine(struct work_struct *work)
>  	if (do_suspend)
>  		phy_suspend(phydev);
>  
> +	if (do_resume)
> +		phy_resume(phydev);
> +

and these should be else if

	if (needs_aneg)
		...
	else if (do_suspend)
		...
	else if (do_resume)
		...

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

* Re: [PATCH v1] net: phy: resume phydev when going to RESUMING
  2014-05-14  1:57   ` Joe Perches
@ 2014-05-15  1:57     ` zhangfei
  0 siblings, 0 replies; 4+ messages in thread
From: zhangfei @ 2014-05-15  1:57 UTC (permalink / raw)
  To: Joe Perches
  Cc: sebastian.hesselbarth, f.fainelli, davem, sergei.shtylyov, netdev,
	Jiancheng Xue



On 05/14/2014 09:57 AM, Joe Perches wrote:
> On Wed, 2014-05-14 at 09:40 +0800, Zhangfei Gao wrote:
>> With commit be9dad1f9f26604fb ("net: phy: suspend phydev when going
>> to HALTED"), an unused PHY device will be put in a low-power mode
>> using BMCR_PDOWN. Some Ethernet drivers might be calling phy_start()
>> and phy_stop() from ndo_open and ndo_close() respectively, while
>> calling phy_connect() and phy_disconnect() from probe and remove.
>> In such a case, the PHY will be powered down during the phy_stop()
>> call, but will fail to be powered up in phy_start().
>> This patch fixes this scenario.
>
> trivial notes:
>
>> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> []
>> @@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work)
>>   	struct delayed_work *dwork = to_delayed_work(work);
>>   	struct phy_device *phydev =
>>   			container_of(dwork, struct phy_device, state_queue);
>> -	int needs_aneg = 0, do_suspend = 0;
>> +	int needs_aneg = 0, do_suspend = 0, do_resume = 0;
>
> Perhaps these 3 vars should bool
Yes, agree.
>
>> @@ -876,6 +878,9 @@ void phy_state_machine(struct work_struct *work)
>>   	if (do_suspend)
>>   		phy_suspend(phydev);
>>
>> +	if (do_resume)
>> +		phy_resume(phydev);
>> +
>
> and these should be else if
>
> 	if (needs_aneg)
> 		...
> 	else if (do_suspend)
> 		...
> 	else if (do_resume)
> 		...
Ok, since needs_aneg can not happen simultaneously with suspend/resume.

Thanks

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

end of thread, other threads:[~2014-05-15  1:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-14  1:31 [PATCH v1] net: phy: resume phydev when going to RESUMING Zhangfei Gao
2014-05-14  1:40 ` Zhangfei Gao
2014-05-14  1:57   ` Joe Perches
2014-05-15  1:57     ` zhangfei

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