From: Phil Elwell Date: Thu, 3 Feb 2022 15:51:41 +0000 (+0000) Subject: net: phy: lan87xx: Decrease phy polling rate X-Git-Tag: submit/tizen/20220208.074352~290 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0272c695e99a8dcc3a01298db56361333f1fdcf;p=platform%2Fkernel%2Flinux-rpi.git net: phy: lan87xx: Decrease phy polling rate 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: https://github.com/raspberrypi/linux/issues/4780 Signed-off-by: Phil Elwell --- diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index 9983eed..65ccc94 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -185,6 +185,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) @@ -200,7 +202,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; @@ -210,10 +212,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;