From f8f9dfeea84cd0d5fcfe383c017893a0b456155f Mon Sep 17 00:00:00 2001 From: Philip Elcan Date: Thu, 16 May 2019 11:32:06 -0400 Subject: [PATCH] gpu: nvgpu: mm: fix MISRA 13.5 violations in page_table Fix MISRA rule 13.5 violation for using a function that has side effects as the right hand side of a logical expression. In this case, is_iommuable() can have side effects in some OS implementations. JIRA NVGPU-3340 Signed-off-by: Philip Elcan Change-Id: If465f68fce0e9d6d8ef98564229eebd112b28f29 Reviewed-on: https://git-master.nvidia.com/r/2120490 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/gmmu/page_table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c index b506bc280..653a74cdd 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c @@ -509,6 +509,7 @@ static int nvgpu_gmmu_do_update_page_table(struct vm_gk20a *vm, { struct gk20a *g = gk20a_from_vm(vm); struct nvgpu_sgl *sgl; + bool is_iommuable, sgt_is_iommuable; int err = 0; if (sgt == NULL) { @@ -540,9 +541,10 @@ static int nvgpu_gmmu_do_update_page_table(struct vm_gk20a *vm, * for (2), (3) and (4) we have to actually go through each SG entry and * map each chunk individually. */ + is_iommuable = nvgpu_iommuable(g); + sgt_is_iommuable = nvgpu_sgt_iommuable(g, sgt); if (nvgpu_aperture_is_sysmem(attrs->aperture) && - nvgpu_iommuable(g) && - nvgpu_sgt_iommuable(g, sgt)) { + is_iommuable && sgt_is_iommuable) { u64 io_addr = nvgpu_sgt_get_gpu_addr(g, sgt, sgt->sgl, attrs); io_addr += space_to_skip;