From 8a2be379cd25f2096ca63a50893688b8cf538691 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Tue, 31 May 2016 10:31:27 +0300 Subject: gpu: nvgpu: detect vidmem configuration from HW Read video memory size from hardware during initialization for devices that support it. JIRA DNVGPU-14 Change-Id: I84e1bca0eaac8dc204e1fb82628acc6b52c3e5cc Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/1157212 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gp106/mm_gp106.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 drivers/gpu/nvgpu/gp106/mm_gp106.c (limited to 'drivers/gpu/nvgpu/gp106/mm_gp106.c') diff --git a/drivers/gpu/nvgpu/gp106/mm_gp106.c b/drivers/gpu/nvgpu/gp106/mm_gp106.c new file mode 100644 index 00000000..1a4b6dd1 --- /dev/null +++ b/drivers/gpu/nvgpu/gp106/mm_gp106.c @@ -0,0 +1,39 @@ +/* + * GP106 memory management + * + * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include "gk20a/gk20a.h" +#include "gp10b/mm_gp10b.h" + +#include "hw_fb_gp106.h" + +static size_t gp106_mm_get_vidmem_size(struct gk20a *g) +{ + u32 range = gk20a_readl(g, fb_mmu_local_memory_range_r()); + u32 mag = fb_mmu_local_memory_range_lower_mag_v(range); + u32 scale = fb_mmu_local_memory_range_lower_scale_v(range); + u32 ecc = fb_mmu_local_memory_range_ecc_mode_v(range); + size_t bytes = ((size_t)mag << scale) * SZ_1M; + + if (ecc) + bytes = bytes / 16 * 15; + + return bytes; +} + +void gp106_init_mm(struct gpu_ops *gops) +{ + gp10b_init_mm(gops); + gops->mm.get_vidmem_size = gp106_mm_get_vidmem_size; +} -- cgit v1.2.2