timekeeping: Add clocksource ID to struct system_counterval_t
authorPeter Hilber <peter.hilber@opensynergy.com>
Thu, 1 Feb 2024 01:04:47 +0000 (02:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 7 Feb 2024 16:05:21 +0000 (17:05 +0100)
Clocksource pointers can be problematic to obtain for drivers which are not
clocksource drivers themselves. In particular, the RFC virtio_rtc driver
[1] would require a new helper function to obtain a pointer to the ARM
Generic Timer clocksource. The ptp_kvm driver also required a similar
workaround.

Add a clocksource ID member to struct system_counterval_t, which in the
future shall identify the clocksource, and which shall replace the struct
clocksource * member. By this, get_device_system_crosststamp() callers
(such as virtio_rtc and ptp_kvm) will be able to supply easily accessible
clocksource ids instead of clocksource pointers.

[1] https://lore.kernel.org/lkml/20231218073849.35294-1-peter.hilber@opensynergy.com/

Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240201010453.2212371-3-peter.hilber@opensynergy.com
include/linux/timekeeping.h

index 7c43e98cf2115088c085417028ad4329be638278..ca234fa4cc046341f6bf0837483e0f6bed8312c5 100644 (file)
@@ -273,10 +273,15 @@ struct system_device_crosststamp {
  * @cycles:    System counter value
  * @cs:                Clocksource corresponding to system counter value. Used by
  *             timekeeping code to verify comparibility of two cycle values
+ * @cs_id:     Clocksource ID corresponding to system counter value. To be
+ *             used instead of cs in the future.
+ *             The default ID, CSID_GENERIC, does not identify a specific
+ *             clocksource.
  */
 struct system_counterval_t {
        u64                     cycles;
        struct clocksource      *cs;
+       enum clocksource_ids    cs_id;
 };
 
 /*