From 8e56c73eab731aabf3f0b98f47ed0d847ddd2656 Mon Sep 17 00:00:00 2001 From: srajum Date: Tue, 24 Aug 2021 19:24:44 +0530 Subject: [PATCH] gpu: nvgpu: fixing MISRA Rule 21.2 violation - "va_start", "time" a reserved identifiers or macro names described in Section 7, "Library", of the C standard, shall not be declared. JIRA NVGPU-6536 Change-Id: I868362819dd7178eb7b165f243fb6d36322d8372 Signed-off-by: srajum Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2582291 (cherry picked from commit 29c2c55b184cf16aee51614da895747750217885) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2674867 Reviewed-by: svcacv Reviewed-by: Rajesh Devaraj Reviewed-by: Vaibhav Kachore Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/mm/vm.c | 8 ++++---- drivers/gpu/nvgpu/common/vgpu/mm/vm_vgpu.c | 4 ++-- drivers/gpu/nvgpu/include/nvgpu/posix/timers.h | 2 +- drivers/gpu/nvgpu/include/nvgpu/timers.h | 2 +- drivers/gpu/nvgpu/include/nvgpu/vm.h | 2 +- drivers/gpu/nvgpu/os/linux/timers.c | 6 +++--- drivers/gpu/nvgpu/os/posix/timers.c | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index f879e2910..10751b924 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c @@ -640,7 +640,7 @@ static int nvgpu_vm_init_vma(struct gk20a *g, struct vm_gk20a *vm, * is set. */ if (!big_pages || unified_va) { - user_vma_start = vm->va_start; + user_vma_start = vm->virtaddr_start; user_vma_limit = nvgpu_safe_sub_u64(vm->va_limit, kernel_reserved); user_lp_vma_start = user_vma_limit; @@ -650,14 +650,14 @@ static int nvgpu_vm_init_vma(struct gk20a *g, struct vm_gk20a *vm, * Ensure small_big_split falls between user vma * start and end. */ - if ((small_big_split <= vm->va_start) || + if ((small_big_split <= vm->virtaddr_start) || (small_big_split >= nvgpu_safe_sub_u64(vm->va_limit, kernel_reserved))) { return -EINVAL; } - user_vma_start = vm->va_start; + user_vma_start = vm->virtaddr_start; user_vma_limit = small_big_split; user_lp_vma_start = small_big_split; user_lp_vma_limit = nvgpu_safe_sub_u64(vm->va_limit, @@ -759,7 +759,7 @@ static int nvgpu_vm_init_attributes(struct mm_gk20a *mm, vm->vma[GMMU_PAGE_SIZE_BIG] = &vm->user_lp; } - vm->va_start = low_hole; + vm->virtaddr_start = low_hole; vm->va_limit = aperture_size; vm->big_page_size = vm->gmmu_page_sizes[GMMU_PAGE_SIZE_BIG]; diff --git a/drivers/gpu/nvgpu/common/vgpu/mm/vm_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/mm/vm_vgpu.c index d3663925f..5204c8bf0 100644 --- a/drivers/gpu/nvgpu/common/vgpu/mm/vm_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/mm/vm_vgpu.c @@ -1,7 +1,7 @@ /* * Virtualized GPU VM * - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,7 +48,7 @@ int vgpu_vm_as_alloc_share(struct gk20a *g, struct vm_gk20a *vm) msg.cmd = TEGRA_VGPU_CMD_AS_ALLOC_SHARE; msg.handle = vgpu_get_handle(g); - p->va_start = vm->va_start; + p->va_start = vm->virtaddr_start; p->va_limit = vm->va_limit; p->big_page_size = vm->big_page_size; diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h b/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h index 1e49d34cf..d8120d4ce 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h @@ -48,7 +48,7 @@ ({ \ const struct nvgpu_timeout *t_ptr = (timeout); \ int ret_cpu = 0; \ - if (nvgpu_current_time_ns() > t_ptr->time) { \ + if (nvgpu_current_time_ns() > t_ptr->time_duration) { \ if ((t_ptr->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) { \ nvgpu_err(t_ptr->g, "Timeout detected @ %p" fmt, \ caller, ##arg); \ diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index 437db0397..0459c97be 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h @@ -68,7 +68,7 @@ struct nvgpu_timeout { * Timeout duration/count. */ union { - s64 time; + s64 time_duration; struct { u32 max_attempts; u32 attempted; diff --git a/drivers/gpu/nvgpu/include/nvgpu/vm.h b/drivers/gpu/nvgpu/include/nvgpu/vm.h index 2c9b1558a..6091b4d00 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vm.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vm.h @@ -240,7 +240,7 @@ struct vm_gk20a { char name[NVGPU_VM_NAME_LEN]; /** Start GPU address of the context. */ - u64 va_start; + u64 virtaddr_start; /** End GPU address of the context. */ u64 va_limit; diff --git a/drivers/gpu/nvgpu/os/linux/timers.c b/drivers/gpu/nvgpu/os/linux/timers.c index e0c2084f8..7b9a8dae6 100644 --- a/drivers/gpu/nvgpu/os/linux/timers.c +++ b/drivers/gpu/nvgpu/os/linux/timers.c @@ -97,7 +97,7 @@ int nvgpu_timeout_init_flags(struct gk20a *g, struct nvgpu_timeout *timeout, if (flags & NVGPU_TIMER_RETRY_TIMER) timeout->retries.max_attempts = duration; else - timeout->time = ktime_to_ns(ktime_add_ns(ktime_get(), + timeout->time_duration = ktime_to_ns(ktime_add_ns(ktime_get(), (s64)NSEC_PER_MSEC * duration)); return 0; @@ -113,7 +113,7 @@ static int nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout, if (nvgpu_timeout_is_pre_silicon(timeout)) return 0; - if (ktime_after(now, ns_to_ktime(timeout->time))) { + if (ktime_after(now, ns_to_ktime(timeout->time_duration))) { if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { char buf[128]; @@ -204,7 +204,7 @@ bool nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout) return timeout->retries.attempted >= timeout->retries.max_attempts; else - return ktime_after(ktime_get(), ns_to_ktime(timeout->time)); + return ktime_after(ktime_get(), ns_to_ktime(timeout->time_duration)); } /** diff --git a/drivers/gpu/nvgpu/os/posix/timers.c b/drivers/gpu/nvgpu/os/posix/timers.c index e08bdeccb..08af2bfc8 100644 --- a/drivers/gpu/nvgpu/os/posix/timers.c +++ b/drivers/gpu/nvgpu/os/posix/timers.c @@ -177,7 +177,7 @@ int nvgpu_timeout_init_flags(struct gk20a *g, struct nvgpu_timeout *timeout, } else { duration_ns = (s64)duration; duration_ns = nvgpu_safe_mult_s64(duration_ns, NSEC_PER_MSEC); - timeout->time = nvgpu_safe_add_s64(nvgpu_current_time_ns(), + timeout->time_duration = nvgpu_safe_add_s64(nvgpu_current_time_ns(), duration_ns); } @@ -190,7 +190,7 @@ bool nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout) return (timeout->retries.attempted >= timeout->retries.max_attempts); } else { - return time_after(get_time_ns(), timeout->time); + return time_after(get_time_ns(), timeout->time_duration); } }