diff mbox series

[1/1] net: phylink: add phylink_set_mac_pm() helper

Message ID 20221006170237.784639-1-shenwei.wang@nxp.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/1] net: phylink: add phylink_set_mac_pm() helper | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 95 this patch: 95
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 17 this patch: 17
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 95 this patch: 95
netdev/checkpatch warning WARNING: Unknown commit id '47ac7b2f6a1f', maybe rebased or not pulled?
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Shenwei Wang Oct. 6, 2022, 5:02 p.m. UTC
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.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
 drivers/net/phy/phylink.c | 9 +++++++++
 include/linux/phylink.h   | 1 +
 2 files changed, 10 insertions(+)

Comments

Russell King (Oracle) Oct. 6, 2022, 7:24 p.m. UTC | #1
On Thu, Oct 06, 2022 at 12:02:37PM -0500, Shenwei Wang wrote:
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index e9d62f9598f9..a741c4bb5dd5 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1722,6 +1722,15 @@ void phylink_stop(struct phylink *pl)
>  }
>  EXPORT_SYMBOL_GPL(phylink_stop);
>  
> +void phylink_set_mac_pm(struct phylink *pl)

This needs documenting. The documentation for the function needs to
mention when this should be called - so users are guided towards
calling it at the right place in their drivers, rather than leaving
them trying to figure it out and possibly get it wrong.

Thanks.
Shenwei Wang Oct. 6, 2022, 8:24 p.m. UTC | #2
> -----Original Message-----
> From: Russell King <linux@armlinux.org.uk>
> Sent: Thursday, October 6, 2022 2:24 PM
> To: Shenwei Wang <shenwei.wang@nxp.com>
> Cc: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit <hkallweit1@gmail.com>;
> David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; netdev@vger.kernel.org; imx@lists.linux.dev
> Subject: [EXT] Re: [PATCH 1/1] net: phylink: add phylink_set_mac_pm() helper
> 
> Caution: EXT Email
> 
> On Thu, Oct 06, 2022 at 12:02:37PM -0500, Shenwei Wang wrote:
> > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> > index e9d62f9598f9..a741c4bb5dd5 100644
> > --- a/drivers/net/phy/phylink.c
> > +++ b/drivers/net/phy/phylink.c
> > @@ -1722,6 +1722,15 @@ void phylink_stop(struct phylink *pl)  }
> > EXPORT_SYMBOL_GPL(phylink_stop);
> >
> > +void phylink_set_mac_pm(struct phylink *pl)
> 
> This needs documenting. The documentation for the function needs to mention
> when this should be called - so users are guided towards calling it at the right
> place in their drivers, rather than leaving them trying to figure it out and possibly
> get it wrong.
> 

Thanks very much for the review. Will add it in the patch V2.

Thanks,
Shenwei

> Thanks.
> 
> --
> 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%7C817e10680d6345ce150908daa7d05d51%7C686ea1d3bc2
> b4c6fa92cd99c5c301635%7C0%7C0%7C638006810614113624%7CUnknown%7
> CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
> XVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=dRZOuDK5vKRHYZomgVbJLPu
> Adg13bxe3QGyPZyRWwwQ%3D&amp;reserved=0
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e9d62f9598f9..a741c4bb5dd5 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1722,6 +1722,15 @@  void phylink_stop(struct phylink *pl)
 }
 EXPORT_SYMBOL_GPL(phylink_stop);
 
+void phylink_set_mac_pm(struct phylink *pl)
+{
+	ASSERT_RTNL();
+
+	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()
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 6d06896fc20d..cfcc680462b9 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -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);