summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-02-16 17:08:04 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-03-16 10:34:36 -0400
commit0725ff9372edc7e096a9d5e82b1fa8d28abcba60 (patch)
tree15becf4478ec93f7edf08b6c9e299eb1cd98dbef
parentae1b86ed4f9bb706a289848829a7909669a538d3 (diff)
gpu: nvgpu: Abstract get_cycles()
get_cycles is a linux specific API used in common code. This API is being used, it seems, as a method to generate time stamps. So add an API to generate 'high resolution' time stamps. This API returns an opaque time stamp: that is not something one may use directly as a time since in the Linux implementation we just use this cycle counter. Other implementations will, of course, be free to implement as a real time stamp. JIRA NVGPU-525 Change-Id: I237aac9bd6c795d000459025bdb4fce92e8aaa3d Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1673811 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/bus.c2
-rw-r--r--drivers/gpu/nvgpu/common/linux/timers.c15
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/timers.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/common/bus.c b/drivers/gpu/nvgpu/common/bus.c
index a84348cd..3889512a 100644
--- a/drivers/gpu/nvgpu/common/bus.c
+++ b/drivers/gpu/nvgpu/common/bus.c
@@ -42,7 +42,7 @@ int nvgpu_get_timestamps_zipper(struct gk20a *g,
42 if (err) 42 if (err)
43 return err; 43 return err;
44 44
45 samples[i].cpu_timestamp = (u64)get_cycles(); 45 samples[i].cpu_timestamp = nvgpu_hr_timestamp();
46 } 46 }
47 47
48end: 48end:
diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c
index d0004aa5..41b55543 100644
--- a/drivers/gpu/nvgpu/common/linux/timers.c
+++ b/drivers/gpu/nvgpu/common/linux/timers.c
@@ -241,3 +241,18 @@ s64 nvgpu_current_time_ms(void)
241{ 241{
242 return ktime_to_ms(ktime_get()); 242 return ktime_to_ms(ktime_get());
243} 243}
244
245/**
246 * nvgpu_hr_timestamp - Opaque 'high resolution' time stamp.
247 *
248 * Return a "high resolution" time stamp. It does not really matter exactly what
249 * it is, so long as it generally returns unique values and monotonically
250 * increases - wrap around _is_ possible though in a system running for long
251 * enough.
252 *
253 * Note: what high resolution means is system dependent.
254 */
255u64 nvgpu_hr_timestamp(void)
256{
257 return get_cycles();
258}
diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h
index b0df29b6..2e260619 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/timers.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h
@@ -109,5 +109,6 @@ void nvgpu_udelay(unsigned int usecs);
109 * Timekeeping. 109 * Timekeeping.
110 */ 110 */
111s64 nvgpu_current_time_ms(void); 111s64 nvgpu_current_time_ms(void);
112u64 nvgpu_hr_timestamp(void);
112 113
113#endif 114#endif