From a4d1a4830e13caecf5f39f15a716f3bd63f37c34 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Thu, 17 May 2018 15:04:51 +0300 Subject: gpu: nvgpu: add nvgpu_current_time_ns() Add an abstraction over a monotonic system clock in nanosecond units. Use ktime_get() for the Linux implementation, similarly to nvgpu_current_time_ms(). Jira NVGPU-708 Change-Id: I3165c20abf2652f1a1fa04e66c04cd34a8fe6dcc Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1723201 Reviewed-by: svc-mobile-coverity Reviewed-by: Deepak Nibade Reviewed-by: Sourab Gupta Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/timers.c | 12 ++++++++++++ drivers/gpu/nvgpu/include/nvgpu/timers.h | 1 + 2 files changed, 13 insertions(+) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index 41b55543..d1aa641f 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c @@ -242,6 +242,18 @@ s64 nvgpu_current_time_ms(void) return ktime_to_ms(ktime_get()); } +/** + * nvgpu_current_time_ns - Time in nanoseconds from a monotonic clock. + * + * Return a clock in nanosecond 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_ns(void) +{ + return ktime_to_ns(ktime_get()); +} + /** * nvgpu_hr_timestamp - Opaque 'high resolution' time stamp. * diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index 2e260619..83dd8d78 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h @@ -109,6 +109,7 @@ void nvgpu_udelay(unsigned int usecs); * Timekeeping. */ s64 nvgpu_current_time_ms(void); +s64 nvgpu_current_time_ns(void); u64 nvgpu_hr_timestamp(void); #endif -- cgit v1.2.2