Commit c7d6cb9
igc: fix lock order in igc_ptp_reset
Commit 1a931c4 ("igc: add lock preventing multiple simultaneous PTM
transactions") added a new mutex to protect concurrent PTM transactions.
This lock is acquired in igc_ptp_reset() in order to ensure the PTM
registers are properly disabled after a device reset.
The flow where the lock is acquired already holds a spinlock, so acquiring
a mutex leads to a sleep-while-locking bug, reported both by smatch,
and the kernel test robot.
The critical section in igc_ptp_reset() does correctly use the
readx_poll_timeout_atomic variants, but the standard PTM flow uses regular
sleeping variants. This makes converting the mutex to a spinlock a bit
tricky.
Instead, re-order the locking in igc_ptp_reset. Acquire the mutex first,
and then the tmreg_lock spinlock. This is safe because there is no other
ordering dependency on these locks, as this is the only place where both
locks were acquired simultaneously. Indeed, any other flow acquiring locks
in that order would be wrong regardless.
Signed-off-by: Jacob Keller <[email protected]>
Fixes: 1a931c4 ("igc: add lock preventing multiple simultaneous PTM transactions")
Link: https://lore.kernel.org/intel-wired-lan/[email protected]/
Link: https://lore.kernel.org/intel-wired-lan/[email protected]/T/#u
Reviewed-by: Przemek Kitszel <[email protected]>
Reviewed-by: Vitaly Lifshits <[email protected]>
Tested-by: Mor Bar-Gabay <[email protected]>
Signed-off-by: Tony Nguyen <[email protected]>1 parent ed375b1 commit c7d6cb9
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1290 | 1290 | | |
1291 | 1291 | | |
1292 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
1293 | 1295 | | |
1294 | 1296 | | |
1295 | 1297 | | |
| |||
1308 | 1310 | | |
1309 | 1311 | | |
1310 | 1312 | | |
1311 | | - | |
1312 | 1313 | | |
1313 | 1314 | | |
1314 | 1315 | | |
| |||
1332 | 1333 | | |
1333 | 1334 | | |
1334 | 1335 | | |
1335 | | - | |
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
| |||
1349 | 1349 | | |
1350 | 1350 | | |
1351 | 1351 | | |
| 1352 | + | |
| 1353 | + | |
1352 | 1354 | | |
1353 | 1355 | | |
0 commit comments