Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to
user setting the time or due to NTP.
Monotonic time is constantly increasing time better suited for comparing two
timestamps.
Signed-off-by: Abhilash Jindal <klock.android@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
unsigned int prev_speed;
unsigned int ret = 0;
unsigned long flags;
unsigned int prev_speed;
unsigned int ret = 0;
unsigned long flags;
- struct timeval tv1, tv2;
if ((!processor) || (!low_speed) || (!high_speed) || (!set_state))
return -EINVAL;
if ((!processor) || (!low_speed) || (!high_speed) || (!set_state))
return -EINVAL;
/* start latency measurement */
if (transition_latency)
/* start latency measurement */
if (transition_latency)
/* switch to high state */
set_state(SPEEDSTEP_HIGH);
/* end latency measurement */
if (transition_latency)
/* switch to high state */
set_state(SPEEDSTEP_HIGH);
/* end latency measurement */
if (transition_latency)
*high_speed = speedstep_get_frequency(processor);
if (!*high_speed) {
*high_speed = speedstep_get_frequency(processor);
if (!*high_speed) {
set_state(SPEEDSTEP_LOW);
if (transition_latency) {
set_state(SPEEDSTEP_LOW);
if (transition_latency) {
- *transition_latency = (tv2.tv_sec - tv1.tv_sec) * USEC_PER_SEC +
- tv2.tv_usec - tv1.tv_usec;
+ *transition_latency = ktime_to_us(ktime_sub(tv2, tv1));
pr_debug("transition latency is %u uSec\n", *transition_latency);
/* convert uSec to nSec and add 20% for safety reasons */
pr_debug("transition latency is %u uSec\n", *transition_latency);
/* convert uSec to nSec and add 20% for safety reasons */