linux/drivers/net/ethernet/intel
Jacob Keller c7d6cb96d5 igc: fix lock order in igc_ptp_reset
Commit 1a931c4f5e ("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 <jacob.e.keller@intel.com>
Fixes: 1a931c4f5e ("igc: add lock preventing multiple simultaneous PTM transactions")
Link: https://lore.kernel.org/intel-wired-lan/Z_-P-Hc1yxcw0lTB@stanley.mountain/
Link: https://lore.kernel.org/intel-wired-lan/202504211511.f7738f5d-lkp@intel.com/T/#u
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Vitaly Lifshits <vitaly.lifshits@intel.com>
Tested-by: Mor Bar-Gabay <morx.bar.gabay@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2025-04-29 14:28:40 -07:00
..
e1000 e1000: Hold RTNL when e1000_down can be called 2024-11-13 10:30:21 -08:00
e1000e treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
fm10k treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
i40e treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
iavf net: move misc netdev_lock flavors to a separate header 2025-03-08 09:06:50 -08:00
ice ice: Check VF VSI Pointer Value in ice_vc_add_fdir_fltr() 2025-04-28 15:59:13 -07:00
idpf idpf: protect shutdown from reset 2025-04-29 14:28:40 -07:00
igb treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
igbvf treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
igc igc: fix lock order in igc_ptp_reset 2025-04-29 14:28:40 -07:00
ixgbe treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
ixgbevf treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
libeth module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
libie module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
Kconfig iavf: add initial framework for registering PTP clock 2025-02-14 10:58:07 -08:00
Makefile net: intel: introduce {, Intel} Ethernet common library 2024-04-24 11:06:25 -07:00
e100.c treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00