From 854e861ad06ffbdd3e93a9b8da942b6df9af4309 Mon Sep 17 00:00:00 2001 From: Vaibhav Kachore Date: Mon, 13 May 2019 10:43:48 +0530 Subject: [PATCH] gpu: nvgpu: fix CERT-C violations This patch fixes following CERT-C violations for power management unit: - CERT INT31-C NVGPU-3403 Change-Id: I4eb2374cc720c6d0bb81d6a4d9750348d4e5a670 Signed-off-by: Vaibhav Kachore Reviewed-on: https://git-master.nvidia.com/r/2117659 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/init/nvgpu_init.c | 4 ++-- drivers/gpu/nvgpu/common/mm/nvgpu_mem.c | 4 ++-- drivers/gpu/nvgpu/hal/sync/syncpt_cmdbuf_gv11b.c | 2 +- drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 034347fa2..5c960d99c 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -149,7 +149,7 @@ int gk20a_finalize_poweron(struct gk20a *g) { int err = 0; #if defined(CONFIG_TEGRA_GK20A_NVHOST) - u32 nr_pages; + u64 nr_pages; #endif nvgpu_log_fn(g, " "); @@ -473,7 +473,7 @@ int gk20a_finalize_poweron(struct gk20a *g) #if defined(CONFIG_TEGRA_GK20A_NVHOST) if (nvgpu_has_syncpoints(g) && (g->syncpt_unit_size != 0UL)) { if (!nvgpu_mem_is_valid(&g->syncpt_mem)) { - nr_pages = U32(DIV_ROUND_UP(g->syncpt_unit_size, + nr_pages = U64(DIV_ROUND_UP(g->syncpt_unit_size, PAGE_SIZE)); err = nvgpu_mem_create_from_phys(g, &g->syncpt_mem, g->syncpt_unit_base, nr_pages); diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c index 071d9e258..a97142025 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c @@ -297,7 +297,7 @@ static const struct nvgpu_sgt_ops nvgpu_mem_phys_ops = { }; int nvgpu_mem_create_from_phys(struct gk20a *g, struct nvgpu_mem *dest, - u64 src_phys, u32 nr_pages) + u64 src_phys, u64 nr_pages) { int ret = 0; struct nvgpu_sgt *sgt; @@ -317,7 +317,7 @@ int nvgpu_mem_create_from_phys(struct gk20a *g, struct nvgpu_mem *dest, (void) memset(dest, 0, sizeof(*dest)); dest->aperture = APERTURE_SYSMEM; - dest->size = (u64)nr_pages * SZ_4K; + dest->size = nr_pages * SZ_4K; dest->aligned_size = dest->size; dest->mem_flags = __NVGPU_MEM_FLAG_NO_DMA; dest->phys_sgt = sgt; diff --git a/drivers/gpu/nvgpu/hal/sync/syncpt_cmdbuf_gv11b.c b/drivers/gpu/nvgpu/hal/sync/syncpt_cmdbuf_gv11b.c index 6bdd27d59..c63b6c612 100644 --- a/drivers/gpu/nvgpu/hal/sync/syncpt_cmdbuf_gv11b.c +++ b/drivers/gpu/nvgpu/hal/sync/syncpt_cmdbuf_gv11b.c @@ -57,7 +57,7 @@ static int set_syncpt_ro_map_gpu_va_locked(struct vm_gk20a *vm) int gv11b_syncpt_alloc_buf(struct nvgpu_channel *c, u32 syncpt_id, struct nvgpu_mem *syncpt_buf) { - u32 nr_pages; + u64 nr_pages; int err = 0; struct gk20a *g = c->g; diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h index 106deec2b..a3231d2d2 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_mem.h @@ -243,7 +243,7 @@ int nvgpu_mem_create_from_mem(struct gk20a *g, * Returns 0 on success, or a relevant error otherwise. */ int nvgpu_mem_create_from_phys(struct gk20a *g, struct nvgpu_mem *dest, - u64 src_phys, u32 nr_pages); + u64 src_phys, u64 nr_pages); /* * Really free a vidmem buffer. There's a fair amount of work involved in