diff mbox series

[net-next,v2,2/9] net: phy: Introduce phy_shutdown for device quiescence.

Message ID 20241004161601.2932901-3-maxime.chevallier@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Allow isolating PHY devices | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; GEN HAS DIFF 2 files changed, 102 insertions(+);
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6 this patch: 6
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 6 this patch: 6
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 40 this patch: 40
netdev/source_inline success Was 0 now: 0

Commit Message

Maxime Chevallier Oct. 4, 2024, 4:15 p.m. UTC
When the hardware platform goes down for reboot, there's always the
chance that the PHY device doesn't get reset, or fully reconfigured by
the bootloader, which could rely on strap settings.

Therefore, when special modes from the PHY are being used, which could
make it non-functional at reboot, introduce a phy_shutdown helper to
pull the PHY out of the non-functional mode it is currently in.

Currently, this applies to the isolation mode.

Suggested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V2 : New patch

 drivers/net/phy/phy_device.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c468e72bef4b..a0d8ff995024 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3733,6 +3733,17 @@  static int phy_remove(struct device *dev)
 	return 0;
 }
 
+static void phy_shutdown(struct device *dev)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+
+	/* If the PHY isn't reset and reconfigured by the bootloader, the PHY
+	 * will stay isolated. Make sure to un-isolate PHYs during shutdown.
+	 */
+	if (phydev->isolated)
+		phy_isolate(phydev, false);
+}
+
 /**
  * phy_driver_register - register a phy_driver with the PHY layer
  * @new_driver: new phy_driver to register
@@ -3766,6 +3777,7 @@  int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
 	new_driver->mdiodrv.driver.bus = &mdio_bus_type;
 	new_driver->mdiodrv.driver.probe = phy_probe;
 	new_driver->mdiodrv.driver.remove = phy_remove;
+	new_driver->mdiodrv.driver.shutdown = phy_shutdown;
 	new_driver->mdiodrv.driver.owner = owner;
 	new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS;