diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2018-08-16 18:00:07 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-09-10 18:23:08 -0400 |
commit | 83efad7adb44647d37d98a57cbb6df48e356917d (patch) | |
tree | eebbe2f831484d2e6ea90d027f0dc16d69f42114 /drivers/gpu/nvgpu/common | |
parent | a02e1c1f0b012b743d4c1ba9c853057b4359107e (diff) |
gpu: nvgpu: Move FB size query to FB
Vidmem size query was in mm_xxx.c. It involves reading a register from
FB, so move the query to FB HAL.
JIRA NVGPU-1063
Change-Id: I30dfd2c4fdcdd6c841f85aaab7431d52473759bd
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1801425
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/fb/fb_gp106.c | 15 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/fb/fb_gp106.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/fb/fb_gv100.c | 15 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/fb/fb_gv100.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vidmem.c | 6 |
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 | |||
56 | size_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 @@ | |||
25 | struct gpu_ops; | 25 | struct gpu_ops; |
26 | 26 | ||
27 | void gp106_fb_reset(struct gk20a *g); | 27 | void gp106_fb_reset(struct gk20a *g); |
28 | size_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 | |||
285 | size_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); | |||
33 | int gv100_fb_memory_unlock(struct gk20a *g); | 33 | int gv100_fb_memory_unlock(struct gk20a *g); |
34 | int gv100_fb_init_nvlink(struct gk20a *g); | 34 | int gv100_fb_init_nvlink(struct gk20a *g); |
35 | int gv100_fb_enable_nvlink(struct gk20a *g); | 35 | int gv100_fb_enable_nvlink(struct gk20a *g); |
36 | size_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 | ||