summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/fb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/fb')
-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
4 files changed, 34 insertions, 0 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