From: Shenwei Wang <shenwei.wang@nxp.com>
To: Russell King <linux@armlinux.org.uk>,
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>
Cc: netdev@vger.kernel.org, imx@lists.linux.dev,
Shenwei Wang <shenwei.wang@nxp.com>
Subject: [PATCH v3 1/1] net: phylink: add phylink_set_mac_pm() helper
Date: Fri, 7 Oct 2022 10:42:46 -0500 [thread overview]
Message-ID: <20221007154246.838404-1-shenwei.wang@nxp.com> (raw)
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>
---
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(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e9d62f9598f9..e78d9aef7a7c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -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()
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);
--
2.34.1
next reply other threads:[~2022-10-07 15:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 15:42 Shenwei Wang [this message]
2022-10-07 21:25 ` [PATCH v3 1/1] net: phylink: add phylink_set_mac_pm() helper Florian Fainelli
2022-10-10 14:54 ` [EXT] " Shenwei Wang
2022-10-08 7:27 ` Russell King (Oracle)
2022-10-10 14:54 ` [EXT] " Shenwei Wang
2022-10-10 15:22 ` Russell King (Oracle)
2022-10-10 16:11 ` Shenwei Wang
2022-10-10 16:21 ` Russell King (Oracle)
2022-10-10 16:30 ` Shenwei Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221007154246.838404-1-shenwei.wang@nxp.com \
--to=shenwei.wang@nxp.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).