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 <phil@raspberrypi.com>
  • Loading branch information
pelwell authored and popcornmix committed Mar 21, 2022
1 parent 342f54d commit 5e73e07
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 @@ -218,6 +218,8 @@ static int lan87xx_read_status(struct phy_device *phydev)
int err = genphy_read_status(phydev);

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

/* Disable EDPD to wake up PHY */
int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
if (rc < 0)
Expand All @@ -233,7 +235,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 @@ -243,10 +245,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 5e73e07

Please sign in to comment.