Message ID | 1489645211-25729-5-git-send-email-sourab.gupta@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, 16 Mar 2017, sourab.gupta@intel.com wrote: Please Cc LKML for patches which touch subsystems managed on LKML. Also CC'ing people on the 0/N letter would be helpful, so we can see what this is about. > For the drivers to be able to use the cross timestamp framework, > they need the information of current clocksource being used by the > kernel timekeeping. No. > This is needed since the callback given by driver into the > get_device_system_crosststamp(), in order to synchronously read the > device time and system counter value, requires the knowledge of the > clocksource being used to read system counter value (as a part of struct > system_counterval_t). Again you are saying WHAT you want but not WHY. The device callback does not need to know anything about the timekeeping clocksource. get_device_system_crosststamp() is for timestamps taken via a clock which is directly correlated with the timekeeper clocksource. ART and TSC are correlated via: TSC = (ART * scale) + offset get_device_system_crosststamp() invokes the device function which reads ART, which is converted to CLOCK_MONOTONIC_RAW by the conversion above, and then uses interpolation to map the CLOCK_MONOTONIC_RAW value to CLOCK_MONOTONIC. The device function does not know anything about TSC. All it knows about is ART. I have no idea what you are trying to do, but given the explanation above it's wrong. Thanks, tglx
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index d2e804e..d62bb0e 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -337,6 +337,11 @@ extern int get_device_system_crosststamp( struct system_device_crosststamp *xtstamp); /* + * Get current clocksource used by system timekeeping framework + */ +struct clocksource *get_current_clocksource(void); + +/* * Simultaneously snapshot realtime and monotonic raw clocks */ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 95b258d..bd85d14 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1167,6 +1167,18 @@ int get_device_system_crosststamp(int (*get_time_fn) EXPORT_SYMBOL_GPL(get_device_system_crosststamp); /** + * get_current_clocksource - Returns the current clocksource in used by tk_core + * + */ +struct clocksource *get_current_clocksource(void) +{ + struct timekeeper *tk = &tk_core.timekeeper; + + return tk->tkr_mono.clock; +} +EXPORT_SYMBOL_GPL(get_current_clocksource); + +/** * do_gettimeofday - Returns the time of day in a timeval * @tv: pointer to the timeval to be set *