From f180ad019971ad8111f21f12dd6760ead7201ee0 Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Mon, 18 Mar 2019 13:59:14 -0400 Subject: [PATCH] gpu: nvgpu: gr: use enum for global_ctx_buffer_index Change the global_ctx_buffer_index member in the nvgpu_gr_ctx struct to be an enum nvgpu_gr_global_ctx_index. global_ctx_buffer_index is used as an array of these indicies, but had been declared as an int. This change resolves a number of MISRA Rule 10.3 violations for implicit assignment of objects of different essential or narrower type. In order to use this enum, it is moved out of global_ctx.h into a new header file ctx_common.h that can be used by both ctx.h and global_ctx.h. JIRA NVGPU-2955 Change-Id: I5e399ba3b0821d696aa0b9909d3bc6bbe99d274c Signed-off-by: Philip Elcan Reviewed-on: https://git-master.nvidia.com/r/2075753 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Adeel Raza Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/ctx.c | 5 +++-- drivers/gpu/nvgpu/include/nvgpu/gr/ctx.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/ctx.c b/drivers/gpu/nvgpu/common/gr/ctx.c index 38a30d956..354ee946a 100644 --- a/drivers/gpu/nvgpu/common/gr/ctx.c +++ b/drivers/gpu/nvgpu/common/gr/ctx.c @@ -317,7 +317,8 @@ static void nvgpu_gr_ctx_unmap_global_ctx_buffers(struct gk20a *g, struct vm_gk20a *vm) { u64 *g_bfr_va = gr_ctx->global_ctx_buffer_va; - int *g_bfr_index = gr_ctx->global_ctx_buffer_index; + enum nvgpu_gr_global_ctx_index *g_bfr_index = + gr_ctx->global_ctx_buffer_index; u32 i; nvgpu_log_fn(g, " "); @@ -339,7 +340,7 @@ int nvgpu_gr_ctx_map_global_ctx_buffers(struct gk20a *g, struct vm_gk20a *vm, bool vpr) { u64 *g_bfr_va; - int *g_bfr_index; + enum nvgpu_gr_global_ctx_index *g_bfr_index; u64 gpu_va = 0ULL; nvgpu_log_fn(g, " "); diff --git a/drivers/gpu/nvgpu/include/nvgpu/gr/ctx.h b/drivers/gpu/nvgpu/include/nvgpu/gr/ctx.h index 6b23fce36..e85f5e8f5 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gr/ctx.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gr/ctx.h @@ -25,6 +25,7 @@ #include #include +#include /* * allocate a minimum of 1 page (4KB) worth of patch space, this is 512 entries @@ -127,7 +128,7 @@ struct nvgpu_gr_ctx { #endif u64 global_ctx_buffer_va[NVGPU_GR_CTX_VA_COUNT]; - int global_ctx_buffer_index[NVGPU_GR_CTX_VA_COUNT]; + enum nvgpu_gr_global_ctx_index global_ctx_buffer_index[NVGPU_GR_CTX_VA_COUNT]; bool global_ctx_buffer_mapped; u32 tsgid;