Skip to contentSkip to conversation

net: phylink: add phylink_set_mac_pm() helper

PATCH In review Shenwei Wang 2 participants 5 messages Oct 10, 2022

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover net: phylink: add phylink_set_mac_pm() helper

Per Russell's suggestion, the implementation is changed from the helper function to add an extra property in phylink_config structure because this change can easily cover SFP usecase too.

Shenwei Wang (2):
net: phylink: add mac_managed_pm in phylink_config structure
net: stmmac: Enable mac_managed_pm phylink config

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 drivers/net/phy/phylink.c                         | 4 ++++
 include/linux/phylink.h                           | 2 ++
 3 files changed, 7 insertions(+)

--
2.34.1

#1 lore raw

PATCH 1/2 net: phylink: add mac_managed_pm in phylink_config structure

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 boolean property in the phylink_config structure so that the MAC driver can use it to tell the PHY driver if it wants to manage the PM.

---
 drivers/net/phy/phylink.c | 4 ++++
 include/linux/phylink.h   | 2 ++
 2 files changed, 6 insertions(+)
drivers/net/phy/phylink.c +4 -0
index e9d62f9598f9..6d64d4b6d606 100644
@@ -74,6 +74,7 @@ struct phylink {
 
 	bool mac_link_dropped;
 	bool using_mac_select_pcs;
+	bool mac_managed_pm;
 
 	struct sfp_bus *sfp_bus;
 	bool sfp_may_have_phy;
@@ -1439,6 +1440,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
 	if (phy_interrupt_is_valid(phy))
 		phy_request_interrupt(phy);
 
+	if (pl->config->mac_managed_pm)
+		phy->mac_managed_pm = true;
+
 	return 0;
 }
 
include/linux/phylink.h +2 -0
index 6d06896fc20d..a3adf7fe7eaf 100644
@@ -88,6 +88,7 @@ enum phylink_op_type {
  *	(See commit 7cceb599d15d ("net: phylink: avoid mac_config calls")
  * @poll_fixed_state: if true, starts link_poll,
  *		      if MAC link is at %MLO_AN_FIXED mode.
+ * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM.
  * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
  * @get_fixed_state: callback to execute to determine the fixed link state,
  *		     if MAC link is at %MLO_AN_FIXED mode.
@@ -100,6 +101,7 @@ struct phylink_config {
 	enum phylink_op_type type;
 	bool legacy_pre_march2020;
 	bool poll_fixed_state;
+	bool mac_managed_pm;
 	bool ovr_an_inband;
 	void (*get_fixed_state)(struct phylink_config *config,
 				struct phylink_link_state *state);
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/2] net: phylink: add mac_managed_pm in phylink_config structure

drivers/net/phy/phylink.c struct phylink { · line 77

Quoted 9 lines · Shenwei Wang
drivers/net/phy/phylink.c +1 -0
index e9d62f9598f9..6d64d4b6d606 100644
@@ -74,6 +74,7 @@ struct phylink {
 
 	bool mac_link_dropped;
 	bool using_mac_select_pcs;
+	bool mac_managed_pm;

I don't think you need this?

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!
#3 lore raw

RE: [EXT] Re: [PATCH 1/2] net: phylink: add mac_managed_pm in phylink_config structure

Quoted 26 lines

-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, October 10, 2022 4:34 PM
To: Shenwei Wang <[email protected]>
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Maxime Coquelin <[email protected]>; Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH 1/2] net: phylink: add mac_managed_pm in phylink_config structure

Caution: EXT Email

Quoted 6 lines · Shenwei Wang
drivers/net/phy/phylink.c +0 -0
index e9d62f9598f9..6d64d4b6d606 100644
@@ -74,6 +74,7 @@ struct phylink {
 
Quoted 5 lines

drivers/net/phy/phylink.c struct phylink { · line 77

Quoted 3 lines
drivers/net/phy/phylink.c +1 -0
      bool mac_link_dropped;
      bool using_mac_select_pcs;
+     bool mac_managed_pm;

I don't think you need this?

It was cleaned up in patch v4.

Thanks,
Shenwei

Quoted 11 lines

--
RMK's Patch system:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar
mlinux.org.uk%2Fdeveloper%2Fpatches%2F&amp;data=05%7C01%7Cshenwei. wang%40nxp.com%7Cb7b04ce3002c4d29581c08daab07233d%7C686ea1d3bc2 b4c6fa92cd99c5c301635%7C0%7C0%7C638010344382281159%7CUnknown%7 CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ XVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=8siCkBn5XpHUEmv3Vx4vzgC QDHDg94rZ%2Flv13pZhc1c%3D&amp;reserved=0
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

#4 lore raw

PATCH 2/2 net: stmmac: Enable mac_managed_pm phylink config

In reply to Shenwei Wang

Enable the mac_managed_pm configuration in the phylink_config structure to avoid the kernel warning during system resume.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
index 8418e795cc21..537e8e61bb97 100644
@@ -1214,6 +1214,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 	if (priv->plat->tx_queues_to_use > 1)
 		priv->phylink_config.mac_capabilities &=
 			~(MAC_10HD | MAC_100HD | MAC_1000HD);
+	priv->phylink_config.mac_managed_pm = true;
 
 	phylink = phylink_create(&priv->phylink_config, fwnode,
 				 mode, &stmmac_phylink_mac_ops);
Signature · 1 line
2.34.1