3
0
Fork 0
forked from mirrors/linux
kernel/drivers/net/ethernet/intel/igc
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
..
igc.h igc: add lock preventing multiple simultaneous PTM transactions 2025-04-11 09:13:28 -07:00
igc_base.c igc: return early when failing to read EECD register 2025-01-07 09:01:15 -08:00
igc_base.h
igc_defines.h igc: increase wait time before retrying PTM 2025-04-11 09:13:28 -07:00
igc_diag.c igc: remove autoneg parameter from igc_mac_info 2024-11-13 10:30:21 -08:00
igc_diag.h
igc_dump.c
igc_ethtool.c igc: remove autoneg parameter from igc_mac_info 2024-11-13 10:30:21 -08:00
igc_hw.h igc: Remove unused igc_read/write_pcie_cap_reg 2025-01-06 13:32:44 -08:00
igc_i225.c
igc_i225.h
igc_leds.c igc: Fix LED-related deadlock on driver unbind 2024-04-24 20:09:30 -07:00
igc_mac.c igc: remove autoneg parameter from igc_mac_info 2024-11-13 10:30:21 -08:00
igc_mac.h
igc_main.c igc: cleanup PTP module if probe fails 2025-04-11 09:13:28 -07:00
igc_nvm.c igc: Remove unused igc_acquire/release_nvm 2025-01-06 13:32:44 -08:00
igc_nvm.h igc: Remove unused igc_acquire/release_nvm 2025-01-06 13:32:44 -08:00
igc_phy.c igc: remove autoneg parameter from igc_mac_info 2024-11-13 10:30:21 -08:00
igc_phy.h
igc_ptp.c igc: fix lock order in igc_ptp_reset 2025-04-29 14:28:40 -07:00
igc_regs.h igc: Move the MULTI GBT AN Control Register to _regs file 2024-08-30 07:44:39 -07:00
igc_tsn.c igc: Add MQPRIO offload support 2024-08-30 07:33:46 -07:00
igc_tsn.h igc: Fix qbv_config_change_errors logics 2024-08-07 13:30:23 -07:00
igc_xdp.c igc: Fix XSK queue NAPI ID mapping 2025-04-02 08:51:41 -07:00
igc_xdp.h
Makefile net: intel: Use *-y instead of *-objs in Makefile 2024-06-10 19:52:44 -07:00