RFC PPS Set event clock source
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | pps: Add PPS_SETCLOCK ioctlinclude/ | +6 | 2 replies | |
| 2/3 | pps: Capture PPS timestamps in multiple clocksinclude/ | +3 | 0 replies | |
| 3/3 | pps: Timestamp pps events per PPS_SETCLOCK clockdrivers/ drivers/ include/ | +43 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/3] PPS Set event clock source
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(-)
Signature · 1 line
2.54.0