diff options
author | Nicolin Chen <nicolinc@nvidia.com> | 2018-08-21 16:20:49 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-08-29 01:33:59 -0400 |
commit | 19cd7ffb5def933db323fe682ec4a263eb1923f9 (patch) | |
tree | 1d3dd9f79f34505b8bdf2e3f2d58aac3522b221f /drivers/gpu/nvgpu/os | |
parent | 06f54be8c979720515d22e24cb4a20868af45f59 (diff) |
gpu: nvgpu: Allow comptag to deduct occupied memory by the system
The comptag allocates memory based on the available total RAM, which
theoretically should be the MAX physical RAM size however practically
should deduct the part being taken by the running system. Otherwise,
the taken memory part will never get used and wasted.
This change adds a comptag_mem_deduct to each platform and to allow
them to assign the deductible value based on their own use cases so
as to save memory.
Bug 2327574
Bug 2284925
Change-Id: I124e20a66183c22723c34a7ec6ce34832c12f02e
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1804157
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/driver_common.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/platform_gk20a.h | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index f1eccd06..16af2cb0 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.c +++ b/drivers/gpu/nvgpu/os/linux/driver_common.c | |||
@@ -93,11 +93,20 @@ static void nvgpu_init_vars(struct gk20a *g) | |||
93 | 93 | ||
94 | static void nvgpu_init_gr_vars(struct gk20a *g) | 94 | static void nvgpu_init_gr_vars(struct gk20a *g) |
95 | { | 95 | { |
96 | struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); | ||
96 | gk20a_init_gr(g); | 97 | gk20a_init_gr(g); |
97 | 98 | ||
98 | nvgpu_log_info(g, "total ram pages : %lu", totalram_pages); | 99 | nvgpu_log_info(g, "total ram pages : %lu", totalram_pages); |
99 | g->gr.max_comptag_mem = totalram_pages | 100 | g->gr.max_comptag_mem = totalram_pages |
100 | >> (10 - (PAGE_SHIFT - 10)); | 101 | >> (10 - (PAGE_SHIFT - 10)); |
102 | |||
103 | /* Deduct the part taken by the running system */ | ||
104 | if (platform->comptag_mem_deduct && | ||
105 | g->gr.max_comptag_mem > platform->comptag_mem_deduct) { | ||
106 | g->gr.max_comptag_mem -= platform->comptag_mem_deduct; | ||
107 | nvgpu_log_info(g, "deducted max memory for comptag: %u", | ||
108 | g->gr.max_comptag_mem); | ||
109 | } | ||
101 | } | 110 | } |
102 | 111 | ||
103 | static void nvgpu_init_timeout(struct gk20a *g) | 112 | static void nvgpu_init_timeout(struct gk20a *g) |
diff --git a/drivers/gpu/nvgpu/os/linux/platform_gk20a.h b/drivers/gpu/nvgpu/os/linux/platform_gk20a.h index f3e80b8c..5848a5ef 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gk20a.h +++ b/drivers/gpu/nvgpu/os/linux/platform_gk20a.h | |||
@@ -272,6 +272,12 @@ struct gk20a_platform { | |||
272 | /* stream id to use */ | 272 | /* stream id to use */ |
273 | u32 ltc_streamid; | 273 | u32 ltc_streamid; |
274 | 274 | ||
275 | /* | ||
276 | * The deductible memory size for max_comptag_mem (in MBytes) | ||
277 | * Usually close to memory size that running system is taking | ||
278 | */ | ||
279 | u32 comptag_mem_deduct; | ||
280 | |||
275 | /* scaling rate */ | 281 | /* scaling rate */ |
276 | unsigned long cached_rate; | 282 | unsigned long cached_rate; |
277 | }; | 283 | }; |