[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID:
<AM9PR04MB8506772CFCC05CE71C383A6AE2202@AM9PR04MB8506.eurprd04.prod.outlook.com>
Date: Thu, 7 Mar 2024 15:45:58 +0000
From: "Jan Petrous (OSS)" <jan.petrous@....nxp.com>
To: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, Andrew Lunn
<andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>, Russell King
<linux@...linux.org.uk>, "David S. Miller" <davem@...emloft.net>, Eric
Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>
Subject: [RFC PATCH net-next] net: phy: Don't suspend/resume device not in use
In the case when an MDIO bus contains PHY device not attached to
the any netdev or is attached to the external netdev, controlled
by another driver and the driver is disabled, the bus, when PM suspend
occurs, is trying to suspend/resume also the unattached phydev.
/* Synopsys DWMAC built-in driver (stmmac) */
gmac0: ethernet@...3c000 {
compatible = "snps,dwc-qos-ethernet", "nxp,s32cc-dwmac";
phy-handle = <&gmac0_mdio_c_phy4>;
phy-mode = "rgmii-id";
gmac0_mdio: mdio@0 {
compatible = "snps,dwmac-mdio";
/* AQR107 attached to pfe_netif1 */
gmac0_mdio_c_phy1: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c45";
reg = <1>;
};
/* KSZ9031RNX attached to gmac0 */
gmac0_mdio_c_phy4: ethernet-phy@4 {
reg = <4>;
};
};
};
/* PFE controller, loadable driver pfeng.ko */
pfe: pfe@...00000 {
compatible = "nxp,s32g-pfe";
/* Network interface 'pfe1' */
pfe_netif1: ethernet@11 {
compatible = "nxp,s32g-pfe-netif";
phy-mode = "sgmii";
phy-handle = <&gmac0_mdio_c_phy1>;
};
};
Because such device didn't go through attach process, internal
parameters like phy_dev->interface is set to the default value, which
is not correct for some drivers. Ie. Aquantia PHY AQR107 doesn't
support PHY_INTERFACE_MODE_GMII and trying to use phy_init_hw()
in mdio_bus_phy_resume() ends up with the following error caused
by initial check of supported interfaces in aqr107_config_init():
[ 63.927708] Aquantia AQR113C stmmac-0:08: PM: failed to resume: error -19']
Signed-off-by: Jan Petrous <jan.petrous@....nxp.com>
---
drivers/net/phy/phy_device.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3611ea64875e..30c03ac6b84c 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -311,6 +311,10 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev)
{
struct phy_device *phydev = to_phy_device(dev);
+ /* Don't suspend device if not in use state */
+ if (phydev->state <= PHY_READY)
+ return 0;
+
if (phydev->mac_managed_pm)
return 0;
@@ -344,6 +348,10 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
struct phy_device *phydev = to_phy_device(dev);
int ret;
+ /* Don't resume device which wasn't previously in use state */
+ if (phydev->state <= PHY_READY)
+ return 0;
+
if (phydev->mac_managed_pm)
return 0;
--
2.43.0
Powered by blists - more mailing lists