summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu
diff options
context:
space:
mode:
authorThomas Fleury <tfleury@nvidia.com>2017-04-27 14:28:27 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-15 14:53:10 -0400
commit741e5c45179db066ddf5bed0be6f36e4d0d4010e (patch)
tree815f83070ae0fcf37a7b234caf8a2f86997f99bb /drivers/gpu/nvgpu/vgpu
parent77e2cbab237637f71367df25384164b8c936a31a (diff)
gpu: nvgpu: hal for timestamps correlation
In order to perform timestamps correlation for FECS traces, we need to collect GPU / GPU timestamps samples. In virtualization case, it is possible for a guest to get GPU timestamps by using read_ptimer. However, if the CPU timestamp is read on guest side, and the GPU timestamp is read on vm-server side, then it introduces some latency that will create an artificial offset for GPU timestamps (~2 us in average). For better CPU / GPU timestamps correlation, Added a command to collect all timestamps on vm-server side. Bug 1900475 Change-Id: Idfdc6ae4c16c501dc5e00053a5b75932c55148d6 Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: http://git-master/r/1472447 (cherry picked from commit 56f56b5cd9d2e75cf7d2613b5e115bfebdbee0ce) Reviewed-on: http://git-master/r/1489183 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu')
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index cdd0d378..a8c28826 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -367,6 +367,48 @@ static int vgpu_read_ptimer(struct gk20a *g, u64 *value)
367 return err; 367 return err;
368} 368}
369 369
370int vgpu_get_timestamps_zipper(struct gk20a *g,
371 u32 source_id, u32 count,
372 struct nvgpu_cpu_time_correlation_sample *samples)
373{
374 struct tegra_vgpu_cmd_msg msg = {0};
375 struct tegra_vgpu_get_timestamps_zipper_params *p =
376 &msg.params.get_timestamps_zipper;
377 int err;
378 u32 i;
379
380 gk20a_dbg_fn("");
381
382 if (count > TEGRA_VGPU_GET_TIMESTAMPS_ZIPPER_MAX_COUNT) {
383 nvgpu_err(g, "count %u overflow", count);
384 return -EINVAL;
385 }
386
387 if (source_id != NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC) {
388 nvgpu_err(g, "source_id %u not supported", source_id);
389 return -EINVAL;
390 }
391
392 msg.cmd = TEGRA_VGPU_CMD_GET_TIMESTAMPS_ZIPPER;
393 msg.handle = vgpu_get_handle(g);
394 p->source_id = TEGRA_VGPU_GET_TIMESTAMPS_ZIPPER_SRC_ID_TSC;
395 p->count = count;
396
397 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
398 err = err ? err : msg.ret;
399 if (err) {
400 nvgpu_err(g, "vgpu get timestamps zipper failed, err=%d", err);
401 return err;
402 }
403
404 for (i = 0; i < count; i++) {
405 samples[i].cpu_timestamp = p->samples[i].cpu_timestamp;
406 samples[i].gpu_timestamp = p->samples[i].gpu_timestamp;
407 }
408
409 return err;
410}
411
370void vgpu_init_hal_common(struct gk20a *g) 412void vgpu_init_hal_common(struct gk20a *g)
371{ 413{
372 struct gpu_ops *gops = &g->ops; 414 struct gpu_ops *gops = &g->ops;
@@ -384,6 +426,7 @@ void vgpu_init_hal_common(struct gk20a *g)
384#endif 426#endif
385 gops->chip_init_gpu_characteristics = vgpu_init_gpu_characteristics; 427 gops->chip_init_gpu_characteristics = vgpu_init_gpu_characteristics;
386 gops->bus.read_ptimer = vgpu_read_ptimer; 428 gops->bus.read_ptimer = vgpu_read_ptimer;
429 gops->bus.get_timestamps_zipper = vgpu_get_timestamps_zipper;
387} 430}
388 431
389static int vgpu_init_hal(struct gk20a *g) 432static int vgpu_init_hal(struct gk20a *g)