]> git.baikalelectronics.ru Git - kernel.git/commit
net: phy: Warn about incorrect mdio_bus_phy_resume() state
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 1 Aug 2022 23:34:03 +0000 (16:34 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Aug 2022 02:20:41 +0000 (19:20 -0700)
commit4faafe4a276b04a4b0e3e1b3dba3fe3854a20f2f
tree71a5858c1bed8f900892bb128578622b6ae4962a
parent29117924047032ef2294a8b1aa966f620385e472
net: phy: Warn about incorrect mdio_bus_phy_resume() state

Calling mdio_bus_phy_resume() with neither the PHY state machine set to
PHY_HALTED nor phydev->mac_managed_pm set to true is a good indication
that we can produce a race condition looking like this:

CPU0 CPU1
bcmgenet_resume
 -> phy_resume
   -> phy_init_hw
 -> phy_start
   -> phy_resume
                                                phy_start_aneg()
mdio_bus_phy_resume
 -> phy_resume
    -> phy_write(..., BMCR_RESET)
     -> usleep()                                  -> phy_read()

with the phy_resume() function triggering a PHY behavior that might have
to be worked around with (see c83fad30555a ("net: phy: broadcom: Fix
brcm_fet_config_init()") for instance) that ultimately leads to an error
reading from the PHY.

Fixes: 1b003f68755c ("net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220801233403.258871-1-f.fainelli@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phy_device.c