summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/vgpu/vgpu.c
diff options
context:
space:
mode:
authorRichard Zhao <rizhao@nvidia.com>2016-07-22 16:55:36 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-08-15 14:41:18 -0400
commit9730a93d8a44d767786ba34ffc68ef28c8e95b96 (patch)
treebd1abad55b68b57c10793b5fe1fa0b853e30f8bf /drivers/gpu/nvgpu/vgpu/vgpu.c
parente1438818b90c5b0d73aae800b12bd6b36aec5142 (diff)
gpu: nvgpu: vgpu: add cmd to get RM server constants
Moving getting constant attributes into one cmd which will be called only once. This patch adds basic infrastructure and gpu arch info, max_freq and num_channels support. JIRA VFND-2103 Change-Id: I100599b49f29c99966f9e90ea381b1f3c09177a3 Signed-off-by: Richard Zhao <rizhao@nvidia.com> Reviewed-on: http://git-master/r/1189832 GVS: Gerrit_Virtual_Submit Reviewed-by: Vladislav Buzov <vbuzov@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index 300ffc98..f5aef512 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -271,22 +271,11 @@ int vgpu_pm_prepare_poweroff(struct device *dev)
271static void vgpu_detect_chip(struct gk20a *g) 271static void vgpu_detect_chip(struct gk20a *g)
272{ 272{
273 struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; 273 struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics;
274 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
274 275
275 u32 mc_boot_0_value; 276 gpu->arch = priv->constants.arch;
276 277 gpu->impl = priv->constants.impl;
277 if (vgpu_get_attribute(vgpu_get_handle(g), 278 gpu->rev = priv->constants.rev;
278 TEGRA_VGPU_ATTRIB_PMC_BOOT_0,
279 &mc_boot_0_value)) {
280 gk20a_err(dev_from_gk20a(g), "failed to detect chip");
281 return;
282 }
283
284 gpu->arch = mc_boot_0_architecture_v(mc_boot_0_value) <<
285 NVGPU_GPU_ARCHITECTURE_SHIFT;
286 gpu->impl = mc_boot_0_implementation_v(mc_boot_0_value);
287 gpu->rev =
288 (mc_boot_0_major_revision_v(mc_boot_0_value) << 4) |
289 mc_boot_0_minor_revision_v(mc_boot_0_value);
290 279
291 gk20a_dbg_info("arch: %x, impl: %x, rev: %x\n", 280 gk20a_dbg_info("arch: %x, impl: %x, rev: %x\n",
292 g->gpu_characteristics.arch, 281 g->gpu_characteristics.arch,
@@ -296,7 +285,7 @@ static void vgpu_detect_chip(struct gk20a *g)
296 285
297static int vgpu_init_gpu_characteristics(struct gk20a *g) 286static int vgpu_init_gpu_characteristics(struct gk20a *g)
298{ 287{
299 u32 max_freq; 288 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
300 int err; 289 int err;
301 290
302 gk20a_dbg_fn(""); 291 gk20a_dbg_fn("");
@@ -305,11 +294,7 @@ static int vgpu_init_gpu_characteristics(struct gk20a *g)
305 if (err) 294 if (err)
306 return err; 295 return err;
307 296
308 if (vgpu_get_attribute(vgpu_get_handle(g), 297 g->gpu_characteristics.max_freq = priv->constants.max_freq;
309 TEGRA_VGPU_ATTRIB_MAX_FREQ, &max_freq))
310 return -ENOMEM;
311
312 g->gpu_characteristics.max_freq = max_freq;
313 g->gpu_characteristics.map_buffer_batch_limit = 0; 298 g->gpu_characteristics.map_buffer_batch_limit = 0;
314 return 0; 299 return 0;
315} 300}
@@ -500,6 +485,29 @@ static int vgpu_pm_init(struct device *dev)
500 return err; 485 return err;
501} 486}
502 487
488static int vgpu_get_constants(struct gk20a *g)
489{
490 struct tegra_vgpu_cmd_msg msg = {};
491 struct tegra_vgpu_constants_params *p = &msg.params.constants;
492 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
493 int err;
494
495 gk20a_dbg_fn("");
496
497 msg.cmd = TEGRA_VGPU_CMD_GET_CONSTANTS;
498 msg.handle = vgpu_get_handle(g);
499 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
500 err = err ? err : msg.ret;
501
502 if (unlikely(err)) {
503 gk20a_err(g->dev, "%s failed, err=%d", __func__, err);
504 return err;
505 }
506
507 priv->constants = *p;
508 return 0;
509}
510
503int vgpu_probe(struct platform_device *pdev) 511int vgpu_probe(struct platform_device *pdev)
504{ 512{
505 struct gk20a *gk20a; 513 struct gk20a *gk20a;
@@ -573,6 +581,12 @@ int vgpu_probe(struct platform_device *pdev)
573 return -ENOSYS; 581 return -ENOSYS;
574 } 582 }
575 583
584 err = vgpu_get_constants(gk20a);
585 if (err) {
586 vgpu_comm_deinit();
587 return err;
588 }
589
576 priv->intr_handler = kthread_run(vgpu_intr_thread, gk20a, "gk20a"); 590 priv->intr_handler = kthread_run(vgpu_intr_thread, gk20a, "gk20a");
577 if (IS_ERR(priv->intr_handler)) 591 if (IS_ERR(priv->intr_handler))
578 return -ENOMEM; 592 return -ENOMEM;