summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2014-10-23 08:35:27 -0400
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:11:51 -0400
commit13ca1676ef9c43b137b0ca55e8143da9fa4b5032 (patch)
treebe9a03e4f4fbcd9d072777b30d99655919734b11 /drivers/gpu/nvgpu/gm20b/ltc_gm20b.c
parent83f3c09510a70cc046b548eaff006403c986e9f7 (diff)
gpu: nvgpu: Split L2 size calculation per chip
gk20a and gm20b calculate L2 size with different parameters. Split the function for calculating size so that it does not query GPU id. Bug 1567274 Change-Id: I09510c1bf0286c9df125d74e51df322c32bde646 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gm20b/ltc_gm20b.c')
-rw-r--r--drivers/gpu/nvgpu/gm20b/ltc_gm20b.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c
index 96e5dbde..a089b59c 100644
--- a/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/ltc_gm20b.c
@@ -347,10 +347,51 @@ void gm20b_flush_ltc(struct gk20a *g)
347 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_f()); 347 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_f());
348} 348}
349 349
350static int gm20b_determine_L2_size_bytes(struct gk20a *g)
351{
352 u32 lts_per_ltc;
353 u32 ways;
354 u32 sets;
355 u32 bytes_per_line;
356 u32 active_ltcs;
357 u32 cache_size;
358
359 u32 tmp;
360 u32 active_sets_value;
361
362 tmp = gk20a_readl(g, ltc_ltc0_lts0_tstg_cfg1_r());
363 ways = hweight32(ltc_ltc0_lts0_tstg_cfg1_active_ways_v(tmp));
364
365 active_sets_value = ltc_ltc0_lts0_tstg_cfg1_active_sets_v(tmp);
366 if (active_sets_value == ltc_ltc0_lts0_tstg_cfg1_active_sets_all_v()) {
367 sets = 64;
368 } else if (active_sets_value ==
369 ltc_ltc0_lts0_tstg_cfg1_active_sets_half_v()) {
370 sets = 32;
371 } else if (active_sets_value ==
372 ltc_ltc0_lts0_tstg_cfg1_active_sets_quarter_v()) {
373 sets = 16;
374 } else {
375 dev_err(dev_from_gk20a(g),
376 "Unknown constant %u for active sets",
377 (unsigned)active_sets_value);
378 sets = 0;
379 }
380
381 active_ltcs = g->gr.num_fbps;
382
383 /* chip-specific values */
384 lts_per_ltc = 2;
385 bytes_per_line = 128;
386 cache_size = active_ltcs * lts_per_ltc * ways * sets * bytes_per_line;
387
388 return cache_size;
389}
390
350void gm20b_init_ltc(struct gpu_ops *gops) 391void gm20b_init_ltc(struct gpu_ops *gops)
351{ 392{
352 /* Gk20a reused ops. */ 393 /* Gk20a reused ops. */
353 gops->ltc.determine_L2_size_bytes = gk20a_determine_L2_size_bytes; 394 gops->ltc.determine_L2_size_bytes = gm20b_determine_L2_size_bytes;
354 gops->ltc.set_max_ways_evict_last = gk20a_ltc_set_max_ways_evict_last; 395 gops->ltc.set_max_ways_evict_last = gk20a_ltc_set_max_ways_evict_last;
355 gops->ltc.set_zbc_color_entry = gk20a_ltc_set_zbc_color_entry; 396 gops->ltc.set_zbc_color_entry = gk20a_ltc_set_zbc_color_entry;
356 gops->ltc.set_zbc_depth_entry = gk20a_ltc_set_zbc_depth_entry; 397 gops->ltc.set_zbc_depth_entry = gk20a_ltc_set_zbc_depth_entry;