net: phylink: add phylink_set_mac_pm() helper
Subsystems (5)
PATCH v2 1/1 net: phylink: add phylink_set_mac_pm() helper
The recent commit
'commit 47ac7b2f6a1f ("net: phy: Warn about incorrect mdio_bus_phy_resume() state")'
requires the MAC driver explicitly tell the phy driver who is managing the PM, otherwise you will see warning during resume stage.
Add a helper to let the MAC driver has a way to tell the PHY driver it will manage the PM.
---
Changes in v2:
- add the API description
- remove the unneccesary ASSERT_RTNL();
drivers/net/phy/phylink.c | 17 +++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 18 insertions(+)
drivers/net/phy/phylink.c +17 -0
@@ -1722,6 +1722,23 @@ void phylink_stop(struct phylink *pl) }EXPORT_SYMBOL_GPL (phylink_stop); +/** +* phylink_set_mac_pm() - set phydev->mac_managed_pm to true +* @pl: a pointer to a &struct phylink returned from phylink_create() +* +* Set the phydev->mac_managed_pm, which is under the phylink instance +* specified by @pl, to true. This is to indicate that the MAC driver is +* responsible for PHY PM. +* +* The function can be called in the net_device_ops ndo_open() method. +*/ +void phylink_set_mac_pm (struct phylink *pl) +{ +if (pl->phydev) + pl->phydev->mac_managed_pm = true; +} +EXPORT_SYMBOL_GPL (phylink_set_mac_pm); +/** * phylink_suspend() - handle a network device suspend event * @pl: a pointer to a &struct phylink returned from phylink_create()
include/linux/phylink.h +1 -0
@@ -540,6 +540,7 @@ void phylink_mac_change(struct phylink *, bool up);void phylink_start (struct phylink *);void phylink_stop (struct phylink *); +void phylink_set_mac_pm (struct phylink *pl);void phylink_suspend (struct phylink *pl,bool mac_wol);void phylink_resume (struct phylink *pl);
--
2.34.1
Russell King (Oracle)
maintainerQuoted 9 lines · Shenwei Wang
+/**
+ *phylink_set_mac_pm()- setphydev->mac_managed_pmto true
+ * @pl: a pointer to a &struct phylink returned fromphylink_create()
+ *
+ * Set thephydev->mac_managed_pm, which is under the phylink instance
+ * specified by @pl, to true. This is to indicate that the MAC driver is
+ * responsible for PHY PM.
+ *
+ * The function can be called in thenet_device_opsndo_open()method.
I think this needs to be a bit clearer - a driver author may well ask "before or after the PHY is connected?" and this really ought to state this detail.
Otherwise, the patch is fine.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!