Skip to contentSkip to conversation

net: phylink: add phylink_set_mac_pm() helper

PATCH Applied Shenwei Wang 2 participants 4 messages Oct 14, 2022 – Oct 15, 2022

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

v6 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.

Changes in v6:
- update the fix tag hash and format

Changes in v5:
- Add fix tag in the commit message

Changes in v4:
- Clean up the codes in phylink.c
- Continue the version number

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                         | 3 +++
 include/linux/phylink.h                           | 2 ++
 3 files changed, 6 insertions(+)

--
2.34.1

#1 lore raw

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

The recent commit

'commit 744d23c71af3 ("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.

Fixes 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() state")
---
 drivers/net/phy/phylink.c | 3 +++
 include/linux/phylink.h   | 2 ++
 2 files changed, 5 insertions(+)
drivers/net/phy/phylink.c +3 -0
index 75464df191ef..6547b6cc6cbe 100644
@@ -1661,6 +1661,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 664dd409feb9..3f01ac8017e0 100644
@@ -122,6 +122,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.
@@ -134,6 +135,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

PATCH v6 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.

Fixes 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() state")
---
 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 65c96773c6d2..8273e6a175c8 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
#3 lore raw
In reply to Shenwei Wang
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Fri, 14 Oct 2022 09:47:27 -0500 you wrote:

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.

Changes in v6:
- update the fix tag hash and format

[...]

Here is the summary with links:
- [NET,v6,1/2] net: phylink: add mac_managed_pm in phylink_config structure

    https://git.kernel.org/netdev/net/c/96de900ae78e
  - [NET,v6,2/2] net: stmmac: Enable mac_managed_pm phylink config
    https://git.kernel.org/netdev/net/c/f151c147b3af

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html