summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2018-06-26 06:44:55 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-05 03:38:08 -0400
commit84db72a21ce4076a66acbb936b5a6dabf39c7ee2 (patch)
treef37edc1a310d32270ed3f23efad59da7879a27e8 /drivers/gpu/nvgpu
parent26fe0fbc92bca183f4e543d45f5fc074d136eba1 (diff)
gpu: nvgpu: add HAL to get offset in gpccs segment
In gr_gk20a_find_priv_offset_in_buffer() we right now calculate offset of a register in gpccs segment based on register address type Separate out sequence to find offset in gpccs segment and move it to new API gr_gk20a_get_offset_in_gpccs_segment() Introduce new HAL gops.gr.get_offset_in_gpccs_segment() and set above API to this HAL Call HAL from gr_gk20a_find_priv_offset_in_buffer() instead of calling direct API Jira NVGPUT-118 Change-Id: I0df798456cf63e3c3a43131f3c4ca7990b89ede0 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1761669 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/gk20a/gk20a.h3
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c115
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.h3
-rw-r--r--drivers/gpu/nvgpu/gm20b/hal_gm20b.c2
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c2
-rw-r--r--drivers/gpu/nvgpu/gp10b/hal_gp10b.c2
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c2
-rw-r--r--drivers/gpu/nvgpu/gv11b/hal_gv11b.c2
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c2
-rw-r--r--drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c2
10 files changed, 95 insertions, 40 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 263d0632..ee1f3304 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -492,6 +492,9 @@ struct gpu_ops {
492 int (*commit_global_ctx_buffers)(struct gk20a *g, 492 int (*commit_global_ctx_buffers)(struct gk20a *g,
493 struct channel_gk20a *c, bool patch); 493 struct channel_gk20a *c, bool patch);
494 u32 (*get_nonpes_aware_tpc)(struct gk20a *g, u32 gpc, u32 tpc); 494 u32 (*get_nonpes_aware_tpc)(struct gk20a *g, u32 gpc, u32 tpc);
495 int (*get_offset_in_gpccs_segment)(struct gk20a *g,
496 int addr_type, u32 num_tpcs, u32 num_ppcs,
497 u32 reg_list_ppc_count, u32 *__offset_in_segment);
495 } gr; 498 } gr;
496 struct { 499 struct {
497 void (*init_hw)(struct gk20a *g); 500 void (*init_hw)(struct gk20a *g);
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index d787a693..074a74c0 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -7136,6 +7136,69 @@ static int gr_gk20a_determine_ppc_configuration(struct gk20a *g,
7136 return 0; 7136 return 0;
7137} 7137}
7138 7138
7139int gr_gk20a_get_offset_in_gpccs_segment(struct gk20a *g,
7140 int addr_type,
7141 u32 num_tpcs,
7142 u32 num_ppcs,
7143 u32 reg_list_ppc_count,
7144 u32 *__offset_in_segment)
7145{
7146 u32 offset_in_segment = 0;
7147 struct gr_gk20a *gr = &g->gr;
7148
7149 if (addr_type == CTXSW_ADDR_TYPE_TPC) {
7150 /*
7151 * reg = gr->ctx_vars.ctxsw_regs.tpc.l;
7152 * offset_in_segment = 0;
7153 */
7154 } else if ((addr_type == CTXSW_ADDR_TYPE_EGPC) ||
7155 (addr_type == CTXSW_ADDR_TYPE_ETPC)) {
7156 offset_in_segment =
7157 ((gr->ctx_vars.ctxsw_regs.tpc.count *
7158 num_tpcs) << 2);
7159
7160 nvgpu_log(g, gpu_dbg_info | gpu_dbg_gpu_dbg,
7161 "egpc etpc offset_in_segment 0x%#08x",
7162 offset_in_segment);
7163 } else if (addr_type == CTXSW_ADDR_TYPE_PPC) {
7164 /*
7165 * The ucode stores TPC data before PPC data.
7166 * Advance offset past TPC data to PPC data.
7167 */
7168 offset_in_segment =
7169 (((gr->ctx_vars.ctxsw_regs.tpc.count +
7170 gr->ctx_vars.ctxsw_regs.etpc.count) *
7171 num_tpcs) << 2);
7172 } else if (addr_type == CTXSW_ADDR_TYPE_GPC) {
7173 /*
7174 * The ucode stores TPC/PPC data before GPC data.
7175 * Advance offset past TPC/PPC data to GPC data.
7176 *
7177 * Note 1 PES_PER_GPC case
7178 */
7179 u32 num_pes_per_gpc = nvgpu_get_litter_value(g,
7180 GPU_LIT_NUM_PES_PER_GPC);
7181 if (num_pes_per_gpc > 1) {
7182 offset_in_segment =
7183 ((((gr->ctx_vars.ctxsw_regs.tpc.count +
7184 gr->ctx_vars.ctxsw_regs.etpc.count) *
7185 num_tpcs) << 2) +
7186 ((reg_list_ppc_count * num_ppcs) << 2));
7187 } else {
7188 offset_in_segment =
7189 (((gr->ctx_vars.ctxsw_regs.tpc.count +
7190 gr->ctx_vars.ctxsw_regs.etpc.count) *
7191 num_tpcs) << 2);
7192 }
7193 } else {
7194 nvgpu_log_fn(g, "Unknown address type.");
7195 return -EINVAL;
7196 }
7197
7198 *__offset_in_segment = offset_in_segment;
7199 return 0;
7200}
7201
7139/* 7202/*
7140 * This function will return the 32 bit offset for a priv register if it is 7203 * This function will return the 32 bit offset for a priv register if it is
7141 * present in the context buffer. The context buffer is in CPU memory. 7204 * present in the context buffer. The context buffer is in CPU memory.
@@ -7147,7 +7210,6 @@ static int gr_gk20a_find_priv_offset_in_buffer(struct gk20a *g,
7147 u32 context_buffer_size, 7210 u32 context_buffer_size,
7148 u32 *priv_offset) 7211 u32 *priv_offset)
7149{ 7212{
7150 struct gr_gk20a *gr = &g->gr;
7151 u32 i, data32; 7213 u32 i, data32;
7152 int err; 7214 int err;
7153 int addr_type; /*enum ctxsw_addr_type */ 7215 int addr_type; /*enum ctxsw_addr_type */
@@ -7158,7 +7220,7 @@ static int gr_gk20a_find_priv_offset_in_buffer(struct gk20a *g,
7158 u32 sys_priv_offset, gpc_priv_offset; 7220 u32 sys_priv_offset, gpc_priv_offset;
7159 u32 ppc_mask, reg_list_ppc_count; 7221 u32 ppc_mask, reg_list_ppc_count;
7160 u8 *context; 7222 u8 *context;
7161 u32 offset_to_segment; 7223 u32 offset_to_segment, offset_in_segment = 0;
7162 7224
7163 nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, "addr=0x%x", addr); 7225 nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg, "addr=0x%x", addr);
7164 7226
@@ -7266,45 +7328,18 @@ static int gr_gk20a_find_priv_offset_in_buffer(struct gk20a *g,
7266 offset_to_segment = gpc_priv_offset * 7328 offset_to_segment = gpc_priv_offset *
7267 ctxsw_prog_ucode_header_size_in_bytes(); 7329 ctxsw_prog_ucode_header_size_in_bytes();
7268 7330
7269 if (addr_type == CTXSW_ADDR_TYPE_TPC) { 7331 err = g->ops.gr.get_offset_in_gpccs_segment(g,
7270 /*reg = gr->ctx_vars.ctxsw_regs.tpc.l;*/ 7332 addr_type,
7271 } else if ((addr_type == CTXSW_ADDR_TYPE_EGPC) || 7333 num_tpcs, num_ppcs, reg_list_ppc_count,
7272 (addr_type == CTXSW_ADDR_TYPE_ETPC)) { 7334 &offset_in_segment);
7273 nvgpu_log(g, gpu_dbg_info | gpu_dbg_gpu_dbg, 7335 if (err)
7274 "egpc etpc offset_to_segment 0x%#08x",
7275 offset_to_segment);
7276 offset_to_segment +=
7277 ((gr->ctx_vars.ctxsw_regs.tpc.count *
7278 num_tpcs) << 2);
7279 } else if (addr_type == CTXSW_ADDR_TYPE_PPC) {
7280 /* The ucode stores TPC data before PPC data.
7281 * Advance offset past TPC data to PPC data. */
7282 offset_to_segment +=
7283 (((gr->ctx_vars.ctxsw_regs.tpc.count +
7284 gr->ctx_vars.ctxsw_regs.etpc.count) *
7285 num_tpcs) << 2);
7286 } else if (addr_type == CTXSW_ADDR_TYPE_GPC) {
7287 /* The ucode stores TPC/PPC data before GPC data.
7288 * Advance offset past TPC/PPC data to GPC data. */
7289 /* note 1 PES_PER_GPC case */
7290 u32 num_pes_per_gpc = nvgpu_get_litter_value(g,
7291 GPU_LIT_NUM_PES_PER_GPC);
7292 if (num_pes_per_gpc > 1) {
7293 offset_to_segment +=
7294 ((((gr->ctx_vars.ctxsw_regs.tpc.count +
7295 gr->ctx_vars.ctxsw_regs.etpc.count) *
7296 num_tpcs) << 2) +
7297 ((reg_list_ppc_count * num_ppcs) << 2));
7298 } else {
7299 offset_to_segment +=
7300 (((gr->ctx_vars.ctxsw_regs.tpc.count +
7301 gr->ctx_vars.ctxsw_regs.etpc.count) *
7302 num_tpcs) << 2);
7303 }
7304 } else {
7305 nvgpu_log_fn(g, "Unknown address type.");
7306 return -EINVAL; 7336 return -EINVAL;
7307 } 7337
7338 offset_to_segment += offset_in_segment;
7339 nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gpu_dbg,
7340 "offset_to_segment 0x%#08x",
7341 offset_to_segment);
7342
7308 err = gr_gk20a_process_context_buffer_priv_segment(g, 7343 err = gr_gk20a_process_context_buffer_priv_segment(g,
7309 addr_type, addr, 7344 addr_type, addr,
7310 i, num_tpcs, 7345 i, num_tpcs,
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
index 6cf3d69b..a77136a6 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h
@@ -849,6 +849,9 @@ int gr_gk20a_create_priv_addr_table(struct gk20a *g,
849void gr_gk20a_split_fbpa_broadcast_addr(struct gk20a *g, u32 addr, 849void gr_gk20a_split_fbpa_broadcast_addr(struct gk20a *g, u32 addr,
850 u32 num_fbpas, 850 u32 num_fbpas,
851 u32 *priv_addr_table, u32 *t); 851 u32 *priv_addr_table, u32 *t);
852int gr_gk20a_get_offset_in_gpccs_segment(struct gk20a *g,
853 int addr_type, u32 num_tpcs, u32 num_ppcs,
854 u32 reg_list_ppc_count, u32 *__offset_in_segment);
852 855
853void gk20a_gr_destroy_ctx_buffer(struct gk20a *g, 856void gk20a_gr_destroy_ctx_buffer(struct gk20a *g,
854 struct gr_ctx_buffer_desc *desc); 857 struct gr_ctx_buffer_desc *desc);
diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
index 6bc13a7f..798b5f06 100644
--- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c
@@ -330,6 +330,8 @@ static const struct gpu_ops gm20b_ops = {
330 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers, 330 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers,
331 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 331 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
332 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 332 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
333 .get_offset_in_gpccs_segment =
334 gr_gk20a_get_offset_in_gpccs_segment,
333 }, 335 },
334 .fb = { 336 .fb = {
335 .reset = fb_gk20a_reset, 337 .reset = fb_gk20a_reset,
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
index 8af70cf5..a22350ce 100644
--- a/drivers/gpu/nvgpu/gp106/hal_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -401,6 +401,8 @@ static const struct gpu_ops gp106_ops = {
401 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers, 401 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers,
402 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 402 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
403 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 403 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
404 .get_offset_in_gpccs_segment =
405 gr_gk20a_get_offset_in_gpccs_segment,
404 }, 406 },
405 .fb = { 407 .fb = {
406 .reset = gp106_fb_reset, 408 .reset = gp106_fb_reset,
diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
index 2430be79..a1c32a5f 100644
--- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
@@ -364,6 +364,8 @@ static const struct gpu_ops gp10b_ops = {
364 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers, 364 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers,
365 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 365 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
366 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 366 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
367 .get_offset_in_gpccs_segment =
368 gr_gk20a_get_offset_in_gpccs_segment,
367 }, 369 },
368 .fb = { 370 .fb = {
369 .reset = fb_gk20a_reset, 371 .reset = fb_gk20a_reset,
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index 102e6a04..9d059b72 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -451,6 +451,8 @@ static const struct gpu_ops gv100_ops = {
451 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 451 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
452 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 452 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
453 .get_nonpes_aware_tpc = gr_gv11b_get_nonpes_aware_tpc, 453 .get_nonpes_aware_tpc = gr_gv11b_get_nonpes_aware_tpc,
454 .get_offset_in_gpccs_segment =
455 gr_gk20a_get_offset_in_gpccs_segment,
454 }, 456 },
455 .fb = { 457 .fb = {
456 .reset = gv100_fb_reset, 458 .reset = gv100_fb_reset,
diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
index 87775a3f..2b58e1c4 100644
--- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c
@@ -418,6 +418,8 @@ static const struct gpu_ops gv11b_ops = {
418 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 418 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
419 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 419 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
420 .get_nonpes_aware_tpc = gr_gv11b_get_nonpes_aware_tpc, 420 .get_nonpes_aware_tpc = gr_gv11b_get_nonpes_aware_tpc,
421 .get_offset_in_gpccs_segment =
422 gr_gk20a_get_offset_in_gpccs_segment,
421 }, 423 },
422 .fb = { 424 .fb = {
423 .reset = gv11b_fb_reset, 425 .reset = gv11b_fb_reset,
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c
index 5c210519..349548cd 100644
--- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c
@@ -235,6 +235,8 @@ static const struct gpu_ops vgpu_gp10b_ops = {
235 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers, 235 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers,
236 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 236 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
237 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 237 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
238 .get_offset_in_gpccs_segment =
239 gr_gk20a_get_offset_in_gpccs_segment,
238 }, 240 },
239 .fb = { 241 .fb = {
240 .reset = fb_gk20a_reset, 242 .reset = fb_gk20a_reset,
diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
index 2b65c992..d4a113f8 100644
--- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
+++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c
@@ -272,6 +272,8 @@ static const struct gpu_ops vgpu_gv11b_ops = {
272 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers, 272 .alloc_global_ctx_buffers = gr_gk20a_alloc_global_ctx_buffers,
273 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers, 273 .map_global_ctx_buffers = gr_gk20a_map_global_ctx_buffers,
274 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers, 274 .commit_global_ctx_buffers = gr_gk20a_commit_global_ctx_buffers,
275 .get_offset_in_gpccs_segment =
276 gr_gk20a_get_offset_in_gpccs_segment,
275 }, 277 },
276 .fb = { 278 .fb = {
277 .reset = gv11b_fb_reset, 279 .reset = gv11b_fb_reset,