Commit a0e026e
net: phy: Fix deadlocking in phy_error() invocation
Since commit 91a7cda ("net: phy: Fix race condition on link status
change") all the phy_error() method invocations have been causing the
nested-mutex-lock deadlock because it's normally done in the PHY-driver
threaded IRQ handlers which since that change have been called with the
phydev->lock mutex held. Here is the calls thread:
IRQ: phy_interrupt()
+-> mutex_lock(&phydev->lock); <--------------------+
drv->handle_interrupt() | Deadlock due
+-> ERROR: phy_error() + to the nested
+-> phy_process_error() | mutex lock
+-> mutex_lock(&phydev->lock); <-+
phydev->state = PHY_ERROR;
mutex_unlock(&phydev->lock);
mutex_unlock(&phydev->lock);
The problem can be easily reproduced just by calling phy_error() from any
PHY-device threaded interrupt handler. Fix it by dropping the phydev->lock
mutex lock from the phy_process_error() method and printing a nasty error
message to the system log if the mutex isn't held in the caller execution
context.
Note for the fix to work correctly in the PHY-subsystem itself the
phydev->lock mutex locking must be added to the phy_error_precise()
function.
Link: https://lore.kernel.org/netdev/20230816180944.19262-1-fancer.lancer@gmail.com
Fixes: 91a7cda ("net: phy: Fix race condition on link status change")
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent db1a6ad commit a0e026e
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
1187 | | - | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1188 | 1191 | | |
1189 | | - | |
1190 | 1192 | | |
1191 | 1193 | | |
1192 | 1194 | | |
| |||
1195 | 1197 | | |
1196 | 1198 | | |
1197 | 1199 | | |
| 1200 | + | |
1198 | 1201 | | |
| 1202 | + | |
1199 | 1203 | | |
1200 | 1204 | | |
1201 | 1205 | | |
| |||
1204 | 1208 | | |
1205 | 1209 | | |
1206 | 1210 | | |
1207 | | - | |
1208 | | - | |
| 1211 | + | |
1209 | 1212 | | |
1210 | 1213 | | |
1211 | 1214 | | |
| |||
0 commit comments