summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-06-16 17:36:29 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-06-20 14:35:17 -0400
commit84703739a52f1c4e878e871429edb22dfcb4005e (patch)
tree334a5d1a86c574a930c8e59d31411534f656f64e /drivers/gpu/nvgpu
parent50e2fdd306c253deae97a6bbf6be20f7502eba86 (diff)
gpu: nvgpu: Move time correlation to common code
Time correlation does not have chip or OS specific dependencies, so move it to generic new source file bus.c. JIRA NVGPU-38 Change-Id: Ic7fdf8c9ccacf05baf1b3438a86b28e517093641 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1505171 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu1
-rw-r--r--drivers/gpu/nvgpu/common/bus.c50
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c1
-rw-r--r--drivers/gpu/nvgpu/gk20a/bus_gk20a.c34
-rw-r--r--drivers/gpu/nvgpu/gk20a/bus_gk20a.h10
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gm20b/bus_gm20b.c3
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/bus.h29
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c1
9 files changed, 87 insertions, 43 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu
index d16e2c3e..790cd656 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu
@@ -51,6 +51,7 @@ nvgpu-y := \
51 common/mm/gmmu.o \ 51 common/mm/gmmu.o \
52 common/mm/vm.o \ 52 common/mm/vm.o \
53 common/mm/vm_area.o \ 53 common/mm/vm_area.o \
54 common/bus.o \
54 common/enabled.o \ 55 common/enabled.o \
55 common/pramin.o \ 56 common/pramin.o \
56 common/semaphore.o \ 57 common/semaphore.o \
diff --git a/drivers/gpu/nvgpu/common/bus.c b/drivers/gpu/nvgpu/common/bus.c
new file mode 100644
index 00000000..9fd827bc
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/bus.c
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <nvgpu/bus.h>
18
19#include "gk20a/gk20a.h"
20
21int nvgpu_get_timestamps_zipper(struct gk20a *g,
22 u32 source_id, u32 count,
23 struct nvgpu_cpu_time_correlation_sample *samples)
24{
25 int err = 0;
26 unsigned int i = 0;
27
28 if (source_id != NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC) {
29 nvgpu_err(g, "source_id %u not supported", source_id);
30 return -EINVAL;
31 }
32
33 if (gk20a_busy(g)) {
34 nvgpu_err(g, "GPU not powered on\n");
35 err = -EINVAL;
36 goto end;
37 }
38
39 for (i = 0; i < count; i++) {
40 err = g->ops.bus.read_ptimer(g, &samples[i].gpu_timestamp);
41 if (err)
42 return err;
43
44 samples[i].cpu_timestamp = (u64)get_cycles();
45 }
46
47end:
48 gk20a_idle(g);
49 return err;
50}
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index 025a30fe..caf8d309 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -24,6 +24,7 @@
24#include <nvgpu/bitops.h> 24#include <nvgpu/bitops.h>
25#include <nvgpu/kmem.h> 25#include <nvgpu/kmem.h>
26#include <nvgpu/bug.h> 26#include <nvgpu/bug.h>
27#include <nvgpu/bus.h>
27 28
28#include "ioctl_ctrl.h" 29#include "ioctl_ctrl.h"
29#include "ioctl_tsg.h" 30#include "ioctl_tsg.h"
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
index f23414b0..45cebd7f 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c
@@ -17,6 +17,7 @@
17#include <nvgpu/page_allocator.h> 17#include <nvgpu/page_allocator.h>
18#include <nvgpu/log.h> 18#include <nvgpu/log.h>
19#include <nvgpu/soc.h> 19#include <nvgpu/soc.h>
20#include <nvgpu/bus.h>
20 21
21#include "gk20a.h" 22#include "gk20a.h"
22#include "bus_gk20a.h" 23#include "bus_gk20a.h"
@@ -128,37 +129,6 @@ int gk20a_read_ptimer(struct gk20a *g, u64 *value)
128 return -EBUSY; 129 return -EBUSY;
129} 130}
130 131
131int gk20a_get_timestamps_zipper(struct gk20a *g,
132 u32 source_id, u32 count,
133 struct nvgpu_cpu_time_correlation_sample *samples)
134{
135 int err = 0;
136 unsigned int i = 0;
137
138 if (source_id != NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC) {
139 nvgpu_err(g, "source_id %u not supported", source_id);
140 return -EINVAL;
141 }
142
143 if (gk20a_busy(g)) {
144 nvgpu_err(g, "GPU not powered on\n");
145 err = -EINVAL;
146 goto end;
147 }
148
149 for (i = 0; i < count; i++) {
150 err = g->ops.bus.read_ptimer(g, &samples[i].gpu_timestamp);
151 if (err)
152 return err;
153
154 samples[i].cpu_timestamp = (u64)get_cycles();
155 }
156
157end:
158 gk20a_idle(g);
159 return err;
160}
161
162static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst) 132static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
163{ 133{
164 u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst); 134 u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst);
@@ -181,6 +151,6 @@ void gk20a_init_bus(struct gpu_ops *gops)
181 gops->bus.init_hw = gk20a_bus_init_hw; 151 gops->bus.init_hw = gk20a_bus_init_hw;
182 gops->bus.isr = gk20a_bus_isr; 152 gops->bus.isr = gk20a_bus_isr;
183 gops->bus.read_ptimer = gk20a_read_ptimer; 153 gops->bus.read_ptimer = gk20a_read_ptimer;
184 gops->bus.get_timestamps_zipper = gk20a_get_timestamps_zipper; 154 gops->bus.get_timestamps_zipper = nvgpu_get_timestamps_zipper;
185 gops->bus.bar1_bind = gk20a_bus_bar1_bind; 155 gops->bus.bar1_bind = gk20a_bus_bar1_bind;
186} 156}
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
index 088c385e..344350b4 100644
--- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.h
@@ -20,12 +20,6 @@
20 20
21struct gk20a; 21struct gk20a;
22struct gpu_ops; 22struct gpu_ops;
23struct nvgpu_mem;
24
25struct nvgpu_cpu_time_correlation_sample {
26 u64 cpu_timestamp;
27 u64 gpu_timestamp;
28};
29 23
30void gk20a_init_bus(struct gpu_ops *gops); 24void gk20a_init_bus(struct gpu_ops *gops);
31 25
@@ -33,8 +27,4 @@ void gk20a_bus_isr(struct gk20a *g);
33int gk20a_read_ptimer(struct gk20a *g, u64 *value); 27int gk20a_read_ptimer(struct gk20a *g, u64 *value);
34void gk20a_bus_init_hw(struct gk20a *g); 28void gk20a_bus_init_hw(struct gk20a *g);
35 29
36int gk20a_get_timestamps_zipper(struct gk20a *g,
37 u32 source_id, u32 count,
38 struct nvgpu_cpu_time_correlation_sample *samples);
39
40#endif /* GK20A_H */ 30#endif /* GK20A_H */
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 84e10448..11490c27 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -33,6 +33,7 @@ struct ecc_gk20a;
33struct gk20a_debug_output; 33struct gk20a_debug_output;
34struct nvgpu_clk_pll_debug_data; 34struct nvgpu_clk_pll_debug_data;
35struct nvgpu_nvhost_dev; 35struct nvgpu_nvhost_dev;
36struct nvgpu_cpu_time_correlation_sample;
36 37
37#include <linux/sched.h> 38#include <linux/sched.h>
38#include <nvgpu/lock.h> 39#include <nvgpu/lock.h>
diff --git a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
index 39778c55..11c11e23 100644
--- a/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/bus_gm20b.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <nvgpu/timers.h> 16#include <nvgpu/timers.h>
17#include <nvgpu/bus.h>
17 18
18#include "bus_gm20b.h" 19#include "bus_gm20b.h"
19#include "gk20a/gk20a.h" 20#include "gk20a/gk20a.h"
@@ -58,6 +59,6 @@ void gm20b_init_bus(struct gpu_ops *gops)
58 gops->bus.init_hw = gk20a_bus_init_hw; 59 gops->bus.init_hw = gk20a_bus_init_hw;
59 gops->bus.isr = gk20a_bus_isr; 60 gops->bus.isr = gk20a_bus_isr;
60 gops->bus.read_ptimer = gk20a_read_ptimer; 61 gops->bus.read_ptimer = gk20a_read_ptimer;
61 gops->bus.get_timestamps_zipper = gk20a_get_timestamps_zipper; 62 gops->bus.get_timestamps_zipper = nvgpu_get_timestamps_zipper;
62 gops->bus.bar1_bind = gm20b_bus_bar1_bind; 63 gops->bus.bar1_bind = gm20b_bus_bar1_bind;
63} 64}
diff --git a/drivers/gpu/nvgpu/include/nvgpu/bus.h b/drivers/gpu/nvgpu/include/nvgpu/bus.h
new file mode 100644
index 00000000..096c084d
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/bus.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13#ifndef __NVGPU_BUS_H__
14#define __NVGPU_BUS_H__
15
16#include <nvgpu/types.h>
17
18struct gk20a;
19
20struct nvgpu_cpu_time_correlation_sample {
21 u64 cpu_timestamp;
22 u64 gpu_timestamp;
23};
24
25int nvgpu_get_timestamps_zipper(struct gk20a *g,
26 u32 source_id, u32 count,
27 struct nvgpu_cpu_time_correlation_sample *samples);
28
29#endif
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index 52f375f9..a9f102c8 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -23,6 +23,7 @@
23#include <nvgpu/bug.h> 23#include <nvgpu/bug.h>
24#include <nvgpu/enabled.h> 24#include <nvgpu/enabled.h>
25#include <nvgpu/debug.h> 25#include <nvgpu/debug.h>
26#include <nvgpu/bus.h>
26 27
27#include "vgpu/vgpu.h" 28#include "vgpu/vgpu.h"
28#include "vgpu/fecs_trace_vgpu.h" 29#include "vgpu/fecs_trace_vgpu.h"