diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu
index d16e2c3e3..790cd656d 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu
@@ -51,6 +51,7 @@ nvgpu-y := \
common/mm/gmmu.o \
common/mm/vm.o \
common/mm/vm_area.o \
+ common/bus.o \
common/enabled.o \
common/pramin.o \
common/semaphore.o \
diff --git a/drivers/gpu/nvgpu/common/bus.c b/drivers/gpu/nvgpu/common/bus.c
new file mode 100644
index 000000000..9fd827bc0
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/bus.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+
+#include "gk20a/gk20a.h"
+
+int nvgpu_get_timestamps_zipper(struct gk20a *g,
+ u32 source_id, u32 count,
+ struct nvgpu_cpu_time_correlation_sample *samples)
+{
+ int err = 0;
+ unsigned int i = 0;
+
+ if (source_id != NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC) {
+ nvgpu_err(g, "source_id %u not supported", source_id);
+ return -EINVAL;
+ }
+
+ if (gk20a_busy(g)) {
+ nvgpu_err(g, "GPU not powered on\n");
+ err = -EINVAL;
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ err = g->ops.bus.read_ptimer(g, &samples[i].gpu_timestamp);
+ if (err)
+ return err;
+
+ samples[i].cpu_timestamp = (u64)get_cycles();
+ }
+
+end:
+ gk20a_idle(g);
+ return err;
+}
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index 025a30fe3..caf8d3096 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include "ioctl_ctrl.h"
#include "ioctl_tsg.h"
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
index f23414b0a..45cebd7fa 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include "gk20a.h"
#include "bus_gk20a.h"
@@ -128,37 +129,6 @@ int gk20a_read_ptimer(struct gk20a *g, u64 *value)
return -EBUSY;
}
-int gk20a_get_timestamps_zipper(struct gk20a *g,
- u32 source_id, u32 count,
- struct nvgpu_cpu_time_correlation_sample *samples)
-{
- int err = 0;
- unsigned int i = 0;
-
- if (source_id != NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC) {
- nvgpu_err(g, "source_id %u not supported", source_id);
- return -EINVAL;
- }
-
- if (gk20a_busy(g)) {
- nvgpu_err(g, "GPU not powered on\n");
- err = -EINVAL;
- goto end;
- }
-
- for (i = 0; i < count; i++) {
- err = g->ops.bus.read_ptimer(g, &samples[i].gpu_timestamp);
- if (err)
- return err;
-
- samples[i].cpu_timestamp = (u64)get_cycles();
- }
-
-end:
- gk20a_idle(g);
- return err;
-}
-
static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
{
u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst);
@@ -181,6 +151,6 @@ void gk20a_init_bus(struct gpu_ops *gops)
gops->bus.init_hw = gk20a_bus_init_hw;
gops->bus.isr = gk20a_bus_isr;
gops->bus.read_ptimer = gk20a_read_ptimer;
- gops->bus.get_timestamps_zipper = gk20a_get_timestamps_zipper;
+ gops->bus.get_timestamps_zipper = nvgpu_get_timestamps_zipper;
gops->bus.bar1_bind = gk20a_bus_bar1_bind;
}
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
index 088c385eb..344350b4a 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
@@ -20,12 +20,6 @@
struct gk20a;
struct gpu_ops;
-struct nvgpu_mem;
-
-struct nvgpu_cpu_time_correlation_sample {
- u64 cpu_timestamp;
- u64 gpu_timestamp;
-};
void gk20a_init_bus(struct gpu_ops *gops);
@@ -33,8 +27,4 @@ void gk20a_bus_isr(struct gk20a *g);
int gk20a_read_ptimer(struct gk20a *g, u64 *value);
void gk20a_bus_init_hw(struct gk20a *g);
-int gk20a_get_timestamps_zipper(struct gk20a *g,
- u32 source_id, u32 count,
- struct nvgpu_cpu_time_correlation_sample *samples);
-
#endif /* GK20A_H */
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 84e104482..11490c27a 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -33,6 +33,7 @@ struct ecc_gk20a;
struct gk20a_debug_output;
struct nvgpu_clk_pll_debug_data;
struct nvgpu_nvhost_dev;
+struct nvgpu_cpu_time_correlation_sample;
#include
#include
diff --git a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
index 39778c55f..11c11e230 100644
--- a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
@@ -14,6 +14,7 @@
*/
#include
+#include
#include "bus_gm20b.h"
#include "gk20a/gk20a.h"
@@ -58,6 +59,6 @@ void gm20b_init_bus(struct gpu_ops *gops)
gops->bus.init_hw = gk20a_bus_init_hw;
gops->bus.isr = gk20a_bus_isr;
gops->bus.read_ptimer = gk20a_read_ptimer;
- gops->bus.get_timestamps_zipper = gk20a_get_timestamps_zipper;
+ gops->bus.get_timestamps_zipper = nvgpu_get_timestamps_zipper;
gops->bus.bar1_bind = gm20b_bus_bar1_bind;
}
diff --git a/drivers/gpu/nvgpu/include/nvgpu/bus.h b/drivers/gpu/nvgpu/include/nvgpu/bus.h
new file mode 100644
index 000000000..096c084d8
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/bus.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+#ifndef __NVGPU_BUS_H__
+#define __NVGPU_BUS_H__
+
+#include
+
+struct gk20a;
+
+struct nvgpu_cpu_time_correlation_sample {
+ u64 cpu_timestamp;
+ u64 gpu_timestamp;
+};
+
+int nvgpu_get_timestamps_zipper(struct gk20a *g,
+ u32 source_id, u32 count,
+ struct nvgpu_cpu_time_correlation_sample *samples);
+
+#endif
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index 52f375f9f..a9f102c86 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#include "vgpu/vgpu.h"
#include "vgpu/fecs_trace_vgpu.h"