From 1c13da1d29c344cb60953eabeca56b601446c64a Mon Sep 17 00:00:00 2001 From: Amulya Date: Thu, 9 Aug 2018 10:40:08 +0530 Subject: gpu: nvgpu: Changed enum gmmu_pgsz_gk20a into macros Changed the enum gmmu_pgsz_gk20a into macros and changed all the instances of it. The enum gmmu_pgsz_gk20a was being used in for loops, where it was compared with an integer. This violates MISRA rule 10.4, which only allows arithmetic operations on operands of the same essential type category. Changing this enum into macro will fix this violation. JIRA NVGPU-993 Change-Id: I6f18b08bc7548093d99e8229378415bcdec749e3 Signed-off-by: Amulya Reviewed-on: https://git-master.nvidia.com/r/1795593 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c | 12 +++++----- drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h | 2 +- drivers/gpu/nvgpu/vgpu/gr_vgpu.c | 30 ++++++++++++------------ drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c | 10 ++++---- drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c | 6 ++--- drivers/gpu/nvgpu/vgpu/mm_vgpu.c | 2 +- drivers/gpu/nvgpu/vgpu/mm_vgpu.h | 2 +- 7 files changed, 32 insertions(+), 32 deletions(-) (limited to 'drivers/gpu/nvgpu/vgpu') diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c index e7bd0a49..6017046f 100644 --- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c +++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c @@ -53,7 +53,7 @@ u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, struct nvgpu_sgt *sgt, u64 buffer_offset, u64 size, - int pgsz_idx, + u32 pgsz_idx, u8 kind_v, u32 ctag_offset, u32 flags, @@ -147,12 +147,12 @@ u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, else prot = TEGRA_VGPU_MAP_PROT_NONE; - if (pgsz_idx == gmmu_page_size_kernel) { - if (page_size == vm->gmmu_page_sizes[gmmu_page_size_small]) { - pgsz_idx = gmmu_page_size_small; + if (pgsz_idx == GMMU_PAGE_SIZE_KERNEL) { + if (page_size == vm->gmmu_page_sizes[GMMU_PAGE_SIZE_SMALL]) { + pgsz_idx = GMMU_PAGE_SIZE_SMALL; } else if (page_size == - vm->gmmu_page_sizes[gmmu_page_size_big]) { - pgsz_idx = gmmu_page_size_big; + vm->gmmu_page_sizes[GMMU_PAGE_SIZE_BIG]) { + pgsz_idx = GMMU_PAGE_SIZE_BIG; } else { nvgpu_err(g, "invalid kernel page size %d", page_size); diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h index 9435b75f..704c400e 100644 --- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h +++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h @@ -30,7 +30,7 @@ u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm, struct nvgpu_sgt *sgt, u64 buffer_offset, u64 size, - int pgsz_idx, + u32 pgsz_idx, u8 kind_v, u32 ctag_offset, u32 flags, diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c index 0077c537..fa64cb82 100644 --- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c @@ -192,7 +192,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, /* Circular Buffer */ gpu_va = __nvgpu_vm_alloc_va(ch_vm, gr->global_ctx_buffer[CIRCULAR].mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gpu_va) goto clean_up; @@ -202,7 +202,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, /* Attribute Buffer */ gpu_va = __nvgpu_vm_alloc_va(ch_vm, gr->global_ctx_buffer[ATTRIBUTE].mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gpu_va) goto clean_up; @@ -212,7 +212,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, /* Page Pool */ gpu_va = __nvgpu_vm_alloc_va(ch_vm, gr->global_ctx_buffer[PAGEPOOL].mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gpu_va) goto clean_up; g_bfr_va[PAGEPOOL_VA] = gpu_va; @@ -221,7 +221,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, /* Priv register Access Map */ gpu_va = __nvgpu_vm_alloc_va(ch_vm, gr->global_ctx_buffer[PRIV_ACCESS_MAP].mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gpu_va) goto clean_up; g_bfr_va[PRIV_ACCESS_MAP_VA] = gpu_va; @@ -232,7 +232,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, #ifdef CONFIG_GK20A_CTXSW_TRACE gpu_va = __nvgpu_vm_alloc_va(ch_vm, gr->global_ctx_buffer[FECS_TRACE_BUFFER].mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gpu_va) goto clean_up; @@ -262,7 +262,7 @@ static int vgpu_gr_map_global_ctx_buffers(struct gk20a *g, for (i = 0; i < NR_GLOBAL_CTX_BUF_VA; i++) { if (g_bfr_va[i]) { __nvgpu_vm_free_va(ch_vm, g_bfr_va[i], - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); g_bfr_va[i] = 0; } } @@ -285,7 +285,7 @@ static void vgpu_gr_unmap_global_ctx_buffers(struct tsg_gk20a *tsg) for (i = 0; i < NR_GLOBAL_CTX_BUF_VA; i++) { if (g_bfr_va[i]) { __nvgpu_vm_free_va(ch_vm, g_bfr_va[i], - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); g_bfr_va[i] = 0; g_bfr_size[i] = 0; } @@ -317,7 +317,7 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g, gr_ctx->mem.gpu_va = __nvgpu_vm_alloc_va(vm, gr->ctx_vars.buffer_total_size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!gr_ctx->mem.gpu_va) return -ENOMEM; @@ -336,7 +336,7 @@ int vgpu_gr_alloc_gr_ctx(struct gk20a *g, if (unlikely(err)) { nvgpu_err(g, "fail to alloc gr_ctx"); __nvgpu_vm_free_va(vm, gr_ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); gr_ctx->mem.aperture = APERTURE_INVALID; } else { gr_ctx->virt_ctx = p->gr_ctx_handle; @@ -365,7 +365,7 @@ static int vgpu_gr_alloc_channel_patch_ctx(struct gk20a *g, patch_ctx->mem.size = 128 * sizeof(u32); patch_ctx->mem.gpu_va = __nvgpu_vm_alloc_va(ch_vm, patch_ctx->mem.size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!patch_ctx->mem.gpu_va) return -ENOMEM; @@ -376,7 +376,7 @@ static int vgpu_gr_alloc_channel_patch_ctx(struct gk20a *g, err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); if (err || msg.ret) { __nvgpu_vm_free_va(ch_vm, patch_ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); err = -ENOMEM; } @@ -394,7 +394,7 @@ static void vgpu_gr_free_channel_patch_ctx(struct tsg_gk20a *tsg) /* server will free on channel close */ __nvgpu_vm_free_va(tsg->vm, patch_ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); patch_ctx->mem.gpu_va = 0; } } @@ -414,7 +414,7 @@ static void vgpu_gr_free_channel_pm_ctx(struct tsg_gk20a *tsg) /* server will free on channel close */ __nvgpu_vm_free_va(tsg->vm, pm_ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); pm_ctx->mem.gpu_va = 0; } @@ -437,7 +437,7 @@ void vgpu_gr_free_gr_ctx(struct gk20a *g, WARN_ON(err || msg.ret); __nvgpu_vm_free_va(vm, gr_ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); tsg = &g->fifo.tsg[gr_ctx->tsgid]; vgpu_gr_unmap_global_ctx_buffers(tsg); @@ -1120,7 +1120,7 @@ int vgpu_gr_update_hwpm_ctxsw_mode(struct gk20a *g, if (pm_ctx->mem.gpu_va == 0) { pm_ctx->mem.gpu_va = __nvgpu_vm_alloc_va(ch->vm, g->gr.ctx_vars.pm_ctxsw_image_size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!pm_ctx->mem.gpu_va) return -ENOMEM; diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c index e718a30d..43cff1c0 100644 --- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c +++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_fifo_gv11b.c @@ -43,7 +43,7 @@ static int set_syncpt_ro_map_gpu_va_locked(struct vm_gk20a *vm) vm->syncpt_ro_map_gpu_va = __nvgpu_vm_alloc_va(vm, g->syncpt_unit_size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!vm->syncpt_ro_map_gpu_va) { nvgpu_err(g, "allocating read-only va space failed"); return -ENOMEM; @@ -63,7 +63,7 @@ static int set_syncpt_ro_map_gpu_va_locked(struct vm_gk20a *vm) "mapping read-only va space failed err %d", err); __nvgpu_vm_free_va(vm, vm->syncpt_ro_map_gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); vm->syncpt_ro_map_gpu_va = 0; return err; } @@ -91,7 +91,7 @@ int vgpu_gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c, return err; syncpt_buf->gpu_va = __nvgpu_vm_alloc_va(c->vm, g->syncpt_size, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!syncpt_buf->gpu_va) { nvgpu_err(g, "allocating syncpt va space failed"); return -ENOMEM; @@ -110,7 +110,7 @@ int vgpu_gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c, if (err) { nvgpu_err(g, "mapping syncpt va space failed err %d", err); __nvgpu_vm_free_va(c->vm, syncpt_buf->gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); return err; } @@ -121,7 +121,7 @@ void vgpu_gv11b_fifo_free_syncpt_buf(struct channel_gk20a *c, struct nvgpu_mem *syncpt_buf) { nvgpu_gmmu_unmap(c->vm, syncpt_buf, syncpt_buf->gpu_va); - __nvgpu_vm_free_va(c->vm, syncpt_buf->gpu_va, gmmu_page_size_kernel); + __nvgpu_vm_free_va(c->vm, syncpt_buf->gpu_va, GMMU_PAGE_SIZE_KERNEL); nvgpu_dma_free(c->g, syncpt_buf); } diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c index 2372b9c4..b536d15e 100644 --- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c +++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_subctx_gv11b.c @@ -40,7 +40,7 @@ int vgpu_gv11b_alloc_subctx_header(struct channel_gk20a *c) p->ch_handle = c->virt_ctx; p->ctx_header_va = __nvgpu_vm_alloc_va(c->vm, ctxsw_prog_fecs_header_v(), - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); if (!p->ctx_header_va) { nvgpu_err(c->g, "alloc va failed for ctx_header"); return -ENOMEM; @@ -50,7 +50,7 @@ int vgpu_gv11b_alloc_subctx_header(struct channel_gk20a *c) if (unlikely(err)) { nvgpu_err(c->g, "alloc ctx_header failed err %d", err); __nvgpu_vm_free_va(c->vm, p->ctx_header_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); return err; } ctx->mem.gpu_va = p->ctx_header_va; @@ -75,7 +75,7 @@ void vgpu_gv11b_free_subctx_header(struct channel_gk20a *c) if (unlikely(err)) nvgpu_err(c->g, "free ctx_header failed err %d", err); __nvgpu_vm_free_va(c->vm, ctx->mem.gpu_va, - gmmu_page_size_kernel); + GMMU_PAGE_SIZE_KERNEL); ctx->mem.gpu_va = 0; } } diff --git a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c index 54b1e7c2..229a9767 100644 --- a/drivers/gpu/nvgpu/vgpu/mm_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/mm_vgpu.c @@ -84,7 +84,7 @@ int vgpu_init_mm_support(struct gk20a *g) void vgpu_locked_gmmu_unmap(struct vm_gk20a *vm, u64 vaddr, u64 size, - int pgsz_idx, + u32 pgsz_idx, bool va_allocated, enum gk20a_mem_rw_flag rw_flag, bool sparse, diff --git a/drivers/gpu/nvgpu/vgpu/mm_vgpu.h b/drivers/gpu/nvgpu/vgpu/mm_vgpu.h index e8f40d5c..41bae96d 100644 --- a/drivers/gpu/nvgpu/vgpu/mm_vgpu.h +++ b/drivers/gpu/nvgpu/vgpu/mm_vgpu.h @@ -33,7 +33,7 @@ enum gk20a_mem_rw_flag; void vgpu_locked_gmmu_unmap(struct vm_gk20a *vm, u64 vaddr, u64 size, - int pgsz_idx, + u32 pgsz_idx, bool va_allocated, enum gk20a_mem_rw_flag rw_flag, bool sparse, -- cgit v1.2.2