From: Jacob Keller <jacob.e.keller@intel.com>
To: Jakub Kicinski <kuba@kernel.org>, <anthony.l.nguyen@intel.com>
Cc: <davem@davemloft.net>, <pabeni@redhat.com>, <edumazet@google.com>,
<andrew+netdev@lunn.ch>, <netdev@vger.kernel.org>,
<maciej.machnikowski@intel.com>, <przemyslaw.korba@intel.com>,
<grzegorz.nitka@intel.com>, <sergey.temerkhanov@intel.com>,
<arkadiusz.kubalewski@intel.com>, <poros@redhat.com>,
<richardcochran@gmail.com>, <horms@kernel.org>,
<pmenzel@molgen.mpg.de>, <aleksandr.loktionov@intel.com>,
<alexander.nowlin@intel.com>
Subject: Re: [PATCH net 15/15] ice: Recalibrate PHY after settime64 on E825-C
Date: Thu, 17 Sep 2026 11:02:40 -0700 [thread overview]
Message-ID: <cc8ab06b-ed9b-4ad6-a775-ace31e4e4545@intel.com> (raw)
In-Reply-To: <20260916011228.1632848-1-kuba@kernel.org>
On 9/15/2026 6:12 PM, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> ice: Recalibrate PHY after settime64 on E825-C
>
> The patch extends the post-settime PHY recalibration path in
> ice_ptp_settime64() so that it also runs for ICE_MAC_GENERIC_3K_E825,
> not only for ICE_MAC_GENERIC (E822/E823). The stated motivation is that
> the E825-C PHY needs recalibration after large system time jumps,
> otherwise PHY timestamps read back incorrectly.
>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> index 832cc6ad2f90c..a5efb0a95941e 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> @@ -2020,8 +2020,9 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
>> /* Reenable periodic outputs */
>> ice_ptp_enable_all_perout(pf);
>>
>> - /* Recalibrate and re-enable timestamp blocks for E822/E823 */
>> - if (hw->mac_type == ICE_MAC_GENERIC)
>> + /* Recalibrate and re-enable timestamp blocks for E822/E823/E825-C */
>> + if (hw->mac_type == ICE_MAC_GENERIC ||
>> + hw->mac_type == ICE_MAC_GENERIC_3K_E825)
>> ice_ptp_restart_all_phy(pf);
>
> [Severity: High]
>
> The E82X sequence has two halves: timestamps are invalidated before the
> time is written, and the PHY is recalibrated afterwards. Only the second
> half is being extended to E825-C here. Earlier in ice_ptp_settime64() the
> invalidation is still E82X only:
>
> if (hw->mac_type == ICE_MAC_GENERIC) {
> err = ice_ptp_clear_phy_offset_ready_e82x(hw);
> if (err)
> dev_warn(ice_pf_to_dev(pf), "Failed to mark timestamps as invalid before settime\n");
> }
>
> Should something equivalent run for ICE_MAC_GENERIC_3K_E825? There is no
> eth56g counterpart of ice_ptp_clear_phy_offset_ready_e82x() in the tree, and
> ice_stop_phy_timer_eth56g() clears only PHY_REG_RX_OFFSET_READY, so
> PHY_REG_TX_OFFSET_READY stays at 1 for the whole restart window while the
> PHY timer is being re-initialised.
>
Even if we call ice_ptp_clear_phy_offset_ready_e825/eth56g or whatever,
we actually found that to be problematic. We can't clear the offset
ready bit without causing other issues.
> Related to that, the ICE_MAC_GENERIC_3K_E825 branch of
> ice_ptp_port_phy_restart() does not quiesce the Tx tracker at all:
>
> case ICE_MAC_GENERIC_3K_E825:
> err = ice_start_phy_timer_eth56g(hw, port);
> break;
>
> whereas the ICE_MAC_GENERIC branch does:
>
> spin_lock_irqsave(&ptp_port->tx.lock, flags);
> ptp_port->tx.calibrating = true;
> spin_unlock_irqrestore(&ptp_port->tx.lock, flags);
>
> tx.calibrating is only ever set in that E82X branch and only ever cleared in
> ice_ptp_wait_for_offsets(), so on E825-C ice_ptp_is_tx_tracker_up() keeps
> returning true (link_up is true, which is why the port was picked in
> ice_ptp_restart_all_phy()):
Right. I believe we do actually need to hold calibrating over this path,
and we should do the same for settime.
>
> return tx->init && !tx->calibrating && ptp_port->link_up;
>
> Does that mean Tx timestamp requests keep being armed and reported while
> ice_start_phy_timer_eth56g() is soft-resetting the PTP block, reprogramming
> PHY_REG_TIMETUS/INCVAL and re-running ice_sync_phy_timer_eth56g()? The
> comment in the ICE_MAC_GENERIC branch describes that state as producing bad
> values:
>
> /* Do not clear calibrating flag here. Tx timestamps remain
> * disabled until ice_ptp_wait_for_offsets() has verified
> * that the Tx and Rx offset calibration has completed.
> * Clearing it here would allow Tx timestamps to be reported
> * before the PHY offset registers are configured, leading
> * to incorrect timestamp values.
> */
>
> One more effect of the same window: the call chain
> ice_start_phy_timer_eth56g() -> ice_ptp_phy_soft_reset_eth56g() ->
> ice_ptp_clear_tx_memory_status_eth56g() clears every hardware Tx timestamp
> entry:
>
> for (idx = 0; idx < INDEX_PER_PORT; idx++) {
> err = ice_clear_ptp_tstamp_eth56g(hw, port, idx);
>
> but the software tracker keeps its in_use bits and skbs, since nothing calls
> ice_ptp_mark_tx_tracker_stale() on this path. Can those already-outstanding
> requests then only complete via the 2 second timeout?
>
Effectively, yes. I think we can address this.
> [Severity: Medium]
>
> This is also the first E825-C path that can reach ice_ptp_port_phy_stop(),
> because ice_ptp_link_change() only calls ice_ptp_port_phy_restart() on a
> link-up transition for this MAC type:
>
> case ICE_MAC_GENERIC_3K_E825:
> if (linkup)
> ice_ptp_port_phy_restart(ptp_port);
> goto exit_kref_put;
>
> ice_ptp_port_phy_restart() tests link_up outside ps_lock:
>
> if (!ptp_port->link_up)
> return ice_ptp_port_phy_stop(ptp_port);
>
> mutex_lock(&ptp_port->ps_lock);
>
> and ice_ptp_link_change() stores that field with no lock held:
>
> /* Update cached link status for this port immediately */
> ptp_port->link_up = linkup;
>
> Can a link bounce concurrent with a settime invert the decision here?
>
> CPU0 (ice_ptp_settime64 -> ice_ptp_restart_all_phy)
> if (port->link_up) /* true */
> ice_ptp_port_phy_restart(port);
> -> !ptp_port->link_up /* link just went down */
> -> ice_ptp_port_phy_stop() /* waits on ps_lock */
>
> CPU1 (link comes back up)
> ice_ptp_link_change()
> ptp_port->link_up = true;
> ice_ptp_port_phy_restart()
> -> ice_start_phy_timer_eth56g() /* holds ps_lock, takes ms */
>
> CPU0 then acquires ps_lock and issues ice_stop_phy_timer_eth56g(hw, port,
> true), which does:
>
> err = ice_write_ptp_reg_eth56g(hw, port, PHY_REG_RX_OFFSET_READY, 0);
>
> Since the E825-C link handler only restarts on link-up, would this leave the
> port with the link up but Rx offsets marked not ready, with no recovery until
> the next link flap?
>
> The unlocked check itself predates this change on the E82x path, but the
> E825-C path that can now hit it is new here.
Right. I think we need to address this sequencing by holding the
ps_lock. For simplicity, I think we need to reduce to a single lock for
all ports as opposed to one per-port. You can't actually concurrently
execute port restarts anyways since a port re-sync requires the source
timer command register (which requires the PTP semaphore), and that
would overall simplify the locking to allow us to take the lock, do the
settime and then reset all ports. We might even be able to amortize the
restart procedure by restarting all ports concurrently that way (as a
future improvement).
I'll look into this and see how complicated a cleanup will be.
next prev parent reply other threads:[~2026-09-17 18:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 0:34 [PATCH net 00/15][pull request] ice: E82x: timestamp processing logic fixes Tony Nguyen
2026-09-11 0:34 ` [PATCH net 01/15] ice: use reference counting and RCU for PTP port access Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:13 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 02/15] ice: fix removal of PTP timestamp tracker during reset Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:19 ` Jacob Keller
2026-09-18 0:22 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 03/15] ice: set in_use only after preparing Tx timestamp index Tony Nguyen
2026-09-11 0:34 ` [PATCH net 04/15] ice: E822: keep Tx timestamps disabled during offset calibration Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:25 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 05/15] ice: E822: cancel offset verification work during reset preparation Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:31 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 06/15] ice: call PTP link change only from link events Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:37 ` Jacob Keller
2026-09-18 1:31 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 07/15] ice: E825: stop clearing PHY_REG_TX_OFFSET_READY Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:41 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 08/15] ice: E825: clear PHY_REG_TX_MEMORY_STATUS prior to soft reset Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:46 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 09/15] ice: E825: perform a soft reset when starting the PHY timer Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 16:58 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 10/15] ice: wait for in-flight Tx timestamps before flushing the tracker Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 17:00 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 11/15] ice: keep Tx timestamp slots tracked until completion or timeout Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 17:47 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 12/15] ice: remove unnecessary discarding of timestamps after clock adjust Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 17:53 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 13/15] ice: skip reading Tx ready bitmap on ports with no timestamps Tony Nguyen
2026-09-11 0:34 ` [PATCH net 14/15] ice: don't clear in_use until HW clears ready bitmap Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 17:56 ` Jacob Keller
2026-09-11 0:34 ` [PATCH net 15/15] ice: Recalibrate PHY after settime64 on E825-C Tony Nguyen
2026-09-16 1:12 ` Jakub Kicinski
2026-09-17 18:02 ` Jacob Keller [this message]
2026-09-16 21:46 ` [PATCH net 00/15][pull request] ice: E82x: timestamp processing logic fixes Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc8ab06b-ed9b-4ad6-a775-ace31e4e4545@intel.com \
--to=jacob.e.keller@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=alexander.nowlin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=grzegorz.nitka@intel.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=maciej.machnikowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmenzel@molgen.mpg.de \
--cc=poros@redhat.com \
--cc=przemyslaw.korba@intel.com \
--cc=richardcochran@gmail.com \
--cc=sergey.temerkhanov@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox