diff mbox series

[v2] net: phy: Don't WARN for PHY_READY state in mdio_bus_phy_resume()

Message ID 20220819082451.1992102-1-xiaolei.wang@windriver.com (mailing list archive)
State Accepted
Commit 6dbe852c379ff032a70a6b13a91914918c82cb07
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: phy: Don't WARN for PHY_READY state in mdio_bus_phy_resume() | 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: 85 this patch: 85
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 85 this patch: 85
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

xiaolei wang Aug. 19, 2022, 8:24 a.m. UTC
For some MAC drivers, they set the mac_managed_pm to true in its
->ndo_open() callback. So before the mac_managed_pm is set to true,
we still want to leverage the mdio_bus_phy_suspend()/resume() for
the phy device suspend and resume. In this case, the phy device is
in PHY_READY, and we shouldn't warn about this. It also seems that
the check of mac_managed_pm in WARN_ON is redundant since we already
check this in the entry of mdio_bus_phy_resume(), so drop it.

Fixes: 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() state")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
 drivers/net/phy/phy_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Florian Fainelli Aug. 20, 2022, 2:57 a.m. UTC | #1
On 8/19/2022 1:24 AM, Xiaolei Wang wrote:
> For some MAC drivers, they set the mac_managed_pm to true in its
> ->ndo_open() callback. So before the mac_managed_pm is set to true,
> we still want to leverage the mdio_bus_phy_suspend()/resume() for
> the phy device suspend and resume. In this case, the phy device is
> in PHY_READY, and we shouldn't warn about this. It also seems that
> the check of mac_managed_pm in WARN_ON is redundant since we already
> check this in the entry of mdio_bus_phy_resume(), so drop it.
> 
> Fixes: 744d23c71af3 ("net: phy: Warn about incorrect mdio_bus_phy_resume() state")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

I see the use case you have and it does make sense to me, thanks!
patchwork-bot+netdevbpf@kernel.org Aug. 23, 2022, 1:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 19 Aug 2022 16:24:51 +0800 you wrote:
> For some MAC drivers, they set the mac_managed_pm to true in its
> ->ndo_open() callback. So before the mac_managed_pm is set to true,
> we still want to leverage the mdio_bus_phy_suspend()/resume() for
> the phy device suspend and resume. In this case, the phy device is
> in PHY_READY, and we shouldn't warn about this. It also seems that
> the check of mac_managed_pm in WARN_ON is redundant since we already
> check this in the entry of mdio_bus_phy_resume(), so drop it.
> 
> [...]

Here is the summary with links:
  - [v2] net: phy: Don't WARN for PHY_READY state in mdio_bus_phy_resume()
    https://git.kernel.org/netdev/net/c/6dbe852c379f

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0c6efd792690..12ff276b80ae 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -316,11 +316,11 @@  static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
 
 	phydev->suspended_by_mdio_bus = 0;
 
-	/* If we managed to get here with the PHY state machine in a state other
-	 * than PHY_HALTED this is an indication that something went wrong and
-	 * we should most likely be using MAC managed PM and we are not.
+	/* If we manged to get here with the PHY state machine in a state neither
+	 * PHY_HALTED nor PHY_READY this is an indication that something went wrong
+	 * and we should most likely be using MAC managed PM and we are not.
 	 */
-	WARN_ON(phydev->state != PHY_HALTED && !phydev->mac_managed_pm);
+	WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY);
 
 	ret = phy_init_hw(phydev);
 	if (ret < 0)