Commit 4b7f5212 authored by Peter Hilber's avatar Peter Hilber Committed by Thomas Gleixner

timekeeping: Evaluate system_counterval_t.cs_id instead of .cs

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.

Address this by evaluating the clocksource ID, rather than the clocksource
pointer, of struct system_counterval_t. By this, setting the clocksource
pointer becomes unneeded, and get_device_system_crosststamp() callers will
no longer need to supply clocksource pointers.

All relevant clocksource drivers provide the ID, so this change is not
changing the behaviour.

[1] https://lore.kernel.org/lkml/20231218073849.35294-1-peter.hilber@opensynergy.com/Signed-off-by: default avatarPeter Hilber <peter.hilber@opensynergy.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240201010453.2212371-7-peter.hilber@opensynergy.com
parent 9be3b2f0
...@@ -268,13 +268,13 @@ struct system_device_crosststamp { ...@@ -268,13 +268,13 @@ struct system_device_crosststamp {
}; };
/** /**
* struct system_counterval_t - system counter value with the pointer to the * struct system_counterval_t - system counter value with the ID of the
* corresponding clocksource * corresponding clocksource
* @cycles: System counter value * @cycles: System counter value
* @cs: Clocksource corresponding to system counter value. Used by * @cs: Clocksource corresponding to system counter value. Timekeeping
* timekeeping code to verify comparibility of two cycle values * code now evaluates cs_id instead.
* @cs_id: Clocksource ID corresponding to system counter value. To be * @cs_id: Clocksource ID corresponding to system counter value. Used by
* used instead of cs in the future. * timekeeping code to verify comparability of two cycle values.
* The default ID, CSID_GENERIC, does not identify a specific * The default ID, CSID_GENERIC, does not identify a specific
* clocksource. * clocksource.
*/ */
......
...@@ -1232,11 +1232,12 @@ int get_device_system_crosststamp(int (*get_time_fn) ...@@ -1232,11 +1232,12 @@ int get_device_system_crosststamp(int (*get_time_fn)
return ret; return ret;
/* /*
* Verify that the clocksource associated with the captured * Verify that the clocksource ID associated with the captured
* system counter value is the same as the currently installed * system counter value is the same as for the currently
* timekeeper clocksource * installed timekeeper clocksource
*/ */
if (tk->tkr_mono.clock != system_counterval.cs) if (system_counterval.cs_id == CSID_GENERIC ||
tk->tkr_mono.clock->id != system_counterval.cs_id)
return -ENODEV; return -ENODEV;
cycles = system_counterval.cycles; cycles = system_counterval.cycles;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment