[RFC PATCH v3 5/7] virtio_rtc: Add PTP clocks

David Woodhouse dwmw2 at infradead.org
Sat Jun 15 01:01:31 PDT 2024


On Mon, 2023-12-18 at 08:38 +0100, Peter Hilber wrote:
> 
> +       ret = viortc_hw_xtstamp_params(&hw_counter, &cs_id);
> +       if (ret)
> +               return ret;
> +
> +       ktime_get_snapshot(&history_begin);
> +       if (history_begin.cs_id != cs_id)
> +               return -EOPNOTSUPP;

I think you have to call ktime_get_snapshot() anyway to get a snapshot
from before your crosststamp? But I still don't much like the fact that
you need to use it to work out which cs_id is being used.

Shouldn't get_device_system_crosststamp() pass that to its get_time_fn
as a hint?

On x86, you are likely to find that history_begin.cs_id is the KVM
clock, so this will return -EOPNOTSUPP and userspace will have to fall
back to PTP_SYS_OFFSET. I note the KVM PTP clock actually *converts* a
TSC-based crosststamp to kvmclock µs for itself, so that it can report 
*cs_id = CSID_X86_KVM_CLK. Not sure how I feel about that though. I'm
inclined to suggest that it shouldn't, as anyone who wants accurate
timekeeping shouldn't be using the KVM clock anyway.

But we should at least be relatively consistent about it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5965 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240615/2369fc7b/attachment-0001.p7s>


More information about the linux-arm-kernel mailing list