summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r--drivers/gpu/nvgpu/common/fb/fb_gp106.c15
-rw-r--r--drivers/gpu/nvgpu/common/fb/fb_gp106.h2
-rw-r--r--drivers/gpu/nvgpu/common/fb/fb_gv100.c15
-rw-r--r--drivers/gpu/nvgpu/common/fb/fb_gv100.h2
-rw-r--r--drivers/gpu/nvgpu/common/mm/vidmem.c6
5 files changed, 37 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/common/fb/fb_gp106.c b/drivers/gpu/nvgpu/common/fb/fb_gp106.c
index c8a32cd2..6dacceb5 100644
--- a/drivers/gpu/nvgpu/common/fb/fb_gp106.c
+++ b/drivers/gpu/nvgpu/common/fb/fb_gp106.c
@@ -52,3 +52,18 @@ void gp106_fb_reset(struct gk20a *g)
52 val &= ~fb_mmu_priv_level_mask_write_violation_m(); 52 val &= ~fb_mmu_priv_level_mask_write_violation_m();
53 gk20a_writel(g, fb_mmu_priv_level_mask_r(), val); 53 gk20a_writel(g, fb_mmu_priv_level_mask_r(), val);
54} 54}
55
56size_t gp106_fb_get_vidmem_size(struct gk20a *g)
57{
58 u32 range = gk20a_readl(g, fb_mmu_local_memory_range_r());
59 u32 mag = fb_mmu_local_memory_range_lower_mag_v(range);
60 u32 scale = fb_mmu_local_memory_range_lower_scale_v(range);
61 u32 ecc = fb_mmu_local_memory_range_ecc_mode_v(range);
62 size_t bytes = ((size_t)mag << scale) * SZ_1M;
63
64 if (ecc) {
65 bytes = bytes / 16U * 15U;
66 }
67
68 return bytes;
69}
diff --git a/drivers/gpu/nvgpu/common/fb/fb_gp106.h b/drivers/gpu/nvgpu/common/fb/fb_gp106.h
index d5ee87f4..bb4ccd6b 100644
--- a/drivers/gpu/nvgpu/common/fb/fb_gp106.h
+++ b/drivers/gpu/nvgpu/common/fb/fb_gp106.h
@@ -25,4 +25,6 @@
25struct gpu_ops; 25struct gpu_ops;
26 26
27void gp106_fb_reset(struct gk20a *g); 27void gp106_fb_reset(struct gk20a *g);
28size_t gp106_fb_get_vidmem_size(struct gk20a *g);
29
28#endif 30#endif
diff --git a/drivers/gpu/nvgpu/common/fb/fb_gv100.c b/drivers/gpu/nvgpu/common/fb/fb_gv100.c
index 848d6efb..4cae5312 100644
--- a/drivers/gpu/nvgpu/common/fb/fb_gv100.c
+++ b/drivers/gpu/nvgpu/common/fb/fb_gv100.c
@@ -281,3 +281,18 @@ int gv100_fb_enable_nvlink(struct gk20a *g)
281 281
282 return 0; 282 return 0;
283} 283}
284
285size_t gv100_fb_get_vidmem_size(struct gk20a *g)
286{
287 u32 range = gk20a_readl(g, fb_mmu_local_memory_range_r());
288 u32 mag = fb_mmu_local_memory_range_lower_mag_v(range);
289 u32 scale = fb_mmu_local_memory_range_lower_scale_v(range);
290 u32 ecc = fb_mmu_local_memory_range_ecc_mode_v(range);
291 size_t bytes = ((size_t)mag << scale) * SZ_1M;
292
293 if (ecc) {
294 bytes = bytes / 16U * 15U;
295 }
296
297 return bytes;
298}
diff --git a/drivers/gpu/nvgpu/common/fb/fb_gv100.h b/drivers/gpu/nvgpu/common/fb/fb_gv100.h
index 195baccf..d47fded2 100644
--- a/drivers/gpu/nvgpu/common/fb/fb_gv100.h
+++ b/drivers/gpu/nvgpu/common/fb/fb_gv100.h
@@ -33,4 +33,6 @@ void gv100_fb_disable_hub_intr(struct gk20a *g);
33int gv100_fb_memory_unlock(struct gk20a *g); 33int gv100_fb_memory_unlock(struct gk20a *g);
34int gv100_fb_init_nvlink(struct gk20a *g); 34int gv100_fb_init_nvlink(struct gk20a *g);
35int gv100_fb_enable_nvlink(struct gk20a *g); 35int gv100_fb_enable_nvlink(struct gk20a *g);
36size_t gv100_fb_get_vidmem_size(struct gk20a *g);
37
36#endif 38#endif
diff --git a/drivers/gpu/nvgpu/common/mm/vidmem.c b/drivers/gpu/nvgpu/common/mm/vidmem.c
index 1ace2333..3f5e0fbb 100644
--- a/drivers/gpu/nvgpu/common/mm/vidmem.c
+++ b/drivers/gpu/nvgpu/common/mm/vidmem.c
@@ -41,7 +41,7 @@ void nvgpu_vidmem_destroy(struct gk20a *g)
41{ 41{
42 struct nvgpu_timeout timeout; 42 struct nvgpu_timeout timeout;
43 43
44 if (!g->ops.mm.get_vidmem_size) 44 if (!g->ops.fb.get_vidmem_size)
45 return; 45 return;
46 46
47 nvgpu_timeout_init(g, &timeout, 100, NVGPU_TIMER_RETRY_TIMER); 47 nvgpu_timeout_init(g, &timeout, 100, NVGPU_TIMER_RETRY_TIMER);
@@ -293,8 +293,8 @@ int nvgpu_vidmem_init(struct mm_gk20a *mm)
293 static struct nvgpu_alloc_carveout bootstrap_co = 293 static struct nvgpu_alloc_carveout bootstrap_co =
294 NVGPU_CARVEOUT("bootstrap-region", 0, 0); 294 NVGPU_CARVEOUT("bootstrap-region", 0, 0);
295 295
296 size = g->ops.mm.get_vidmem_size ? 296 size = g->ops.fb.get_vidmem_size ?
297 g->ops.mm.get_vidmem_size(g) : 0; 297 g->ops.fb.get_vidmem_size(g) : 0;
298 if (!size) 298 if (!size)
299 return 0; 299 return 0;
300 300