From: Paolo Abeni <pabeni@redhat.com>
To: James Hilliard <james.hilliard1@gmail.com>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Yangbo Lu <yangbo.lu@nxp.com>
Cc: Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] ptp: vclock: preserve time across failed physical clock samples
Date: Tue, 13 Oct 2026 10:55:26 +0200 [thread overview]
Message-ID: <6317234b-1158-412b-85ff-7fa6210b7930@redhat.com> (raw)
In-Reply-To: <20261005-ptp-vclock-sampling-v2-2-8ed12d4d10af@gmail.com>
On 10/5/26 20:45, James Hilliard wrote:
> The cyclecounter read callback cannot report errors. Passing an
> unsuccessful PHC read through it consumes an invalid sample, and a zero
> sample followed by the real counter can add an extra 32-bit wrap to
> virtual time. This was identified by code inspection of reset-time PHC
> access and the virtual clock callers.
>
> Read the parent clock before updating or initializing the virtual
> counter, propagate failures from clock operations, and leave its state
> unchanged on failure. Initialize it before publishing a new virtual
> clock.
>
> Simply skipping failed reads is insufficient: the next successful read
> can arrive after the 32-bit counter has wrapped, while timestamp
> conversion has an even shorter half-wrap window. Use the full physical
> nanosecond sample with a wide frequency-adjustment multiply and retain
> fractional nanoseconds. This also allows delayed packet timestamps to be
> converted without truncating their distance from the last sample.
> Serialize extended and cross-timestamp sampling with adjustments and
> advance the anchor on each successful clock read.
>
> The initial sample can also fail partway through a sysfs request to create
> multiple virtual clocks. Unregister any clocks created by that request
> and clear their index entries, preserving the previously installed clocks
> and count. Otherwise the failed request leaves registered children that
> are not included in n_vclocks. This cleanup also handles existing
> allocation and registration failure paths.
>
> Fixes: 5d43f951b1ac ("ptp: add ptp virtual clock driver framework")
> Fixes: 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion")
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
This addresses multiple issues, should instead be split accordingly.
Also sashiko remarks hints at possible regression wrt the new wrap schema.
/P
prev parent reply other threads:[~2026-10-13 8:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 18:45 [PATCH net v2 0/2] ptp: make virtual clock sampling and teardown failure-safe James Hilliard
2026-10-05 18:45 ` [PATCH net v2 1/2] ptp: drain virtual clock sysfs operations before unregistering children James Hilliard
2026-10-07 21:47 ` netdev-bot+sashiko
2026-10-05 18:45 ` [PATCH net v2 2/2] ptp: vclock: preserve time across failed physical clock samples James Hilliard
2026-10-07 21:47 ` netdev-bot+sashiko
2026-10-13 8:55 ` Paolo Abeni [this message]
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=6317234b-1158-412b-85ff-7fa6210b7930@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=yangbo.lu@nxp.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
all inboxes | Powered by JetHome®