From: Gerik Kubiak <gerikkub@gmail.com>
To: giometti@enneenne.com
Cc: richardcochran@gmail.com, linux-kernel@vger.kernel.org,
Gerik Kubiak <gerikkub@gmail.com>
Subject: [RFC PATCH 0/3] PPS Set event clock source
Date: Sat, 27 Jun 2026 13:50:25 -0700 [thread overview]
Message-ID: <20260627205028.105252-1-gerikkub@gmail.com> (raw)
Hello all,
This patch series adds support for userspace to specify the clock source
used to collect pps events. The current behavior timestamps events in
the REALTIME clock and this series adds support for the BOOTTIME and
MONOTONIC_RAW clocks via a new ioctl on a pps fd.
This is a minimal proof of concept RFC to understand if there is
interest in this feature and if the current approach to the userspace
API is appropriate.
My usecase is using the pps subsystem to synchronize sensor data
to an external clock. The sensor data is timestamped by the BOOTTIME
clock in the kernel and I would like to use the pps subsystem to
correlate these timestamps to an external clock via a pps-gpio device.
sensor data, which is timestamped in the BOOTTIME clock to the external
The pps subsystem would work well for this if it could return timestamps
in the BOOTTIME clock. Otherwise I would need to correlate the clocks
in userspace, which is non-trivial and may be constantly changing.
This series adds support for this behavior across three patches.
1. Create a new userspace API for setting the requested clock using
an ioctl
2. Update the pps_get_ts function to capture the event in the clocks
of interest
3. Update the pps subsystem to track the requested clock and return the
stored timestamp corresponding the requested clock
I have a few outstanding issues with this series that need
clarifications before merging
1. The current implementation collects timestamps for all relevant
clocks in pps_get_ts. This seems like overkill, but it prevents
issues when the clock source changes. A slimmer implementation would
collect timestamps with the selected clock and drop events if
userspace changes the clock source after an event has been collected.
2. This implements pps sources for REALTIME, MONOTONIC_RAW and BOOTTIME
clocks. This was done to keep the single call to ktime_get_snapshot.
It would make sense for this API to support MONOTONIC as well, but I
believe that will require changes to ktime_get_snapshot to include
the MONOTONIC clock in the system_time_snapshot struct.
3. I created a new ioctl on the pps fd to prevent changing the existing
pps API calls. Is this the preferred way to implement this new
behavior? It seems cleaner to add an additional flag and field to the
existing pps_kparams struct, but it wasn't clear to me if this could
be done without breaking the existing userspace contract.
Thank you,
Gerik
Gerik Kubiak (3):
pps: Add PPS_SETCLOCK ioctl
pps: Capture PPS timestamps in multiple clocks
pps: Timestamp pps events per PPS_SETCLOCK clock
drivers/pps/kapi.c | 27 ++++++++++++++++++++-------
drivers/pps/pps.c | 22 ++++++++++++++++++++++
include/linux/pps_kernel.h | 10 ++++------
include/uapi/linux/pps.h | 6 ++++++
4 files changed, 52 insertions(+), 13 deletions(-)
--
2.54.0
next reply other threads:[~2026-06-27 20:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 20:50 Gerik Kubiak [this message]
2026-06-27 20:50 ` [RFC PATCH 1/3] pps: Add PPS_SETCLOCK ioctl Gerik Kubiak
2026-06-27 20:50 ` [RFC PATCH 2/3] pps: Capture PPS timestamps in multiple clocks Gerik Kubiak
2026-06-27 20:50 ` [RFC PATCH 3/3] pps: Timestamp pps events per PPS_SETCLOCK clock Gerik Kubiak
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=20260627205028.105252-1-gerikkub@gmail.com \
--to=gerikkub@gmail.com \
--cc=giometti@enneenne.com \
--cc=linux-kernel@vger.kernel.org \
--cc=richardcochran@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.