summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Zhao <rizhao@nvidia.com>2016-07-26 20:48:58 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-08-15 14:41:25 -0400
commitdeffbf8ee2017d4ea804f35946673dd0f6e0fcf2 (patch)
tree811b5d8a5da49d27a6581301772df54eacc8a55a
parentead314881633c128905c6aaeb5b6e4bf0cc1bb17 (diff)
gpu: nvgpu: vgpu: get constants of gpc_tpc_count/mask arrays
It'll cover multi-gpcs. JIRA VFND-2103 Change-Id: Ie82bdaad360294696c5a679d694f6f0e2364ca2e Signed-off-by: Richard Zhao <rizhao@nvidia.com> Reviewed-on: http://git-master/r/1194631 GVS: Gerrit_Virtual_Submit Reviewed-by: Vladislav Buzov <vbuzov@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/vgpu/gr_vgpu.c32
-rw-r--r--drivers/gpu/nvgpu/vgpu/vgpu.c7
-rw-r--r--include/linux/tegra_vgpu.h14
3 files changed, 24 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
index a5345764..87faa2f2 100644
--- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c
@@ -617,18 +617,6 @@ static int vgpu_gr_free_obj_ctx(struct channel_gk20a *c,
617 return 0; 617 return 0;
618} 618}
619 619
620static u32 vgpu_gr_get_gpc_tpc_count(struct gk20a *g, u32 gpc_index)
621{
622 u32 data;
623
624 WARN_ON(gpc_index > 0);
625
626 if (vgpu_get_attribute(vgpu_get_handle(g),
627 TEGRA_VGPU_ATTRIB_GPC0_TPC_COUNT, &data))
628 gk20a_err(dev_from_gk20a(g), "failed to retrieve gpc0_tpc_count");
629 return data;
630}
631
632static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr) 620static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr)
633{ 621{
634 struct vgpu_priv_data *priv = vgpu_get_priv_data(g); 622 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
@@ -640,11 +628,6 @@ static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr)
640 gr->gpc_count = priv->constants.gpc_count; 628 gr->gpc_count = priv->constants.gpc_count;
641 gr->max_tpc_per_gpc_count = priv->constants.max_tpc_per_gpc_count; 629 gr->max_tpc_per_gpc_count = priv->constants.max_tpc_per_gpc_count;
642 630
643 if (vgpu_get_attribute(vgpu_get_handle(g),
644 TEGRA_VGPU_ATTRIB_TPC_COUNT,
645 &gr->tpc_count))
646 return -ENOMEM;
647
648 gr->max_tpc_count = gr->max_gpc_count * gr->max_tpc_per_gpc_count; 631 gr->max_tpc_count = gr->max_gpc_count * gr->max_tpc_per_gpc_count;
649 632
650 gr->gpc_tpc_count = kzalloc(gr->gpc_count * sizeof(u32), GFP_KERNEL); 633 gr->gpc_tpc_count = kzalloc(gr->gpc_count * sizeof(u32), GFP_KERNEL);
@@ -660,9 +643,12 @@ static int vgpu_gr_init_gr_config(struct gk20a *g, struct gr_gk20a *gr)
660 if (!gr->sm_to_cluster) 643 if (!gr->sm_to_cluster)
661 goto cleanup; 644 goto cleanup;
662 645
646 gr->tpc_count = 0;
663 for (gpc_index = 0; gpc_index < gr->gpc_count; gpc_index++) { 647 for (gpc_index = 0; gpc_index < gr->gpc_count; gpc_index++) {
664 gr->gpc_tpc_count[gpc_index] = 648 gr->gpc_tpc_count[gpc_index] =
665 vgpu_gr_get_gpc_tpc_count(g, gpc_index); 649 priv->constants.gpc_tpc_count[gpc_index];
650
651 gr->tpc_count += gr->gpc_tpc_count[gpc_index];
666 652
667 if (g->ops.gr.get_gpc_tpc_mask) 653 if (g->ops.gr.get_gpc_tpc_mask)
668 gr->gpc_tpc_mask[gpc_index] = 654 gr->gpc_tpc_mask[gpc_index] =
@@ -739,15 +725,9 @@ static int vgpu_gr_get_zcull_info(struct gk20a *g, struct gr_gk20a *gr,
739 725
740static u32 vgpu_gr_get_gpc_tpc_mask(struct gk20a *g, u32 gpc_index) 726static u32 vgpu_gr_get_gpc_tpc_mask(struct gk20a *g, u32 gpc_index)
741{ 727{
742 u32 data; 728 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
743
744 WARN_ON(gpc_index > 0);
745
746 if (vgpu_get_attribute(vgpu_get_handle(g),
747 TEGRA_VGPU_ATTRIB_GPC0_TPC_MASK, &data))
748 gk20a_err(dev_from_gk20a(g), "failed to retrieve gpc0_tpc_mask");
749 729
750 return data; 730 return priv->constants.gpc_tpc_mask[gpc_index];
751} 731}
752 732
753static u32 vgpu_gr_get_max_fbps_count(struct gk20a *g) 733static u32 vgpu_gr_get_max_fbps_count(struct gk20a *g)
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c
index f5aef512..125be58c 100644
--- a/drivers/gpu/nvgpu/vgpu/vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/vgpu.c
@@ -504,6 +504,13 @@ static int vgpu_get_constants(struct gk20a *g)
504 return err; 504 return err;
505 } 505 }
506 506
507 if (unlikely(p->gpc_count > TEGRA_VGPU_MAX_GPC_COUNT ||
508 p->max_tpc_per_gpc_count > TEGRA_VGPU_MAX_TPC_COUNT_PER_GPC)) {
509 gk20a_err(g->dev, "gpc_count %d max_tpc_per_gpc %d overflow",
510 (int)p->gpc_count, (int)p->max_tpc_per_gpc_count);
511 return -EINVAL;
512 }
513
507 priv->constants = *p; 514 priv->constants = *p;
508 return 0; 515 return 0;
509} 516}
diff --git a/include/linux/tegra_vgpu.h b/include/linux/tegra_vgpu.h
index 4b308316..fdab9b06 100644
--- a/include/linux/tegra_vgpu.h
+++ b/include/linux/tegra_vgpu.h
@@ -117,7 +117,7 @@ enum {
117 TEGRA_VGPU_ATTRIB_COMPTAG_LINES = 3, /* deprecated */ 117 TEGRA_VGPU_ATTRIB_COMPTAG_LINES = 3, /* deprecated */
118 TEGRA_VGPU_ATTRIB_GPC_COUNT = 4, /* deprecated */ 118 TEGRA_VGPU_ATTRIB_GPC_COUNT = 4, /* deprecated */
119 TEGRA_VGPU_ATTRIB_MAX_TPC_PER_GPC_COUNT = 5, /* deprecated */ 119 TEGRA_VGPU_ATTRIB_MAX_TPC_PER_GPC_COUNT = 5, /* deprecated */
120 TEGRA_VGPU_ATTRIB_MAX_TPC_COUNT = 6, 120 TEGRA_VGPU_ATTRIB_MAX_TPC_COUNT = 6, /* deprecated */
121 TEGRA_VGPU_ATTRIB_PMC_BOOT_0 = 7, /* deprecated */ 121 TEGRA_VGPU_ATTRIB_PMC_BOOT_0 = 7, /* deprecated */
122 TEGRA_VGPU_ATTRIB_L2_SIZE = 8, /* deprecated */ 122 TEGRA_VGPU_ATTRIB_L2_SIZE = 8, /* deprecated */
123 TEGRA_VGPU_ATTRIB_GPC0_TPC0_SM_ARCH = 9, /* deprecated */ 123 TEGRA_VGPU_ATTRIB_GPC0_TPC0_SM_ARCH = 9, /* deprecated */
@@ -125,13 +125,13 @@ enum {
125 TEGRA_VGPU_ATTRIB_FBP_EN_MASK = 11, /* deprecated */ 125 TEGRA_VGPU_ATTRIB_FBP_EN_MASK = 11, /* deprecated */
126 TEGRA_VGPU_ATTRIB_MAX_LTC_PER_FBP = 12, /* deprecated */ 126 TEGRA_VGPU_ATTRIB_MAX_LTC_PER_FBP = 12, /* deprecated */
127 TEGRA_VGPU_ATTRIB_MAX_LTS_PER_LTC = 13, /* deprecated */ 127 TEGRA_VGPU_ATTRIB_MAX_LTS_PER_LTC = 13, /* deprecated */
128 TEGRA_VGPU_ATTRIB_GPC0_TPC_MASK = 14, 128 TEGRA_VGPU_ATTRIB_GPC0_TPC_MASK = 14, /* deprecated */
129 TEGRA_VGPU_ATTRIB_CACHELINE_SIZE = 15, /* deprecated */ 129 TEGRA_VGPU_ATTRIB_CACHELINE_SIZE = 15, /* deprecated */
130 TEGRA_VGPU_ATTRIB_COMPTAGS_PER_CACHELINE = 16, /* deprecated */ 130 TEGRA_VGPU_ATTRIB_COMPTAGS_PER_CACHELINE = 16, /* deprecated */
131 TEGRA_VGPU_ATTRIB_SLICES_PER_LTC = 17, /* deprecated */ 131 TEGRA_VGPU_ATTRIB_SLICES_PER_LTC = 17, /* deprecated */
132 TEGRA_VGPU_ATTRIB_LTC_COUNT = 18, /* deprecated */ 132 TEGRA_VGPU_ATTRIB_LTC_COUNT = 18, /* deprecated */
133 TEGRA_VGPU_ATTRIB_TPC_COUNT = 19, /* deprecated */ 133 TEGRA_VGPU_ATTRIB_TPC_COUNT = 19, /* deprecated */
134 TEGRA_VGPU_ATTRIB_GPC0_TPC_COUNT = 20, 134 TEGRA_VGPU_ATTRIB_GPC0_TPC_COUNT = 20, /* deprecated */
135 TEGRA_VGPU_ATTRIB_MAX_FREQ = 21, /* deprecated */ 135 TEGRA_VGPU_ATTRIB_MAX_FREQ = 21, /* deprecated */
136}; 136};
137 137
@@ -403,6 +403,9 @@ struct tegra_vgpu_gpu_clk_rate_params {
403 u32 rate; /* in kHz */ 403 u32 rate; /* in kHz */
404}; 404};
405 405
406#define TEGRA_VGPU_MAX_GPC_COUNT 16
407#define TEGRA_VGPU_MAX_TPC_COUNT_PER_GPC 16
408
406struct tegra_vgpu_constants_params { 409struct tegra_vgpu_constants_params {
407 u32 arch; 410 u32 arch;
408 u32 impl; 411 u32 impl;
@@ -427,6 +430,11 @@ struct tegra_vgpu_constants_params {
427 u32 fbp_en_mask; 430 u32 fbp_en_mask;
428 u32 ltc_per_fbp; 431 u32 ltc_per_fbp;
429 u32 max_lts_per_ltc; 432 u32 max_lts_per_ltc;
433 u8 gpc_tpc_count[TEGRA_VGPU_MAX_GPC_COUNT];
434 /* mask bits should be equal or larger than
435 * TEGRA_VGPU_MAX_TPC_COUNT_PER_GPC
436 */
437 u16 gpc_tpc_mask[TEGRA_VGPU_MAX_GPC_COUNT];
430}; 438};
431 439
432struct tegra_vgpu_cmd_msg { 440struct tegra_vgpu_cmd_msg {