From ebeab34190026eebd6e6db791d51a305612b04b1 Mon Sep 17 00:00:00 2001 From: srajum Date: Thu, 17 Sep 2020 12:14:09 +0530 Subject: [PATCH] gpu: nvgpu: Fixing issue with disabled NVGPU_MM_HONORS_APERTURE aperture - Patch with SHA "23293fef" introduced an issue, if NVGPU_MM_HONORS_APERTURE is not enabled then we'll set aperture to VIDMEM and will miss any invalid apertures being passed in. JIRA NVGPU-6051 Change-Id: I7d5cf58bcd01c927b794c934be8d0341a61b8e34 Signed-off-by: srajum Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2415016 Reviewed-by: automaticguardword Reviewed-by: Alex Waterman Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/mm/nvgpu_mem.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c index 9f88bc488..0ca4fe7c1 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c @@ -41,6 +41,11 @@ u32 nvgpu_aperture_mask_raw(struct gk20a *g, enum nvgpu_aperture aperture, { u32 ret_mask = 0; + if ((aperture == APERTURE_INVALID) || (aperture >= APERTURE_MAX_ENUM)) { + nvgpu_do_assert_print(g, "Bad aperture"); + return 0; + } + /* * Some iGPUs treat sysmem (i.e SoC DRAM) as vidmem. In these cases the * "sysmem" aperture should really be translated to VIDMEM. @@ -59,14 +64,6 @@ u32 nvgpu_aperture_mask_raw(struct gk20a *g, enum nvgpu_aperture aperture, case APERTURE_VIDMEM: ret_mask = vidmem_mask; break; - case APERTURE_INVALID: - nvgpu_do_assert_print(g, "Bad aperture"); - ret_mask = 0; - break; - case APERTURE_MAX_ENUM: - nvgpu_do_assert_print(g, "Bad aperture"); - ret_mask = 0; - break; default: nvgpu_do_assert_print(g, "Bad aperture"); ret_mask = 0;