Commit 6e14a5ee authored by Zhangfei Gao's avatar Zhangfei Gao Committed by David S. Miller

net: phy: resume phydev when going to RESUMING

With commit be9dad1f ("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: default avatarJiancheng Xue <xuejiancheng@huawei.com>
Signed-off-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c2e3fa9
...@@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -715,7 +715,7 @@ void phy_state_machine(struct work_struct *work)
struct delayed_work *dwork = to_delayed_work(work); struct delayed_work *dwork = to_delayed_work(work);
struct phy_device *phydev = struct phy_device *phydev =
container_of(dwork, struct phy_device, state_queue); container_of(dwork, struct phy_device, state_queue);
int needs_aneg = 0, do_suspend = 0; bool needs_aneg = false, do_suspend = false, do_resume = false;
int err = 0; int err = 0;
mutex_lock(&phydev->lock); mutex_lock(&phydev->lock);
...@@ -727,7 +727,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -727,7 +727,7 @@ void phy_state_machine(struct work_struct *work)
case PHY_PENDING: case PHY_PENDING:
break; break;
case PHY_UP: case PHY_UP:
needs_aneg = 1; needs_aneg = true;
phydev->link_timeout = PHY_AN_TIMEOUT; phydev->link_timeout = PHY_AN_TIMEOUT;
...@@ -757,7 +757,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -757,7 +757,7 @@ void phy_state_machine(struct work_struct *work)
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
} else if (0 == phydev->link_timeout--) } else if (0 == phydev->link_timeout--)
needs_aneg = 1; needs_aneg = true;
break; break;
case PHY_NOLINK: case PHY_NOLINK:
err = phy_read_status(phydev); err = phy_read_status(phydev);
...@@ -791,7 +791,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -791,7 +791,7 @@ void phy_state_machine(struct work_struct *work)
netif_carrier_on(phydev->attached_dev); netif_carrier_on(phydev->attached_dev);
} else { } else {
if (0 == phydev->link_timeout--) if (0 == phydev->link_timeout--)
needs_aneg = 1; needs_aneg = true;
} }
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
...@@ -827,7 +827,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -827,7 +827,7 @@ void phy_state_machine(struct work_struct *work)
phydev->link = 0; phydev->link = 0;
netif_carrier_off(phydev->attached_dev); netif_carrier_off(phydev->attached_dev);
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
do_suspend = 1; do_suspend = true;
} }
break; break;
case PHY_RESUMING: case PHY_RESUMING:
...@@ -876,6 +876,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -876,6 +876,7 @@ void phy_state_machine(struct work_struct *work)
} }
phydev->adjust_link(phydev->attached_dev); phydev->adjust_link(phydev->attached_dev);
} }
do_resume = true;
break; break;
} }
...@@ -883,9 +884,10 @@ void phy_state_machine(struct work_struct *work) ...@@ -883,9 +884,10 @@ void phy_state_machine(struct work_struct *work)
if (needs_aneg) if (needs_aneg)
err = phy_start_aneg(phydev); err = phy_start_aneg(phydev);
else if (do_suspend)
if (do_suspend)
phy_suspend(phydev); phy_suspend(phydev);
else if (do_resume)
phy_resume(phydev);
if (err < 0) if (err < 0)
phy_error(phydev); phy_error(phydev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment