diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index f1eccd06a..16af2cb09 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) static void nvgpu_init_gr_vars(struct gk20a *g) { + struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); gk20a_init_gr(g); nvgpu_log_info(g, "total ram pages : %lu", totalram_pages); g->gr.max_comptag_mem = totalram_pages >> (10 - (PAGE_SHIFT - 10)); + + /* Deduct the part taken by the running system */ + if (platform->comptag_mem_deduct && + g->gr.max_comptag_mem > platform->comptag_mem_deduct) { + g->gr.max_comptag_mem -= platform->comptag_mem_deduct; + nvgpu_log_info(g, "deducted max memory for comptag: %u", + g->gr.max_comptag_mem); + } } 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 f3e80b8c4..5848a5ef4 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 { /* stream id to use */ u32 ltc_streamid; + /* + * The deductible memory size for max_comptag_mem (in MBytes) + * Usually close to memory size that running system is taking + */ + u32 comptag_mem_deduct; + /* scaling rate */ unsigned long cached_rate; };