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 12/15] ice: remove unnecessary discarding of timestamps after clock adjust
Date: Thu, 17 Sep 2026 10:53:26 -0700 [thread overview]
Message-ID: <31a84ab2-a48a-430f-9322-78fdd35297f5@intel.com> (raw)
In-Reply-To: <20260916011225.1632772-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: remove unnecessary discarding of timestamps after clock adjust
>
> This drops the ice_ptp_mark_tx_tracker_stale() call from
> ice_ptp_reset_cached_phctime(), so outstanding Tx timestamps are no longer
> discarded when the PHC is adjusted or set. The stale bit itself is kept and
> is now only used by the link-down path. The kernel-doc of
> ice_ptp_mark_tx_tracker_stale() is updated to describe the new meaning.
>
> A couple of questions below.
>
>> The original motivation for discarding timestamps was that extending an old
>> timestamp using the new cached value of PHC was a problem, as it could
>> produce incorrect results. The change did not describe what such "incorrect
>> results" were.
>>
>> There are no such incorrect results. Extending the 32 bit timestamp with
>> the new time value just means that the timestamp is reported in terms of
>> the newly updated and adjusted system clock.
>
> [Severity: High]
> Does this hold for the .settime path too, or only for the atomic .adjtime
> path?
>
> ice_ptp_adjtime() only uses the atomic ice_ptp_write_adj() path for
> |delta| <= S32_MAX:
>
> if (delta > S32_MAX || delta < S32_MIN) {
> dev_dbg(dev, "delta = %lld, adjtime non-atomic\n", delta);
>
> Larger deltas, and every clock_settime() on /dev/ptpN, take
> ice_ptp_adjtime_nonatomic() -> ice_ptp_settime64() -> ice_ptp_write_init()
> -> ice_ptp_init_time(), which replaces the 64-bit source timer with an
> arbitrary new value rather than shifting it by a bounded amount.
>
> The PHY Tx timestamp memory keeps only the captured low 32 bits of nominal
> nanoseconds, and ice_ptp_settime64() only restarts the PHY blocks on E82X:
>
> /* Recalibrate and re-enable timestamp blocks for E822/E823 */
> if (hw->mac_type == ICE_MAC_GENERIC)
> ice_ptp_restart_all_phy(pf);
>
> So on ICE_MAC_E810 / ICE_MAC_E830 a capture taken just before the step is
> still in the PHY bank with its ready bit set when
> ice_ptp_process_tx_tstamp() runs after the cache was replaced. With the
> stale bit no longer set, that slot passes the drop checks and
> ice_ptp_extend_40b_ts() extends the pre-step low 32 bits with the post-step
> READ_ONCE(pf->ptp.cached_phc_time).
>
> Isn't the value produced by ice_ptp_extend_32b_ts() then the alias of the
> real event time nearest the new clock, i.e. off by (step mod 2^32), which is
> up to about +/- 2.147 s and can even be dated after the new PHC value? The
> same function documents that this is outside its stated assumption:
>
> * 2) assume that the in_tstamp was captured 2^31 nanoseconds (~2.1
> * seconds) before or after the PHC time was captured.
>
> Separately, is the reverse branch safe when the clock is set to a small
> absolute value (for example phc_ctl set 0)?
>
> if (delta > (U32_MAX / 2)) {
> /* reverse the delta calculation here */
> delta = (phc_time_lo - in_tstamp);
> ns = cached_phc_time - delta;
>
> With cached_phc_time smaller than delta this u64 subtraction wraps, and
> ns_to_ktime() then reports a negative hardware timestamp. Previously the
> stale bit hid this case; now it is reachable.
>
> In both cases the result is counted in pf->ptp.tx_hwtstamp_good and handed
> to skb_tstamp_tx() rather than dropped. Would it make sense to keep
> discarding outstanding captures for the settime and large-adjtime paths, or
> alternatively to restrict the claim in the commit message to the atomic
> adjustment case and note the trade-off (a wrong timestamp delivered instead
> of no timestamp)?
>
Ugh. Yea, I think that analysis is right. We still need this for larger
adjustments and I think since we haven't had too many reports of missed
timestamps that it makes more sense to just drop this change from the
series.
next prev parent reply other threads:[~2026-09-17 17:53 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 [this message]
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
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=31a84ab2-a48a-430f-9322-78fdd35297f5@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