]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sh_eth: avoid PHY being resumed when interface is not up
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Wed, 15 Mar 2023 07:41:15 +0000 (08:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:50 +0000 (13:33 +0100)
[ Upstream commit 8b667d80115406c3c405668996a6d7334985ce46 ]

SH_ETH doesn't need mdiobus suspend/resume, that's why it sets
'mac_managed_pm'. However, setting it needs to be moved from init to
probe, so mdiobus PM functions will really never be called (e.g. when
the interface is not up yet during suspend/resume).

Fixes: cf2e91979a0a ("net: sh_eth: Fix PHY state warning splat during system resume")
Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/renesas/sh_eth.c

index 71a4991133080fac9bbbbc20437a09025795fc6d..14dc5833c465c856063d0c3009aee0d78282b7b4 100644 (file)
@@ -2029,8 +2029,6 @@ static int sh_eth_phy_init(struct net_device *ndev)
        if (mdp->cd->register_type != SH_ETH_REG_GIGABIT)
                phy_set_max_speed(phydev, SPEED_100);
 
-       /* Indicate that the MAC is responsible for managing PHY PM */
-       phydev->mac_managed_pm = true;
        phy_attached_info(phydev);
 
        return 0;
@@ -3074,6 +3072,8 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
        struct bb_info *bitbang;
        struct platform_device *pdev = mdp->pdev;
        struct device *dev = &mdp->pdev->dev;
+       struct phy_device *phydev;
+       struct device_node *pn;
 
        /* create bit control struct for PHY */
        bitbang = devm_kzalloc(dev, sizeof(struct bb_info), GFP_KERNEL);
@@ -3108,6 +3108,14 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
        if (ret)
                goto out_free_bus;
 
+       pn = of_parse_phandle(dev->of_node, "phy-handle", 0);
+       phydev = of_phy_find_device(pn);
+       if (phydev) {
+               phydev->mac_managed_pm = true;
+               put_device(&phydev->mdio.dev);
+       }
+       of_node_put(pn);
+
        return 0;
 
 out_free_bus: