Skip to content

Commit 11e122c

Browse files
Shaohui Xiedavem330
authored andcommitted
net: phy: fix PHY_RUNNING in phy_state_machine
Currently, if phy state is PHY_RUNNING, we always register a CHANGE when phy works in polling or interrupt ignored, this will make the adjust_link being called even the phy link did Not changed. checking the phy link to make sure the link did changed before we register a CHANGE, if link did not changed, we do nothing. Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5d37852 commit 11e122c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/net/phy/phy.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ void phy_state_machine(struct work_struct *work)
811811
bool needs_aneg = false, do_suspend = false;
812812
enum phy_state old_state;
813813
int err = 0;
814+
int old_link;
814815

815816
mutex_lock(&phydev->lock);
816817

@@ -896,11 +897,18 @@ void phy_state_machine(struct work_struct *work)
896897
phydev->adjust_link(phydev->attached_dev);
897898
break;
898899
case PHY_RUNNING:
899-
/* Only register a CHANGE if we are
900-
* polling or ignoring interrupts
900+
/* Only register a CHANGE if we are polling or ignoring
901+
* interrupts and link changed since latest checking.
901902
*/
902-
if (!phy_interrupt_is_valid(phydev))
903-
phydev->state = PHY_CHANGELINK;
903+
if (!phy_interrupt_is_valid(phydev)) {
904+
old_link = phydev->link;
905+
err = phy_read_status(phydev);
906+
if (err)
907+
break;
908+
909+
if (old_link != phydev->link)
910+
phydev->state = PHY_CHANGELINK;
911+
}
904912
break;
905913
case PHY_CHANGELINK:
906914
err = phy_read_status(phydev);

0 commit comments

Comments
 (0)