> -----Original Message----- > From: Jacob Keller <[email protected]> > Sent: Thursday, November 19, 2026 1:31 AM > To: Intel Wired LAN <[email protected]>; Nguyen, Anthony > L <[email protected]>; Kitszel, Przemyslaw > <[email protected]>; Korba, Przemyslaw > <[email protected]>; Nitka, Grzegorz > <[email protected]>; Temerkhanov, Sergey > <[email protected]>; Machnikowski, Maciej > <[email protected]>; Kubalewski, Arkadiusz > <[email protected]>; Keller, Jacob E > <[email protected]> > Subject: [PATCH iwl-next v4 2/4] ice: exit PTP callbacks early if not > ICE_PTP_READY > > Add a check for the PTP state at the start of ice_ptp_settime64(), > ice_ptp_adjtime(), ice_ptp_adjfine(), and ice_ptp_gpio_enable(). If the > driver PTP state is not ICE_PTP_READY, exit with -EIO instead of > continuing to try to modify the clock while the driver may still be > loading, resetting, unloading, or after a failed rebuild. > > The check is currently best effort and doesn't guarantee to prevent a > race between the start of a new command and a reset. For that, we will > need more time to investigate and develop a proper synchronization > mechanism. > > The ice_ptp_gpio_enable() still allows requests to disable the pins. > This is intentional as it will be called by ptp_clock_unregister() when > tearing down. Additionally, the core PTP code often ignores the return > value of > ptp_disable_pinfunc() anyways. Allowing disables through ensures the > internal driver state matches, while new enable requests are blocked > until the driver is ready. > > Signed-off-by: Jacob Keller <[email protected]> > --- > drivers/net/ethernet/intel/ice/ice_ptp.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c > b/drivers/net/ethernet/intel/ice/ice_ptp.c > index 2b8b6f2a7ef8..777db22a7c24 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c > @@ -1612,6 +1612,9 @@ static int ice_ptp_adjfine(struct ptp_clock_info > *info, long scaled_ppm) > u64 incval; > int err; > > + if (pf->ptp.state != ICE_PTP_READY) > + return -EIO; > + > incval = adjust_by_scaled_ppm(ice_base_incval(pf), scaled_ppm); > err = ice_ptp_write_incval_locked(hw, incval); > if (err) { > @@ -2002,6 +2005,9 @@ static int ice_ptp_gpio_enable(struct > ptp_clock_info *info, > struct ptp_perout_request *cached = > &pf->ptp.perout_rqs[rq->perout.index]; > > + if (on && pf->ptp.state != ICE_PTP_READY) > + return -EIO; > + > err = ice_ptp_cfg_perout(pf, &rq->perout, on); > if (!err) { > *cached = rq->perout; > @@ -2016,6 +2022,9 @@ static int ice_ptp_gpio_enable(struct > ptp_clock_info *info, > struct ptp_extts_request *cached = > &pf->ptp.extts_rqs[rq->extts.index]; > > + if (on && pf->ptp.state != ICE_PTP_READY) > + return -EIO; > + > err = ice_ptp_cfg_extts(pf, &rq->extts, on); > if (!err) > *cached = rq->extts; > @@ -2070,6 +2079,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, > const struct timespec64 *ts) > struct ice_hw *hw = &pf->hw; > int err; > > + if (pf->ptp.state != ICE_PTP_READY) > + return -EIO; > + > /* For Vernier mode on E82X, we need to recalibrate after new > settime. > * Start with marking timestamps as invalid. > */ > @@ -2139,6 +2151,9 @@ static int ice_ptp_adjtime(struct ptp_clock_info > *info, s64 delta) > struct device *dev; > int err; > > + if (pf->ptp.state != ICE_PTP_READY) > + return -EIO; > + > dev = ice_pf_to_dev(pf); > > /* Hardware only supports atomic adjustments using signed 32-bit > > -- > 2.56.0.215.g47fdf2208c5b
Reviewed-by: Aleksandr Loktionov <[email protected]>
