netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC net-next 0/7] net: phy: avoid race when erroring stopping PHY
@ 2023-09-08 11:20 Russell King (Oracle)
  2023-09-08 11:20 ` [PATCH RFC net-next 1/7] net: phy: always call phy_process_state_change() under lock Russell King (Oracle)
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Russell King (Oracle) @ 2023-09-08 11:20 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: chenhao418, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Jijie Shao, lanhao, liuyonglong, netdev, Paolo Abeni, shenjian15,
	wangjie125, wangpeiyang1

This series addresses a problem reported by Jijie Shao where the PHY
state machine can race with phy_stop() leading to an incorrect state.

The issue centres around phy_state_machine() dropping the phydev->lock
mutex briefly, which allows phy_stop() to get in half-way through the
state machine, and when the state machine resumes, it overwrites
phydev->state with a value incompatible with a stopped PHY. This causes
a subsequent phy_start() to issue a warning.

We address this firstly by using versions of functions that do not take
tne lock, moving them into the locked region. The only function that
this can't be done with is phy_suspend() which needs to call into the
driver without taking the lock.

For phy_suspend(), we split the state machine into two parts - the
initial part which runs under the phydev->lock, and the second part
which runs without the lock.

We finish off by using the split state machine in phy_stop() which
removes another unnecessary unlock-lock sequence from phylib.

 drivers/net/phy/phy.c | 204 +++++++++++++++++++++++++++-----------------------
 1 file changed, 110 insertions(+), 94 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-12  6:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 11:20 [PATCH RFC net-next 0/7] net: phy: avoid race when erroring stopping PHY Russell King (Oracle)
2023-09-08 11:20 ` [PATCH RFC net-next 1/7] net: phy: always call phy_process_state_change() under lock Russell King (Oracle)
2023-09-08 11:20 ` [PATCH RFC net-next 2/7] net: phy: call phy_error_precise() while holding the lock Russell King (Oracle)
2023-09-08 11:20 ` [PATCH RFC net-next 3/7] net: phy: move call to start aneg Russell King (Oracle)
2023-09-08 11:21 ` [PATCH RFC net-next 4/7] net: phy: move phy_suspend() to end of phy_state_machine() Russell King (Oracle)
2023-09-08 11:21 ` [PATCH RFC net-next 5/7] net: phy: move phy_state_machine() Russell King (Oracle)
2023-09-08 11:21 ` [PATCH RFC net-next 6/7] net: phy: split locked and unlocked section of phy_state_machine() Russell King (Oracle)
2023-09-08 11:21 ` [PATCH RFC net-next 7/7] net: phy: convert phy_stop() to use split state machine Russell King (Oracle)
2023-09-11  8:54 ` [PATCH RFC net-next 0/7] net: phy: avoid race when erroring stopping PHY Russell King (Oracle)
2023-09-12  6:35   ` Jijie Shao

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).