[Intel-wired-lan] [PATCH iwl-net v2 5/5] i40e: fix races in PTP external timestamp work handling

Nowlin, Alexander alexander.nowlin at intel.com
Wed Sep 30 01:18:09 UTC 2026


> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces at osuosl.org> On Behalf Of xuanqiang.luo at linux.dev
> Sent: Tuesday, August 4, 2026 11:52 PM
> To: intel-wired-lan at lists.osuosl.org; horms at kernel.org
> Cc: vadim.fedorenko at linux.dev; Nguyen, Anthony L <anthony.l.nguyen at intel.com>; Kitszel, Przemyslaw <przemyslaw.kitszel at intel.com>; andrew+netdev at lunn.ch; davem at davemloft.net; edumazet at google.com; kuba at kernel.org; pabeni at redhat.com; richardcochran at gmail.com; Kwapulinski, Piotr <piotr.kwapulinski at intel.com>; Kubalewski, Arkadiusz <arkadiusz.kubalewski at intel.com>; Loktionov, Aleksandr <aleksandr.loktionov at intel.com>; netdev at vger.kernel.org; Xuanqiang Luo <luoxuanqiang at kylinos.cn>
> Subject: [Intel-wired-lan] [PATCH iwl-net v2 5/5] i40e: fix races in PTP external timestamp work handling
> 
> From: Xuanqiang Luo <luoxuanqiang at kylinos.cn>
> 
> The time sync interrupt queues ptp_extts0_work, which reads device registers and reports events through pf->ptp_clock. i40e_ptp_stop() unregisters the PHC before disabling the event source or draining the work. The worker can therefore use the clock or PF after either has been freed.
> 
> Move the event-source shutdown before PHC unregister. i40e_ptp_stop() first clears I40E_FLAG_PTP_ENA under ptp_config_lock, so timestamp configuration cannot re-enable the source after the lock is released.
> Then call disable_work_sync() to reject later queue attempts and drain work already pending or running.
> 
> INIT_WORK() is currently called from i40e_ptp_set_timestamp_mode(), which runs on reset and whenever timestamping is reconfigured. Reinitializing pending or running work can corrupt its workqueue state. > Initialize the work once from i40e_sw_init() instead.
> 
> Fixes: 1050713026a0 ("i40e: add support for PTP external synchronization clock")
> Signed-off-by: Xuanqiang Luo <luoxuanqiang at kylinos.cn>
> ---
>  drivers/net/ethernet/intel/i40e/i40e.h      |  1 +
>  drivers/net/ethernet/intel/i40e/i40e_main.c |  1 +  drivers/net/ethernet/intel/i40e/i40e_ptp.c  | 25 +++++++++++++++------
>  3 files changed, 20 insertions(+), 7 deletions(-)

Tested-by: Alexander Nowlin <alexander.nowlin at intel.com>


More information about the Intel-wired-lan mailing list