Skip to content

Commit

Permalink
net: phy: lan87xx: Decrease phy polling rate
Browse files Browse the repository at this point in the history
Polling at 100Hz for 1.5s consumes quite a bit of kworker time with no
obvious benefit. Reduce that polling rate to ~6Hz.

To further save CPU and power, defer the next poll if no energy is
detected.

See: #4780

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell authored and popcornmix committed Aug 23, 2022
1 parent 64ad740 commit ffc21e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/net/phy/smsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ static int lan87xx_read_status(struct phy_device *phydev)
int err = genphy_read_status(phydev);

if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
int energy_detected;

/* Disable EDPD to wake up PHY */
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
if (rc < 0)
Expand All @@ -235,7 +237,7 @@ static int lan87xx_read_status(struct phy_device *phydev)
*/
read_poll_timeout(phy_read, rc,
rc & MII_LAN83C185_ENERGYON || rc < 0,
10000, 1500000, true, phydev,
150000, 1500000, true, phydev,
MII_LAN83C185_CTRL_STATUS);
if (rc < 0)
return rc;
Expand All @@ -245,10 +247,16 @@ static int lan87xx_read_status(struct phy_device *phydev)
if (rc < 0)
return rc;

energy_detected = !!(rc & MII_LAN83C185_ENERGYON);

rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
rc | MII_LAN83C185_EDPWRDOWN);
if (rc < 0)
return rc;

/* Save CPU and power by deferring the next poll */
if (!energy_detected)
msleep(2000);
}

return err;
Expand Down

0 comments on commit ffc21e5

Please sign in to comment.