Skip to content

ptp: make virtual clock sampling and teardown failure-safe

James Hilliard lkml netdev 6 versions – Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected] change-id 20260930-ptp-vclock-sampling-902f98408c93

Versions newest first

  1. v6 Latest5 patches 0 repliesApplied 5/5
  2. v55 patches 0 repliesSuperseded
  3. v45 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v35 patches2 repliesSuperseded
v22 patches1 replySuperseded
v11 patch1 replySuperseded

Changes in v6 from the cover letter

- Limit retry delays to the next regular refresh deadline so exponential
backoff cannot skip that attempt and lose a counter wrap after the parent
has recovered. Keep the backoff across deadlines to limit repeated work
during sustained failures.
- Report: https://lore.kernel.org/r/[email protected]
- Rebase onto current net.
- Link to v5: https://patch.msgid.link/[email protected]

Patches in v6 All 5 applied

#Subject and filesSizeRepliesApplied
1/5ptp: drain virtual clock sysfs operations before unregistering childrendrivers/ptp/ptp_clock.c drivers/ptp/ptp_private.h drivers/ptp/ptp_sysfs.c+12 -00 repliesApplied
2/5ptp: unwind partially completed virtual clock creationdrivers/ptp/ptp_sysfs.c+7 -10 repliesApplied
3/5ptp: vclock: propagate physical clock sampling errorsdrivers/ptp/ptp_private.h drivers/ptp/ptp_sysfs.c drivers/ptp/ptp_vclock.c+76 -230 repliesApplied
4/5ptp: vclock: serialize extended samples with counter updatesdrivers/ptp/ptp_vclock.c+14 -180 repliesApplied
5/5ptp: vclock: preserve missing hardware timestampsdrivers/ptp/ptp_vclock.c include/linux/ptp_clock_kernel.h+3 -10 repliesApplied

Reviews trailers per patch

2 of 5 patches have a Reviewed-by or Acked-by.

PatchVadim Fedorenko
1/5R-b
2/5
3/5
4/5
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH net v6 0/5] ptp: make virtual clock sampling and teardown failure-safe

Fix virtual-clock sampling errors, registration rollback and parent teardown in separate patches. Keep failed PHC reads out of the timecounter and serialize extended samples with virtual-clock adjustments. Also preserve the zero sentinel for packets without hardware timestamps.

Retain the existing cyclecounter mask, scaling and conversion windows. Retry the first failed refresh promptly, then back off consecutive failures while preserving regular two-second refresh attempts. Queue the first refresh immediately after registration. Prolonged sampling gaps remain subject to the existing half-wrap conversion window and full-wrap sampling limit.

Changes in v6:
- Limit retry delays to the next regular refresh deadline so exponential
backoff cannot skip that attempt and lose a counter wrap after the parent
has recovered. Keep the backoff across deadlines to limit repeated work
during sustained failures.
- Report: https://lore.kernel.org/r/[email protected]
- Rebase onto current net.
- Link to v5: https://patch.msgid.link/[email protected]

Changes in v5:
- Replace the fixed 10 ms failure retry with per-clock exponential backoff, starting at 10 ms and capped at the normal two-second interval. Reset
the retry state after a successful refresh, following Sashiko's report
and Paolo Abeni's review.
- Report: https://lore.kernel.org/r/[email protected]
- Rebase onto current net.
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
- Retry failed refreshes after 10 ms, keeping the normal two-second
interval after success.
- Queue the first refresh immediately after registration, while keeping
counter initialization before publication.
- Clarify the half-wrap conversion window and full-wrap sampling limit.
- Document the zero-input return from ptp_convert_timestamp().
- Add Vadim Fedorenko's Reviewed-by tags to patches 1 and 5.
- Rebase onto current net.
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- Split the independent fixes into separate patches, as requested by Paolo.
- Retain the existing timecounter arithmetic and conversion windows; drop
the full-width rewrite and extended-read anchor updates from v2.
- Propagate registration errors through sysfs, including a failed initial
PHC sample, and initialize the counter before publishing the clock.
- Preserve absent hardware timestamps instead of converting zero.
- Correct the sysfs teardown rationale and its Fixes tag.
- Rebase onto current net.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Drain virtual clock sysfs changes before parent unregister walks children.
- Use full-width samples and overflow-safe scaling across long sampling gaps.
- Update the anchor for extended and cross-timestamp reads under the clock lock.
- Link to v1: https://patch.msgid.link/[email protected]

Assisted-by Codex:gpt-6-astra

---
James Hilliard (5):
ptp: drain virtual clock sysfs operations before unregistering children
ptp: unwind partially completed virtual clock creation
ptp: vclock: propagate physical clock sampling errors
ptp: vclock: serialize extended samples with counter updates
ptp: vclock: preserve missing hardware timestamps

 drivers/ptp/ptp_clock.c          |   5 ++
 drivers/ptp/ptp_private.h        |   7 ++-
 drivers/ptp/ptp_sysfs.c          |  18 +++++-
 drivers/ptp/ptp_vclock.c         | 123 ++++++++++++++++++++++++++-------------
 include/linux/ptp_clock_kernel.h |   2 +-
 5 files changed, 112 insertions(+), 43 deletions(-)

---
base-commit: 6430fb7f1cc4e329e386521b7b208df443de92f2
change-id: 20260930-ptp-vclock-sampling-902f98408c93

Best regards,

Signature · 1 line
James Hilliard <[email protected]>