From 571c7c2fb37176671d55f004df4ed1055f7e8cb1 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Thu, 15 Jun 2017 10:58:32 +0300 Subject: gpu: nvgpu: add a simple time API Add nvgpu_current_time_ms() to return a time from a monotonic clock source in milliseconds. The start time is unspecified; this API is meant to be used for duration measurements. Jira NVGPU-83 Change-Id: I135c8ee88283149422a68d5fa859241eebbd6459 Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/1503001 Reviewed-by: Deepak Nibade GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/timers.c | 12 ++++++++++++ drivers/gpu/nvgpu/include/nvgpu/timers.h | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index efd04557..140ae80e 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c @@ -229,3 +229,15 @@ void nvgpu_msleep(unsigned int msecs) { msleep(msecs); } + +/** + * nvgpu_current_time_ms - Time in milliseconds from a monotonic clock. + * + * Return a clock in millisecond units. The start time of the clock is + * unspecified; the time returned can be compared with older ones to measure + * durations. The source clock does not jump when the system clock is adjusted. + */ +s64 nvgpu_current_time_ms(void) +{ + return ktime_to_ms(ktime_get()); +} diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index 0aadd0df..be903e54 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h @@ -17,6 +17,8 @@ #ifndef __NVGPU_TIMERS_H__ #define __NVGPU_TIMERS_H__ +#include + struct gk20a; /* @@ -97,4 +99,9 @@ void nvgpu_msleep(unsigned int msecs); void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us); void nvgpu_udelay(unsigned int usecs); +/* + * Timekeeping. + */ +s64 nvgpu_current_time_ms(void); + #endif -- cgit v1.2.2