RE: [PATCH iwl-net 1/2] ice: ptp: serialize E825 PHY timer start with PTP lock and incval

From: Singh, Ayush1X

Date: Mon Nov 23 2026 - 02:12:12 EST


> -----Original Message-----
> From: Nitka, Grzegorz <grzegorz.nitka@xxxxxxxxx>
> Sent: 26 September 2026 03:58
> To: intel-wired-lan@xxxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; richardcochran@xxxxxxxxx; andrew+netdev@xxxxxxx; Kitszel, Przemyslaw <przemyslaw.kitszel@xxxxxxxxx>; Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kubalewski, Arkadiusz <arkadiusz.kubalewski@xxxxxxxxx>; davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; Machnikowski, Maciej <maciej.machnikowski@xxxxxxxxx>; Nitka, Grzegorz <grzegorz.nitka@xxxxxxxxx>; Neustadter, Marc <marc.neustadter@xxxxxxxxx>; Temerkhanov, Sergey <sergey.temerkhanov@xxxxxxxxx>; Olech, Milena <milena.olech@xxxxxxxxx>
> Subject: [PATCH iwl-net 1/2] ice: ptp: serialize E825 PHY timer start with PTP lock and incval
>
> From: Maciek Machnikowski <maciej.machnikowski@xxxxxxxxx>
>
> ice_start_phy_timer_eth56g() programmed the PHY increment value and performed the PHY-to-PHC phase synchronization in two separate PTP semaphore critical sections, and touched the shared source command register (GLTSYN_CMD via ice_ptp_src_cmd()) and read the source incval before acquiring the semaphore at all.
>
> Because GLTSYN_CMD is a single global register latched for the source timer and all PHY ports by GLTSYN_CMD_SYNC, a concurrent adjtime (small offset, <= S32_MAX) or adjfine could clobber the source command between the incval-init and the phase-sync steps. In the worst case the source timer command written by ice_ptp_adj_clock() (ICE_PTP_ADJ_TIME) was overwritten by the unlocked ICE_PTP_NOP from ice_start_phy_timer_eth56g(), so the adjustment was applied to the PHY ports but not to the PHC. This left the E825 PHY clock permanently offset from the PHC, showing up as an intermittent clock drift.
>
> Hold the PTP semaphore across the entire start sequence: acquire it before the first shared-register access (ice_ptp_src_cmd()), keep it held through the incval read, PHY incval init, and the phase synchronization, then release it once. Since the hardware semaphore is not recursive, split the phase-sync helper into ice_sync_phy_timer_eth56g_unlocked(), which assumes the caller already holds the lock, and call it directly from ice_start_phy_timer_eth56g(). The locking wrapper is removed as it no longer has any callers.
>
> Fixes: 781ff8f2d575 ("ice: ptp: serialize E825 PHY timer start with PTP lock")
> Signed-off-by: Maciek Machnikowski <maciej.machnikowski@xxxxxxxxx>
> Co-developed-by: Grzegorz Nitka <grzegorz.nitka@xxxxxxxxx>
> Signed-off-by: Grzegorz Nitka <grzegorz.nitka@xxxxxxxxx>
> Suggested-by: Marc Neustadter <marc.neustadter@xxxxxxxxx>
> Reviewed-by: Sergey Temerkhanov <sergey.temerkhanov@xxxxxxxxx>
> Reviewed-by: Milena Olech <milena.olech@xxxxxxxxx>
> ---
> drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 48 +++++++++------------
> 1 file changed, 21 insertions(+), 27 deletions(-)

Tested-by: Singh, Ayush1X < ayush1x.singh@xxxxxxxxx > (A Contingent worker at Intel)