diff options
author | Thomas Fleury <tfleury@nvidia.com> | 2017-04-27 14:28:27 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-06-15 14:53:10 -0400 |
commit | 741e5c45179db066ddf5bed0be6f36e4d0d4010e (patch) | |
tree | 815f83070ae0fcf37a7b234caf8a2f86997f99bb /drivers/gpu/nvgpu/gk20a/bus_gk20a.c | |
parent | 77e2cbab237637f71367df25384164b8c936a31a (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/gk20a/bus_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/bus_gk20a.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c index 52ef08e4..7f0ca013 100644 --- a/drivers/gpu/nvgpu/gk20a/bus_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/bus_gk20a.c | |||
@@ -128,6 +128,66 @@ int gk20a_read_ptimer(struct gk20a *g, u64 *value) | |||
128 | return -EBUSY; | 128 | return -EBUSY; |
129 | } | 129 | } |
130 | 130 | ||
131 | static inline u64 get_cpu_timestamp_tsc(void) | ||
132 | { | ||
133 | return ((u64) get_cycles()); | ||
134 | } | ||
135 | |||
136 | static inline u64 get_cpu_timestamp_jiffies(void) | ||
137 | { | ||
138 | return (get_jiffies_64() - INITIAL_JIFFIES); | ||
139 | } | ||
140 | |||
141 | static inline u64 get_cpu_timestamp_timeofday(void) | ||
142 | { | ||
143 | struct timeval tv; | ||
144 | |||
145 | do_gettimeofday(&tv); | ||
146 | return timeval_to_jiffies(&tv); | ||
147 | } | ||
148 | |||
149 | int gk20a_get_timestamps_zipper(struct gk20a *g, | ||
150 | u32 source_id, u32 count, | ||
151 | struct nvgpu_cpu_time_correlation_sample *samples) | ||
152 | { | ||
153 | int err = 0; | ||
154 | unsigned int i = 0; | ||
155 | u64 (*get_cpu_timestamp)(void) = NULL; | ||
156 | |||
157 | switch (source_id) { | ||
158 | case NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TSC: | ||
159 | get_cpu_timestamp = get_cpu_timestamp_tsc; | ||
160 | break; | ||
161 | case NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_JIFFIES: | ||
162 | get_cpu_timestamp = get_cpu_timestamp_jiffies; | ||
163 | break; | ||
164 | case NVGPU_GPU_GET_CPU_TIME_CORRELATION_INFO_SRC_ID_TIMEOFDAY: | ||
165 | get_cpu_timestamp = get_cpu_timestamp_timeofday; | ||
166 | break; | ||
167 | default: | ||
168 | nvgpu_err(g, "invalid cpu clock source id\n"); | ||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | if (gk20a_busy(g)) { | ||
173 | nvgpu_err(g, "GPU not powered on\n"); | ||
174 | err = -EINVAL; | ||
175 | goto end; | ||
176 | } | ||
177 | |||
178 | for (i = 0; i < count; i++) { | ||
179 | err = g->ops.bus.read_ptimer(g, &samples[i].gpu_timestamp); | ||
180 | if (err) | ||
181 | return err; | ||
182 | |||
183 | samples[i].cpu_timestamp = get_cpu_timestamp(); | ||
184 | } | ||
185 | |||
186 | end: | ||
187 | gk20a_idle(g); | ||
188 | return err; | ||
189 | } | ||
190 | |||
131 | static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst) | 191 | static int gk20a_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst) |
132 | { | 192 | { |
133 | u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst); | 193 | u64 iova = gk20a_mm_inst_block_addr(g, bar1_inst); |
@@ -150,5 +210,6 @@ void gk20a_init_bus(struct gpu_ops *gops) | |||
150 | gops->bus.init_hw = gk20a_bus_init_hw; | 210 | gops->bus.init_hw = gk20a_bus_init_hw; |
151 | gops->bus.isr = gk20a_bus_isr; | 211 | gops->bus.isr = gk20a_bus_isr; |
152 | gops->bus.read_ptimer = gk20a_read_ptimer; | 212 | gops->bus.read_ptimer = gk20a_read_ptimer; |
213 | gops->bus.get_timestamps_zipper = gk20a_get_timestamps_zipper; | ||
153 | gops->bus.bar1_bind = gk20a_bus_bar1_bind; | 214 | gops->bus.bar1_bind = gk20a_bus_bar1_bind; |
154 | } | 215 | } |