[PATCH net-next 08/12] net: phy: phy_mux: Add phy_mux_set_mac_managed_pm()
From: Maxime Chevallier
Date: Fri Dec 04 2026 - 06:08:47 EST
MAC drivers that deal with the suspend/resume of their PHY on their own
say so with the mac_managed_pm flag, that ends-up being set on the PHY
when the MAC connects to it.
With a mux, the PHYs are attached by the mux and the parent only gets to
see the PHY of the selected port. The flag is needed on all of them
though, as they are all attached to the netdev.
Add a helper for the mux's parent to set the flag on all the PHYs behind
the mux.
Signed-off-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
---
drivers/net/phy/phy_mux.c | 15 +++++++++++++++
include/linux/phy_mux.h | 5 +++++
2 files changed, 20 insertions(+)
diff --git a/drivers/net/phy/phy_mux.c b/drivers/net/phy/phy_mux.c
index de3336970bd9..ed0bb8a3f429 100644
--- a/drivers/net/phy/phy_mux.c
+++ b/drivers/net/phy/phy_mux.c
@@ -413,6 +413,21 @@ void phy_mux_detach(struct phy_mux *mux)
}
EXPORT_SYMBOL_GPL(phy_mux_detach);
+/**
+ * phy_mux_set_mac_managed_pm() - Leave the PM of the PHYs to the MAC driver
+ * @mux: The mux, attached
+ */
+void phy_mux_set_mac_managed_pm(struct phy_mux *mux)
+{
+ struct phy_mux_port *port;
+ unsigned long id;
+
+ xa_for_each(&mux->ports, id, port)
+ if (port->attached)
+ port->phydev->mac_managed_pm = true;
+}
+EXPORT_SYMBOL_GPL(phy_mux_set_mac_managed_pm);
+
/**
* phy_mux_start() - Start selecting ports
* @mux: The mux, attached
diff --git a/include/linux/phy_mux.h b/include/linux/phy_mux.h
index 77cf389b8c77..00703371eea8 100644
--- a/include/linux/phy_mux.h
+++ b/include/linux/phy_mux.h
@@ -94,6 +94,7 @@ int fwnode_phy_mux_attach(const struct fwnode_handle *fwnode,
void phy_mux_detach(struct phy_mux *mux);
void phy_mux_start(struct phy_mux *mux);
void phy_mux_stop(struct phy_mux *mux);
+void phy_mux_set_mac_managed_pm(struct phy_mux *mux);
struct fwnode_handle *
fwnode_phy_mux_find_sfp_port(const struct fwnode_handle *fwnode);
struct phy_mux_port *phy_mux_get_sfp_port(struct phy_mux *mux);
@@ -121,6 +122,10 @@ static inline void phy_mux_stop(struct phy_mux *mux)
{
}
+static inline void phy_mux_set_mac_managed_pm(struct phy_mux *mux)
+{
+}
+
static inline struct fwnode_handle *
fwnode_phy_mux_find_sfp_port(const struct fwnode_handle *fwnode)
{
--
2.56.1