diff options
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/module.c | 5 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/sim.c | 35 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/sim_pci.c | 30 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/linux/sim_pci.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/sim.h | 1 |
5 files changed, 50 insertions, 23 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index f00b3cce..86abd36b 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c | |||
@@ -249,6 +249,11 @@ int gk20a_pm_finalize_poweron(struct device *dev) | |||
249 | if (err) | 249 | if (err) |
250 | return err; | 250 | return err; |
251 | 251 | ||
252 | if (g->sim) { | ||
253 | if (g->sim->sim_init_late) | ||
254 | g->sim->sim_init_late(g); | ||
255 | } | ||
256 | |||
252 | err = gk20a_finalize_poweron(g); | 257 | err = gk20a_finalize_poweron(g); |
253 | if (err) | 258 | if (err) |
254 | goto done; | 259 | goto done; |
diff --git a/drivers/gpu/nvgpu/common/sim.c b/drivers/gpu/nvgpu/common/sim.c index 6094d063..81146cd9 100644 --- a/drivers/gpu/nvgpu/common/sim.c +++ b/drivers/gpu/nvgpu/common/sim.c | |||
@@ -33,8 +33,7 @@ int nvgpu_alloc_sim_buffer(struct gk20a *g, struct nvgpu_mem *mem) | |||
33 | { | 33 | { |
34 | int err; | 34 | int err; |
35 | 35 | ||
36 | err = nvgpu_dma_alloc(g, PAGE_SIZE, mem); | 36 | err = nvgpu_dma_alloc_sys(g, PAGE_SIZE, mem); |
37 | |||
38 | if (err) | 37 | if (err) |
39 | return err; | 38 | return err; |
40 | /* | 39 | /* |
@@ -251,21 +250,14 @@ static int nvgpu_sim_esc_readl(struct gk20a *g, | |||
251 | return err; | 250 | return err; |
252 | } | 251 | } |
253 | 252 | ||
254 | int nvgpu_init_sim_support(struct gk20a *g) | 253 | static void nvgpu_sim_init_late(struct gk20a *g) |
255 | { | 254 | { |
256 | int err = -ENOMEM; | ||
257 | u64 phys; | 255 | u64 phys; |
258 | 256 | ||
259 | if (!g->sim) | 257 | if (!g->sim) |
260 | return 0; | 258 | return; |
261 | |||
262 | /* allocate sim event/msg buffers */ | ||
263 | err = nvgpu_alloc_sim_buffer(g, &g->sim->send_bfr); | ||
264 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->recv_bfr); | ||
265 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->msg_bfr); | ||
266 | 259 | ||
267 | if (err) | 260 | nvgpu_info(g, "sim init late"); |
268 | goto fail; | ||
269 | /*mark send ring invalid*/ | 261 | /*mark send ring invalid*/ |
270 | sim_writel(g->sim, sim_send_ring_r(), sim_send_ring_status_invalid_f()); | 262 | sim_writel(g->sim, sim_send_ring_r(), sim_send_ring_status_invalid_f()); |
271 | 263 | ||
@@ -300,6 +292,25 @@ int nvgpu_init_sim_support(struct gk20a *g) | |||
300 | sim_recv_ring_size_4kb_f() | | 292 | sim_recv_ring_size_4kb_f() | |
301 | sim_recv_ring_addr_lo_f(phys >> PAGE_SHIFT)); | 293 | sim_recv_ring_addr_lo_f(phys >> PAGE_SHIFT)); |
302 | 294 | ||
295 | return; | ||
296 | } | ||
297 | |||
298 | int nvgpu_init_sim_support(struct gk20a *g) | ||
299 | { | ||
300 | int err = -ENOMEM; | ||
301 | |||
302 | if (!g->sim) | ||
303 | return 0; | ||
304 | |||
305 | /* allocate sim event/msg buffers */ | ||
306 | err = nvgpu_alloc_sim_buffer(g, &g->sim->send_bfr); | ||
307 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->recv_bfr); | ||
308 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->msg_bfr); | ||
309 | |||
310 | if (err) | ||
311 | goto fail; | ||
312 | |||
313 | g->sim->sim_init_late = nvgpu_sim_init_late; | ||
303 | g->sim->remove_support = nvgpu_remove_sim_support; | 314 | g->sim->remove_support = nvgpu_remove_sim_support; |
304 | g->sim->esc_readl = nvgpu_sim_esc_readl; | 315 | g->sim->esc_readl = nvgpu_sim_esc_readl; |
305 | return 0; | 316 | return 0; |
diff --git a/drivers/gpu/nvgpu/common/sim_pci.c b/drivers/gpu/nvgpu/common/sim_pci.c index a72623e9..2f6f6765 100644 --- a/drivers/gpu/nvgpu/common/sim_pci.c +++ b/drivers/gpu/nvgpu/common/sim_pci.c | |||
@@ -201,21 +201,14 @@ static int nvgpu_sim_esc_readl(struct gk20a *g, | |||
201 | return err; | 201 | return err; |
202 | } | 202 | } |
203 | 203 | ||
204 | int nvgpu_init_sim_support_pci(struct gk20a *g) | 204 | static void nvgpu_sim_init_late(struct gk20a *g) |
205 | { | 205 | { |
206 | int err = -ENOMEM; | ||
207 | u64 phys; | 206 | u64 phys; |
208 | 207 | ||
209 | if (!g->sim) | 208 | if (!g->sim) |
210 | return 0; | 209 | return; |
211 | 210 | ||
212 | /* allocate sim event/msg buffers */ | 211 | nvgpu_info(g, "sim init late pci"); |
213 | err = nvgpu_alloc_sim_buffer(g, &g->sim->send_bfr); | ||
214 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->recv_bfr); | ||
215 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->msg_bfr); | ||
216 | |||
217 | if (err) | ||
218 | goto fail; | ||
219 | /* mark send ring invalid */ | 212 | /* mark send ring invalid */ |
220 | sim_writel(g->sim, sim_send_ring_r(), sim_send_ring_status_invalid_f()); | 213 | sim_writel(g->sim, sim_send_ring_r(), sim_send_ring_status_invalid_f()); |
221 | 214 | ||
@@ -249,7 +242,24 @@ int nvgpu_init_sim_support_pci(struct gk20a *g) | |||
249 | sim_recv_ring_target_phys_pci_coherent_f() | | 242 | sim_recv_ring_target_phys_pci_coherent_f() | |
250 | sim_recv_ring_size_4kb_f() | | 243 | sim_recv_ring_size_4kb_f() | |
251 | sim_recv_ring_addr_lo_f(phys >> PAGE_SHIFT)); | 244 | sim_recv_ring_addr_lo_f(phys >> PAGE_SHIFT)); |
245 | } | ||
246 | |||
247 | int nvgpu_init_sim_support_pci(struct gk20a *g) | ||
248 | { | ||
249 | int err = -ENOMEM; | ||
250 | |||
251 | if(!g->sim) | ||
252 | return 0; | ||
253 | |||
254 | /* allocate sim event/msg buffers */ | ||
255 | err = nvgpu_alloc_sim_buffer(g, &g->sim->send_bfr); | ||
256 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->recv_bfr); | ||
257 | err = err || nvgpu_alloc_sim_buffer(g, &g->sim->msg_bfr); | ||
258 | |||
259 | if (err) | ||
260 | goto fail; | ||
252 | 261 | ||
262 | g->sim->sim_init_late = nvgpu_sim_init_late; | ||
253 | g->sim->remove_support = nvgpu_remove_sim_support; | 263 | g->sim->remove_support = nvgpu_remove_sim_support; |
254 | g->sim->esc_readl = nvgpu_sim_esc_readl; | 264 | g->sim->esc_readl = nvgpu_sim_esc_readl; |
255 | return 0; | 265 | return 0; |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/sim_pci.h b/drivers/gpu/nvgpu/include/nvgpu/linux/sim_pci.h index 5784ecba..b248f07b 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/sim_pci.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/sim_pci.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * GK20A sim support | 3 | * nvgpu sim support pci |
4 | * | 4 | * |
5 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | 5 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. |
6 | * | 6 | * |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/sim.h b/drivers/gpu/nvgpu/include/nvgpu/sim.h index 78b749dd..f3ba2fed 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/sim.h +++ b/drivers/gpu/nvgpu/include/nvgpu/sim.h | |||
@@ -34,6 +34,7 @@ struct sim_nvgpu { | |||
34 | struct nvgpu_mem send_bfr; | 34 | struct nvgpu_mem send_bfr; |
35 | struct nvgpu_mem recv_bfr; | 35 | struct nvgpu_mem recv_bfr; |
36 | struct nvgpu_mem msg_bfr; | 36 | struct nvgpu_mem msg_bfr; |
37 | void (*sim_init_late)(struct gk20a *); | ||
37 | void (*remove_support)(struct gk20a *); | 38 | void (*remove_support)(struct gk20a *); |
38 | int (*esc_readl)( | 39 | int (*esc_readl)( |
39 | struct gk20a *g, char *path, u32 index, u32 *data); | 40 | struct gk20a *g, char *path, u32 index, u32 *data); |