Revision 1758bde2e4aa5ff188d53e7d9d388bbb7e12eebb authored by Lukas Wunner on 28 June 2022, 10:15:08 UTC, committed by Jakub Kicinski on 30 June 2022, 03:38:52 UTC
Upon system sleep, mdio_bus_phy_suspend() stops the phy_state_machine(),
but subsequent interrupts may retrigger it:

They may have been left enabled to facilitate wakeup and are not
quiesced until the ->suspend_noirq() phase.  Unwanted interrupts may
hence occur between mdio_bus_phy_suspend() and dpm_suspend_noirq(),
as well as between dpm_resume_noirq() and mdio_bus_phy_resume().

Retriggering the phy_state_machine() through an interrupt is not only
undesirable for the reason given in mdio_bus_phy_suspend() (freezing it
midway with phydev->lock held), but also because the PHY may be
inaccessible after it's suspended:  Accesses to USB-attached PHYs are
blocked once usb_suspend_both() clears the can_submit flag and PHYs on
PCI network cards may become inaccessible upon suspend as well.

Amend phy_interrupt() to avoid triggering the state machine if the PHY
is suspended.  Signal wakeup instead if the attached net_device or its
parent has been configured as a wakeup source.  (Those conditions are
identical to mdio_bus_phy_may_suspend().)  Postpone handling of the
interrupt until the PHY has resumed.

Before stopping the phy_state_machine() in mdio_bus_phy_suspend(),
wait for a concurrent phy_interrupt() to run to completion.  That is
necessary because phy_interrupt() may have checked the PHY's suspend
status before the system sleep transition commenced and it may thus
retrigger the state machine after it was stopped.

Likewise, after re-enabling interrupt handling in mdio_bus_phy_resume(),
wait for a concurrent phy_interrupt() to complete to ensure that
interrupts which it postponed are properly rerun.

The issue was exposed by commit 1ce8b37241ed ("usbnet: smsc95xx: Forward
PHY interrupts to PHY driver to avoid polling"), but has existed since
forever.

Fixes: 541cd3ee00a4 ("phylib: Fix deadlock on resume")
Link: https://lore.kernel.org/netdev/a5315a8a-32c2-962f-f696-de9a26d30091@samsung.com/
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: stable@vger.kernel.org # v2.6.33+
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/b7f386d04e9b5b0e2738f0125743e30676f309ef.1656410895.git.lukas@wunner.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e65af54
History
File Mode Size
Kconfig -rw-r--r-- 8.0 KB
Makefile -rw-r--r-- 1.9 KB
at91_cf.c -rw-r--r-- 10.1 KB
bcm63xx_pcmcia.c -rw-r--r-- 13.3 KB
bcm63xx_pcmcia.h -rw-r--r-- 1.3 KB
cardbus.c -rw-r--r-- 2.8 KB
cirrus.h -rw-r--r-- 5.0 KB
cistpl.c -rw-r--r-- 35.1 KB
cs.c -rw-r--r-- 21.5 KB
cs_internal.h -rw-r--r-- 5.0 KB
db1xxx_ss.c -rw-r--r-- 15.5 KB
ds.c -rw-r--r-- 34.8 KB
electra_cf.c -rw-r--r-- 7.7 KB
i82092.c -rw-r--r-- 15.2 KB
i82092aa.h -rw-r--r-- 804 bytes
i82365.c -rw-r--r-- 37.1 KB
i82365.h -rw-r--r-- 4.9 KB
max1600.c -rw-r--r-- 2.8 KB
max1600.h -rw-r--r-- 577 bytes
o2micro.h -rw-r--r-- 5.9 KB
omap_cf.c -rw-r--r-- 7.9 KB
pcmcia_cis.c -rw-r--r-- 12.7 KB
pcmcia_resource.c -rw-r--r-- 24.1 KB
pd6729.c -rw-r--r-- 18.3 KB
pd6729.h -rw-r--r-- 609 bytes
pxa2xx_base.c -rw-r--r-- 9.9 KB
pxa2xx_base.h -rw-r--r-- 202 bytes
pxa2xx_mainstone.c -rw-r--r-- 3.0 KB
pxa2xx_sharpsl.c -rw-r--r-- 6.9 KB
ricoh.h -rw-r--r-- 7.6 KB
rsrc_iodyn.c -rw-r--r-- 3.6 KB
rsrc_mgr.c -rw-r--r-- 1.5 KB
rsrc_nonstatic.c -rw-r--r-- 29.5 KB
sa1100_generic.c -rw-r--r-- 5.9 KB
sa1100_generic.h -rw-r--r-- 890 bytes
sa1100_h3600.c -rw-r--r-- 3.9 KB
sa1100_simpad.c -rw-r--r-- 2.4 KB
sa1111_badge4.c -rw-r--r-- 3.7 KB
sa1111_generic.c -rw-r--r-- 6.7 KB
sa1111_generic.h -rw-r--r-- 880 bytes
sa1111_jornada720.c -rw-r--r-- 3.0 KB
sa1111_lubbock.c -rw-r--r-- 3.4 KB
sa1111_neponset.c -rw-r--r-- 2.0 KB
sa11xx_base.c -rw-r--r-- 7.3 KB
sa11xx_base.h -rw-r--r-- 4.7 KB
soc_common.c -rw-r--r-- 23.2 KB
soc_common.h -rw-r--r-- 3.1 KB
socket_sysfs.c -rw-r--r-- 5.6 KB
tcic.c -rw-r--r-- 23.4 KB
tcic.h -rw-r--r-- 8.0 KB
ti113x.h -rw-r--r-- 27.6 KB
topic.h -rw-r--r-- 5.9 KB
vg468.h -rw-r--r-- 4.1 KB
vrc4171_card.c -rw-r--r-- 17.1 KB
xxs1500_ss.c -rw-r--r-- 7.8 KB
yenta_socket.c -rw-r--r-- 39.2 KB
yenta_socket.h -rw-r--r-- 4.8 KB

back to top