OSDN Git Service

net: phy: avoid suspending twice a PHY
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 27 Jan 2015 06:05:40 +0000 (22:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Jan 2015 08:16:51 +0000 (00:16 -0800)
commit803dd9c77ac3a08958535f2a1ad5890104e2c235
treeddf90b1789e8a24547a0bf6786274df77eebd330
parent8a477a6fb6a33651adda772360b85fd813569743
net: phy: avoid suspending twice a PHY

As part of a call to ndo_close() a netdevice driver may call
phy_disconnect() -> phy_detach() -> phy_suspend(), such that the PHY is
suspsended at this point and a netdevice driver may clock gate the
backing peripheral providing MDIO bus accessses as well.

Update mdio_bus_phy_may_suspend() to return whether a PHY is allowed to
be suspended and conversely resumed if and only if it was not previously
suspended before while it is currently in detached (netdev pointer is
NULL) state.

This fixes bus errors seen during S2/S3 suspend/resume cycles for
netdevice drivers such as GENET which clock gates the entire Ethernet
MAC, including the MDIO bus block.

Acked-by: Fugang Duan <B38611@freescale.com>
Tested-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio_bus.c