kernel: bump 5.15 to 5.15.62
[openwrt/staging/jow.git] / target / linux / bcm27xx / patches-5.15 / 950-0700-net-phy-lan87xx-Decrease-phy-polling-rate.patch
1 From 01649f43afb30df3c7450fd09c04a5a8ee6cb2c1 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Thu, 3 Feb 2022 15:51:41 +0000
4 Subject: [PATCH] net: phy: lan87xx: Decrease phy polling rate
5
6 Polling at 100Hz for 1.5s consumes quite a bit of kworker time with no
7 obvious benefit. Reduce that polling rate to ~6Hz.
8
9 To further save CPU and power, defer the next poll if no energy is
10 detected.
11
12 See: https://github.com/raspberrypi/linux/issues/4780
13
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
15 ---
16 drivers/net/phy/smsc.c | 10 +++++++++-
17 1 file changed, 9 insertions(+), 1 deletion(-)
18
19 --- a/drivers/net/phy/smsc.c
20 +++ b/drivers/net/phy/smsc.c
21 @@ -220,6 +220,8 @@ static int lan87xx_read_status(struct ph
22 int err = genphy_read_status(phydev);
23
24 if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
25 + int energy_detected;
26 +
27 /* Disable EDPD to wake up PHY */
28 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
29 if (rc < 0)
30 @@ -235,7 +237,7 @@ static int lan87xx_read_status(struct ph
31 */
32 read_poll_timeout(phy_read, rc,
33 rc & MII_LAN83C185_ENERGYON || rc < 0,
34 - 10000, 1500000, true, phydev,
35 + 150000, 1500000, true, phydev,
36 MII_LAN83C185_CTRL_STATUS);
37 if (rc < 0)
38 return rc;
39 @@ -245,10 +247,16 @@ static int lan87xx_read_status(struct ph
40 if (rc < 0)
41 return rc;
42
43 + energy_detected = !!(rc & MII_LAN83C185_ENERGYON);
44 +
45 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
46 rc | MII_LAN83C185_EDPWRDOWN);
47 if (rc < 0)
48 return rc;
49 +
50 + /* Save CPU and power by deferring the next poll */
51 + if (!energy_detected)
52 + msleep(2000);
53 }
54
55 return err;