net: phylink: add phylink_set_mac_pm() helper
Subsystems (5)
PATCH v3 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 v3:
- update the API description according to Russell's feedback.
Changes in v2:
- add the API description
- remove the unneccesary ASSERT_RTNL();
drivers/net/phy/phylink.c | 18 ++++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 19 insertions(+)
drivers/net/phy/phylink.c +18 -0
@@ -1722,6 +1722,24 @@ 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 end of net_device_ops ndo_open() method +* or any place after phy is connected. +*/ +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
Quoted 5 lines · Shenwei Wang
The recent commit
'commit
47ac7b2f6a1f("net: phy: Warn about incorrectmdio_bus_phy_resume()state")'
Quoted 8 lines
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.
Signed-off-by Shenwei Wang <[email protected]>
This is fine and needed, but first net-next tree is currently closed, and second, you need to submit the user of that helper function in the same patch series.
Signature · 1 line
Florian
Quoted 24 lines
-----Original Message-----
From: Florian Fainelli <[email protected]>
Sent: Friday, October 7, 2022 4:26 PM
To: Shenwei Wang <[email protected]>; Russell King <[email protected]>; Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>
Cc: [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v3 1/1] net: phylink: addphylink_set_mac_pm()helperCaution: EXT Email
Quoted 8 lines · Shenwei Wang
The recent commit
'commit
47ac7b2f6a1f("net: phy: Warn about incorrectmdio_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.
Quoted 7 lines
Quoted 4 lines
Add a helper to let the MAC driver has a way to tell the PHY driver it will manage the PM.
Signed-off-by Shenwei Wang <[email protected]>This is fine and needed, but first net-next tree is currently closed, and second, you need to submit the user of that helper function in the same patch series.
Thank you for the review. When should I repost the patches?
Regards,
Shenwei
Quoted 2 lines
--
Florian
Russell King (Oracle)
maintainerQuoted 10 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 the end ofnet_device_opsndo_open()method
+ * or any place after phy is connected.
May I suggest a different wording:
"If the driver wishes to use this feature, this function should be called each time after the driver connects a PHY with phylink."
This makes it clear that after one of:
phylink_connect_phy()phylink_of_phy_connect()phylink_fwnode_phy_connect()
has been called, and the driver wants to call this function, the driver needs to call this every time just after the driver connects a PHY.
The alternative is that we store this information away when this function is called, and always update the phydev when one is connected.
There is also the question whether this should also be applied to PHYs on SFP modules or not. Should a network driver using mac managed PM, but also supports SFPs, and a copper SFP is plugged in with an accessible PHY, what should happen if the system goes into a low power state?
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!
Quoted 31 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, October 8, 2022 2:28 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v3 1/1] net: phylink: addphylink_set_mac_pm()helperCaution: EXT Email
drivers/net/phy/phylink.c void phylink_stop(struct phylink *pl) · line 1734
Quoted 13 lines · Shenwei Wang
drivers/net/phy/phylink.c +13
-0+/** +* 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 end of net_device_ops ndo_open() +method +* or any place after phy is connected. May I suggest a different wording:
Quoted 3 lines
"If the driver wishes to use this feature, this function should be called each time after the driver connects a PHY with phylink."
Your wording is much better. Will use it in the next version.
Quoted 9 lines
This makes it clear that after one of:
phylink_connect_phy()phylink_of_phy_connect()phylink_fwnode_phy_connect()has been called, and the driver wants to call this function, the driver needs to call this every time just after the driver connects a PHY.
Quoted 8 lines
The alternative is that we store this information away when this function is called, and always update the phydev when one is connected.
There is also the question whether this should also be applied to PHYs on SFP modules or not. Should a network driver using mac managed PM, but also supports SFPs, and a copper SFP is plugged in with an accessible PHY, what should happen if the system goes into a low power state?
In theory, the SFP should be covered by this patch too. Since the resume flow is Controlled by the value of phydev->mac_managed_pm, it should work in the same way after the phydev is linked to the SFP phy instance.
Regards,
Shenwei
Quoted 10 lines
--
RMK's Patch system:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar
mlinux.org.uk%2Fdeveloper%2Fpatches%2F&data=05%7C01%7Cshenwei. wang%40nxp.com%7Cedf38f379deb4eda9ccb08daa8fe995a%7C686ea1d3bc2b 4c6fa92cd99c5c301635%7C0%7C0%7C638008108695053955%7CUnknown%7C TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX VCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DiHVcXkqri4qtbsp7BwR6kPhW GqLzr%2BVf4tj9JXPzoQ%3D&reserved=0
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Russell King (Oracle)
maintainerQuoted 53 lines · Shenwei Wang
Quoted 29 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Saturday, October 8, 2022 2:28 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v3 1/1] net: phylink: addphylink_set_mac_pm()helperCaution: EXT Email
drivers/net/phy/phylink.c void phylink_stop(struct phylink *pl) · line 1734
Quoted 13 lines · Shenwei Wang
drivers/net/phy/phylink.c +13
-0+/** +* 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 end of net_device_ops ndo_open() +method +* or any place after phy is connected. May I suggest a different wording:
Quoted 3 lines
"If the driver wishes to use this feature, this function should be called each time after the driver connects a PHY with phylink."
Your wording is much better. Will use it in the next version.
Quoted 9 lines
This makes it clear that after one of:
phylink_connect_phy()phylink_of_phy_connect()phylink_fwnode_phy_connect()has been called, and the driver wants to call this function, the driver needs to call this every time just after the driver connects a PHY.
Quoted 8 lines
The alternative is that we store this information away when this function is called, and always update the phydev when one is connected.
There is also the question whether this should also be applied to PHYs on SFP modules or not. Should a network driver using mac managed PM, but also supports SFPs, and a copper SFP is plugged in with an accessible PHY, what should happen if the system goes into a low power state?
Quoted 3 lines
In theory, the SFP should be covered by this patch too. Since the resume flow is Controlled by the value of
phydev->mac_managed_pm, it should work in the same way after the phydev is linked to the SFP phy instance.
It won't, because the MAC doesn't know when it needs to call your new function.
Given this, I think a different approach is needed here:
1) require a MAC to call this function after phylink_create() and record the configuration in struct phylink, or put a configuration boolean in the phylink_config structure (probably better).
2) whenever any PHY is attached, check the status of this feature, and pass the configuration on to phylib.
That means MACs don't have to keep calling the function - they declare early on whether they will be using MAC managed PM or not and then they're done with that. Keeps it simple.
Russell.
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!
Quoted 16 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, October 10, 2022 10:23 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric DumazetQuoted 1 line
Quoted 1 line
with an accessible PHY, what should happen if the system goes into a low
power state?
Quoted 5 lines
Quoted 1 line
In theory, the SFP should be covered by this patch too. Since the resume flow is Controlled by the value of
phydev->mac_managed_pm, it should work in the same way after the phydev is linked to the SFP phy instance.
Quoted 8 lines
It won't, because the MAC doesn't know when it needs to call your new function.
Given this, I think a different approach is needed here:
1) require a MAC to call this function after
phylink_create()and record the configuration in struct phylink, or put a configuration boolean in thephylink_configstructure (probably better).
I prefer to use the function call because it is simple to implement and is easy to use.
Quoted 7 lines
2) whenever any PHY is attached, check the status of this feature, and pass the configuration on to phylib.
That means MACs don't have to keep calling the function - they declare early on whether they will be using MAC managed PM or not and then they're done with that. Keeps it simple.
Agree. Let me implement this idea in the next version.
Thanks,
Shenwei
Quoted 12 lines
Russell.
--
RMK's Patch system:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar
mlinux.org.uk%2Fdeveloper%2Fpatches%2F&data=05%7C01%7Cshenwei. wang%40nxp.com%7C2d5aa021cfa74162a1e008daaad350cc%7C686ea1d3bc2b 4c6fa92cd99c5c301635%7C0%7C0%7C638010121814590052%7CUnknown%7C TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX VCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vEHqzO3CSdtvSuaW80%2FaBK sDp895q7leiz1w%2BZNmGCU%3D&reserved=0
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Russell King (Oracle)
maintainerQuoted 18 lines · Shenwei Wang
Quoted 18 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, October 10, 2022 10:23 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric DumazetQuoted 1 line
Quoted 1 line
with an accessible PHY, what should happen if the system goes into a low
power state?
Quoted 5 lines
Quoted 1 line
In theory, the SFP should be covered by this patch too. Since the resume flow is Controlled by the value of
phydev->mac_managed_pm, it should work in the same way after the phydev is linked to the SFP phy instance.It won't, because the MAC doesn't know when it needs to call your new function.
Quoted 8 lines
Quoted 6 lines
Given this, I think a different approach is needed here:
1) require a MAC to call this function after
phylink_create()and record the configuration in struct phylink, or put a configuration boolean in thephylink_configstructure (probably better).I prefer to use the function call because it is simple to implement and is easy to use.
blah->phylink_config.mac_managed_pm = true;
in the appropriate drivers before they call phylink_create() would be difficult to use?
Given that we use this method to configure the MAC speeds and phy interface modes already, I'm not sure why we'd want some other approach for 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!
Quoted 48 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, October 10, 2022 11:22 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v3 1/1] net: phylink: addphylink_set_mac_pm()helperCaution: EXT Email
Quoted 9 lines · Shenwei Wang
Quoted 9 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: Monday, October 10, 2022 10:23 AM
To: Shenwei Wang <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; David S. Miller <[email protected]>; Eric DumazetQuoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
with an accessible PHY, what should happen if the system goes into a low
power state?
Quoted 5 lines
Quoted 1 line
In theory, the SFP should be covered by this patch too. Since the resume flow is Controlled by the value of
phydev->mac_managed_pm, it should work in the same way after the phydev is linked to the SFP phyinstance.
Quoted 2 lines
Quoted 2 lines
It won't, because the MAC doesn't know when it needs to call your new
function.
Quoted 9 lines
Quoted 7 lines
Given this, I think a different approach is needed here:
1) require a MAC to call this function after
phylink_create()and record the configuration in struct phylink, or put a configuration boolean in thephylink_configstructure (probably better).I prefer to use the function call because it is simple to implement and is easy to
use.
Quoted 8 lines
blah->phylink_config.mac_managed_pm = true;in the appropriate drivers before they call
phylink_create()would be difficult to use?Given that we use this method to configure the MAC speeds and phy interface modes already, I'm not sure why we'd want some other approach for this.
Okay. Let's go in the config direction.
Regards,
Shenwei
Quoted 10 lines
--
RMK's Patch system:
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ar
mlinux.org.uk%2Fdeveloper%2Fpatches%2F&data=05%7C01%7Cshenwei. wang%40nxp.com%7C82e5e5068b23483f015008daaadb86de%7C686ea1d3bc2 b4c6fa92cd99c5c301635%7C0%7C0%7C638010157080134477%7CUnknown%7 CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ XVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rpoL9UwtjVEQp2lWkm%2FVj kp99Romx%2BARfj%2FFmdpsO%2BY%3D&reserved=0
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!